diff --git a/src/api/java/com/enderio/api/travel/TravelTargetApi.java b/src/api/java/com/enderio/api/travel/TravelTargetApi.java index bcf74f745f..432ad7883f 100644 --- a/src/api/java/com/enderio/api/travel/TravelTargetApi.java +++ b/src/api/java/com/enderio/api/travel/TravelTargetApi.java @@ -9,7 +9,6 @@ import java.util.stream.Stream; public interface TravelTargetApi { - TravelTargetApi INSTANCE = ServiceLoader.load(TravelTargetApi.class).findFirst().orElseThrow(); Optional get(Level level, BlockPos pos); diff --git a/src/conduits/java/com/enderio/conduits/client/model/ConduitBlockModel.java b/src/conduits/java/com/enderio/conduits/client/model/ConduitBlockModel.java index 17e4d992d5..ae057cfbfe 100644 --- a/src/conduits/java/com/enderio/conduits/client/model/ConduitBlockModel.java +++ b/src/conduits/java/com/enderio/conduits/client/model/ConduitBlockModel.java @@ -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; diff --git a/src/conduits/java/com/enderio/conduits/common/ConduitApiImpl.java b/src/conduits/java/com/enderio/conduits/common/ConduitApiImpl.java index 3c86401da1..1f0da6afa9 100644 --- a/src/conduits/java/com/enderio/conduits/common/ConduitApiImpl.java +++ b/src/conduits/java/com/enderio/conduits/common/ConduitApiImpl.java @@ -8,7 +8,6 @@ import java.util.function.Supplier; -// TODO: Maybe use service location for the TravelTargetAPI. public class ConduitApiImpl implements ConduitApi { @Override diff --git a/src/conduits/java/com/enderio/conduits/common/types/energy/EnergyConduitTicker.java b/src/conduits/java/com/enderio/conduits/common/types/energy/EnergyConduitTicker.java index 4ab093cf19..e2e5221e76 100644 --- a/src/conduits/java/com/enderio/conduits/common/types/energy/EnergyConduitTicker.java +++ b/src/conduits/java/com/enderio/conduits/common/types/energy/EnergyConduitTicker.java @@ -29,7 +29,7 @@ public void tickGraph(ConduitType type, List> 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; diff --git a/src/conduits/java/com/enderio/conduits/common/types/energy/EnergyConduitType.java b/src/conduits/java/com/enderio/conduits/common/types/energy/EnergyConduitType.java index 29399fc460..a926c938e6 100644 --- a/src/conduits/java/com/enderio/conduits/common/types/energy/EnergyConduitType.java +++ b/src/conduits/java/com/enderio/conduits/common/types/energy/EnergyConduitType.java @@ -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); } diff --git a/src/core/java/com/enderio/core/common/recipes/CountedIngredient.java b/src/core/java/com/enderio/core/common/recipes/CountedIngredient.java index 5d88fb4345..d91f351efd 100644 --- a/src/core/java/com/enderio/core/common/recipes/CountedIngredient.java +++ b/src/core/java/com/enderio/core/common/recipes/CountedIngredient.java @@ -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. */ diff --git a/src/machines/java/com/enderio/machines/common/init/MachineBlocks.java b/src/machines/java/com/enderio/machines/common/init/MachineBlocks.java index 9c02b22681..c696fb3b12 100644 --- a/src/machines/java/com/enderio/machines/common/init/MachineBlocks.java +++ b/src/machines/java/com/enderio/machines/common/init/MachineBlocks.java @@ -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; diff --git a/src/main/java/com/enderio/base/client/ClientSetup.java b/src/main/java/com/enderio/base/client/ClientSetup.java index da2ef7db70..f80ce20218 100644 --- a/src/main/java/com/enderio/base/client/ClientSetup.java +++ b/src/main/java/com/enderio/base/client/ClientSetup.java @@ -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; diff --git a/src/main/java/com/enderio/base/client/renderer/item/GlassIconDecorator.java b/src/main/java/com/enderio/base/client/decorator/GlassIconDecorator.java similarity index 96% rename from src/main/java/com/enderio/base/client/renderer/item/GlassIconDecorator.java rename to src/main/java/com/enderio/base/client/decorator/GlassIconDecorator.java index 3111c89cee..a013ac2433 100644 --- a/src/main/java/com/enderio/base/client/renderer/item/GlassIconDecorator.java +++ b/src/main/java/com/enderio/base/client/decorator/GlassIconDecorator.java @@ -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; diff --git a/src/main/java/com/enderio/base/client/renderer/item/package-info.java b/src/main/java/com/enderio/base/client/decorator/package-info.java similarity index 66% rename from src/main/java/com/enderio/base/client/renderer/item/package-info.java rename to src/main/java/com/enderio/base/client/decorator/package-info.java index 8a324dd5fe..44df538435 100644 --- a/src/main/java/com/enderio/base/client/renderer/item/package-info.java +++ b/src/main/java/com/enderio/base/client/decorator/package-info.java @@ -1,4 +1,4 @@ @javax.annotation.ParametersAreNonnullByDefault @net.minecraft.MethodsReturnNonnullByDefault -package com.enderio.base.client.renderer.item; +package com.enderio.base.client.decorator; diff --git a/src/main/java/com/enderio/base/client/gui/screen/CoordinateMenuScreen.java b/src/main/java/com/enderio/base/client/gui/screen/CoordinateMenuScreen.java index 799c6c7118..ef87b74ca5 100644 --- a/src/main/java/com/enderio/base/client/gui/screen/CoordinateMenuScreen.java +++ b/src/main/java/com/enderio/base/client/gui/screen/CoordinateMenuScreen.java @@ -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; @@ -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); @@ -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()); } @@ -68,7 +71,6 @@ protected Vector2i getBackgroundImageSize() { return BG_SIZE; } - private void onNameChanged(String name) { PacketDistributor.sendToServer(new UpdateCoordinateSelectionNameMenuPacket(getMenu().containerId, name)); } diff --git a/src/main/java/com/enderio/base/client/renderer/PaintedBlockColor.java b/src/main/java/com/enderio/base/client/paint/PaintedBlockColor.java similarity index 94% rename from src/main/java/com/enderio/base/client/renderer/PaintedBlockColor.java rename to src/main/java/com/enderio/base/client/paint/PaintedBlockColor.java index a60c40477e..4a53309401 100644 --- a/src/main/java/com/enderio/base/client/renderer/PaintedBlockColor.java +++ b/src/main/java/com/enderio/base/client/paint/PaintedBlockColor.java @@ -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; @@ -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; diff --git a/src/main/java/com/enderio/base/client/renderer/entity/PaintedSandRenderer.java b/src/main/java/com/enderio/base/client/paint/PaintedSandRenderer.java similarity index 98% rename from src/main/java/com/enderio/base/client/renderer/entity/PaintedSandRenderer.java rename to src/main/java/com/enderio/base/client/paint/PaintedSandRenderer.java index 9b892f1fb7..1bf4c22833 100644 --- a/src/main/java/com/enderio/base/client/renderer/entity/PaintedSandRenderer.java +++ b/src/main/java/com/enderio/base/client/paint/PaintedSandRenderer.java @@ -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; diff --git a/src/main/java/com/enderio/base/client/model/PaintedBlockGeometry.java b/src/main/java/com/enderio/base/client/paint/model/PaintedBlockGeometry.java similarity index 98% rename from src/main/java/com/enderio/base/client/model/PaintedBlockGeometry.java rename to src/main/java/com/enderio/base/client/paint/model/PaintedBlockGeometry.java index 331bf9f896..e044b98105 100644 --- a/src/main/java/com/enderio/base/client/model/PaintedBlockGeometry.java +++ b/src/main/java/com/enderio/base/client/paint/model/PaintedBlockGeometry.java @@ -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; diff --git a/src/main/java/com/enderio/base/client/model/PaintedBlockModel.java b/src/main/java/com/enderio/base/client/paint/model/PaintedBlockModel.java similarity index 99% rename from src/main/java/com/enderio/base/client/model/PaintedBlockModel.java rename to src/main/java/com/enderio/base/client/paint/model/PaintedBlockModel.java index f154b27fd1..a42169827d 100644 --- a/src/main/java/com/enderio/base/client/model/PaintedBlockModel.java +++ b/src/main/java/com/enderio/base/client/paint/model/PaintedBlockModel.java @@ -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; diff --git a/src/main/java/com/enderio/base/client/model/PaintingQuadTransformer.java b/src/main/java/com/enderio/base/client/paint/model/PaintingQuadTransformer.java similarity index 97% rename from src/main/java/com/enderio/base/client/model/PaintingQuadTransformer.java rename to src/main/java/com/enderio/base/client/paint/model/PaintingQuadTransformer.java index e463f49279..9636485054 100644 --- a/src/main/java/com/enderio/base/client/model/PaintingQuadTransformer.java +++ b/src/main/java/com/enderio/base/client/paint/model/PaintingQuadTransformer.java @@ -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; diff --git a/src/main/java/com/enderio/base/client/renderer/entity/package-info.java b/src/main/java/com/enderio/base/client/renderer/entity/package-info.java deleted file mode 100644 index a91639e400..0000000000 --- a/src/main/java/com/enderio/base/client/renderer/entity/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@javax.annotation.ParametersAreNonnullByDefault -@net.minecraft.MethodsReturnNonnullByDefault - -package com.enderio.base.client.renderer.entity; diff --git a/src/main/java/com/enderio/base/client/renderer/travel/package-info.java b/src/main/java/com/enderio/base/client/renderer/travel/package-info.java deleted file mode 100644 index 709050b5ac..0000000000 --- a/src/main/java/com/enderio/base/client/renderer/travel/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@javax.annotation.ParametersAreNonnullByDefault -@net.minecraft.MethodsReturnNonnullByDefault - -package com.enderio.base.client.renderer.travel; diff --git a/src/main/java/com/enderio/base/client/renderer/travel/TravelParticleHandler.java b/src/main/java/com/enderio/base/client/travel/TravelParticleHandler.java similarity index 98% rename from src/main/java/com/enderio/base/client/renderer/travel/TravelParticleHandler.java rename to src/main/java/com/enderio/base/client/travel/TravelParticleHandler.java index b1fa31bfaa..93f46fbf5f 100644 --- a/src/main/java/com/enderio/base/client/renderer/travel/TravelParticleHandler.java +++ b/src/main/java/com/enderio/base/client/travel/TravelParticleHandler.java @@ -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; @@ -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); diff --git a/src/main/java/com/enderio/base/client/renderer/travel/TravelTargetRendering.java b/src/main/java/com/enderio/base/client/travel/TravelTargetRendering.java similarity index 98% rename from src/main/java/com/enderio/base/client/renderer/travel/TravelTargetRendering.java rename to src/main/java/com/enderio/base/client/travel/TravelTargetRendering.java index 9690a4bc82..a07a343740 100644 --- a/src/main/java/com/enderio/base/client/renderer/travel/TravelTargetRendering.java +++ b/src/main/java/com/enderio/base/client/travel/TravelTargetRendering.java @@ -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; diff --git a/src/main/java/com/enderio/base/client/model/package-info.java b/src/main/java/com/enderio/base/client/travel/package-info.java similarity index 70% rename from src/main/java/com/enderio/base/client/model/package-info.java rename to src/main/java/com/enderio/base/client/travel/package-info.java index 369a1ec5ed..69e4315828 100644 --- a/src/main/java/com/enderio/base/client/model/package-info.java +++ b/src/main/java/com/enderio/base/client/travel/package-info.java @@ -1,4 +1,4 @@ @javax.annotation.ParametersAreNonnullByDefault @net.minecraft.MethodsReturnNonnullByDefault -package com.enderio.base.client.model; +package com.enderio.base.client.travel; diff --git a/src/main/java/com/enderio/base/common/init/EIOBlocks.java b/src/main/java/com/enderio/base/common/init/EIOBlocks.java index d26f07e536..231fc593b2 100644 --- a/src/main/java/com/enderio/base/common/init/EIOBlocks.java +++ b/src/main/java/com/enderio/base/common/init/EIOBlocks.java @@ -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; diff --git a/src/main/java/com/enderio/base/common/init/EIOCriterions.java b/src/main/java/com/enderio/base/common/init/EIOCriterions.java index 129c2d7662..1626dbfcc4 100644 --- a/src/main/java/com/enderio/base/common/init/EIOCriterions.java +++ b/src/main/java/com/enderio/base/common/init/EIOCriterions.java @@ -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; diff --git a/src/main/java/com/enderio/base/common/init/EIOEntities.java b/src/main/java/com/enderio/base/common/init/EIOEntities.java index 552f58cb7d..6d90bcdd65 100644 --- a/src/main/java/com/enderio/base/common/init/EIOEntities.java +++ b/src/main/java/com/enderio/base/common/init/EIOEntities.java @@ -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; diff --git a/src/main/java/com/enderio/base/common/init/EIOItems.java b/src/main/java/com/enderio/base/common/init/EIOItems.java index 68c52d5cb2..c178a315e3 100644 --- a/src/main/java/com/enderio/base/common/init/EIOItems.java +++ b/src/main/java/com/enderio/base/common/init/EIOItems.java @@ -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; @@ -101,14 +102,14 @@ public class EIOItems { public static final RegiliteItem 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 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); @@ -119,8 +120,8 @@ public class EIOItems { new Item.Properties().stacksTo(1)) .setTab(EIOCreativeTabs.MAIN); - public static final RegiliteItem LOOT_CAPACITOR = ITEM_REGISTRY - .registerItem("loot_capacitor", CapacitorItem::new, new Item.Properties() + public static final RegiliteItem LOOT_CAPACITOR = ITEM_REGISTRY + .registerItem("loot_capacitor", LootCapacitorItem::new, new Item.Properties() .stacksTo(1)); // endregion diff --git a/src/main/java/com/enderio/base/common/item/capacitors/LootCapacitorItem.java b/src/main/java/com/enderio/base/common/item/capacitors/LootCapacitorItem.java new file mode 100644 index 0000000000..3b47d359c3 --- /dev/null +++ b/src/main/java/com/enderio/base/common/item/capacitors/LootCapacitorItem.java @@ -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; + } +} diff --git a/src/main/java/com/enderio/base/common/lang/EIOLang.java b/src/main/java/com/enderio/base/common/lang/EIOLang.java index 3140cc5b26..1f04a3e2fe 100644 --- a/src/main/java/com/enderio/base/common/lang/EIOLang.java +++ b/src/main/java/com/enderio/base/common/lang/EIOLang.java @@ -15,6 +15,13 @@ public class EIOLang { public static final Component BLOCK_BLAST_RESISTANT = TooltipUtil.style(addTranslation("tooltip", EnderIO.loc("block.blast_resistant"), "Blast resistant")); + // region GUI Interactions + + public static final Component OK = addTranslation("gui", EnderIO.loc("ok"), "Ok"); + public static final Component CANCEL = addTranslation("gui", EnderIO.loc("cancel"), "Cancel"); + + // endregion + // region Fused Quartz public static final Component FUSED_QUARTZ_EMITS_LIGHT = TooltipUtil.style(addTranslation("tooltip", EnderIO.loc("fused_quartz.emits_light"), "Emits light")); @@ -71,12 +78,37 @@ public class EIOLang { public static final MutableComponent CAPACITOR_TOOLTIP_ENERGY_CAPACITY = addTranslation("tooltip", CapacitorModifier.ENERGY_CAPACITY.modifierId, "Energy Capacity Modifier: %s"); public static final MutableComponent CAPACITOR_TOOLTIP_ENERGY_USE = addTranslation("tooltip", CapacitorModifier.ENERGY_USE.modifierId, "Energy Use Modifier: %s"); - public static final Component GLIDER_DISABLED = addTranslation("message", EnderIO.loc("glider.disable"), "Gliding is disabled: "); - public static final Component GLIDER_DISABLED_FALL_FLYING = addTranslation("message", EnderIO.loc("glider.disable.fall_flying"), "Elytra Flight"); + // region Loot Capacitor + + // Declares order. In this case: Modifier Quality, Modifier Type, Base Quality. Takes first modifier. + public static final MutableComponent LOOT_CAPACITOR_NAME = addTranslation("item", EnderIO.loc("loot_capacitor_template"), "%s %s %s"); + public static final MutableComponent LOOT_CAPACITOR_BASE_DUD = addTranslation("item", EnderIO.loc("loot_capacitor_dud"), "Capacitor Dud"); + public static final MutableComponent LOOT_CAPACITOR_BASE_NORMAL = addTranslation("item", EnderIO.loc("loot_capacitor_normal"), "Capacitor"); + public static final MutableComponent LOOT_CAPACITOR_BASE_ENHANCED = addTranslation("item", EnderIO.loc("loot_capacitor_enhanced"), "Enhanced Capacitor"); + public static final MutableComponent LOOT_CAPACITOR_BASE_WONDER = addTranslation("item", EnderIO.loc("loot_capacitor_wonder"), "Wonder Capacitor"); + public static final MutableComponent LOOT_CAPACITOR_BASE_IMPOSSIBLE = addTranslation("item", EnderIO.loc("loot_capacitor_impossible"), "Impossible Capacitor"); + + public static final MutableComponent LOOT_CAPACITOR_TYPE_ENERGY_CAPACITY = addTranslation("item", EnderIO.loc("loot_capacitor_energy_capacity"), "Insatiable"); + public static final MutableComponent LOOT_CAPACITOR_TYPE_ENERGY_USE = addTranslation("item", EnderIO.loc("loot_capacitor_energy_use"), "Hungry"); + public static final MutableComponent LOOT_CAPACITOR_TYPE_UNKNOWN = addTranslation("item", EnderIO.loc("loot_capacitor_unknown"), "Mystery"); + + public static final MutableComponent LOOT_CAPACITOR_MODIFIER_FAILED = addTranslation("item", EnderIO.loc("loot_capacitor_modifier_failed"), "Failed"); + public static final MutableComponent LOOT_CAPACITOR_MODIFIER_SIMPLE = addTranslation("item", EnderIO.loc("loot_capacitor_modifier_simple"), "Simple"); + public static final MutableComponent LOOT_CAPACITOR_MODIFIER_NICE = addTranslation("item", EnderIO.loc("loot_capacitor_modifier_nice"), "Nice"); + public static final MutableComponent LOOT_CAPACITOR_MODIFIER_GOOD = addTranslation("item", EnderIO.loc("loot_capacitor_modifier_good"), "Good"); + public static final MutableComponent LOOT_CAPACITOR_MODIFIER_ENHANCED = addTranslation("item", EnderIO.loc("loot_capacitor_modifier_enhanced"), "Enhanced"); + public static final MutableComponent LOOT_CAPACITOR_MODIFIER_PREMIUM = addTranslation("item", EnderIO.loc("loot_capacitor_modifier_premium"), "Premium"); + public static final MutableComponent LOOT_CAPACITOR_MODIFIER_INCREDIBLY = addTranslation("item", EnderIO.loc("loot_capacitor_modifier_incredibly"), "Incredibly"); + public static final MutableComponent LOOT_CAPACITOR_MODIFIER_UNSTABLE = addTranslation("item", EnderIO.loc("loot_capacitor_modifier_unstable"), "Unstable"); + + // endregion // endregion + public static final Component GLIDER_DISABLED = addTranslation("message", EnderIO.loc("glider.disable"), "Gliding is disabled: "); + public static final Component GLIDER_DISABLED_FALL_FLYING = addTranslation("message", EnderIO.loc("glider.disable.fall_flying"), "Elytra Flight"); + // region Enchantments public static final Component AUTO_SMELT_DESC = enchantmentDescription("auto_smelt", "desc", diff --git a/src/main/java/com/enderio/base/common/advancement/PaintingTrigger.java b/src/main/java/com/enderio/base/common/paint/PaintingTrigger.java similarity index 84% rename from src/main/java/com/enderio/base/common/advancement/PaintingTrigger.java rename to src/main/java/com/enderio/base/common/paint/PaintingTrigger.java index ba6a068344..c83c6c9a38 100644 --- a/src/main/java/com/enderio/base/common/advancement/PaintingTrigger.java +++ b/src/main/java/com/enderio/base/common/paint/PaintingTrigger.java @@ -1,4 +1,4 @@ -package com.enderio.base.common.advancement; +package com.enderio.base.common.paint; import com.enderio.EnderIO; import com.enderio.base.common.init.EIOCriterions; @@ -34,9 +34,10 @@ public Codec codec() { public record TriggerInstance(Optional player, Block paint) implements SimpleInstance { - private static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player), - BuiltInRegistries.BLOCK.byNameCodec().fieldOf("paint").forGetter(TriggerInstance::paint) + private static final Codec CODEC = RecordCodecBuilder.create( + instance -> instance.group( + EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player), + BuiltInRegistries.BLOCK.byNameCodec().fieldOf("paint").forGetter(TriggerInstance::paint) ).apply(instance, TriggerInstance::new)); public boolean matches(Block paint) { diff --git a/src/main/java/com/enderio/base/data/advancement/EIOAdvancementGenerator.java b/src/main/java/com/enderio/base/data/advancement/EIOAdvancementGenerator.java index 8c35fc675b..e372b96319 100644 --- a/src/main/java/com/enderio/base/data/advancement/EIOAdvancementGenerator.java +++ b/src/main/java/com/enderio/base/data/advancement/EIOAdvancementGenerator.java @@ -1,7 +1,7 @@ package com.enderio.base.data.advancement; import com.enderio.EnderIO; -import com.enderio.base.common.advancement.PaintingTrigger; +import com.enderio.base.common.paint.PaintingTrigger; import com.enderio.base.common.lang.EIOLang; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementHolder;