From c135700d7e0a182b09c8c3af41e082b7c8e1250e Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Tue, 27 Aug 2024 15:34:07 -0400 Subject: [PATCH] forgot about the fucking router compat --- .../tileentity/IControlReceiverFilter.java | 7 ++- .../network/TileEntityCraneBase.java | 4 +- .../network/TileEntityCraneRouter.java | 58 +++++++++++++++++++ src/main/resources/assets/hbm/lang/en_US.lang | 1 + 4 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/hbm/tileentity/IControlReceiverFilter.java b/src/main/java/com/hbm/tileentity/IControlReceiverFilter.java index 844c001e2..be5279ca1 100644 --- a/src/main/java/com/hbm/tileentity/IControlReceiverFilter.java +++ b/src/main/java/com/hbm/tileentity/IControlReceiverFilter.java @@ -79,7 +79,7 @@ public interface IControlReceiverFilter extends IControlReceiver, ICopiable { NBTTagCompound slotNBT = items.getCompoundTagAt(count); byte slot = slotNBT.getByte("slot"); ItemStack loadedStack = ItemStack.loadItemStackFromNBT(slotNBT); - if (loadedStack != null) { + if (loadedStack != null && slot < getFilterSlots()[1]) { inv.setInventorySlotContents(slot + getFilterSlots()[0], ItemStack.loadItemStackFromNBT(slotNBT)); nextMode(slot); tile.getWorldObj().markTileEntityChunkModified(tile.xCoord, tile.yCoord, tile.zCoord, tile); @@ -90,4 +90,9 @@ public interface IControlReceiverFilter extends IControlReceiver, ICopiable { } } + + @Override + default String[] infoForDisplay(World world, int x, int y, int z) { + return new String[] { "copytool.filter" }; + } } diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityCraneBase.java b/src/main/java/com/hbm/tileentity/network/TileEntityCraneBase.java index a13fb00fa..61a81339b 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityCraneBase.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityCraneBase.java @@ -160,7 +160,7 @@ public abstract class TileEntityCraneBase extends TileEntityMachineBase implemen NBTTagCompound slotNBT = items.getCompoundTagAt(count); byte slot = slotNBT.getByte("slot"); ItemStack loadedStack = ItemStack.loadItemStackFromNBT(slotNBT); - if (loadedStack != null) { + if (loadedStack != null && slot < filter.getFilterSlots()[1]) { inv.setInventorySlotContents(slot + filter.getFilterSlots()[0], ItemStack.loadItemStackFromNBT(slotNBT)); filter.nextMode(slot); this.getWorldObj().markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this); @@ -175,6 +175,6 @@ public abstract class TileEntityCraneBase extends TileEntityMachineBase implemen @Override public String[] infoForDisplay(World world, int x, int y, int z) { - return new String[]{"Filter", "Orientation"}; + return new String[]{"copytool.filter", "copytool.orientation"}; } } diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityCraneRouter.java b/src/main/java/com/hbm/tileentity/network/TileEntityCraneRouter.java index a12e59851..ff914eb34 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityCraneRouter.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityCraneRouter.java @@ -12,8 +12,11 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Vec3; import net.minecraft.world.World; @@ -136,4 +139,59 @@ public class TileEntityCraneRouter extends TileEntityMachineBase implements IGUI setFilterContents(data); } } + + @Override + public NBTTagCompound getSettings(World world, int x, int y, int z) { + IInventory inv = (IInventory) this; + NBTTagCompound nbt = new NBTTagCompound(); + NBTTagList tags = new NBTTagList(); + + int count = 0; + for (int i = getFilterSlots()[0]; i < getFilterSlots()[1]; i++) { + NBTTagCompound slotNBT = new NBTTagCompound(); + if (inv.getStackInSlot(i) != null) { + slotNBT.setByte("slot", (byte) count); + inv.getStackInSlot(i).writeToNBT(slotNBT); + tags.appendTag(slotNBT); + } + count++; + } + + nbt.setTag("items", tags); + nbt.setIntArray("modes", modes); + + return nbt; + } + + @Override + public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) { + + NBTTagList items = nbt.getTagList("items", 10); + int listSize = items.tagCount(); + + if(listSize > 0 && nbt.hasKey("modes")) { + for (int i = 0; i < listSize; i++) { + NBTTagCompound slotNBT = items.getCompoundTagAt(i); + byte slot = slotNBT.getByte("slot"); + ItemStack loadedStack = ItemStack.loadItemStackFromNBT(slotNBT); + + if (loadedStack != null && slot > index * 5 && slot < Math.min(index * 5 + 5, 30)) { + this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(slotNBT)); + nextMode(slot); + this.getWorldObj().markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this); + } + } + } else { + IControlReceiverFilter.super.pasteSettings(nbt, index, world, player, x, y, z); + } + } + + @Override + public String[] infoForDisplay(World world, int x, int y, int z) { + String[] options = new String[patterns.length]; + for (int i = 0; i < options.length; i++) { + options[i] = "copytool.pattern" + i; + } + return options; + } } diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index ffab06692..a9ac23387 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -4273,6 +4273,7 @@ item.seg_20.name=Size 20 Connector item.serum.name=Serum item.servo_set.name=Servo Set item.servo_set_desh.name=Desh Servo Set +item.settings_tool.name=Settings Tool item.shackles.name=Shackles item.shellntm.name=%s Shell item.shimmer_axe.name=Shimmer Axe