radioactive crates, containment box

This commit is contained in:
Boblet 2023-02-21 13:14:58 +01:00
parent dbe2b1fcc9
commit a7e51e6059
14 changed files with 289 additions and 403 deletions

View File

@ -4,10 +4,11 @@ mod_build_number=4515
credits=HbMinecraft, rodolphito (explosion algorithms), grangerave (explosion algorithms),\
\ Hoboy (textures, models), Doctor17 (russian localization), Drillgon200 (effects, models, porting),\
\ UFFR (fork with all sorts of features), Pu-238 (Tom impact effects), Bismarck (chinese localization),\
\ Frooz (models), Minecreep (models), VT-6/24 (models, textures), Pheo (textures, various machines, weapons), Vær (fibrosis, gas centrifuges,\
\ ZIRNOX, CP-1 parts, starter guide), Adam29 (liquid petroleum, ethanol, electric furnace),\
\ UFFR (RTGs, guns, casings), Pu-238 (Tom impact effects), Bismarck (chinese localization),\
\ Frooz (models), Minecreep (models), VT-6/24 (models, textures), Pheo (textures, various machines, models, weapons), Vær (gas centrifuges,\
\ better worldgen, ZIRNOX, CP-1 parts, starter guide), Adam29 (liquid petroleum, ethanol, electric furnace),\
\ Pashtet (russian localization), MartinTheDragon (calculator, chunk-based fallout), haru315 (spiral point algorithm),\
\ Sten89 (models), Pixelguru26 (textures), TheBlueHat (textures), Aionoso (GUI textures), impbk2002 (project settings),\
\ Sten89 (models), Pixelguru26 (textures), TheBlueHat (textures), Alcater (GUI textures, porting), impbk2002 (project settings),\
\ OvermindDL1 (project settings), TehTemmie (reacher radiation function), Toshayo (satellite loot system, project settings), Silly541 (config for safe ME drives),\
\ Voxelstice (OpenComputers integration), martemen (project settings), Pvndols (thorium fuel recipe)
\ Voxelstice (OpenComputers integration, turbine spinup), martemen (project settings), Pvndols (thorium fuel recipe, gas turbine), JamesH2 (blood, nitric acid),\
\ sdddddf80 (mixer recipe config)

View File

@ -8,7 +8,6 @@ import com.hbm.entity.cart.EntityMinecartDestroyer;
import com.hbm.interfaces.Spaghetti;
import com.hbm.inventory.container.*;
import com.hbm.inventory.gui.*;
import com.hbm.inventory.inv.InventoryLeadBox;
import com.hbm.items.ModItems;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.bomb.*;
@ -802,7 +801,6 @@ public class GUIHandler implements IGuiHandler {
// NON-TE CONTAINERS
switch(ID) {
case ModItems.guiID_item_box: return new ContainerLeadBox(player, player.inventory, new InventoryLeadBox(player.getHeldItem()));
case ModItems.guiID_item_book: return new ContainerBook(player.inventory);
case ModItems.guiID_cart_crate: return new ContainerCrateSteel(player.inventory, (EntityMinecartCrate)player.worldObj.getEntityByID(x));
case ModItems.guiID_cart_destroyer: return new ContainerCartDestroyer(player.inventory, (EntityMinecartDestroyer)player.worldObj.getEntityByID(x));
@ -1593,8 +1591,6 @@ public class GUIHandler implements IGuiHandler {
return new GUIScreenSatInterface(player);
case ModItems.guiID_item_sat_coord:
return new GUIScreenSatCoord(player);
case ModItems.guiID_item_box:
return new GUILeadBox(new ContainerLeadBox(player, player.inventory, new InventoryLeadBox(player.getHeldItem())));
case ModItems.guiID_item_bobmazon:
if(BobmazonOfferFactory.getOffers(player.getHeldItem()) != null)
return new GUIScreenBobmazon(player, BobmazonOfferFactory.getOffers(player.getHeldItem()));

View File

@ -509,6 +509,7 @@ public class HazardRegistry {
public static void registerTrafos() {
HazardSystem.trafos.add(new HazardTransformerRadiationNBT());
HazardSystem.trafos.add(new HazardTransformerRadiationContainer());
if(!(GeneralConfig.enableLBSM && GeneralConfig.enableLBSMSafeMEDrives)) {
HazardSystem.trafos.add(new HazardTransformerRadiationME());

View File

@ -0,0 +1,60 @@
package com.hbm.hazard.transformer;
import java.util.List;
import com.hbm.blocks.generic.BlockStorageCrate;
import com.hbm.hazard.HazardEntry;
import com.hbm.hazard.HazardRegistry;
import com.hbm.hazard.HazardSystem;
import com.hbm.items.ModItems;
import com.hbm.util.ItemStackUtil;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
public class HazardTransformerRadiationContainer extends HazardTransformerBase {
@Override
public void transformPre(ItemStack stack, List<HazardEntry> entries) { }
@Override
public void transformPost(ItemStack stack, List<HazardEntry> entries) {
boolean isCrate = Block.getBlockFromItem(stack.getItem()) instanceof BlockStorageCrate;
boolean isBox = stack.getItem() == ModItems.containment_box;
if(!isCrate && !isBox) return;
if(!stack.hasTagCompound()) return;
float radiation = 0;
if(isCrate) {
for(int i = 0; i < 54; 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);
if(fromNBT == null) return;
for(ItemStack held : fromNBT) {
if(held != null) {
radiation += HazardSystem.getHazardLevelFromStack(held, HazardRegistry.RADIATION) * held.stackSize;
}
}
radiation = (float) Math.sqrt(radiation + 1F / ((radiation + 2F) * (radiation + 2F))) - 1F / (radiation + 2F);
}
if(radiation > 0) {
entries.add(new HazardEntry(HazardRegistry.RADIATION, radiation));
}
}
}

View File

@ -1,6 +1,8 @@
package com.hbm.inventory.container;
import com.hbm.inventory.inv.InventoryLeadBox;
import com.hbm.items.tool.ItemLeadBox.InventoryLeadBox;
import com.hbm.util.InventoryUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@ -8,190 +10,67 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerLeadBox extends Container {
/**
* The Item Inventory for this Container, only needed if you want to
* reference isUseableByPlayer
*/
public final InventoryLeadBox inventory;
/**
* Using these will make transferStackInSlot easier to understand and
* implement INV_START is the index of the first slot in the Player's
* Inventory, so our InventoryItem's number of slots (e.g. 5 slots is array
* indices 0-4, so start at 5) Notice how we don't have to remember how many
* slots we made? We can just use InventoryItem.INV_SIZE and if we ever
* change it, the Container updates automatically.
*/
private static final int INV_START = InventoryLeadBox.INV_SIZE,
INV_END = INV_START + 26,
HOTBAR_START = INV_END + 1,
HOTBAR_END = HOTBAR_START + 8;
// If you're planning to add armor slots, put those first like this:
// ARMOR_START = InventoryItem.INV_SIZE, ARMOR_END = ARMOR_START+3,
// INV_START = ARMOR_END+1, and then carry on like above.
public ContainerLeadBox(EntityPlayer par1Player, InventoryPlayer inventoryPlayer, InventoryLeadBox inventoryItem) {
this.inventory = inventoryItem;
int i;
// ITEM INVENTORY - you'll need to adjust the slot locations to match
// your texture file
// I have them set vertically in columns of 4 to the right of the player
// model
for (i = 0; i < InventoryLeadBox.INV_SIZE; ++i) {
// You can make a custom Slot if you need different behavior,
// such as only certain item types can be put into this slot
// We made a custom slot to prevent our inventory-storing item
// from being stored within itself, but if you want to allow that
// and
// you followed my advice at the end of the above step, then you
// could get away with using the vanilla Slot class
this.addSlotToContainer(new Slot(this.inventory, i, 80 + (18 * (int) (i / 4)), 8 + (18 * (i % 4))));
}
// If you want, you can add ARMOR SLOTS here as well, but you need to
// make a public version of SlotArmor. I won't be doing that in this
// tutorial.
/*
* for (i = 0; i < 4; ++i) { // These are the standard positions for
* survival inventory layout this.addSlotToContainer(new
* SlotArmor(this.player, inventoryPlayer,
* inventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18, i)); }
*/
// PLAYER INVENTORY - uses default locations for standard inventory
// texture file
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
private InventoryLeadBox box;
public ContainerLeadBox(InventoryPlayer invPlayer, InventoryLeadBox box) {
this.box = box;
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 5; j++) {
this.addSlotToContainer(new Slot(box, j + i * 5, 43 + j * 18, 18 + i * 18));
}
}
// PLAYER ACTION BAR - uses default locations for standard action bar
// texture file
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 104 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 162));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
ItemStack var3 = null;
Slot var4 = (Slot) this.inventorySlots.get(par2);
if(var4 != null && var4.getHasStack()) {
ItemStack var5 = var4.getStack();
var3 = var5.copy();
if(par2 <= box.getSizeInventory() - 1) {
if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, box.getSizeInventory(), this.inventorySlots.size(), true)) {
return null;
}
} else if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, 0, box.getSizeInventory(), false)) {
return null;
}
if(var5.stackSize == 0) {
var4.putStack((ItemStack) null);
} else {
var4.onSlotChanged();
}
var4.onPickupFromSlot(p_82846_1_, var5);
}
return var3;
}
@Override
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {
// prevents the player from moving around the currently open box
if(index == player.inventory.currentItem + 47) return null;
return super.slotClick(index, button, mode, player);
}
@Override
public boolean canInteractWith(EntityPlayer player) {
// be sure to return the inventory's isUseableByPlayer method
// if you defined special behavior there:
return inventory.isUseableByPlayer(player);
return box.isUseableByPlayer(player);
}
/**
* Called when a player shift-clicks on a slot. You must override this or
* you will crash when someone does that.
*/
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
ItemStack itemstack = null;
Slot slot = (Slot) this.inventorySlots.get(index);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
// If item is in our custom Inventory or armor slot
if (index < INV_START) {
// try to place in player inventory / action bar
if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, true)) {
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
// Item is in inventory / hotbar, try to place in custom inventory
// or armor slots
else {
/*
* If your inventory only stores certain instances of Items, you
* can implement shift-clicking to your inventory like this:
*
* // Check that the item is the right type if
* (itemstack1.getItem() instanceof ItemCustom) { // Try to
* merge into your custom inventory slots // We use
* 'InventoryItem.INV_SIZE' instead of INV_START just in case //
* you also add armor or other custom slots if
* (!this.mergeItemStack(itemstack1, 0, InventoryItem.INV_SIZE,
* false)) { return null; } } // If you added armor slots, check
* them here as well: // Item being shift-clicked is armor - try
* to put in armor slot if (itemstack1.getItem() instanceof
* ItemArmor) { int type = ((ItemArmor)
* itemstack1.getItem()).armorType; if
* (!this.mergeItemStack(itemstack1, ARMOR_START + type,
* ARMOR_START + type + 1, false)) { return null; } } Otherwise,
* you have basically 2 choices: 1. shift-clicking between
* player inventory and custom inventory 2. shift-clicking
* between action bar and inventory
*
* Be sure to choose only ONE of the following
* implementations!!!
*/
/**
* Implementation number 1: Shift-click into your custom
* inventory
*/
if (index >= INV_START) {
// place in custom inventory
if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) {
return null;
}
}
/**
* Implementation number 2: Shift-click items between action bar
* and inventory
*/
// item is in player's inventory, but not in action bar
if (index >= INV_START && index < HOTBAR_START) {
// place in action bar
if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END + 1, false)) {
return null;
}
}
// item in action bar - place in player inventory
else if (index >= HOTBAR_START && index < HOTBAR_END + 1) {
if (!this.mergeItemStack(itemstack1, INV_START, INV_END + 1, false)) {
return null;
}
}
}
if (itemstack1.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize) {
return null;
}
slot.onPickupFromSlot(player, itemstack1);
}
return itemstack;
}
/**
* You should override this method to prevent the player from moving the
* stack that opened the inventory, otherwise if the player moves it, the
* inventory will not be able to save properly
*/
@Override
public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) {
// this will prevent the player from interacting with the item that
// opened the inventory:
if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack() == player.getHeldItem()) {
return null;
}
return super.slotClick(slot, button, flag, player);
}
}

View File

@ -3,25 +3,44 @@ package com.hbm.inventory.gui;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerLeadBox;
import com.hbm.inventory.inv.InventoryLeadBox;
import com.hbm.items.tool.ItemLeadBox.InventoryLeadBox;
import com.hbm.lib.RefStrings;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public class GUILeadBox extends GuiContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_containment.png");
private final InventoryLeadBox inventory;
private ItemStack firstHeld;
public GUILeadBox(ContainerLeadBox container) {
super(container);
this.inventory = container.inventory;
public GUILeadBox(InventoryPlayer invPlayer, InventoryLeadBox box) {
super(new ContainerLeadBox(invPlayer, box));
this.inventory = box;
this.xSize = 176;
this.ySize = 186;
}
@Override
public void drawScreen(int x, int y, float interp) {
if(firstHeld == null) {
// *very* unlikely to be incorrect on the first frame after opening, so doing this is good enough
firstHeld = this.mc.thePlayer.getHeldItem();
// if the open box has changed or disappeared, close the inventory
} else if(this.mc.thePlayer.getHeldItem() != firstHeld) {
//this.mc.thePlayer.closeScreen();
//return;
}
super.drawScreen(x, y, interp);
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
@ -37,5 +56,4 @@ public class GUILeadBox extends GuiContainer {
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}
}

View File

@ -1,201 +0,0 @@
package com.hbm.inventory.inv;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.Constants;
public class InventoryLeadBox implements IInventory {
private String name = "Inventory Item";
/** Provides NBT Tag Compound to reference */
private final ItemStack invItem;
/** Defining your inventory size this way is handy */
public static final int INV_SIZE = 20;
/**
* Inventory's size must be same as number of slots you add to the Container
* class
*/
private ItemStack[] inventory = new ItemStack[INV_SIZE];
/**
* @param itemstack - the ItemStack to which this inventory belongs
*/
public InventoryLeadBox(ItemStack stack)
{
invItem = stack;
// Create a new NBT Tag Compound if one doesn't already exist, or you will crash
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
}
// note that it's okay to use stack instead of invItem right there
// both reference the same memory location, so whatever you change using
// either reference will change in the other
// Read the inventory contents from NBT
readFromNBT(stack.getTagCompound());
}
@Override
public int getSizeInventory() {
return inventory.length;
}
@Override
public ItemStack getStackInSlot(int slot) {
return inventory[slot];
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
ItemStack stack = getStackInSlot(slot);
if (stack != null) {
if (stack.stackSize > amount) {
stack = stack.splitStack(amount);
// Don't forget this line or your inventory will not be saved!
markDirty();
} else {
// this method also calls onInventoryChanged, so we don't need
// to call it again
setInventorySlotContents(slot, null);
}
}
return stack;
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
ItemStack stack = getStackInSlot(slot);
setInventorySlotContents(slot, null);
return stack;
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
inventory[slot] = stack;
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
stack.stackSize = getInventoryStackLimit();
}
// Don't forget this line or your inventory will not be saved!
markDirty();
}
// 1.7.2+ renamed to getInventoryName
@Override
public String getInventoryName() {
return name;
}
// 1.7.2+ renamed to hasCustomInventoryName
@Override
public boolean hasCustomInventoryName() {
return name.length() > 0;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
/**
* This is the method that will handle saving the inventory contents, as it
* is called (or should be called!) anytime the inventory changes. Perfect.
* Much better than using onUpdate in an Item, as this will also let you
* change things in your inventory without ever opening a Gui, if you want.
*/
// 1.7.2+ renamed to markDirty
@Override
public void markDirty() {
for (int i = 0; i < getSizeInventory(); ++i) {
if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) {
inventory[i] = null;
}
}
// This line here does the work:
writeToNBT(invItem.getTagCompound());
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return true;
}
// 1.7.2+ renamed to openInventory(EntityPlayer player)
@Override
public void openInventory() { }
// 1.7.2+ renamed to closeInventory(EntityPlayer player)
@Override
public void closeInventory() { }
/**
* This method doesn't seem to do what it claims to do, as items can still
* be left-clicked and placed in the inventory even when this returns false
*/
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
// Don't want to be able to store the inventory item within itself
// Bad things will happen, like losing your inventory
// Actually, this needs a custom Slot to work
return false; //I'm fairly certain this has been deprecated for awhile, so setting this to false will be fine
}
/**
* A custom method to read our inventory from an ItemStack's NBT compound
*/
public void readFromNBT(NBTTagCompound compound) {
// Gets the custom taglist we wrote to this compound, if any
// 1.7.2+ change to compound.getTagList("ItemInventory",
// Constants.NBT.TAG_COMPOUND);
NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < items.tagCount(); ++i) {
// 1.7.2+ change to items.getCompoundTagAt(i)
NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i);
int slot = item.getInteger("Slot");
// Just double-checking that the saved slot index is within our
// inventory array bounds
if (slot >= 0 && slot < getSizeInventory()) {
inventory[slot] = ItemStack.loadItemStackFromNBT(item);
}
}
}
/**
* A custom method to write our inventory to an ItemStack's NBT compound
*/
public void writeToNBT(NBTTagCompound tagcompound) {
// Create a new NBT Tag List to store itemstacks as NBT Tags
NBTTagList items = new NBTTagList();
for (int i = 0; i < getSizeInventory(); ++i) {
// Only write stacks that contain items
if (getStackInSlot(i) != null) {
// Make a new NBT Tag Compound to write the itemstack and slot
// index to
NBTTagCompound item = new NBTTagCompound();
item.setInteger("Slot", i);
// Writes the itemstack in slot(i) to the Tag Compound we just
// made
getStackInSlot(i).writeToNBT(item);
// add the tag compound to our tag list
items.appendTag(item);
}
}
// Add the TagList to the ItemStack's Tag Compound with the name
// "ItemInventory"
tagcompound.setTag("ItemInventory", items);
}
}

View File

@ -2636,7 +2636,6 @@ public class ModItems {
public static final int guiID_item_fluid = 1100;
public static final int guiID_item_designator = 10100;
public static final int guiID_item_sat_interface = 10101;
public static final int guiID_item_box = 10102;
public static final int guiID_item_bobmazon = 10103;
public static final int guiID_item_sat_coord = 10104;
public static final int guiID_item_book = 10105;

View File

@ -3,11 +3,14 @@ package com.hbm.items.machine;
import java.util.List;
import com.hbm.blocks.ModBlocks;
import com.hbm.util.ChatBuilder;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
public class ItemReactorSensor extends Item {
@ -20,9 +23,16 @@ public class ItemReactorSensor extends Item {
if (b == ModBlocks.reactor_research) {
if (stack.stackTagCompound == null)
if(stack.stackTagCompound == null)
stack.stackTagCompound = new NBTTagCompound();
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("Position set!").color(EnumChatFormatting.GREEN).flush());
}
stack.stackTagCompound.setInteger("x", x);
stack.stackTagCompound.setInteger("y", y);
stack.stackTagCompound.setInteger("z", z);

View File

@ -1,27 +1,148 @@
package com.hbm.items.tool;
import com.hbm.items.ModItems;
import com.hbm.inventory.container.ContainerLeadBox;
import com.hbm.inventory.gui.GUILeadBox;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.util.ItemStackUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class ItemLeadBox extends Item {
public class ItemLeadBox extends Item implements IGUIProvider {
// Without this method, your inventory will NOT work!!!
@Override
public int getMaxItemUseDuration(ItemStack stack) {
return 1; // return any value greater than zero
return 1;
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
//if(world.isRemote)
// player.openGui(MainRegistry.instance, ModItems.guiID_item_box, world, 0, 0, 0);
if(!world.isRemote) player.openGui(MainRegistry.instance, 0, world, 0, 0, 0);
return stack;
}
@Override
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new ContainerLeadBox(player.inventory, new InventoryLeadBox(player.getHeldItem()));
}
@Override
@SideOnly(Side.CLIENT)
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUILeadBox(player.inventory, new InventoryLeadBox(player.getHeldItem()));
}
public static class InventoryLeadBox implements IInventory {
public final ItemStack box;
public ItemStack[] slots;
public InventoryLeadBox(ItemStack box) {
this.box = box;
slots = new ItemStack[this.getSizeInventory()];
if(!box.hasTagCompound())
box.setTagCompound(new NBTTagCompound());
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(box);
if(fromNBT != null) {
for(int i = 0; i < Math.min(slots.length, fromNBT.length); i++) {
slots[i] = fromNBT[i];
}
}
}
@Override
public int getSizeInventory() {
return 20;
}
@Override
public ItemStack getStackInSlot(int slot) {
return slots[slot];
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
ItemStack stack = getStackInSlot(slot);
if (stack != null) {
if (stack.stackSize > amount) {
stack = stack.splitStack(amount);
markDirty();
} else {
setInventorySlotContents(slot, null);
}
}
return stack;
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
ItemStack stack = getStackInSlot(slot);
setInventorySlotContents(slot, null);
return stack;
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
if(stack != null) {
stack.stackSize = Math.min(stack.stackSize, this.getInventoryStackLimit());
}
slots[slot] = stack;
markDirty();
}
@Override
public String getInventoryName() {
return "container.leadBox";
}
@Override
public boolean hasCustomInventoryName() {
return box.hasDisplayName();
}
@Override
public int getInventoryStackLimit() {
return 1;
}
@Override
public void markDirty() {
for(int i = 0; i < getSizeInventory(); ++i) {
if(getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) {
slots[i] = null;
}
}
ItemStackUtil.addStacksToNBT(box, slots);
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return true;
}
@Override public void openInventory() { }
@Override public void closeInventory() { }
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
return true;
}
}
}

View File

@ -656,7 +656,7 @@ public class CraftingManager {
addRecipeAuto(new ItemStack(ModBlocks.spikes, 4), new Object[] { "FFF", "BBB", "TTT", 'F', Items.flint, 'B', ModItems.bolt_tungsten, 'T', W.ingot() });
addRecipeAuto(new ItemStack(ModItems.custom_fall, 1), new Object[] { "IIP", "CHW", "IIP", 'I', ModItems.plate_polymer, 'P', BIGMT.plate(), 'C', ModItems.circuit_red_copper, 'H', ModItems.hull_small_steel, 'W', ModItems.coil_copper });
addRecipeAuto(new ItemStack(ModBlocks.machine_controller, 1), new Object[] { "TDT", "DCD", "TDT", 'T', TCALLOY.ingot(), 'D', ModItems.crt_display, 'C', ModItems.circuit_targeting_tier3 });
addRecipeAuto(new ItemStack(ModItems.containment_box, 1), new Object[] { "LLL", "LCL", "LLL", 'L', PB.plate(), 'C', Blocks.chest });
addRecipeAuto(new ItemStack(ModItems.containment_box, 1), new Object[] { "LUL", "UCU", "LUL", 'L', PB.plate(), 'U', U238.billet(), 'C', ModBlocks.crate_steel });
addRecipeAuto(new ItemStack(ModBlocks.absorber, 1), new Object[] { "ICI", "CPC", "ICI", 'I', CU.ingot(), 'C', COAL.dust(), 'P', PB.dust() });
addRecipeAuto(new ItemStack(ModBlocks.absorber_red, 1), new Object[] { "ICI", "CPC", "ICI", 'I', TI.ingot(), 'C', COAL.dust(), 'P', ModBlocks.absorber });

View File

@ -1470,6 +1470,7 @@ item.coltan_tool.name=Koltass
item.combine_scrap.name=CMB Schrott
item.component_emitter.name=Emitterkomponente
item.component_limiter.name=Stabilisatorkomponente
item.containment_box.name=Sicherheitsbehälter
item.cordite.name=Kordit
item.cotton_candy.name=Radioaktive Zuckerwatte
item.crate_caller.name=Nachschub-Requester

View File

@ -2118,6 +2118,7 @@ item.coltan_tool.name=Coltass
item.combine_scrap.name=CMB Scrap Metal
item.component_emitter.name=Emitter Component
item.component_limiter.name=Stabilizer Component
item.containment_box.name=Containment Box
item.cordite.name=Cordite
item.cotton_candy.name=Radioactive Cotton Candy
item.crate_caller.name=Supply Drop Requester

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 314 B