From 3edef49c04dfce978ed073d8b7cd40358c32868d Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Wed, 20 Dec 2023 15:02:25 -0600 Subject: [PATCH] Some sack fixes, other misc things. --- .../actuallyadditions/api/ActuallyTags.java | 9 ++ .../mod/ActuallyAdditions.java | 6 +- .../mod/ActuallyAdditionsClient.java | 6 +- .../config/values/ConfigStringListValues.java | 10 --- .../mod/event/CommonEvents.java | 6 +- .../mod/inventory/ActuallyContainers.java | 2 +- .../{ContainerBag.java => SackContainer.java} | 88 +++++++------------ .../gui/{GuiBag.java => SackGui.java} | 8 +- .../mod/items/ActuallyItems.java | 6 +- .../mod/items/{ItemBag.java => Sack.java} | 12 +-- .../mod/items/{ItemWorm.java => Worm.java} | 4 +- 11 files changed, 67 insertions(+), 90 deletions(-) rename src/main/java/de/ellpeck/actuallyadditions/mod/inventory/{ContainerBag.java => SackContainer.java} (69%) rename src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/{GuiBag.java => SackGui.java} (94%) rename src/main/java/de/ellpeck/actuallyadditions/mod/items/{ItemBag.java => Sack.java} (92%) rename src/main/java/de/ellpeck/actuallyadditions/mod/items/{ItemWorm.java => Worm.java} (97%) diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyTags.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyTags.java index 501827882..afb2c435c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyTags.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyTags.java @@ -4,12 +4,21 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraft.item.Item; import net.minecraft.tags.ITag; import net.minecraft.tags.ItemTags; +import net.minecraft.util.ResourceLocation; public final class ActuallyTags { + public static final void init() { + // lol + Items.touch(); + } public static class Items { + public static void touch() { + // load the stupid tags + } public static final ITag.INamedTag DRILLS = tag("drills"); public static final ITag.INamedTag COFFEE_BEANS = tag("coffee_beans"); public static final ITag.INamedTag TINY_COALS = tag("tiny_coals"); + public static final ITag.INamedTag HOLDS_ITEMS = ItemTags.createOptional(new ResourceLocation("forge", "holds_items")); public static final ITag.INamedTag CRYSTALS = tag("crystals"); private static ITag.INamedTag tag(String name) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java index 3cd865d02..af7b5f03e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java @@ -11,6 +11,7 @@ package de.ellpeck.actuallyadditions.mod; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; +import de.ellpeck.actuallyadditions.api.ActuallyTags; import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; @@ -26,7 +27,7 @@ import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.inventory.ActuallyContainers; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.items.ItemCoffee; -import de.ellpeck.actuallyadditions.mod.items.ItemWorm; +import de.ellpeck.actuallyadditions.mod.items.Worm; import de.ellpeck.actuallyadditions.mod.misc.BannerHelper; import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot; import de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler; @@ -103,13 +104,14 @@ public class ActuallyAdditions { ENTITIES.register(eventBus); eventBus.addListener(this::onConfigReload); ActuallyParticles.init(eventBus); + ActuallyTags.init(); MinecraftForge.EVENT_BUS.addListener(this::serverStarted); MinecraftForge.EVENT_BUS.addListener(this::serverStopped); MinecraftForge.EVENT_BUS.register(new CommonEvents()); MinecraftForge.EVENT_BUS.register(new DungeonLoot()); MinecraftForge.EVENT_BUS.addListener(ActuallyAdditions::reloadEvent); - MinecraftForge.EVENT_BUS.addListener(ItemWorm::onHoe); + MinecraftForge.EVENT_BUS.addListener(Worm::onHoe); InitFluids.init(eventBus); eventBus.addListener(this::setup); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditionsClient.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditionsClient.java index a5f00e2ea..698b6fd01 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditionsClient.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditionsClient.java @@ -19,7 +19,9 @@ import de.ellpeck.actuallyadditions.mod.inventory.ActuallyContainers; import de.ellpeck.actuallyadditions.mod.inventory.gui.*; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit; -import de.ellpeck.actuallyadditions.mod.particle.*; +import de.ellpeck.actuallyadditions.mod.particle.ActuallyParticles; +import de.ellpeck.actuallyadditions.mod.particle.ParticleBeam; +import de.ellpeck.actuallyadditions.mod.particle.ParticleLaserItem; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.network.play.ClientPlayNetHandler; @@ -38,7 +40,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; public class ActuallyAdditionsClient { public static void setup(FMLClientSetupEvent event) { - ScreenManager.register(ActuallyContainers.BAG_CONTAINER.get(), GuiBag::new); + ScreenManager.register(ActuallyContainers.BAG_CONTAINER.get(), SackGui::new); ScreenManager.register(ActuallyContainers.BIO_REACTOR_CONTAINER.get(), GuiBioReactor::new); ScreenManager.register(ActuallyContainers.BREAKER_CONTAINER.get(), GuiBreaker::new); ScreenManager.register(ActuallyContainers.CANOLA_PRESS_CONTAINER.get(), GuiCanolaPress::new); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigStringListValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigStringListValues.java index e5d5238dc..d177a5755 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigStringListValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigStringListValues.java @@ -14,11 +14,6 @@ import de.ellpeck.actuallyadditions.mod.config.ConfigCategories; public enum ConfigStringListValues { - CONFIGURE_ITEMS( - "Configuration Items", - ConfigCategories.OTHER, - new String[] { "minecraft:redstone_torch", "minecraft:compass" }, - "The non-Actually Additions items that are used to configure blocks from the mod. The first one is the Redstone Torch used to configure the Redstone Mode, and the second one is the Compass used to configure Laser Relays. If another mod overrides usage of either one of these items, you can change the registry name of the used items (using blocks is not possible) here."), CRUSHER_RECIPE_EXCEPTIONS( "Crusher Recipe Exceptions", ConfigCategories.OTHER, @@ -70,11 +65,6 @@ public enum ConfigStringListValues { ConfigCategories.OTHER, new String[] { "minecraft:villager_golem" }, "By default, the Spawner Changer allows every living entity to be put into a spawner. If there is one that shouldn't be able to, put its MAPPING NAME here."), - SACK_BLACKLIST( - "Sack Blacklist", - ConfigCategories.OTHER, - new String[0], - "The items that aren't allowed to be put in the Traveller's Sack. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_block@3"), REPAIR_BLACKLIST( "Repair Blacklist", ConfigCategories.OTHER, diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java index 72dad948f..8a50d4ada 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java @@ -17,7 +17,7 @@ import de.ellpeck.actuallyadditions.mod.data.PlayerData; import de.ellpeck.actuallyadditions.mod.data.WorldData; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.items.DrillItem; -import de.ellpeck.actuallyadditions.mod.items.ItemBag; +import de.ellpeck.actuallyadditions.mod.items.Sack; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; @@ -66,11 +66,11 @@ public class CommonEvents { if (i != player.inventory.selected) { ItemStack invStack = player.inventory.getItem(i); - if (StackUtil.isValid(invStack) && invStack.getItem() instanceof ItemBag && invStack.hasTag()) { + if (StackUtil.isValid(invStack) && invStack.getItem() instanceof Sack && invStack.hasTag()) { if (invStack.getOrCreateTag().getBoolean("AutoInsert")) { boolean changed = false; - boolean isVoid = ((ItemBag) invStack.getItem()).isVoid; + boolean isVoid = ((Sack) invStack.getItem()).isVoid; ItemStackHandlerAA inv = new ItemStackHandlerAA(28); //TODO whats going on here DrillItem.loadSlotsFromNBT(inv, invStack); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ActuallyContainers.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ActuallyContainers.java index 50bf34df7..474dcb5d7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ActuallyContainers.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ActuallyContainers.java @@ -10,7 +10,7 @@ import net.minecraftforge.registries.ForgeRegistries; public class ActuallyContainers { public static final DeferredRegister> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, ActuallyAdditions.MODID); - public static final RegistryObject> BAG_CONTAINER = CONTAINERS.register("bag_container", () -> IForgeContainerType.create(ContainerBag::fromNetwork)); + public static final RegistryObject> BAG_CONTAINER = CONTAINERS.register("bag_container", () -> IForgeContainerType.create(SackContainer::fromNetwork)); public static final RegistryObject> BIO_REACTOR_CONTAINER = CONTAINERS.register("bioreactor_container", () -> IForgeContainerType.create(ContainerBioReactor::fromNetwork)); public static final RegistryObject> BREAKER_CONTAINER = CONTAINERS.register("breaker_container", () -> IForgeContainerType.create(ContainerBreaker::fromNetwork)); public static final RegistryObject> CANOLA_PRESS_CONTAINER = CONTAINERS.register("canola_press_container", () -> IForgeContainerType.create(ContainerCanolaPress::fromNetwork)); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/SackContainer.java similarity index 69% rename from src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java rename to src/main/java/de/ellpeck/actuallyadditions/mod/inventory/SackContainer.java index 69de80175..1f5eaa810 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/SackContainer.java @@ -10,12 +10,12 @@ package de.ellpeck.actuallyadditions.mod.inventory; +import de.ellpeck.actuallyadditions.api.ActuallyTags; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotDeletion; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.items.DrillItem; -import de.ellpeck.actuallyadditions.mod.items.ItemBag; +import de.ellpeck.actuallyadditions.mod.items.Sack; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; @@ -24,19 +24,16 @@ import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ClickType; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Slot; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import org.apache.commons.lang3.tuple.Pair; -import java.util.ArrayList; -import java.util.List; +import javax.annotation.Nonnull; import java.util.UUID; -public class ContainerBag extends Container implements IButtonReactor { +public class SackContainer extends Container implements IButtonReactor { public final FilterSettings filter = new FilterSettings(4, false, false, false); private final ItemStackHandlerAA bagInventory; @@ -46,45 +43,49 @@ public class ContainerBag extends Container implements IButtonReactor { public static final int SIZE = 28; - public static ContainerBag fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) { - return new ContainerBag(windowId, inv, data.readUUID(), new ItemStackHandlerAA(28)); + public static SackContainer fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) { + return new SackContainer(windowId, inv, data.readUUID(), new ItemStackHandlerAA(28)); } - public ContainerBag(int windowId, PlayerInventory playerInventory, UUID uuid, ItemStackHandlerAA handler) { + public SackContainer(int windowId, PlayerInventory playerInventory, UUID uuid, ItemStackHandlerAA handler) { super(ActuallyContainers.BAG_CONTAINER.get(), windowId); this.inventory = playerInventory; - this.bagInventory = handler; //new ItemStackHandlerAA(SIZE, (slot, stack, automation) -> !isBlacklisted(stack), ItemStackHandlerAA.REMOVE_TRUE); + this.bagInventory = handler; - for (int i = 0; i < 4; i++) { - this.addSlot(new SlotFilter(this.filter, i, 155, 10 + i * 18)); + for (int row = 0; row < 4; row++) { + this.addSlot(new SlotFilter(this.filter, row, 155, 10 + row * 18)); } - if (false) { // isvoid, move to its own container + if (false) { // TODO isvoid, move to its own container this.addSlot(new SlotDeletion(this.bagInventory, 0, 64, 65) { @Override public boolean mayPlace(ItemStack stack) { - return ContainerBag.this.filter.check(stack); + return SackContainer.this.filter.check(stack); } }); } - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 7; j++) { - this.addSlot(new SlotItemHandlerUnconditioned(this.bagInventory, j + i * 7, 10 + j * 18, 10 + i * 18) { + // Sack inventory + for (int row = 0; row < 4; row++) { + for (int col = 0; col < 7; col++) { + this.addSlot(new SlotItemHandlerUnconditioned(this.bagInventory, col + row * 7, 10 + col * 18, 10 + row * 18) { @Override public boolean mayPlace(ItemStack stack) { - return !isBlacklisted(stack) && ContainerBag.this.filter.check(stack); + return !stack.getItem().is(ActuallyTags.Items.HOLDS_ITEMS) && SackContainer.this.filter.check(stack); } }); } } - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 9; j++) { - this.addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 94 + i * 18)); + // Player Inventory + for (int row = 0; row < 3; row++) { + for (int col = 0; col < 9; col++) { + this.addSlot(new Slot(playerInventory, col + row * 9 + 9, 8 + col * 18, 94 + row * 18)); } } + + // Player Hotbar for (int i = 0; i < 9; i++) { if (i == playerInventory.selected) { this.addSlot(new SlotImmovable(playerInventory, i, 8 + i * 18, 152)); @@ -94,8 +95,8 @@ public class ContainerBag extends Container implements IButtonReactor { } ItemStack stack = playerInventory.getSelected(); - if (!stack.isEmpty() && stack.getItem() instanceof ItemBag) { - DrillItem.loadSlotsFromNBT(this.bagInventory, playerInventory.getSelected()); + if (!stack.isEmpty() && stack.getItem() instanceof Sack) { + //DrillItem.loadSlotsFromNBT(this.bagInventory, playerInventory.getSelected()); if (stack.hasTag()) { CompoundNBT compound = stack.getOrCreateTag(); this.filter.readFromNBT(compound, "Filter"); @@ -105,7 +106,7 @@ public class ContainerBag extends Container implements IButtonReactor { } @Override - public void broadcastChanges() { + public void broadcastChanges() { // TODO is this needed anymore? super.broadcastChanges(); if (this.filter.needsUpdateSend() || this.autoInsert != this.oldAutoInsert) { @@ -149,7 +150,7 @@ public class ContainerBag extends Container implements IButtonReactor { } @Override - public ItemStack quickMoveStack(PlayerEntity player, int slot) { + public ItemStack quickMoveStack(@Nonnull PlayerEntity player, int slot) { int inventoryStart = this.bagInventory.getSlots() + 4; int inventoryEnd = inventoryStart + 26; int hotbarStart = inventoryEnd + 1; @@ -165,7 +166,7 @@ public class ContainerBag extends Container implements IButtonReactor { if (slot >= inventoryStart) { //Shift from Inventory if (!this.filter.check(newStack) || !this.moveItemStackTo(newStack, 4, 32, false)) { - if (slot >= inventoryStart && slot <= inventoryEnd) { + if (slot <= inventoryEnd) { if (!this.moveItemStackTo(newStack, hotbarStart, hotbarEnd + 1, false)) { return ItemStack.EMPTY; } @@ -209,8 +210,8 @@ public class ContainerBag extends Container implements IButtonReactor { @Override public void removed(PlayerEntity player) { ItemStack stack = this.inventory.getSelected(); - if (!stack.isEmpty() && stack.getItem() instanceof ItemBag) { - DrillItem.writeSlotsToNBT(this.bagInventory, this.inventory.getSelected()); + if (!stack.isEmpty() && stack.getItem() instanceof Sack) { + //DrillItem.writeSlotsToNBT(this.bagInventory, this.inventory.getSelected()); CompoundNBT compound = stack.getOrCreateTag(); this.filter.writeToNBT(compound, "Filter"); compound.putBoolean("AutoInsert", this.autoInsert); @@ -220,7 +221,7 @@ public class ContainerBag extends Container implements IButtonReactor { @Override public boolean stillValid(PlayerEntity player) { - return true; //!this.sack.isEmpty() && player.getMainHandItem() == this.sack; //TODO fix later + return true; } @Override @@ -231,31 +232,4 @@ public class ContainerBag extends Container implements IButtonReactor { //this.filter.onButtonPressed(buttonID); //TODO } } - - private static final List> BLACKLIST = new ArrayList<>(); - - private static boolean runOnce = false; - - // TODO: [port] FIX THIS - public static boolean isBlacklisted(ItemStack stack) { - //TODO replace with modern tagging blocking etc - return false; -/* if (!runOnce) { - runOnce = true; - for (String s : ConfigStringListValues.SACK_BLACKLIST.getValue()) { - String[] split = s.split("@"); - Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(split[0])); - if (item == null) { - ActuallyAdditions.LOGGER.error("Invalid item in sack blacklist: " + s); - continue; - } - if (split.length == 1) { - BLACKLIST.add(Pair.of(item, 0)); - } else if (split.length == 2) { - BLACKLIST.add(Pair.of(item, Integer.parseInt(split[1]))); - } - } - } - return BLACKLIST.contains(Pair.of(stack.getItem(), 0));*/ - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBag.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/SackGui.java similarity index 94% rename from src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBag.java rename to src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/SackGui.java index 044bc9afe..208a44f25 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBag.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/SackGui.java @@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; -import de.ellpeck.actuallyadditions.mod.inventory.ContainerBag; +import de.ellpeck.actuallyadditions.mod.inventory.SackContainer; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.entity.player.PlayerInventory; @@ -21,16 +21,16 @@ import net.minecraft.util.text.ITextComponent; import javax.annotation.Nonnull; -public class GuiBag extends AAScreen { +public class SackGui extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_bag"); private static final ResourceLocation RES_LOC_VOID = AssetUtil.getGuiLocation("gui_void_bag"); - private final ContainerBag container; + private final SackContainer container; private final boolean isVoid; private FilterSettingsGui filter; private Button buttonAutoInsert; - public GuiBag(ContainerBag container, PlayerInventory inventory, ITextComponent title) { + public SackGui(SackContainer container, PlayerInventory inventory, ITextComponent title) { super(container, inventory, title); this.imageWidth = 176; this.imageHeight = 90 + 86; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java index d04dc1769..f5acc849c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java @@ -99,9 +99,9 @@ public final class ActuallyItems { public static final RegistryObject LASER_UPGRADE_RANGE = ITEMS.register("laser_upgrade_range", ItemLaserRelayUpgrade::new); public static final RegistryObject LASER_UPGRADE_INVISIBILITY = ITEMS.register("laser_upgrade_invisibility", ItemLaserRelayUpgrade::new); public static final Supplier HANDHELD_FILLER = ITEMS.register("handheld_filler", ItemFillingWand::new); - public static final RegistryObject TRAVELERS_SACK = ITEMS.register("travelers_sack", () -> new ItemBag(false)); - public static final RegistryObject VOID_SACK = ITEMS.register("void_sack", () -> new ItemBag(true)); - public static final RegistryObject WORM = ITEMS.register("worm", ItemWorm::new); + public static final RegistryObject TRAVELERS_SACK = ITEMS.register("travelers_sack", () -> new Sack(false)); + public static final RegistryObject VOID_SACK = ITEMS.register("void_sack", () -> new Sack(true)); + public static final RegistryObject WORM = ITEMS.register("worm", Worm::new); public static final RegistryObject PLAYER_PROBE = ITEMS.register("player_probe", ItemPlayerProbe::new); public static final RegistryObject FILTER = ITEMS.register("filter", ItemFilter::new); public static final RegistryObject WATER_BOWL = ITEMS.register("water_bowl", ItemWaterBowl::new); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBag.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/Sack.java similarity index 92% rename from src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBag.java rename to src/main/java/de/ellpeck/actuallyadditions/mod/items/Sack.java index 17481eb18..a9cfdc28b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBag.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/Sack.java @@ -10,7 +10,7 @@ package de.ellpeck.actuallyadditions.mod.items; -import de.ellpeck.actuallyadditions.mod.inventory.ContainerBag; +import de.ellpeck.actuallyadditions.mod.inventory.SackContainer; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.sack.SackData; import de.ellpeck.actuallyadditions.mod.sack.SackManager; @@ -32,10 +32,10 @@ import net.minecraftforge.items.CapabilityItemHandler; import java.util.UUID; -public class ItemBag extends ItemBase { +public class Sack extends ItemBase { public final boolean isVoid; - public ItemBag(boolean isVoid) { + public Sack(boolean isVoid) { super(ActuallyItems.defaultProps().stacksTo(1)); this.isVoid = isVoid; } @@ -87,7 +87,7 @@ public class ItemBag extends ItemBase { @Override public ActionResult use(World world, PlayerEntity player, Hand hand) { ItemStack sackStack = player.getItemInHand(hand); - if (!world.isClientSide && hand == Hand.MAIN_HAND && sackStack.getItem() instanceof ItemBag && player instanceof ServerPlayerEntity) { + if (!world.isClientSide && hand == Hand.MAIN_HAND && sackStack.getItem() instanceof Sack && player instanceof ServerPlayerEntity) { if (!isVoid) { SackData data = getData(sackStack); @@ -100,7 +100,7 @@ public class ItemBag extends ItemBase { NetworkHooks.openGui((ServerPlayerEntity) player, new SimpleNamedContainerProvider((id, inv, entity) -> - new ContainerBag(id, inv, uuid, data.getSpecialHandler()), sackStack.getHoverName()), (buffer -> buffer.writeUUID(uuid))); + new SackContainer(id, inv, uuid, data.getSpecialHandler()), sackStack.getHoverName()), (buffer -> buffer.writeUUID(uuid))); } @@ -112,7 +112,7 @@ public class ItemBag extends ItemBase { } public static SackData getData(ItemStack stack) { - if (!(stack.getItem() instanceof ItemBag)) + if (!(stack.getItem() instanceof Sack)) return null; UUID uuid; CompoundNBT tag = stack.getOrCreateTag(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/Worm.java similarity index 97% rename from src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java rename to src/main/java/de/ellpeck/actuallyadditions/mod/items/Worm.java index 0bb1eb997..525990ba2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/Worm.java @@ -28,9 +28,9 @@ import net.minecraftforge.eventbus.api.Event; import java.util.List; -public class ItemWorm extends ItemBase { +public class Worm extends ItemBase { - public ItemWorm() { + public Worm() { super(); }