From ffcce8d9bbc5985e8ef13dcbc803371b47b863bf Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Thu, 29 Aug 2024 20:12:58 -0400 Subject: [PATCH] finishing touches --- .../java/com/hbm/crafting/ToolRecipes.java | 1 + .../com/hbm/items/tool/ItemSettingsTool.java | 62 ++++++++++++------- .../tileentity/IControlReceiverFilter.java | 7 ++- .../com/hbm/tileentity/IFluidCopiable.java | 2 +- .../machine/TileEntityFoundryOutlet.java | 8 +-- .../network/TileEntityCraneBase.java | 4 +- .../network/TileEntityCraneRouter.java | 1 + src/main/resources/assets/hbm/lang/en_US.lang | 11 ++++ 8 files changed, 65 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/hbm/crafting/ToolRecipes.java b/src/main/java/com/hbm/crafting/ToolRecipes.java index d190636e0..113b4c80a 100644 --- a/src/main/java/com/hbm/crafting/ToolRecipes.java +++ b/src/main/java/com/hbm/crafting/ToolRecipes.java @@ -137,6 +137,7 @@ public class ToolRecipes { CraftingManager.addRecipeAuto(new ItemStack(ModItems.bismuth_tool, 1), new Object[] { "TBT", "SRS", "SCS", 'T', TA.nugget(), 'B', ModItems.nugget_bismuth, 'S', ANY_RESISTANTALLOY.ingot(), 'R', ModItems.reacher, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.CHIP) }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.sat_designator, 1), new Object[] { "RRD", "PIC", " P", 'P', GOLD.plate(), 'R', Items.redstone, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), 'D', ModItems.sat_chip, 'I', GOLD.ingot() }); CraftingManager.addShapelessAuto(new ItemStack(ModItems.sat_relay), new Object[] { ModItems.sat_chip, ModItems.ducttape, ModItems.radar_linker }); + CraftingManager.addRecipeAuto(new ItemStack(ModItems.settings_tool), new Object[] { " P ", "PCP", "III", 'P', IRON.plate(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ANALOG), 'I', ModItems.plate_polymer }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.pipette, 1), new Object[] { " L", " G ", "G ", 'L', ANY_RUBBER.ingot(), 'G', KEY_CLEARGLASS}); CraftingManager.addRecipeAuto(new ItemStack(ModItems.pipette_boron, 1), new Object[] { " P", " B ", "B ", 'P', RUBBER.ingot(), 'B', ModBlocks.glass_boron}); diff --git a/src/main/java/com/hbm/items/tool/ItemSettingsTool.java b/src/main/java/com/hbm/items/tool/ItemSettingsTool.java index f0e1541cb..e7bc4bb85 100644 --- a/src/main/java/com/hbm/items/tool/ItemSettingsTool.java +++ b/src/main/java/com/hbm/items/tool/ItemSettingsTool.java @@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; import net.minecraft.world.World; import javax.annotation.Nullable; @@ -48,9 +49,12 @@ public class ItemSettingsTool extends Item { if(displayInfo.tagCount() > 0){ for (int j = 0; j < displayInfo.tagCount(); j++) { NBTTagCompound nbt = displayInfo.getCompoundTagAt(j); - String info = nbt.getString("info"); EnumChatFormatting format = stack.stackTagCompound.getInteger("copyIndex") == j ? EnumChatFormatting.AQUA : EnumChatFormatting.YELLOW; - PacketDispatcher.wrapper.sendTo(new PlayerInformPacket(format + info, 897 + j, 4000 ), (EntityPlayerMP) entity); + PacketDispatcher.wrapper.sendTo( + new PlayerInformPacket(ChatBuilder.startTranslation(nbt.getString("info")) + .color(format) + .flush() + , 897 + j, 4000 ), (EntityPlayerMP) entity); } } } @@ -61,12 +65,16 @@ public class ItemSettingsTool extends Item { public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { list.add("Can copy the settings (filters, fluid ID, etc) of machines"); list.add("Shift right-click to copy, right click to paste"); - if(stack.stackTagCompound != null) { + /*if(stack.stackTagCompound != null) { NBTTagCompound nbt = stack.stackTagCompound; - list.add(EnumChatFormatting.YELLOW + "Current machine:" - + (nbt.hasKey("tileName") ? EnumChatFormatting.BLUE + " " + nbt.getString("tileName") : EnumChatFormatting.RED + " None ")); - } + if (nbt.hasKey("tileName")){ + list.add(ChatBuilder.startTranslation(nbt.getString("tileName")).color(EnumChatFormatting.BLUE).flush().getFormattedText()); + } else { + list.add(EnumChatFormatting.RED + " None "); + } + }*/ + //the translation wont fucking work I swear to allah } @Override public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float fX, float fY, float fZ) { @@ -76,25 +84,33 @@ public class ItemSettingsTool extends Item { if(player.isSneaking()) { stack.stackTagCompound = copiable.getSettings(world, x, y, z); - stack.stackTagCompound.setString("tileName", copiable.getSettingsSourceID(schrodinger)); - stack.stackTagCompound.setInteger("copyIndex", 0); - stack.stackTagCompound.setInteger("inputDelay", 0); - String[] info = copiable.infoForDisplay(world, x, y, z); - if(info != null) { - NBTTagList displayInfo = new NBTTagList(); - for (String str : info) { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setString("info", str); - displayInfo.appendTag(nbt); - } - stack.stackTagCompound.setTag("displayInfo", displayInfo); - } + if(stack.stackTagCompound != null) { - if(world.isRemote) { + stack.stackTagCompound.setString("tileName", copiable.getSettingsSourceID(schrodinger)); + stack.stackTagCompound.setInteger("copyIndex", 0); + stack.stackTagCompound.setInteger("inputDelay", 0); + String[] info = copiable.infoForDisplay(world, x, y, z); + if (info != null) { + NBTTagList displayInfo = new NBTTagList(); + for (String str : info) { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setString("info", str); + displayInfo.appendTag(nbt); + } + stack.stackTagCompound.setTag("displayInfo", displayInfo); + } + + if (world.isRemote) { + player.addChatMessage(ChatBuilder.start("[").color(EnumChatFormatting.DARK_AQUA) + .nextTranslation(this.getUnlocalizedName() + ".name").color(EnumChatFormatting.DARK_AQUA) + .next("] ").color(EnumChatFormatting.DARK_AQUA) + .next("Copied settings of " + copiable.getSettingsSourceDisplay(schrodinger)).color(EnumChatFormatting.AQUA).flush()); + } + } else { player.addChatMessage(ChatBuilder.start("[").color(EnumChatFormatting.DARK_AQUA) - .nextTranslation(this.getUnlocalizedName() + ".name").color(EnumChatFormatting.DARK_AQUA) - .next("] ").color(EnumChatFormatting.DARK_AQUA) - .next("Copied settings of " + copiable.getSettingsSourceDisplay(schrodinger)).color(EnumChatFormatting.AQUA).flush()); + .nextTranslation(this.getUnlocalizedName() + ".name").color(EnumChatFormatting.DARK_AQUA) + .next("] ").color(EnumChatFormatting.DARK_AQUA) + .next("Copy failed, machine has no settings tool support: " + copiable.getSettingsSourceDisplay(schrodinger)).color(EnumChatFormatting.RED).flush()); } } else if(stack.hasTagCompound()) { diff --git a/src/main/java/com/hbm/tileentity/IControlReceiverFilter.java b/src/main/java/com/hbm/tileentity/IControlReceiverFilter.java index be5279ca1..c48e053fc 100644 --- a/src/main/java/com/hbm/tileentity/IControlReceiverFilter.java +++ b/src/main/java/com/hbm/tileentity/IControlReceiverFilter.java @@ -74,12 +74,16 @@ public interface IControlReceiverFilter extends IControlReceiver, ICopiable { int listSize = items.tagCount(); if(listSize > 0) { int count = 0; + for (int i = getFilterSlots()[0]; i < getFilterSlots()[1]; i++) { if (i < listSize) { NBTTagCompound slotNBT = items.getCompoundTagAt(count); byte slot = slotNBT.getByte("slot"); ItemStack loadedStack = ItemStack.loadItemStackFromNBT(slotNBT); - if (loadedStack != null && slot < getFilterSlots()[1]) { + //whether the filter info came from a router + boolean router = nbt.hasKey("modes") && slot > index * 5 && slot < index * + 5; + + if (loadedStack != null && index < listSize && (slot < getFilterSlots()[1] || router)) { inv.setInventorySlotContents(slot + getFilterSlots()[0], ItemStack.loadItemStackFromNBT(slotNBT)); nextMode(slot); tile.getWorldObj().markTileEntityChunkModified(tile.xCoord, tile.yCoord, tile.zCoord, tile); @@ -87,7 +91,6 @@ public interface IControlReceiverFilter extends IControlReceiver, ICopiable { } count++; } - } } diff --git a/src/main/java/com/hbm/tileentity/IFluidCopiable.java b/src/main/java/com/hbm/tileentity/IFluidCopiable.java index 15cb4c0c6..68c61fa0a 100644 --- a/src/main/java/com/hbm/tileentity/IFluidCopiable.java +++ b/src/main/java/com/hbm/tileentity/IFluidCopiable.java @@ -50,7 +50,7 @@ public interface IFluidCopiable extends ICopiable { default void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) { if(getTankToPaste() != null) { int[] ids = nbt.getIntArray("fluidID"); - if(ids.length > 0) { + if(ids.length > 0 && index < ids.length) { int id = ids[index]; getTankToPaste().setTankType(Fluids.fromID(id)); } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryOutlet.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryOutlet.java index a5f0d6086..15202f6de 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryOutlet.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryOutlet.java @@ -19,7 +19,7 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; -public class TileEntityFoundryOutlet extends TileEntityFoundryBase implements ICopiable { +public class TileEntityFoundryOutlet extends TileEntityFoundryBase{ public NTMMaterial filter = null; public NTMMaterial lastFilter = null; @@ -146,7 +146,7 @@ public class TileEntityFoundryOutlet extends TileEntityFoundryBase implements IC if(nbt.hasKey("invertFilter")) this.invertFilter = nbt.getBoolean("invertFilter"); if(nbt.hasKey("matFilter")) { int[] ids = nbt.getIntArray("matFilter"); - if(ids.length > 0) + if(ids.length > 0 && index < ids.length) this.filter = Mats.matById.get(ids[index]); } @@ -155,8 +155,8 @@ public class TileEntityFoundryOutlet extends TileEntityFoundryBase implements IC @Override public String[] infoForDisplay(World world, int x, int y, int z) { ArrayList info = new ArrayList<>(); - info.add("copyTool.invertRedstone"); - info.add("copyTool.invertFilter"); + info.add("copytool.invertRedstone"); + info.add("copytool.invertFilter"); if (filter != null) info.add(filter.getUnlocalizedName()); return info.toArray(new String[0]); } diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityCraneBase.java b/src/main/java/com/hbm/tileentity/network/TileEntityCraneBase.java index 61a81339b..ef464547d 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityCraneBase.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityCraneBase.java @@ -160,7 +160,9 @@ 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 && slot < filter.getFilterSlots()[1]) { + //whether the filter info came from a router + boolean router = nbt.hasKey("modes") && slot > index * 5 && slot < index * + 5; + if (loadedStack != null && (slot < filter.getFilterSlots()[1] || router)) { inv.setInventorySlotContents(slot + filter.getFilterSlots()[0], ItemStack.loadItemStackFromNBT(slotNBT)); filter.nextMode(slot); this.getWorldObj().markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this); diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityCraneRouter.java b/src/main/java/com/hbm/tileentity/network/TileEntityCraneRouter.java index ff914eb34..c1d717099 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityCraneRouter.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityCraneRouter.java @@ -181,6 +181,7 @@ public class TileEntityCraneRouter extends TileEntityMachineBase implements IGUI this.getWorldObj().markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this); } } + modes = nbt.getIntArray("modes"); } else { IControlReceiverFilter.super.pasteSettings(nbt, index, world, player, x, y, z); } diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index a9ac23387..d5e64ebc0 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -858,6 +858,17 @@ container.wasteDrum=Spent Fuel Pool Drum container.watzPowerplant=Watz Power Plant container.zirnox=ZIRNOX Nuclear Reactor +copytool.filter=Filter +copytool.invertRedstone=Redstone Inverted +copytool.invertFilter=Filter Inverted +copytool.orientation=Orientation +copytool.pattern0=Red Side +copytool.pattern1=Orange Side +copytool.pattern2=Yellow Side +copytool.pattern3=Green Side +copytool.pattern4=Blue Side +copytool.pattern5=Purple Side + crucible.aa=Advanced Alloy Production crucible.abronze=Arsenic Bronze Production crucible.bbronze=Bismuth Bronze Production