am I stupid?

Fix a few issues related to naming.
Fix toolboxes blocking all radiation.
Add toolbox tooltip.
Swap toolbox operations; clicking now swaps hotbars and shift-clicking opens the inventory for easier access (recommended by Mellow).
This commit is contained in:
BallOfEnergy 2025-03-27 21:16:29 -05:00
parent 9839107c4e
commit e79eae78a7
5 changed files with 40 additions and 22 deletions

View File

@ -20,55 +20,67 @@ public class HazardTransformerRadiationContainer extends HazardTransformerBase {
@Override
public void transformPost(ItemStack stack, List<HazardEntry> entries) {
boolean isCrate = Block.getBlockFromItem(stack.getItem()) instanceof BlockStorageCrate;
boolean isBox = stack.getItem() == ModItems.containment_box;
boolean isBag = stack.getItem() == ModItems.plastic_bag;
if(!isCrate && !isBox && !isBag) return;
boolean isContainer = stack.getItem() == ModItems.toolbox; // For anything using the standard ItemInventory shit.
if(!isCrate && !isBox && !isBag && !isContainer) return;
if(!stack.hasTagCompound()) return;
float radiation = 0;
if(isContainer) {
ItemStack[] items = ItemStackUtil.readStacksFromNBT(stack, 24); // Biggest container: toolbox; 24 slots.
if(items != null)
for(ItemStack held : items)
if(held != null)
radiation += HazardSystem.getHazardLevelFromStack(held, HazardRegistry.RADIATION) * held.stackSize;
// this indentation is killing me man
}
if(isCrate) {
for(int i = 0; i < 104; i++) {
ItemStack held = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("slot" + i));
if(held != null) {
radiation += HazardSystem.getHazardLevelFromStack(held, HazardRegistry.RADIATION) * held.stackSize;
}
}
}
if(isBox) {
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(stack, 20);
if(fromNBT == null) return;
for(ItemStack held : fromNBT) {
if(held != null) {
radiation += HazardSystem.getHazardLevelFromStack(held, HazardRegistry.RADIATION) * held.stackSize;
}
}
radiation = (float) BobMathUtil.squirt(radiation);
}
if(isBag) {
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(stack, 1);
if(fromNBT == null) return;
for(ItemStack held : fromNBT) {
if(held != null) {
radiation += HazardSystem.getHazardLevelFromStack(held, HazardRegistry.RADIATION) * held.stackSize;
}
}
radiation *= 2F;
}
if(radiation > 0) {
entries.add(new HazardEntry(HazardRegistry.RADIATION, radiation));
}

View File

@ -17,7 +17,7 @@ import java.util.Random;
* Base class for items containing an inventory. This can be seen in crates, containment boxes, and the toolbox.
* @author BallOfEnergy/Gammawave
*/
public abstract class IItemInventory implements IInventory {
public abstract class ItemInventory implements IInventory {
public EntityPlayer player;
public ItemStack[] slots;

View File

@ -3,7 +3,7 @@ package com.hbm.items.block;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.container.*;
import com.hbm.inventory.gui.*;
import com.hbm.items.IItemInventory;
import com.hbm.items.ItemInventory;
import com.hbm.items.tool.ItemKey;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IGUIProvider;
@ -80,7 +80,7 @@ public class ItemBlockStorageCrate extends ItemBlockBase implements IGUIProvider
throw new NullPointerException();
}
public static class InventoryCrate extends IItemInventory {
public static class InventoryCrate extends ItemInventory {
public InventoryCrate(EntityPlayer player, ItemStack crate) {

View File

@ -2,7 +2,7 @@ package com.hbm.items.tool;
import com.hbm.inventory.container.ContainerLeadBox;
import com.hbm.inventory.gui.GUILeadBox;
import com.hbm.items.IItemInventory;
import com.hbm.items.ItemInventory;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.util.ItemStackUtil;
@ -45,7 +45,7 @@ public class ItemLeadBox extends Item implements IGUIProvider {
return new GUILeadBox(player.inventory, new InventoryLeadBox(player, player.getHeldItem()));
}
public static class InventoryLeadBox extends IItemInventory {
public static class InventoryLeadBox extends ItemInventory {
public InventoryLeadBox(EntityPlayer player, ItemStack box) {
this.player = player;

View File

@ -2,7 +2,7 @@ package com.hbm.items.tool;
import com.hbm.inventory.container.ContainerToolBox;
import com.hbm.inventory.gui.GUIToolBox;
import com.hbm.items.IItemInventory;
import com.hbm.items.ItemInventory;
import com.hbm.items.ModItems;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
@ -53,6 +53,12 @@ public class ItemToolBox extends Item implements IGUIProvider {
return renderPass == 1 ? this.iconClosed : getIconFromDamageForRenderPass(stack.getItemDamage(), renderPass);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
list.add("Click with the toolbox to swap hotbars in/out of the toolbox.");
list.add("Shift-click with the toolbox to open the toolbox.");
}
// Finds active rows in the toolbox (rows with items inside them).
public List<Integer> getActiveRows(ItemStack box) {
ItemStack[] stacks = ItemStackUtil.readStacksFromNBT(box, 24);
@ -166,7 +172,7 @@ public class ItemToolBox extends Item implements IGUIProvider {
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if(!world.isRemote) {
if (player.isSneaking()) {
if (!player.isSneaking()) {
moveRows(stack, player);
player.inventoryContainer.detectAndSendChanges();
} else {
@ -190,7 +196,7 @@ public class ItemToolBox extends Item implements IGUIProvider {
return new GUIToolBox(player.inventory, new InventoryToolBox(player, player.getHeldItem()));
}
public static class InventoryToolBox extends IItemInventory {
public static class InventoryToolBox extends ItemInventory {
public InventoryToolBox(EntityPlayer player, ItemStack box) {
this.player = player;