mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
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:
parent
9839107c4e
commit
e79eae78a7
@ -20,55 +20,67 @@ public class HazardTransformerRadiationContainer extends HazardTransformerBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transformPost(ItemStack stack, List<HazardEntry> entries) {
|
public void transformPost(ItemStack stack, List<HazardEntry> entries) {
|
||||||
|
|
||||||
boolean isCrate = Block.getBlockFromItem(stack.getItem()) instanceof BlockStorageCrate;
|
boolean isCrate = Block.getBlockFromItem(stack.getItem()) instanceof BlockStorageCrate;
|
||||||
boolean isBox = stack.getItem() == ModItems.containment_box;
|
boolean isBox = stack.getItem() == ModItems.containment_box;
|
||||||
boolean isBag = stack.getItem() == ModItems.plastic_bag;
|
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;
|
if(!stack.hasTagCompound()) return;
|
||||||
|
|
||||||
float radiation = 0;
|
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) {
|
if(isCrate) {
|
||||||
|
|
||||||
for(int i = 0; i < 104; i++) {
|
for(int i = 0; i < 104; i++) {
|
||||||
ItemStack held = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("slot" + i));
|
ItemStack held = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("slot" + i));
|
||||||
|
|
||||||
if(held != null) {
|
if(held != null) {
|
||||||
radiation += HazardSystem.getHazardLevelFromStack(held, HazardRegistry.RADIATION) * held.stackSize;
|
radiation += HazardSystem.getHazardLevelFromStack(held, HazardRegistry.RADIATION) * held.stackSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isBox) {
|
if(isBox) {
|
||||||
|
|
||||||
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(stack, 20);
|
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(stack, 20);
|
||||||
if(fromNBT == null) return;
|
if(fromNBT == null) return;
|
||||||
|
|
||||||
for(ItemStack held : fromNBT) {
|
for(ItemStack held : fromNBT) {
|
||||||
if(held != null) {
|
if(held != null) {
|
||||||
radiation += HazardSystem.getHazardLevelFromStack(held, HazardRegistry.RADIATION) * held.stackSize;
|
radiation += HazardSystem.getHazardLevelFromStack(held, HazardRegistry.RADIATION) * held.stackSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
radiation = (float) BobMathUtil.squirt(radiation);
|
radiation = (float) BobMathUtil.squirt(radiation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isBag) {
|
if(isBag) {
|
||||||
|
|
||||||
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(stack, 1);
|
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(stack, 1);
|
||||||
if(fromNBT == null) return;
|
if(fromNBT == null) return;
|
||||||
|
|
||||||
for(ItemStack held : fromNBT) {
|
for(ItemStack held : fromNBT) {
|
||||||
if(held != null) {
|
if(held != null) {
|
||||||
radiation += HazardSystem.getHazardLevelFromStack(held, HazardRegistry.RADIATION) * held.stackSize;
|
radiation += HazardSystem.getHazardLevelFromStack(held, HazardRegistry.RADIATION) * held.stackSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
radiation *= 2F;
|
radiation *= 2F;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(radiation > 0) {
|
if(radiation > 0) {
|
||||||
entries.add(new HazardEntry(HazardRegistry.RADIATION, radiation));
|
entries.add(new HazardEntry(HazardRegistry.RADIATION, radiation));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.
|
* Base class for items containing an inventory. This can be seen in crates, containment boxes, and the toolbox.
|
||||||
* @author BallOfEnergy/Gammawave
|
* @author BallOfEnergy/Gammawave
|
||||||
*/
|
*/
|
||||||
public abstract class IItemInventory implements IInventory {
|
public abstract class ItemInventory implements IInventory {
|
||||||
|
|
||||||
public EntityPlayer player;
|
public EntityPlayer player;
|
||||||
public ItemStack[] slots;
|
public ItemStack[] slots;
|
||||||
@ -3,7 +3,7 @@ package com.hbm.items.block;
|
|||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.blocks.ModBlocks;
|
||||||
import com.hbm.inventory.container.*;
|
import com.hbm.inventory.container.*;
|
||||||
import com.hbm.inventory.gui.*;
|
import com.hbm.inventory.gui.*;
|
||||||
import com.hbm.items.IItemInventory;
|
import com.hbm.items.ItemInventory;
|
||||||
import com.hbm.items.tool.ItemKey;
|
import com.hbm.items.tool.ItemKey;
|
||||||
import com.hbm.main.MainRegistry;
|
import com.hbm.main.MainRegistry;
|
||||||
import com.hbm.tileentity.IGUIProvider;
|
import com.hbm.tileentity.IGUIProvider;
|
||||||
@ -80,7 +80,7 @@ public class ItemBlockStorageCrate extends ItemBlockBase implements IGUIProvider
|
|||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class InventoryCrate extends IItemInventory {
|
public static class InventoryCrate extends ItemInventory {
|
||||||
|
|
||||||
public InventoryCrate(EntityPlayer player, ItemStack crate) {
|
public InventoryCrate(EntityPlayer player, ItemStack crate) {
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package com.hbm.items.tool;
|
|||||||
|
|
||||||
import com.hbm.inventory.container.ContainerLeadBox;
|
import com.hbm.inventory.container.ContainerLeadBox;
|
||||||
import com.hbm.inventory.gui.GUILeadBox;
|
import com.hbm.inventory.gui.GUILeadBox;
|
||||||
import com.hbm.items.IItemInventory;
|
import com.hbm.items.ItemInventory;
|
||||||
import com.hbm.main.MainRegistry;
|
import com.hbm.main.MainRegistry;
|
||||||
import com.hbm.tileentity.IGUIProvider;
|
import com.hbm.tileentity.IGUIProvider;
|
||||||
import com.hbm.util.ItemStackUtil;
|
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()));
|
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) {
|
public InventoryLeadBox(EntityPlayer player, ItemStack box) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package com.hbm.items.tool;
|
|||||||
|
|
||||||
import com.hbm.inventory.container.ContainerToolBox;
|
import com.hbm.inventory.container.ContainerToolBox;
|
||||||
import com.hbm.inventory.gui.GUIToolBox;
|
import com.hbm.inventory.gui.GUIToolBox;
|
||||||
import com.hbm.items.IItemInventory;
|
import com.hbm.items.ItemInventory;
|
||||||
import com.hbm.items.ModItems;
|
import com.hbm.items.ModItems;
|
||||||
import com.hbm.lib.RefStrings;
|
import com.hbm.lib.RefStrings;
|
||||||
import com.hbm.main.MainRegistry;
|
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);
|
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).
|
// Finds active rows in the toolbox (rows with items inside them).
|
||||||
public List<Integer> getActiveRows(ItemStack box) {
|
public List<Integer> getActiveRows(ItemStack box) {
|
||||||
ItemStack[] stacks = ItemStackUtil.readStacksFromNBT(box, 24);
|
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) {
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||||
|
|
||||||
if(!world.isRemote) {
|
if(!world.isRemote) {
|
||||||
if (player.isSneaking()) {
|
if (!player.isSneaking()) {
|
||||||
moveRows(stack, player);
|
moveRows(stack, player);
|
||||||
player.inventoryContainer.detectAndSendChanges();
|
player.inventoryContainer.detectAndSendChanges();
|
||||||
} else {
|
} else {
|
||||||
@ -190,7 +196,7 @@ public class ItemToolBox extends Item implements IGUIProvider {
|
|||||||
return new GUIToolBox(player.inventory, new InventoryToolBox(player, player.getHeldItem()));
|
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) {
|
public InventoryToolBox(EntityPlayer player, ItemStack box) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user