Skip to content

Commit

Permalink
20.6: Rearrange more packages and add fun loot capacitor names.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rover656 committed May 11, 2024
1 parent 63631e7 commit 59c8020
Show file tree
Hide file tree
Showing 29 changed files with 169 additions and 57 deletions.
1 change: 0 additions & 1 deletion src/api/java/com/enderio/api/travel/TravelTargetApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.stream.Stream;

public interface TravelTargetApi {

TravelTargetApi INSTANCE = ServiceLoader.load(TravelTargetApi.class).findFirst().orElseThrow();

Optional<TravelTarget> get(Level level, BlockPos pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.enderio.api.conduit.ConduitType;
import com.enderio.api.conduit.ExtendedConduitData;
import com.enderio.api.misc.RedstoneControl;
import com.enderio.base.client.model.PaintingQuadTransformer;
import com.enderio.base.client.paint.model.PaintingQuadTransformer;
import com.enderio.conduits.common.Area;
import com.enderio.conduits.common.blockentity.ConduitBlockEntity;
import com.enderio.conduits.common.blockentity.ConduitBundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import java.util.function.Supplier;

// TODO: Maybe use service location for the TravelTargetAPI.
public class ConduitApiImpl implements ConduitApi {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void tickGraph(ConduitType<?> type, List<NodeIdentifier<?>> loadedNodes,
super.tickGraph(type, loadedNodes, level, graph, isRedstoneActive);
for (NodeIdentifier<?> node : loadedNodes) {
EnergyExtendedData energyExtendedData = node.getExtendedConduitData().castTo(EnergyExtendedData.class);
IEnergyStorage energy = energyExtendedData.getSelfCap(); //TODO throw on null?
IEnergyStorage energy = energyExtendedData.getSelfCap();
if (energy.getEnergyStored() == 0) {
energyExtendedData.setCapacity(500);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@ public EnergyConduitType() {

@Override
public ConduitConnectionData getDefaultConnection(Level level, BlockPos pos, Direction direction) {
// BlockEntity blockEntity = level.getBlockEntity(pos.relative(direction));
// if (blockEntity != null) { TODO: NEO-PORT: non be caps
IEnergyStorage capability = level.getCapability(Capabilities.EnergyStorage.BLOCK, pos.relative(direction), direction.getOpposite());
if (capability != null) {
return new ConduitConnectionData(capability.canReceive(), capability.canExtract(), RedstoneControl.ALWAYS_ACTIVE);

}
// }
IEnergyStorage capability = level.getCapability(Capabilities.EnergyStorage.BLOCK, pos.relative(direction), direction.getOpposite());
if (capability != null) {
return new ConduitConnectionData(capability.canReceive(), capability.canExtract(), RedstoneControl.ALWAYS_ACTIVE);
}

return super.getDefaultConnection(level, pos, direction);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import java.util.function.Predicate;
import java.util.stream.Stream;

// TODO: Javadocs

/**
* An ingredient with an item count associated with it.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.enderio.machines.common.init;

import com.enderio.EnderIO;
import com.enderio.base.client.renderer.PaintedBlockColor;
import com.enderio.base.client.paint.PaintedBlockColor;
import com.enderio.base.common.init.EIOCreativeTabs;
import com.enderio.base.common.init.EIODataComponents;
import com.enderio.base.common.paint.item.PaintedBlockItem;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/enderio/base/client/ClientSetup.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.enderio.base.client;

import com.enderio.EnderIO;
import com.enderio.base.client.model.PaintedBlockGeometry;
import com.enderio.base.client.paint.model.PaintedBlockGeometry;
import com.enderio.base.client.particle.RangeParticle;
import com.enderio.base.client.renderer.block.EnderSkullRenderer;
import com.enderio.base.client.renderer.glider.ActiveGliderRenderLayer;
import com.enderio.base.client.renderer.item.GlassIconDecorator;
import com.enderio.base.client.renderer.travel.TravelTargetRendering;
import com.enderio.base.client.decorator.GlassIconDecorator;
import com.enderio.base.client.travel.TravelTargetRendering;
import com.enderio.base.common.block.skull.EnderSkullBlock;
import com.enderio.base.common.init.EIOBlockEntities;
import com.enderio.base.common.init.EIOBlocks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.enderio.base.client.renderer.item;
package com.enderio.base.client.decorator;

import com.enderio.api.misc.Vector2i;
import com.enderio.base.common.block.glass.FusedQuartzBlock;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@javax.annotation.ParametersAreNonnullByDefault
@net.minecraft.MethodsReturnNonnullByDefault

package com.enderio.base.client.renderer.item;
package com.enderio.base.client.decorator;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.enderio.EnderIO;
import com.enderio.api.misc.Vector2i;
import com.enderio.base.common.lang.EIOLang;
import com.enderio.base.common.menu.CoordinateMenu;
import com.enderio.base.common.network.UpdateCoordinateSelectionNameMenuPacket;
import com.enderio.core.client.gui.screen.EIOScreen;
Expand All @@ -26,6 +27,7 @@ public CoordinateMenuScreen(CoordinateMenu pMenu, Inventory pPlayerInventory, Co
@Override
protected void init() {
super.init();

EditBox name = new EditBox(this.font, leftPos + 43 + 4, topPos + 20 + 4, 92 - 12, 18, Component.literal("name"));
name.setCanLoseFocus(false);
name.setTextColor(0xFFFFFFFF);
Expand All @@ -34,11 +36,12 @@ protected void init() {
name.setMaxLength(50);
name.setResponder(this::onNameChanged);
name.setValue(menu.getName());

this.addRenderableWidget(name);
this.setInitialFocus(name);
name.setEditable(true);
// TODO: Translation string
this.addRenderableWidget(new Button.Builder(Component.literal("Ok"), mouseButton -> Minecraft.getInstance().player.closeContainer())

this.addRenderableWidget(new Button.Builder(EIOLang.OK, mouseButton -> Minecraft.getInstance().player.closeContainer())
.bounds(getGuiLeft() + imageWidth - 30, getGuiTop() + imageHeight - 30, 20, 20)
.build());
}
Expand Down Expand Up @@ -68,7 +71,6 @@ protected Vector2i getBackgroundImageSize() {
return BG_SIZE;
}


private void onNameChanged(String name) {
PacketDistributor.sendToServer(new UpdateCoordinateSelectionNameMenuPacket(getMenu().containerId, name));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.enderio.base.client.renderer;
package com.enderio.base.client.paint;

import com.enderio.base.common.paint.block.PaintedBlock;
import com.enderio.base.common.paint.block.PaintedSlabBlock;
import com.enderio.base.common.paint.blockentity.DoublePaintedBlockEntity;
import com.enderio.base.common.paint.blockentity.PaintedBlockEntity;
import com.enderio.base.common.init.EIODataComponents;
import net.minecraft.client.Minecraft;
Expand All @@ -12,7 +11,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SlabBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.enderio.base.client.renderer.entity;
package com.enderio.base.client.paint;

import com.enderio.base.common.paint.PaintedSandEntity;
import com.mojang.blaze3d.vertex.PoseStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.enderio.base.client.model;
package com.enderio.base.client.paint.model;

import com.enderio.base.common.paint.PaintUtils;
import com.google.gson.JsonDeserializationContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.enderio.base.client.model;
package com.enderio.base.client.paint.model;

import com.enderio.base.client.renderer.PaintedBlockColor;
import com.enderio.base.client.paint.PaintedBlockColor;
import com.enderio.base.common.init.EIODataComponents;
import com.enderio.base.common.paint.blockentity.DoublePaintedBlockEntity;
import com.enderio.base.common.paint.blockentity.PaintedBlockEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.enderio.base.client.model;
package com.enderio.base.client.paint.model;

import com.enderio.core.client.RenderUtil;
import com.enderio.core.data.model.ModelHelper;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.enderio.base.client.renderer.travel;
package com.enderio.base.client.travel;

import com.enderio.base.common.handler.TravelHandler;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -31,7 +31,6 @@ public static void clientTick(ClientTickEvent.Post e) {
}
}


private static void addTravelParticle(Vec3 pos) {
int time = tick/3%20;
float x = Mth.sin((float)(time*Math.PI)/10f);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.enderio.base.client.renderer.travel;
package com.enderio.base.client.travel;

import com.enderio.api.travel.RegisterTravelRenderersEvent;
import com.enderio.api.travel.TravelRenderer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@javax.annotation.ParametersAreNonnullByDefault
@net.minecraft.MethodsReturnNonnullByDefault

package com.enderio.base.client.model;
package com.enderio.base.client.travel;
2 changes: 1 addition & 1 deletion src/main/java/com/enderio/base/common/init/EIOBlocks.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.enderio.base.common.init;

import com.enderio.EnderIO;
import com.enderio.base.client.renderer.PaintedBlockColor;
import com.enderio.base.client.paint.PaintedBlockColor;
import com.enderio.base.common.block.ColdFireBlock;
import com.enderio.base.common.block.DarkSteelLadderBlock;
import com.enderio.base.common.block.EIOPressurePlateBlock;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.enderio.base.common.init;

import com.enderio.EnderIO;
import com.enderio.base.common.advancement.PaintingTrigger;
import com.enderio.base.common.paint.PaintingTrigger;
import com.enderio.base.common.advancement.UseGliderTrigger;
import net.minecraft.advancements.CriterionTrigger;
import net.minecraft.core.registries.Registries;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.enderio.base.common.init;

import com.enderio.EnderIO;
import com.enderio.base.client.renderer.entity.PaintedSandRenderer;
import com.enderio.base.client.paint.PaintedSandRenderer;
import com.enderio.base.common.paint.PaintedSandEntity;
import com.enderio.regilite.holder.RegiliteEntity;
import com.enderio.regilite.registry.EntityRegistry;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/enderio/base/common/init/EIOItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.enderio.api.capacitor.CapacitorData;
import com.enderio.api.grindingball.GrindingBallData;
import com.enderio.base.common.item.capacitors.CapacitorItem;
import com.enderio.base.common.item.capacitors.LootCapacitorItem;
import com.enderio.base.common.item.misc.BrokenSpawnerItem;
import com.enderio.base.common.item.misc.CreativeTabIconItem;
import com.enderio.base.common.item.misc.EnderiosItem;
Expand Down Expand Up @@ -101,14 +102,14 @@ public class EIOItems {
public static final RegiliteItem<CapacitorItem> BASIC_CAPACITOR = ITEM_REGISTRY
.registerItem("basic_capacitor",
props -> new CapacitorItem(
props.component(EIODataComponents.CAPACITOR_DATA, CapacitorData.simple(1.0f))),
props.component(EIODataComponents.CAPACITOR_DATA, CapacitorData.simple(1))),
new Item.Properties().stacksTo(1))
.setTab(EIOCreativeTabs.MAIN);

public static final RegiliteItem<CapacitorItem> DOUBLE_LAYER_CAPACITOR = ITEM_REGISTRY
.registerItem("double_layer_capacitor",
props -> new CapacitorItem(
props.component(EIODataComponents.CAPACITOR_DATA, CapacitorData.simple(2.0f))),
props.component(EIODataComponents.CAPACITOR_DATA, CapacitorData.simple(2))),
new Item.Properties().stacksTo(1))
.setTab(EIOCreativeTabs.MAIN);

Expand All @@ -119,8 +120,8 @@ public class EIOItems {
new Item.Properties().stacksTo(1))
.setTab(EIOCreativeTabs.MAIN);

public static final RegiliteItem<CapacitorItem> LOOT_CAPACITOR = ITEM_REGISTRY
.registerItem("loot_capacitor", CapacitorItem::new, new Item.Properties()
public static final RegiliteItem<LootCapacitorItem> LOOT_CAPACITOR = ITEM_REGISTRY
.registerItem("loot_capacitor", LootCapacitorItem::new, new Item.Properties()
.stacksTo(1));

// endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.enderio.base.common.item.capacitors;

import com.enderio.api.capacitor.CapacitorData;
import com.enderio.api.capacitor.CapacitorModifier;
import com.enderio.base.common.init.EIOAttachments;
import com.enderio.base.common.init.EIODataComponents;
import com.enderio.base.common.lang.EIOLang;
import com.enderio.core.common.util.TooltipUtil;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.ItemStack;

public class LootCapacitorItem extends CapacitorItem {
public LootCapacitorItem(Properties properties) {
super(properties);
}

@Override
public Component getName(ItemStack pStack) {
var capacitorData = pStack.getOrDefault(EIODataComponents.CAPACITOR_DATA, CapacitorData.NONE);

if (capacitorData.modifiers().isEmpty()) {
return getBaseName(capacitorData);
}

return getModifierQuality(capacitorData)
.copy()
.append(" ")
.append(getModifierType(capacitorData))
.append(" ")
.append(getBaseName(capacitorData));
}

private MutableComponent getBaseName(CapacitorData capacitorData) {
float base = capacitorData.base();

if (base < 1f) {
return EIOLang.LOOT_CAPACITOR_BASE_DUD;
} else if (base < 1.5f) {
return EIOLang.LOOT_CAPACITOR_BASE_NORMAL;
} else if (base < 2.5f) {
return EIOLang.LOOT_CAPACITOR_BASE_ENHANCED;
} else if (base < 3.5f) {
return EIOLang.LOOT_CAPACITOR_BASE_WONDER;
}

return EIOLang.LOOT_CAPACITOR_BASE_IMPOSSIBLE;
}

private MutableComponent getModifierType(CapacitorData capacitorData) {
var firstType = capacitorData.modifiers().keySet().stream().findFirst();

if (firstType.isEmpty()) {
throw new IllegalArgumentException();
}

// TODO: Use a map for this instead.
if (firstType.get() == CapacitorModifier.ENERGY_CAPACITY) {
return EIOLang.LOOT_CAPACITOR_TYPE_ENERGY_CAPACITY;
} else if (firstType.get() == CapacitorModifier.ENERGY_USE) {
return EIOLang.LOOT_CAPACITOR_TYPE_ENERGY_USE;
}

return EIOLang.LOOT_CAPACITOR_TYPE_UNKNOWN;
}

private MutableComponent getModifierQuality(CapacitorData capacitorData) {
var firstModifier = capacitorData.modifiers().values().stream().findFirst();

if (firstModifier.isEmpty()) {
throw new IllegalArgumentException();
}

float modifier = firstModifier.get();

if (modifier < 1f) {
return EIOLang.LOOT_CAPACITOR_MODIFIER_FAILED;
} else if (modifier < 1.5f) {
return EIOLang.LOOT_CAPACITOR_MODIFIER_SIMPLE;
} else if (modifier < 2.5f) {
return EIOLang.LOOT_CAPACITOR_MODIFIER_NICE;
} else if (modifier < 3f) {
return EIOLang.LOOT_CAPACITOR_MODIFIER_GOOD;
} else if (modifier < 3.5f) {
return EIOLang.LOOT_CAPACITOR_MODIFIER_ENHANCED;
} else if (modifier < 4f) {
return EIOLang.LOOT_CAPACITOR_MODIFIER_PREMIUM;
} else if (modifier < 4.25f) {
return EIOLang.LOOT_CAPACITOR_MODIFIER_INCREDIBLY;
}

return EIOLang.LOOT_CAPACITOR_MODIFIER_UNSTABLE;
}
}
Loading

0 comments on commit 59c8020

Please sign in to comment.