From 98bc692d29e234f2ad310c4bc7fe3219c04ebf90 Mon Sep 17 00:00:00 2001 From: Boblet Date: Wed, 9 Apr 2025 11:53:16 +0200 Subject: [PATCH] this is the last fucking refactor PR --- changelog | 3 +- .../com/hbm/inventory/gui/GUIRBMKConsole.java | 2 +- .../java/com/hbm/items/armor/ArmorModel.java | 33 ++++++++----------- .../networkproviders/PneumaticNetwork.java | 14 +++++++- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/changelog b/changelog index 5eacc5d10..2f3e642c2 100644 --- a/changelog +++ b/changelog @@ -37,4 +37,5 @@ * Fixed issues with the new crate functionality * Fixed dupe regarding the toolbox * Fixed dummies with no OC components taking up a ton of component slots -* Fixed infested glyphids spawning maggots also on the clientside, creating unkillable ghosts \ No newline at end of file +* Fixed infested glyphids spawning maggots also on the clientside, creating unkillable ghosts +* Fixed top left column not being selectable in the RBMK console \ No newline at end of file diff --git a/src/main/java/com/hbm/inventory/gui/GUIRBMKConsole.java b/src/main/java/com/hbm/inventory/gui/GUIRBMKConsole.java index 542ddb96b..4bbbed6d9 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIRBMKConsole.java +++ b/src/main/java/com/hbm/inventory/gui/GUIRBMKConsole.java @@ -134,7 +134,7 @@ public class GUIRBMKConsole extends GuiScreen { int index = ((mouseX - bX - guiLeft) / size + (mouseY - bY - guiTop) / size * 15); - if(index > 0 && index < selection.length && console.columns[index] != null) { + if(index >= 0 && index < selection.length && console.columns[index] != null) { this.selection[index] = !this.selection[index]; mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 0.75F + (this.selection[index] ? 0.25F : 0.0F))); diff --git a/src/main/java/com/hbm/items/armor/ArmorModel.java b/src/main/java/com/hbm/items/armor/ArmorModel.java index f1ffacf4f..c6a2b5137 100644 --- a/src/main/java/com/hbm/items/armor/ArmorModel.java +++ b/src/main/java/com/hbm/items/armor/ArmorModel.java @@ -31,17 +31,12 @@ import net.minecraft.util.ResourceLocation; // clientonly... public class ArmorModel extends ItemArmor { - @SideOnly(Side.CLIENT) - private static final ModelGoggles modelGoggles = new ModelGoggles(); - @SideOnly(Side.CLIENT) - private static final ModelHat modelHat = new ModelHat(0); - @SideOnly(Side.CLIENT) - private static final ModelCloak modelCloak = new ModelCloak(); + @SideOnly(Side.CLIENT) private ModelGoggles modelGoggles; + @SideOnly(Side.CLIENT) private ModelHat modelHat; + @SideOnly(Side.CLIENT) private ModelCloak modelCloak; @SideOnly(Side.CLIENT) - private static final ResourceLocation[] gogglesBlurs = IntStream.range(0, 6) - .mapToObj(i -> new ResourceLocation(RefStrings.MODID + ":textures/misc/overlay_goggles_" + i + ".png")) - .toArray(ResourceLocation[]::new); + private ResourceLocation[] gogglesBlurs; public ArmorModel(ArmorMaterial armorMaterial, int armorType) { super(armorMaterial, 0, armorType); @@ -52,16 +47,19 @@ public class ArmorModel extends ItemArmor { public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { if(this == ModItems.goggles) { if(armorSlot == 0) { + if(modelGoggles == null) modelGoggles = new ModelGoggles(); return modelGoggles; } } if(this == ModItems.hat) { if(armorSlot == 0) { + if(modelHat == null) modelHat = new ModelHat(0); return modelHat; } } if(this == ModItems.cape_radiation || this == ModItems.cape_gasmask || this == ModItems.cape_schrabidium || this == ModItems.cape_hidden) { if(armorSlot == 1) { + if(modelCloak == null) modelCloak = new ModelCloak(); return modelCloak; } } @@ -94,6 +92,10 @@ public class ArmorModel extends ItemArmor { if(this != ModItems.goggles && this != ModItems.hazmat_helmet_red && this != ModItems.hazmat_helmet_grey) return; + + if(gogglesBlurs == null) gogglesBlurs = IntStream.range(0, 6) + .mapToObj(i -> new ResourceLocation(RefStrings.MODID + ":textures/misc/overlay_goggles_" + i + ".png")) + .toArray(ResourceLocation[]::new); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); @@ -124,15 +126,8 @@ public class ArmorModel extends ItemArmor { @Override public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) { - - if(this == ModItems.cape_radiation) { - list.add("Avalible for everyone"); - } - if(this == ModItems.cape_gasmask) { - list.add("Avalible for everyone"); - } - if(this == ModItems.cape_schrabidium) { - list.add("Avalible for everyone"); - } + if(this == ModItems.cape_radiation) list.add("Avalible for everyone"); + if(this == ModItems.cape_gasmask) list.add("Avalible for everyone"); + if(this == ModItems.cape_schrabidium) list.add("Avalible for everyone"); } } diff --git a/src/main/java/com/hbm/uninos/networkproviders/PneumaticNetwork.java b/src/main/java/com/hbm/uninos/networkproviders/PneumaticNetwork.java index eb9d851f4..0dafda6b6 100644 --- a/src/main/java/com/hbm/uninos/networkproviders/PneumaticNetwork.java +++ b/src/main/java/com/hbm/uninos/networkproviders/PneumaticNetwork.java @@ -5,6 +5,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; +import java.util.Random; import com.hbm.tileentity.network.TileEntityPneumoTube; import com.hbm.uninos.NodeNet; @@ -24,6 +25,7 @@ public class PneumaticNetwork extends NodeNet { public static final byte RECEIVE_ROBIN = 0; public static final byte RECEIVE_RANDOM = 1; + public Random rand = new Random(); public int nextReceiver = 0; protected static int timeout = 1_000; @@ -41,6 +43,11 @@ public class PneumaticNetwork extends NodeNet { } public boolean send(IInventory source, TileEntityPneumoTube tube, ForgeDirection dir, int sendOrder, int receiveOrder) { + + // turns out there may be a short time window where the cleanup hasn't happened yet, but chunkloading has already caused tiles to go invalid + // so we just run it again here, just to be sure. + long timestamp = System.currentTimeMillis(); + receivers.entrySet().removeIf(x -> { return (timestamp - x.getValue().getValue() > timeout) || NodeNet.isBadLink(x.getKey()); }); if(receivers.isEmpty()) return false; @@ -65,7 +72,12 @@ public class PneumaticNetwork extends NodeNet { receiverList.sort(comparator); int index = nextReceiver % receivers.size(); - Entry> chosenReceiverEntry = receiverList.get(index); + Entry> chosenReceiverEntry = null; + + if(receiveOrder == RECEIVE_ROBIN) chosenReceiverEntry = receiverList.get(index); + if(receiveOrder == RECEIVE_RANDOM) chosenReceiverEntry = receiverList.get(rand.nextInt(receiverList.size())); + + if(chosenReceiverEntry == null) return false; //TBI - the painful part