From 33c8ad70a37067b31fd9955e386e3e1bf38cbe55 Mon Sep 17 00:00:00 2001 From: abel1502 Date: Mon, 23 Sep 2024 15:17:12 +0300 Subject: [PATCH 1/5] Expand gitignore --- .gitignore | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 22222fc39..1317d0286 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,28 @@ # eclipse -eclipse -bin -*.launch -.settings -.metadata -.classpath -.project +/eclipse +/bin +/*.launch +/.settings +/.metadata +/.classpath +/.project # idea -out -*.ipr -*.iws -*.iml -.idea +/out +/*.ipr +/*.iws +/*.iml +/.idea # gradle -build -.gradle +/build +/.gradle + +# vscode +/.vscode # other -run +/run # CurseForge configuration /curseforge.properties From 8aad7fb44b771d0d332806a07f958124c08014ed Mon Sep 17 00:00:00 2001 From: abel1502 Date: Mon, 23 Sep 2024 18:21:57 +0300 Subject: [PATCH 2/5] Fix conveyor grabber delay --- .../tileentity/network/TileEntityCraneGrabber.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityCraneGrabber.java b/src/main/java/com/hbm/tileentity/network/TileEntityCraneGrabber.java index 728ff2e67..b5bf3c2d0 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityCraneGrabber.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityCraneGrabber.java @@ -32,6 +32,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP public boolean isWhitelist = false; public ModulePatternMatcher matcher; + public long lastGrabbedTick = 0; public TileEntityCraneGrabber() { super(11); @@ -63,7 +64,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP } } - if(worldObj.getTotalWorldTime() % delay == 0 && !this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) { + if(worldObj.getTotalWorldTime() >= lastGrabbedTick + delay && !this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) { int amount = 1; if(slots[9] != null && slots[9].getItem() == ModItems.upgrade_stack) { @@ -111,6 +112,8 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP boolean match = this.matchesFilter(stack); if(this.isWhitelist && !match || !this.isWhitelist && match) continue; + lastGrabbedTick = worldObj.getTotalWorldTime(); + ItemStack copy = stack.copy(); int toAdd = Math.min(stack.stackSize, amount); copy.stackSize = toAdd; @@ -132,8 +135,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP NBTTagCompound data = new NBTTagCompound(); - data.setBoolean("isWhitelist", isWhitelist); - this.matcher.writeToNBT(data); + this.writeToNBT(data); this.networkPack(data, 15); } } @@ -141,9 +143,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP public void networkUnpack(NBTTagCompound nbt) { super.networkUnpack(nbt); - this.isWhitelist = nbt.getBoolean("isWhitelist"); - this.matcher.modes = new String[this.matcher.modes.length]; - this.matcher.readFromNBT(nbt); + this.readFromNBT(nbt); } public boolean matchesFilter(ItemStack stack) { @@ -175,6 +175,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP super.readFromNBT(nbt); this.isWhitelist = nbt.getBoolean("isWhitelist"); this.matcher.readFromNBT(nbt); + this.lastGrabbedTick = nbt.getLong("lastGrabbedTick"); } @Override @@ -182,6 +183,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP super.writeToNBT(nbt); nbt.setBoolean("isWhitelist", this.isWhitelist); this.matcher.writeToNBT(nbt); + nbt.setLong("lastGrabbedTick", lastGrabbedTick); } @Override From df92d913da853b0b7dbfa6f84fed2d3c5c39855f Mon Sep 17 00:00:00 2001 From: abel1502 Date: Mon, 23 Sep 2024 18:36:03 +0300 Subject: [PATCH 3/5] Add caching for TileEntityMachineBase update packages Now they aren't send unless something has changed, except for one every second as a workaround for an apparent issue --- .../hbm/tileentity/TileEntityMachineBase.java | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hbm/tileentity/TileEntityMachineBase.java b/src/main/java/com/hbm/tileentity/TileEntityMachineBase.java index d34c5ee38..81c099073 100644 --- a/src/main/java/com/hbm/tileentity/TileEntityMachineBase.java +++ b/src/main/java/com/hbm/tileentity/TileEntityMachineBase.java @@ -8,6 +8,7 @@ import com.hbm.util.fauxpointtwelve.DirPos; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; @@ -23,6 +24,9 @@ public abstract class TileEntityMachineBase extends TileEntityLoadedBase impleme private String customName; + private NBTTagCompound lastPackedNBT = null; + private ByteBuf lastPackedBuf = null; + public TileEntityMachineBase(int slotCount) { slots = new ItemStack[slotCount]; } @@ -157,7 +161,18 @@ public abstract class TileEntityMachineBase extends TileEntityLoadedBase impleme @Deprecated public void networkPack(NBTTagCompound nbt, int range) { nbt.setBoolean("muffled", muffled); - if(!worldObj.isRemote) PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range)); + + if(worldObj.isRemote) { + return; + } + + // Same as networkPackNT + if (lastPackedNBT != null && lastPackedNBT.equals(nbt) && worldObj.getWorldTime() % 20 != 0) { + return; + } + this.lastPackedNBT = nbt; + + PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range)); } @Deprecated @@ -167,7 +182,27 @@ public abstract class TileEntityMachineBase extends TileEntityLoadedBase impleme /** Sends a sync packet that uses ByteBuf for efficient information-cramming */ public void networkPackNT(int range) { - if(!worldObj.isRemote) PacketDispatcher.wrapper.sendToAllAround(new BufPacket(xCoord, yCoord, zCoord, this), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range)); + if(worldObj.isRemote) { + return; + } + + BufPacket packet = new BufPacket(xCoord, yCoord, zCoord, this); + ByteBuf buf = Unpooled.buffer(); + packet.toBytes(buf); + + // Don't send unnecessary packets, except for maybe one every second or so. + // If we stop sending duplicate packets entirely, this causes issues when + // a client unloads and then loads back a chunk with an unchanged tile entity. + // For that client, the tile entity will appear default until anything changes about it. + // In my testing, this can be reliably reproduced with a full fluid barrel, for instance. + // I think it might be fixable by doing something with getDescriptionPacket() and onDataPacket(), + // but this sidesteps the problem for the mean time. + if (lastPackedBuf != null && buf.equals(lastPackedBuf) && worldObj.getWorldTime() % 20 != 0) { + return; + } + this.lastPackedBuf = buf; + + PacketDispatcher.wrapper.sendToAllAround(packet, new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range)); } @Override public void serialize(ByteBuf buf) { From c5fa0c5d2b504a3dce0d8a30ad8026c32f007c9c Mon Sep 17 00:00:00 2001 From: abel1502 Date: Mon, 23 Sep 2024 18:41:57 +0300 Subject: [PATCH 4/5] Fix builder's choice concrete tooltip --- src/main/java/com/hbm/blocks/ModBlocks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 9550cd93d..e03b7e264 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -2626,7 +2626,7 @@ public class ModBlocks { GameRegistry.registerBlock(reinforced_ducrete, ItemBlockBlastInfo.class, reinforced_ducrete.getUnlocalizedName()); GameRegistry.registerBlock(concrete_smooth, ItemBlockBlastInfo.class, concrete_smooth.getUnlocalizedName()); GameRegistry.registerBlock(concrete_colored, ItemBlockColoredConcrete.class, concrete_colored.getUnlocalizedName()); - register(concrete_colored_ext); + GameRegistry.registerBlock(concrete_colored_ext, ItemBlockBlastInfo.class, concrete_colored_ext.getUnlocalizedName()); GameRegistry.registerBlock(concrete, ItemBlockBlastInfo.class, concrete.getUnlocalizedName()); GameRegistry.registerBlock(concrete_asbestos, ItemBlockBlastInfo.class, concrete_asbestos.getUnlocalizedName()); GameRegistry.registerBlock(concrete_super, ItemBlockBlastInfo.class, concrete_super.getUnlocalizedName()); From c41bdc68865430f30a26a2495ef427c09461416e Mon Sep 17 00:00:00 2001 From: abel1502 Date: Mon, 23 Sep 2024 16:21:57 +0300 Subject: [PATCH 5/5] Fix TileEntityScaffoldDynamic --- src/main/java/com/hbm/blocks/generic/BlockScaffoldDynamic.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hbm/blocks/generic/BlockScaffoldDynamic.java b/src/main/java/com/hbm/blocks/generic/BlockScaffoldDynamic.java index 814ddb5b1..62a42594c 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockScaffoldDynamic.java +++ b/src/main/java/com/hbm/blocks/generic/BlockScaffoldDynamic.java @@ -167,7 +167,8 @@ public class BlockScaffoldDynamic extends BlockContainer implements IToolable, I } } - public static class TileEntityScaffoldDynamic extends TileEntity { + // Full class name needed because otherwise there's some conflict with the static import * from this class + public static class TileEntityScaffoldDynamic extends net.minecraft.tileentity.TileEntity { public int composite; public int prevComposite;