mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-26 15:03:09 +00:00
Basic custom drawer crafting support
This commit is contained in:
1 parent
30ea409244
commit
24bcad1fbe
15 files changed
+791
-44
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.block;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityFramingTable;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.handlers.GuiHandler;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockFramingTable extends BlockContainer
|
||||
{
|
||||
public BlockFramingTable (String blockName) {
|
||||
super(Material.wood);
|
||||
|
||||
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
|
||||
setHardness(2.5f);
|
||||
setStepSound(soundTypeWood);
|
||||
setBlockName(blockName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int meta) {
|
||||
return new TileEntityFramingTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float vx, float vy, float vz) {
|
||||
player.openGui(StorageDrawers.instance, GuiHandler.framingGuiID, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.block.tile;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawersCustom;
|
||||
import net.minecraft.block.Block;
|
||||
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.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
public class TileEntityFramingTable extends TileEntity implements IInventory
|
||||
{
|
||||
private ItemStack[] tableItemStacks = new ItemStack[5];
|
||||
|
||||
private String customName;
|
||||
|
||||
@Override
|
||||
public int getSizeInventory () {
|
||||
return tableItemStacks.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int slot) {
|
||||
return tableItemStacks[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int count) {
|
||||
if (tableItemStacks[slot] != null) {
|
||||
if (tableItemStacks[slot].stackSize <= count) {
|
||||
ItemStack stack = tableItemStacks[slot];
|
||||
tableItemStacks[slot] = null;
|
||||
markDirty();
|
||||
return stack;
|
||||
}
|
||||
else {
|
||||
ItemStack stack = tableItemStacks[slot].splitStack(slot);
|
||||
if (tableItemStacks[slot].stackSize == 0)
|
||||
tableItemStacks[slot] = null;
|
||||
|
||||
markDirty();
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int slot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack stack) {
|
||||
tableItemStacks[slot] = stack;
|
||||
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit())
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName () {
|
||||
return hasCustomInventoryName() ? customName : "container.storagedrawers.framingTable";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName () {
|
||||
return customName != null && customName.length() > 0;
|
||||
}
|
||||
|
||||
public void setCustomName (String name) {
|
||||
customName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit () {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer (EntityPlayer player) {
|
||||
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
|
||||
return false;
|
||||
|
||||
return player.getDistanceSq(xCoord + .5, yCoord + .5, zCoord + .5) <= 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory () {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory () {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot (int slot, ItemStack stack) {
|
||||
if (slot == 0)
|
||||
return isItemValidDrawer(stack);
|
||||
if (slot == 4)
|
||||
return false;
|
||||
if (slot >= 1 && slot < 4)
|
||||
return isItemValidMaterial(stack);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isItemValidDrawer (ItemStack stack) {
|
||||
if (stack == null)
|
||||
return false;
|
||||
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
return block instanceof BlockDrawersCustom;
|
||||
}
|
||||
|
||||
public static boolean isItemValidMaterial (ItemStack stack) {
|
||||
if (stack == null)
|
||||
return false;
|
||||
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
if (block == null)
|
||||
return false;
|
||||
|
||||
return block.isOpaqueCube();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
|
||||
NBTTagList itemList = tag.getTagList("Items", 10);
|
||||
tableItemStacks = new ItemStack[getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < itemList.tagCount(); i++) {
|
||||
NBTTagCompound item = itemList.getCompoundTagAt(i);
|
||||
byte slot = item.getByte("Slot");
|
||||
|
||||
if (slot >= 0 && slot < tableItemStacks.length)
|
||||
tableItemStacks[slot] = ItemStack.loadItemStackFromNBT(item);
|
||||
}
|
||||
|
||||
if (tag.hasKey("CustomName", Constants.NBT.TAG_STRING))
|
||||
customName = tag.getString("CustomName");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
|
||||
NBTTagList itemList = new NBTTagList();
|
||||
for (int i = 0; i < tableItemStacks.length; i++) {
|
||||
if (tableItemStacks[i] != null) {
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
item.setByte("Slot", (byte)i);
|
||||
tableItemStacks[i].writeToNBT(item);
|
||||
itemList.appendTag(item);
|
||||
}
|
||||
}
|
||||
|
||||
tag.setTag("Items", itemList);
|
||||
|
||||
if (hasCustomInventoryName())
|
||||
tag.setString("CustomName", customName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.client.gui;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityFramingTable;
|
||||
import com.jaquadro.minecraft.storagedrawers.inventory.ContainerFramingTable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiFraming extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation guiTextires = new ResourceLocation(StorageDrawers.MOD_ID.toLowerCase(), "textures/gui/framing.png");
|
||||
private TileEntityFramingTable tileFramingTable;
|
||||
|
||||
public GuiFraming (InventoryPlayer inventory, TileEntityFramingTable tileEntity) {
|
||||
super(new ContainerFramingTable(inventory, tileEntity));
|
||||
tileFramingTable = tileEntity;
|
||||
|
||||
xSize = 176;
|
||||
ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int mouseX, int mouseY) {
|
||||
String name = tileFramingTable.hasCustomInventoryName() ? tileFramingTable.getInventoryName() : I18n.format(tileFramingTable.getInventoryName());
|
||||
fontRendererObj.drawString(name, 8, 6, 4210752);
|
||||
fontRendererObj.drawString(I18n.format("container.inventory"), 8, ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float dt, int mouseX, int mouseY) {
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
mc.getTextureManager().bindTexture(guiTextires);
|
||||
|
||||
int guiX = (width - xSize) / 2;
|
||||
int guiY = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiX, guiY, 0, 0, xSize, ySize);
|
||||
}
|
||||
}
|
||||
+81
-11
@@ -1,10 +1,13 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.client.renderer;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawersCustom;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ClientProxy;
|
||||
import com.jaquadro.minecraft.storagedrawers.util.RenderHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -13,6 +16,7 @@ public class DrawersItemRenderer implements IItemRenderer
|
||||
{
|
||||
private RenderHelper renderHelper = new RenderHelper();
|
||||
private ModularBoxRenderer boxRenderer = new ModularBoxRenderer();
|
||||
private PanelBoxRenderer panelRenderer = new PanelBoxRenderer();
|
||||
private float[] colorScratch = new float[3];
|
||||
|
||||
@Override
|
||||
@@ -40,10 +44,6 @@ public class DrawersItemRenderer implements IItemRenderer
|
||||
|
||||
private void renderDrawer (BlockDrawers block, ItemStack item, RenderBlocks renderer, ItemRenderType renderType) {
|
||||
int side = 4;
|
||||
boxRenderer.setUnit(.0625);
|
||||
boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
|
||||
for (int i = 0; i < 6; i++)
|
||||
boxRenderer.setIcon(block.getIcon(i, item.getItemDamage()), i);
|
||||
|
||||
if (renderType == ItemRenderType.INVENTORY)
|
||||
GL11.glRotatef(90, 0, 1, 0);
|
||||
@@ -52,6 +52,24 @@ public class DrawersItemRenderer implements IItemRenderer
|
||||
if (renderType == ItemRenderType.INVENTORY || renderType == ItemRenderType.ENTITY)
|
||||
GL11.glTranslatef(block.halfDepth ? -.75f : -.5f, -.5f, -.5f);
|
||||
|
||||
if (block instanceof BlockDrawersCustom)
|
||||
renderCustomBlock(block, item, renderer);
|
||||
else
|
||||
renderBaseBlock(block, item, renderer);
|
||||
|
||||
if (item.hasTagCompound() && item.getTagCompound().hasKey("tile")) {
|
||||
double depth = block.halfDepth ? .5 : 1;
|
||||
RenderHelper.instance.setRenderBounds(1 - depth - .005, 0, 0, 1, 1, 1);
|
||||
RenderHelper.instance.renderFace(side, null, block, block.getTapeIcon(), 1, 1, 1);
|
||||
}
|
||||
|
||||
if (renderType == ItemRenderType.INVENTORY || renderType == ItemRenderType.ENTITY)
|
||||
GL11.glTranslatef(block.halfDepth ? .75f : .5f, .5f, .5f);
|
||||
}
|
||||
|
||||
private void renderBaseBlock (BlockDrawers block, ItemStack item, RenderBlocks renderer) {
|
||||
int side = 4;
|
||||
|
||||
switch (side - 2) {
|
||||
case 0:
|
||||
renderer.uvRotateTop = 3;
|
||||
@@ -67,6 +85,11 @@ public class DrawersItemRenderer implements IItemRenderer
|
||||
break;
|
||||
}
|
||||
|
||||
boxRenderer.setUnit(block.getTrimWidth());
|
||||
boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
|
||||
for (int i = 0; i < 6; i++)
|
||||
boxRenderer.setIcon(block.getIcon(i, item.getItemDamage()), i);
|
||||
|
||||
renderExterior(block, 0, 0, 0,side, renderer);
|
||||
|
||||
renderer.uvRotateTop = 0;
|
||||
@@ -75,17 +98,64 @@ public class DrawersItemRenderer implements IItemRenderer
|
||||
boxRenderer.setInteriorIcon(block.getIcon(side, item.getItemDamage()), ForgeDirection.OPPOSITES[side]);
|
||||
|
||||
renderInterior(block, 0, 0, 0, side, renderer);
|
||||
}
|
||||
|
||||
boxRenderer.setExteriorIcon(block.getTapeIcon(), side);
|
||||
private void renderCustomBlock (BlockDrawers block, ItemStack item, RenderBlocks renderer) {
|
||||
BlockDrawersCustom custom = (BlockDrawersCustom)block;
|
||||
ItemStack materialSide = null;
|
||||
ItemStack materialTrim = null;
|
||||
ItemStack materialFront = null;
|
||||
|
||||
if (item.hasTagCompound() && item.getTagCompound().hasKey("tile")) {
|
||||
double depth = block.halfDepth ? .5 : 1;
|
||||
RenderHelper.instance.setRenderBounds(1 - depth - .005, 0, 0, 1, 1, 1);
|
||||
RenderHelper.instance.renderFace(side, null, block, block.getTapeIcon(), 1, 1, 1);
|
||||
if (item.hasTagCompound()) {
|
||||
NBTTagCompound tag = item.getTagCompound();
|
||||
if (tag.hasKey("MatS"))
|
||||
materialSide = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatS"));
|
||||
if (tag.hasKey("MatT"))
|
||||
materialTrim = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatT"));
|
||||
if (tag.hasKey("MatF"))
|
||||
materialFront = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatF"));
|
||||
}
|
||||
|
||||
if (renderType == ItemRenderType.INVENTORY || renderType == ItemRenderType.ENTITY)
|
||||
GL11.glTranslatef(block.halfDepth ? .75f : .5f, .5f, .5f);
|
||||
if (materialSide == null)
|
||||
materialSide = new ItemStack(block);
|
||||
if (materialTrim == null)
|
||||
materialTrim = materialSide;
|
||||
if (materialFront == null)
|
||||
materialFront = materialSide;
|
||||
|
||||
panelRenderer.setTrimWidth(block.getTrimWidth());
|
||||
panelRenderer.setTrimDepth(0);
|
||||
panelRenderer.setTrimColor(ModularBoxRenderer.COLOR_WHITE);
|
||||
panelRenderer.setTrimIcon(Block.getBlockFromItem(materialTrim.getItem()).getIcon(0, materialTrim.getItemDamage()));
|
||||
panelRenderer.setPanelColor(ModularBoxRenderer.COLOR_WHITE);
|
||||
panelRenderer.setPanelIcon(Block.getBlockFromItem(materialSide.getItem()).getIcon(0, materialSide.getItemDamage()));
|
||||
|
||||
//if (ClientProxy.renderPass == 0) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (i == 2)
|
||||
continue;
|
||||
panelRenderer.renderFaceTrim(i, null, block, 0, 0, 0, 0, 0, 0, 1, 1, 1);
|
||||
panelRenderer.renderInteriorTrim(i, null, block, 0, 0, 0, 0, 0, 0, 1, 1, 1);
|
||||
panelRenderer.renderFacePanel(i, null, block, 0, 0, 0, 0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
|
||||
panelRenderer.setPanelIcon(Block.getBlockFromItem(materialFront.getItem()).getIcon(4, materialFront.getItemDamage()));
|
||||
panelRenderer.setTrimDepth(block.getTrimDepth());
|
||||
|
||||
panelRenderer.renderFaceTrim(2, null, block, 0, 0, 0, 0, 0, 0, 1, 1, 1);
|
||||
panelRenderer.renderInteriorTrim(2, null, block, 0, 0, 0, 0, 0, 0, 1, 1, 1);
|
||||
panelRenderer.renderFacePanel(2, null, block, 0, 0, 0, 0, 0, 0, 1, 1, 1);
|
||||
//}
|
||||
//else if (ClientProxy.renderPass == 1) {
|
||||
panelRenderer.setTrimDepth(block.getTrimDepth());
|
||||
panelRenderer.setTrimIcon(custom.getTrimShadowOverlay());
|
||||
panelRenderer.renderFaceTrim(2, null, block, 0, 0, 0, 0, 0, 0, 1, 1, 1);
|
||||
|
||||
panelRenderer.setPanelIcon(custom.getHandleOverlay());
|
||||
panelRenderer.renderFacePanel(2, null, block, 0, 0, 0, 0, 0, 0, 1, 1, 1);
|
||||
panelRenderer.setPanelIcon(custom.getFaceShadowOverlay());
|
||||
panelRenderer.renderFacePanel(2, null, block, 0, 0, 0, 0, 0, 0, 1, 1, 1);
|
||||
//}
|
||||
}
|
||||
|
||||
private void renderExterior (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
|
||||
|
||||
@@ -90,7 +90,7 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
|
||||
if (StorageDrawers.config.cache.enableIndicatorUpgrades)
|
||||
renderIndicator(block, x, y, z, side, renderer, tile.getEffectiveStatusLevel());
|
||||
if (StorageDrawers.config.cache.enableLockUpgrades)
|
||||
renderLock(block, x, y, z, side, renderer, tile.isLocked(LockAttribute.LOCK_POPULATED));
|
||||
renderLock(block, x, y, z, side, renderer, tile.isLocked(LockAttribute.LOCK_POPULATED), tile.getOwner() != null);
|
||||
if (StorageDrawers.config.cache.enableVoidUpgrades)
|
||||
renderVoid(block, x, y, z, side, renderer, tile.isVoid());
|
||||
renderShroud(block, x, y, z, side, renderer, tile.isShrouded());
|
||||
@@ -158,8 +158,6 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
|
||||
renderTape(block, x, y, z, side, renderer, tile.isSealed());
|
||||
|
||||
renderShroud(block, x, y, z, side, renderer, tile.isShrouded());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private void renderLock (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, boolean locked, boolean owned) {
|
||||
|
||||
@@ -2,15 +2,9 @@ package com.jaquadro.minecraft.storagedrawers.core;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.*;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityController;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersComp;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersStandard;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntitySlave;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.*;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemCompDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemController;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemTrim;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.*;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -30,9 +24,11 @@ public class ModBlocks
|
||||
public static BlockController controller;
|
||||
public static BlockTrim trim;
|
||||
public static BlockSlave controllerSlave;
|
||||
public static BlockFramingTable framingTable;
|
||||
|
||||
public static BlockDrawersCustom fullCustom1;
|
||||
public static BlockDrawersCustom fullCustom2;
|
||||
public static BlockDrawersCustom fullCustom4;
|
||||
|
||||
public void init () {
|
||||
resolver = new DataResolver(StorageDrawers.MOD_ID);
|
||||
@@ -46,22 +42,24 @@ public class ModBlocks
|
||||
controller = new BlockController("drawerController");
|
||||
trim = new BlockTrim("trim");
|
||||
controllerSlave = new BlockSlave("controllerSlave");
|
||||
framingTable = new BlockFramingTable("framingTable");
|
||||
|
||||
fullCustom1 = new BlockDrawersCustom("fullCustom1", 1, false);
|
||||
fullCustom2 = new BlockDrawersCustom("fullCustom2", 2, false);
|
||||
fullCustom4 = new BlockDrawersCustom("fullCustom4", 4, false);
|
||||
|
||||
ConfigManager config = StorageDrawers.config;
|
||||
|
||||
if (config.isBlockEnabled("fulldrawers1"))
|
||||
GameRegistry.registerBlock(fullDrawers1, ItemDrawers.class, "fullDrawers1");
|
||||
GameRegistry.registerBlock(fullDrawers1, ItemBasicDrawers.class, "fullDrawers1");
|
||||
if (config.isBlockEnabled("fulldrawers2"))
|
||||
GameRegistry.registerBlock(fullDrawers2, ItemDrawers.class, "fullDrawers2");
|
||||
GameRegistry.registerBlock(fullDrawers2, ItemBasicDrawers.class, "fullDrawers2");
|
||||
if (config.isBlockEnabled("fulldrawers4"))
|
||||
GameRegistry.registerBlock(fullDrawers4, ItemDrawers.class, "fullDrawers4");
|
||||
GameRegistry.registerBlock(fullDrawers4, ItemBasicDrawers.class, "fullDrawers4");
|
||||
if (config.isBlockEnabled("halfdrawers2"))
|
||||
GameRegistry.registerBlock(halfDrawers2, ItemDrawers.class, "halfDrawers2");
|
||||
GameRegistry.registerBlock(halfDrawers2, ItemBasicDrawers.class, "halfDrawers2");
|
||||
if (config.isBlockEnabled("halfdrawers4"))
|
||||
GameRegistry.registerBlock(halfDrawers4, ItemDrawers.class, "halfDrawers4");
|
||||
GameRegistry.registerBlock(halfDrawers4, ItemBasicDrawers.class, "halfDrawers4");
|
||||
if (config.isBlockEnabled("compdrawers"))
|
||||
GameRegistry.registerBlock(compDrawers, ItemCompDrawers.class, "compDrawers");
|
||||
if (config.isBlockEnabled("controller"))
|
||||
@@ -71,8 +69,11 @@ public class ModBlocks
|
||||
if (config.isBlockEnabled("trim"))
|
||||
GameRegistry.registerBlock(trim, ItemTrim.class, "trim");
|
||||
|
||||
GameRegistry.registerBlock(fullCustom1, ItemDrawers.class, "fullCustom1");
|
||||
GameRegistry.registerBlock(fullCustom2, ItemDrawers.class, "fullCustom2");
|
||||
GameRegistry.registerBlock(framingTable, "framingTable");
|
||||
|
||||
GameRegistry.registerBlock(fullCustom1, ItemCustomDrawers.class, "fullCustom1");
|
||||
GameRegistry.registerBlock(fullCustom2, ItemCustomDrawers.class, "fullCustom2");
|
||||
GameRegistry.registerBlock(fullCustom4, ItemCustomDrawers.class, "fullCustom4");
|
||||
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityDrawersStandard.class, getQualifiedName("tileDrawersStandard"),
|
||||
getQualifiedName(fullDrawers1), getQualifiedName(fullDrawers2), getQualifiedName(fullDrawers4),
|
||||
@@ -87,6 +88,8 @@ public class ModBlocks
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntitySlave.class, getQualifiedName("tileControllerSlave"),
|
||||
getQualifiedName(controllerSlave));
|
||||
|
||||
GameRegistry.registerTileEntity(TileEntityFramingTable.class, getQualifiedName("framingTable"));
|
||||
|
||||
StorageDrawers.proxy.registerDrawer(fullDrawers1);
|
||||
StorageDrawers.proxy.registerDrawer(fullDrawers2);
|
||||
StorageDrawers.proxy.registerDrawer(fullDrawers4);
|
||||
@@ -94,6 +97,10 @@ public class ModBlocks
|
||||
StorageDrawers.proxy.registerDrawer(halfDrawers4);
|
||||
StorageDrawers.proxy.registerDrawer(compDrawers);
|
||||
|
||||
StorageDrawers.proxy.registerDrawer(fullCustom1);
|
||||
StorageDrawers.proxy.registerDrawer(fullCustom2);
|
||||
StorageDrawers.proxy.registerDrawer(fullCustom4);
|
||||
|
||||
for (String key : new String[] { "drawerBasic" })
|
||||
OreDictionary.registerOre(key, new ItemStack(fullDrawers1, 1, OreDictionary.WILDCARD_VALUE));
|
||||
for (String key : new String[] { "drawerBasic" })
|
||||
@@ -105,9 +112,6 @@ public class ModBlocks
|
||||
for (String key : new String[] { "drawerBasic" })
|
||||
OreDictionary.registerOre(key, new ItemStack(halfDrawers4, 1, OreDictionary.WILDCARD_VALUE));
|
||||
|
||||
for (String key : new String[] { "drawerBasic" })
|
||||
OreDictionary.registerOre(key, new ItemStack(fullCustom1, 1, OreDictionary.WILDCARD_VALUE));
|
||||
|
||||
resolver.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.core.handlers;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityFramingTable;
|
||||
import com.jaquadro.minecraft.storagedrawers.client.gui.GuiDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.inventory.ContainerDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.inventory.ContainerDrawers1;
|
||||
import com.jaquadro.minecraft.storagedrawers.inventory.ContainerDrawers2;
|
||||
import com.jaquadro.minecraft.storagedrawers.inventory.ContainerDrawers4;
|
||||
import com.jaquadro.minecraft.storagedrawers.client.gui.GuiFraming;
|
||||
import com.jaquadro.minecraft.storagedrawers.inventory.*;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -15,12 +14,15 @@ import net.minecraft.world.World;
|
||||
public class GuiHandler implements IGuiHandler
|
||||
{
|
||||
public static int drawersGuiID = 0;
|
||||
public static int framingGuiID = 1;
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityDrawers)
|
||||
return new ContainerDrawers(player.inventory, (TileEntityDrawers) tile);
|
||||
if (tile instanceof TileEntityFramingTable)
|
||||
return new ContainerFramingTable(player.inventory, (TileEntityFramingTable) tile);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -30,6 +32,8 @@ public class GuiHandler implements IGuiHandler
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityDrawers)
|
||||
return new GuiDrawers(player.inventory, (TileEntityDrawers) tile);
|
||||
if (tile instanceof TileEntityFramingTable)
|
||||
return new GuiFraming(player.inventory, (TileEntityFramingTable) tile);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@ package com.jaquadro.minecraft.storagedrawers.integration.refinedrelocation;
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.RefinedRelocation;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemBasicDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemDrawers;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -14,7 +15,7 @@ import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSortingDrawers extends ItemDrawers
|
||||
public class ItemSortingDrawers extends ItemBasicDrawers
|
||||
{
|
||||
public ItemSortingDrawers (Block block) {
|
||||
super(block);
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.inventory;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawersCustom;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityFramingTable;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemCustomDrawers;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCraftResult;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ContainerFramingTable extends Container
|
||||
{
|
||||
private static final int InventoryX = 8;
|
||||
private static final int InventoryY = 84;
|
||||
private static final int HotbarY = 142;
|
||||
|
||||
private static final int InputX = 23;
|
||||
private static final int InputY = 35;
|
||||
private static final int MaterialSideX = 50;
|
||||
private static final int MaterialSideY = 17;
|
||||
private static final int MaterialTrimX = 102;
|
||||
private static final int MaterialTrimY = 17;
|
||||
private static final int MaterialFrontX = 50;
|
||||
private static final int MaterialFrontY = 53;
|
||||
private static final int OutputX = 133;
|
||||
private static final int OutputY = 35;
|
||||
|
||||
private IInventory tableInventory;
|
||||
private IInventory craftResult = new InventoryCraftResult();
|
||||
|
||||
private Slot inputSlot;
|
||||
private Slot materialSideSlot;
|
||||
private Slot materialTrimSlot;
|
||||
private Slot materialFrontSlot;
|
||||
private Slot outputSlot;
|
||||
private List<Slot> playerSlots;
|
||||
private List<Slot> hotbarSlots;
|
||||
|
||||
public ContainerFramingTable (InventoryPlayer inventory, TileEntityFramingTable tileEntity) {
|
||||
tableInventory = new InventoryContainerProxy(tileEntity, this);
|
||||
|
||||
inputSlot = addSlotToContainer(new Slot(tableInventory, 0, InputX, InputY));
|
||||
materialSideSlot = addSlotToContainer(new Slot(tableInventory, 1, MaterialSideX, MaterialSideY));
|
||||
materialTrimSlot = addSlotToContainer(new Slot(tableInventory, 2, MaterialTrimX, MaterialTrimY));
|
||||
materialFrontSlot = addSlotToContainer(new Slot(tableInventory, 3, MaterialFrontX, MaterialFrontY));
|
||||
outputSlot = addSlotToContainer(new SlotCraftResult(inventory.player, tableInventory, craftResult, new int[] { 0, 1, 2, 3 }, 4, OutputX, OutputY));
|
||||
|
||||
playerSlots = new ArrayList<Slot>();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 9; j++)
|
||||
playerSlots.add(addSlotToContainer(new Slot(inventory, j + i * 9 + 9, InventoryX + j * 18, InventoryY + i * 18)));
|
||||
}
|
||||
|
||||
hotbarSlots = new ArrayList<Slot>();
|
||||
for (int i = 0; i < 9; i++)
|
||||
hotbarSlots.add(addSlotToContainer(new Slot(inventory, i, InventoryX + i * 18, HotbarY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith (EntityPlayer player) {
|
||||
return tableInventory.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged (IInventory inventory) {
|
||||
ItemStack target = tableInventory.getStackInSlot(inputSlot.getSlotIndex());
|
||||
ItemStack matSide = tableInventory.getStackInSlot(materialSideSlot.getSlotIndex());
|
||||
ItemStack matTrim = tableInventory.getStackInSlot(materialTrimSlot.getSlotIndex());
|
||||
ItemStack matFront = tableInventory.getStackInSlot(materialFrontSlot.getSlotIndex());
|
||||
|
||||
if (target != null) {
|
||||
Block block = Block.getBlockFromItem(target.getItem());
|
||||
if (block instanceof BlockDrawersCustom) {
|
||||
craftResult.setInventorySlotContents(outputSlot.getSlotIndex(), ItemCustomDrawers.makeItemStack(block, 1, matSide, matTrim, matFront));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
craftResult.setInventorySlotContents(outputSlot.getSlotIndex(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot (EntityPlayer player, int slotIndex) {
|
||||
ItemStack itemStack = null;
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
|
||||
// Assume inventory and hotbar slot IDs are contiguous
|
||||
int inventoryStart = playerSlots.get(0).slotNumber;
|
||||
int hotbarStart = hotbarSlots.get(0).slotNumber;
|
||||
int hotbarEnd = hotbarSlots.get(hotbarSlots.size() - 1).slotNumber + 1;
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack slotStack = slot.getStack();
|
||||
itemStack = slotStack.copy();
|
||||
|
||||
// Try merge output into inventory and signal change
|
||||
if (slotIndex == outputSlot.slotNumber) {
|
||||
if (!mergeItemStack(slotStack, inventoryStart, hotbarEnd, true))
|
||||
return null;
|
||||
slot.onSlotChange(slotStack, itemStack);
|
||||
}
|
||||
|
||||
// Try merge stacks within inventory and hotbar spaces
|
||||
else if (slotIndex >= inventoryStart && slotIndex < hotbarEnd) {
|
||||
if (slotIndex >= inventoryStart && slotIndex < hotbarStart) {
|
||||
if (!mergeItemStack(slotStack, hotbarStart, hotbarEnd, false))
|
||||
return null;
|
||||
}
|
||||
else if (slotIndex >= hotbarStart && slotIndex < hotbarEnd && !this.mergeItemStack(slotStack, inventoryStart, hotbarStart, false))
|
||||
return null;
|
||||
}
|
||||
|
||||
// Try merge stack into inventory
|
||||
else if (!mergeItemStack(slotStack, inventoryStart, hotbarEnd, false))
|
||||
return null;
|
||||
|
||||
if (slotStack.stackSize == 0)
|
||||
slot.putStack(null);
|
||||
else
|
||||
slot.onSlotChanged();
|
||||
|
||||
if (slotStack.stackSize == itemStack.stackSize)
|
||||
return null;
|
||||
|
||||
slot.onPickupFromSlot(player, slotStack);
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InventoryContainerProxy implements IInventory
|
||||
{
|
||||
private IInventory parent;
|
||||
private Container container;
|
||||
|
||||
public InventoryContainerProxy (IInventory parentInventory, Container container) {
|
||||
this.parent = parentInventory;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory () {
|
||||
return parent.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int slot) {
|
||||
return parent.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int count) {
|
||||
ItemStack stack = parent.getStackInSlot(slot);
|
||||
if (stack == null)
|
||||
return null;
|
||||
|
||||
int stackCount = stack.stackSize;
|
||||
ItemStack result = parent.decrStackSize(slot, count);
|
||||
|
||||
ItemStack stackAfter = parent.getStackInSlot(slot);
|
||||
if (stack != stackAfter || stackCount != stackAfter.stackSize)
|
||||
container.onCraftMatrixChanged(this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int slot) {
|
||||
return parent.getStackInSlotOnClosing(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack stack) {
|
||||
parent.setInventorySlotContents(slot, stack);
|
||||
container.onCraftMatrixChanged(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName () {
|
||||
return parent.getInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName () {
|
||||
return parent.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit () {
|
||||
return parent.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty () {
|
||||
parent.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer (EntityPlayer player) {
|
||||
return parent.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory () {
|
||||
parent.openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory () {
|
||||
parent.closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot (int slot, ItemStack stack) {
|
||||
return parent.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.inventory;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
|
||||
public class SlotCraftResult extends Slot
|
||||
{
|
||||
private final IInventory inputInventory;
|
||||
private final int[] inputSlots;
|
||||
private EntityPlayer player;
|
||||
private int amountCrafted;
|
||||
|
||||
public SlotCraftResult (EntityPlayer player, IInventory inputInventory, IInventory inventory, int[] inputSlots, int slot, int x, int y) {
|
||||
super(inventory, slot, x, y);
|
||||
|
||||
this.player = player;
|
||||
this.inputSlots = inputSlots;
|
||||
this.inputInventory = inputInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid (ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int count) {
|
||||
if (getHasStack())
|
||||
amountCrafted += Math.min(count, getStack().stackSize);
|
||||
|
||||
return super.decrStackSize(count);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCrafting (ItemStack stack, int count) {
|
||||
amountCrafted += count;
|
||||
super.onCrafting(stack, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCrafting (ItemStack stack) {
|
||||
stack.onCrafting(player.worldObj, player, amountCrafted);
|
||||
amountCrafted = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot (EntityPlayer player, ItemStack itemStack) {
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent(player, itemStack, inputInventory);
|
||||
onCrafting(itemStack);
|
||||
|
||||
for (int slot : inputSlots) {
|
||||
ItemStack itemTarget = inputInventory.getStackInSlot(slot);
|
||||
if (itemTarget != null) {
|
||||
inputInventory.decrStackSize(slot, 1);
|
||||
|
||||
if (itemTarget.getItem().hasContainerItem(itemTarget)) {
|
||||
ItemStack itemContainer = itemTarget.getItem().getContainerItem(itemTarget);
|
||||
if (itemContainer != null && itemContainer.isItemStackDamageable() && itemContainer.getItemDamage() > itemContainer.getMaxDamage()) {
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.player, itemContainer));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!itemTarget.getItem().doesContainerItemLeaveCraftingGrid(itemTarget) || !this.player.inventory.addItemStackToInventory(itemContainer)) {
|
||||
if (inputInventory.getStackInSlot(slot) == null)
|
||||
inputInventory.setInventorySlotContents(slot, itemContainer);
|
||||
else
|
||||
this.player.dropPlayerItemWithRandomChoice(itemContainer, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.item;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockWood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class ItemBasicDrawers extends ItemDrawers
|
||||
{
|
||||
protected final Block blockTemplate;
|
||||
protected final String[] blockNames;
|
||||
|
||||
public ItemBasicDrawers (Block block) {
|
||||
this(block, BlockWood.field_150096_a);
|
||||
}
|
||||
|
||||
protected ItemBasicDrawers (Block block, String[] names) {
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
blockTemplate = block;
|
||||
blockNames = names;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return blockTemplate.getIcon(2, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
int i = stack.getItemDamage();
|
||||
|
||||
if (i < 0 || i >= blockNames.length)
|
||||
i = 0;
|
||||
|
||||
return super.getUnlocalizedName() + "." + blockNames[i];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.item;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
|
||||
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.world.World;
|
||||
|
||||
public class ItemCustomDrawers extends ItemDrawers
|
||||
{
|
||||
public ItemCustomDrawers (Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
|
||||
if (!super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))
|
||||
return false;
|
||||
|
||||
TileEntityDrawers tile = (TileEntityDrawers) world.getTileEntity(x, y, z);
|
||||
if (tile != null && stack.hasTagCompound() && !stack.getTagCompound().hasKey("tile")) {
|
||||
if (stack.getTagCompound().hasKey("MatS"))
|
||||
tile.setMaterialSide(ItemStack.loadItemStackFromNBT(stack.getTagCompound().getCompoundTag("MatS")));
|
||||
if (stack.getTagCompound().hasKey("MatT"))
|
||||
tile.setMaterialTrim(ItemStack.loadItemStackFromNBT(stack.getTagCompound().getCompoundTag("MatT")));
|
||||
if (stack.getTagCompound().hasKey("MatF"))
|
||||
tile.setMaterialFront(ItemStack.loadItemStackFromNBT(stack.getTagCompound().getCompoundTag("MatF")));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ItemStack makeItemStack (Block block, int count, ItemStack matSide, ItemStack matTrim, ItemStack matFront) {
|
||||
Item item = Item.getItemFromBlock(block);
|
||||
if (!(item instanceof ItemCustomDrawers))
|
||||
return null;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
if (matSide != null) {
|
||||
NBTTagCompound itag = new NBTTagCompound();
|
||||
matSide.writeToNBT(itag);
|
||||
tag.setTag("MatS", itag);
|
||||
}
|
||||
|
||||
if (matTrim != null) {
|
||||
NBTTagCompound itag = new NBTTagCompound();
|
||||
matTrim.writeToNBT(itag);
|
||||
tag.setTag("MatT", itag);
|
||||
}
|
||||
|
||||
if (matFront != null) {
|
||||
NBTTagCompound itag = new NBTTagCompound();
|
||||
matFront.writeToNBT(itag);
|
||||
tag.setTag("MatF", itag);
|
||||
}
|
||||
|
||||
ItemStack stack = new ItemStack(item, count, 0);
|
||||
if (!tag.hasNoTags())
|
||||
stack.setTagCompound(tag);
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockWood;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemMultiTexture;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -22,14 +23,11 @@ import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemDrawers extends ItemMultiTexture
|
||||
public class ItemDrawers extends ItemBlock
|
||||
{
|
||||
public ItemDrawers (Block block) {
|
||||
super(block, block, BlockWood.field_150096_a);
|
||||
}
|
||||
|
||||
protected ItemDrawers (Block block, String[] names) {
|
||||
super(block, block, names);
|
||||
super(block);
|
||||
setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.item.pack;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemBasicDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.pack.BlockDrawersPack;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class ItemDrawersPack extends ItemDrawers
|
||||
public class ItemDrawersPack extends ItemBasicDrawers
|
||||
{
|
||||
public ItemDrawersPack (Block block) {
|
||||
super(block, getUnlocalizedNames(block));
|
||||
|
||||
Reference in new issue
Block a user