mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
*insert megalovania here*
This commit is contained in:
parent
6ba6f294e2
commit
0563ef2560
@ -0,0 +1,80 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.items.tool.ItemPlasticBag.InventoryPlasticBag;
|
||||
import com.hbm.util.InventoryUtil;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerPlasticBag extends Container {
|
||||
|
||||
private InventoryPlasticBag bag;
|
||||
|
||||
public ContainerPlasticBag(InventoryPlayer invPlayer, InventoryPlasticBag bag) {
|
||||
this.bag = bag;
|
||||
this.bag.openInventory();
|
||||
|
||||
this.addSlotToContainer(new Slot(bag, 0, 80, 65));
|
||||
|
||||
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, 134 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 192));
|
||||
}
|
||||
}
|
||||
|
||||
@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 <= bag.getSizeInventory() - 1) {
|
||||
if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, bag.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, 0, bag.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(mode == 2 && button == player.inventory.currentItem) return null;
|
||||
if(index == player.inventory.currentItem + 47) return null;
|
||||
return super.slotClick(index, button, mode, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return bag.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
this.bag.closeInventory();
|
||||
}
|
||||
}
|
||||
48
src/main/java/com/hbm/inventory/gui/GUIPlasticBag.java
Normal file
48
src/main/java/com/hbm/inventory/gui/GUIPlasticBag.java
Normal file
@ -0,0 +1,48 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerPlasticBag;
|
||||
import com.hbm.items.tool.ItemPlasticBag.InventoryPlasticBag;
|
||||
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 GUIPlasticBag extends GuiContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_plastic_bag.png");
|
||||
private ItemStack firstHeld;
|
||||
|
||||
public GUIPlasticBag(InventoryPlayer invPlayer, InventoryPlasticBag box) {
|
||||
super(new ContainerPlasticBag(invPlayer, box));
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 216;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
if(firstHeld == null) {
|
||||
firstHeld = this.mc.thePlayer.getHeldItem();
|
||||
}
|
||||
|
||||
super.drawScreen(x, y, interp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
}
|
||||
}
|
||||
@ -1207,6 +1207,7 @@ public class ModItems {
|
||||
public static Item debris_element;
|
||||
|
||||
public static Item containment_box;
|
||||
public static Item plastic_bag;
|
||||
|
||||
public static Item test_nuke_igniter;
|
||||
public static Item test_nuke_propellant;
|
||||
@ -3844,6 +3845,7 @@ public class ModItems {
|
||||
scrap_oil = new Item().setUnlocalizedName("scrap_oil").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":scrap_oil");
|
||||
scrap_nuclear = new Item().setUnlocalizedName("scrap_nuclear").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":scrap_nuclear");
|
||||
containment_box = new ItemLeadBox().setUnlocalizedName("containment_box").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":containment_box");
|
||||
plastic_bag = new ItemPlasticBag().setUnlocalizedName("plastic_bag").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":plastic_bag");
|
||||
|
||||
debris_graphite = new Item().setUnlocalizedName("debris_graphite").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":debris_graphite");
|
||||
debris_metal = new Item().setUnlocalizedName("debris_metal").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":debris_metal");
|
||||
@ -6771,6 +6773,7 @@ public class ModItems {
|
||||
GameRegistry.registerItem(digamma_diagnostic, digamma_diagnostic.getUnlocalizedName());
|
||||
GameRegistry.registerItem(pollution_detector, pollution_detector.getUnlocalizedName());
|
||||
GameRegistry.registerItem(containment_box, containment_box.getUnlocalizedName());
|
||||
GameRegistry.registerItem(plastic_bag, plastic_bag.getUnlocalizedName());
|
||||
|
||||
//Keys and Locks
|
||||
GameRegistry.registerItem(key, key.getUnlocalizedName());
|
||||
|
||||
126
src/main/java/com/hbm/items/tool/ItemPlasticBag.java
Normal file
126
src/main/java/com/hbm/items/tool/ItemPlasticBag.java
Normal file
@ -0,0 +1,126 @@
|
||||
package com.hbm.items.tool;
|
||||
|
||||
import com.hbm.inventory.container.ContainerPlasticBag;
|
||||
import com.hbm.inventory.gui.GUIPlasticBag;
|
||||
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 ItemPlasticBag extends Item implements IGUIProvider {
|
||||
|
||||
public ItemPlasticBag() {
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack stack) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
|
||||
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 ContainerPlasticBag(player.inventory, new InventoryPlasticBag(player, player.getHeldItem()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GUIPlasticBag(player.inventory, new InventoryPlasticBag(player, player.getHeldItem()));
|
||||
}
|
||||
|
||||
public static class InventoryPlasticBag implements IInventory {
|
||||
|
||||
public final EntityPlayer player;
|
||||
public final ItemStack bag;
|
||||
public ItemStack[] slots;
|
||||
|
||||
public InventoryPlasticBag(EntityPlayer player, ItemStack box) {
|
||||
this.player = player;
|
||||
this.bag = box;
|
||||
slots = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
if(!box.hasTagCompound())
|
||||
box.setTagCompound(new NBTTagCompound());
|
||||
|
||||
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(box, slots.length);
|
||||
|
||||
if(fromNBT != null) {
|
||||
for(int i = 0; i < slots.length; i++) {
|
||||
slots[i] = fromNBT[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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 void markDirty() {
|
||||
|
||||
for(int i = 0; i < getSizeInventory(); ++i) {
|
||||
if(getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) {
|
||||
slots[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStackUtil.addStacksToNBT(bag, slots);
|
||||
}
|
||||
|
||||
@Override public int getSizeInventory() { return 1; }
|
||||
@Override public ItemStack getStackInSlot(int slot) { return slots[slot]; }
|
||||
@Override public String getInventoryName() { return "container.plasticBag"; }
|
||||
@Override public boolean hasCustomInventoryName() { return bag.hasDisplayName(); }
|
||||
@Override public int getInventoryStackLimit() { return 1; }
|
||||
@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; }
|
||||
}
|
||||
}
|
||||
97
src/main/resources/assets/hbm/models/mobs/plasticbag.obj
Normal file
97
src/main/resources/assets/hbm/models/mobs/plasticbag.obj
Normal file
@ -0,0 +1,97 @@
|
||||
# Blender v2.79 (sub 0) OBJ File: 'plasticbag.blend'
|
||||
# www.blender.org
|
||||
o Cube_Cube.001
|
||||
v -0.187500 -0.250000 0.125000
|
||||
v -0.187500 0.250000 0.125000
|
||||
v -0.187500 -0.250000 -0.125000
|
||||
v -0.187500 0.250000 -0.125000
|
||||
v 0.187500 -0.250000 0.125000
|
||||
v 0.187500 0.250000 0.125000
|
||||
v 0.187500 -0.250000 -0.125000
|
||||
v 0.187500 0.250000 -0.125000
|
||||
v -0.125000 0.250000 0.125000
|
||||
v -0.125000 0.250000 -0.125000
|
||||
v -0.062500 0.250000 0.125000
|
||||
v -0.062500 0.250000 -0.125000
|
||||
v -0.125000 0.375000 0.125000
|
||||
v -0.125000 0.375000 -0.125000
|
||||
v -0.062500 0.375000 0.125000
|
||||
v -0.062500 0.375000 -0.125000
|
||||
v 0.062500 0.250000 0.125000
|
||||
v 0.062500 0.250000 -0.125000
|
||||
v 0.125000 0.250000 0.125000
|
||||
v 0.125000 0.250000 -0.125000
|
||||
v 0.062500 0.375000 0.125000
|
||||
v 0.062500 0.375000 -0.125000
|
||||
v 0.125000 0.375000 0.125000
|
||||
v 0.125000 0.375000 -0.125000
|
||||
v -0.062500 0.437500 0.125000
|
||||
v -0.062500 0.437500 -0.125000
|
||||
v 0.062500 0.437500 0.125000
|
||||
v 0.062500 0.437500 -0.125000
|
||||
vt 1.000000 1.000000
|
||||
vt 0.600000 0.333333
|
||||
vt 1.000000 0.333333
|
||||
vt 0.600000 1.000000
|
||||
vt -0.000000 0.333333
|
||||
vt 1.000000 1.000000
|
||||
vt 0.600000 0.333333
|
||||
vt 1.000000 0.333333
|
||||
vt 0.600000 1.000000
|
||||
vt -0.000000 0.333333
|
||||
vt 0.600000 0.000000
|
||||
vt -0.000000 0.000000
|
||||
vt 1.000000 0.000000
|
||||
vt 0.900000 0.166667
|
||||
vt 0.900000 0.000000
|
||||
vt 0.700000 0.000000
|
||||
vt 0.600000 0.166667
|
||||
vt 0.600000 0.000000
|
||||
vt 1.000000 0.000000
|
||||
vt 0.900000 0.166667
|
||||
vt 0.900000 0.000000
|
||||
vt 0.700000 0.000000
|
||||
vt 0.600000 0.166667
|
||||
vt 0.600000 0.000000
|
||||
vt 0.700000 0.250000
|
||||
vt 0.700000 0.166667
|
||||
vt 0.900000 0.250000
|
||||
vt 0.700000 0.166667
|
||||
vt 0.700000 0.250000
|
||||
vt 1.000000 0.166667
|
||||
vt 1.000000 0.166667
|
||||
vt 0.900000 0.250000
|
||||
vt -0.000000 1.000000
|
||||
vt -0.000000 1.000000
|
||||
vn -1.0000 0.0000 0.0000
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
vn 1.0000 0.0000 0.0000
|
||||
vn 0.0000 0.0000 1.0000
|
||||
vn 0.0000 -1.0000 0.0000
|
||||
s off
|
||||
f 2/1/1 3/2/1 1/3/1
|
||||
f 4/4/2 7/5/2 3/2/2
|
||||
f 8/6/3 5/7/3 7/8/3
|
||||
f 6/9/4 1/10/4 5/7/4
|
||||
f 7/11/5 1/10/5 3/12/5
|
||||
f 19/13/4 21/14/4 17/15/4
|
||||
f 11/16/4 13/17/4 9/18/4
|
||||
f 10/19/2 16/20/2 12/21/2
|
||||
f 18/22/2 24/23/2 20/24/2
|
||||
f 16/20/2 28/25/2 22/26/2
|
||||
f 27/27/4 15/28/4 21/14/4
|
||||
f 13/17/4 15/28/4 25/29/4
|
||||
f 21/14/4 23/30/4 27/27/4
|
||||
f 22/26/2 28/25/2 24/23/2
|
||||
f 16/20/2 14/31/2 26/32/2
|
||||
f 2/1/1 4/4/1 3/2/1
|
||||
f 4/4/2 8/33/2 7/5/2
|
||||
f 8/6/3 6/9/3 5/7/3
|
||||
f 6/9/4 2/34/4 1/10/4
|
||||
f 7/11/5 5/7/5 1/10/5
|
||||
f 19/13/4 23/30/4 21/14/4
|
||||
f 11/16/4 15/28/4 13/17/4
|
||||
f 10/19/2 14/31/2 16/20/2
|
||||
f 18/22/2 22/26/2 24/23/2
|
||||
f 16/20/2 26/32/2 28/25/2
|
||||
f 27/27/4 25/29/4 15/28/4
|
||||
BIN
src/main/resources/assets/hbm/textures/entity/plasticbag.png
Normal file
BIN
src/main/resources/assets/hbm/textures/entity/plasticbag.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 567 B |
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/main/resources/assets/hbm/textures/items/plastic_bag.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/plastic_bag.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 235 B |
Loading…
x
Reference in New Issue
Block a user