mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-27 15:33:13 +00:00
Add framed trim
This commit is contained in:
1 parent
60aa58839e
commit
b3ee2a3b01
15 files changed
+516
-1
No files matched your search
@@ -87,6 +87,7 @@ tile.fullCustom2.name=Framed Drawers 1x2
|
||||
tile.fullCustom4.name=Framed Drawers 2x2
|
||||
tile.halfCustom2.name=Framed Drawers 1x2
|
||||
tile.halfCustom4.name=Framed Drawers 2x2
|
||||
tile.trimCustom.name=Framed Trim
|
||||
|
||||
tile.compDrawers.name=Compacting Drawer
|
||||
tile.drawerController.name=Drawer Controller
|
||||
|
||||
@@ -10,10 +10,13 @@ import net.minecraft.block.BlockWood;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockTrim extends Block implements INetworked
|
||||
@@ -35,6 +38,34 @@ public class BlockTrim extends Block implements INetworked
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer (World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
if (willHarvest)
|
||||
return true;
|
||||
|
||||
return super.removedByPlayer(world, player, x, y, z, willHarvest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock (World world, EntityPlayer player, int x, int y, int z, int meta) {
|
||||
super.harvestBlock(world, player, x, y, z, meta);
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
protected ItemStack getMainDrop (World world, int x, int y, int z, int metadata) {
|
||||
return new ItemStack(Item.getItemFromBlock(this), 1, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops (World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ItemStack dropStack = getMainDrop(world, x, y, z, metadata);
|
||||
|
||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
drops.add(dropStack);
|
||||
|
||||
return drops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item item, CreativeTabs creativeTabs, List list) {
|
||||
list.add(new ItemStack(item, 1, 0));
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.block;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityTrim;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ClientProxy;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemCustomTrim;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockTrimCustom extends BlockTrim implements ITileEntityProvider
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon defaultFace;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon defaultTrim;
|
||||
|
||||
public BlockTrimCustom (String name) {
|
||||
super(name);
|
||||
isBlockContainer = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType () {
|
||||
return StorageDrawers.proxy.trimCustomRenderID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass () {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass (int pass) {
|
||||
ClientProxy.renderPass = pass;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube () {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getMainDrop (World world, int x, int y, int z, int metadata) {
|
||||
TileEntityTrim tile = getTileEntity(world, x, y, z);
|
||||
if (tile == null)
|
||||
return ItemCustomTrim.makeItemStack(this, 1, null, null);
|
||||
|
||||
return ItemCustomTrim.makeItemStack(this, 1, tile.getMaterialSide(), tile.getMaterialTrim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item item, CreativeTabs creativeTabs, List list) {
|
||||
if (StorageDrawers.config.cache.addonShowVanilla)
|
||||
list.add(new ItemStack(item));
|
||||
}
|
||||
|
||||
public TileEntityTrim getTileEntity (IBlockAccess blockAccess, int x, int y, int z) {
|
||||
TileEntity tile = blockAccess.getTileEntity(x, y, z);
|
||||
return (tile instanceof TileEntityTrim) ? (TileEntityTrim) tile : null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getDefaultFaceIcon () {
|
||||
return defaultFace;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getDefaultTrimIcon () {
|
||||
return defaultTrim;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister register) {
|
||||
super.registerBlockIcons(register);
|
||||
|
||||
defaultFace = register.registerIcon(StorageDrawers.MOD_ID + ":base/base_default");
|
||||
defaultTrim = register.registerIcon(StorageDrawers.MOD_ID + ":base/trim_default");
|
||||
|
||||
iconTrim[0] = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_raw_side");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int meta) {
|
||||
return new TileEntityTrim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock (World world, int x, int y, int z, Block block, int meta) {
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockEventReceived (World world, int x, int y, int z, int eventNum, int eventArg) {
|
||||
super.onBlockEventReceived(world, x, y, z, eventNum, eventArg);
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
return (tile != null) && tile.receiveClientEvent(eventNum, eventArg);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.block.tile;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawersCustom;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockTrimCustom;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -121,7 +122,7 @@ public class TileEntityFramingTable extends TileEntity implements IInventory
|
||||
return false;
|
||||
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
return block instanceof BlockDrawersCustom;
|
||||
return block instanceof BlockDrawersCustom || block instanceof BlockTrimCustom;
|
||||
}
|
||||
|
||||
public static boolean isItemValidMaterial (ItemStack stack) {
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.block.tile;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityTrim extends TileEntity
|
||||
{
|
||||
private ItemStack materialSide;
|
||||
private ItemStack materialTrim;
|
||||
|
||||
public ItemStack getMaterialSide () {
|
||||
return materialSide;
|
||||
}
|
||||
|
||||
public ItemStack getMaterialTrim () {
|
||||
return materialTrim;
|
||||
}
|
||||
|
||||
public ItemStack getEffectiveMaterialSide () {
|
||||
return materialSide;
|
||||
}
|
||||
|
||||
public ItemStack getEffectiveMaterialTrim () {
|
||||
return materialTrim != null ? materialTrim : materialSide;
|
||||
}
|
||||
|
||||
public void setMaterialSide (ItemStack material) {
|
||||
materialSide = material;
|
||||
}
|
||||
|
||||
public void setMaterialTrim (ItemStack material) {
|
||||
materialTrim = material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
|
||||
materialSide = null;
|
||||
if (tag.hasKey("MatS"))
|
||||
materialSide = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatS"));
|
||||
|
||||
materialTrim = null;
|
||||
if (tag.hasKey("MatT"))
|
||||
materialTrim = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatT"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
|
||||
if (materialSide != null) {
|
||||
NBTTagCompound itag = new NBTTagCompound();
|
||||
materialSide.writeToNBT(itag);
|
||||
tag.setTag("MatS", itag);
|
||||
}
|
||||
|
||||
if (materialTrim != null) {
|
||||
NBTTagCompound itag = new NBTTagCompound();
|
||||
materialTrim.writeToNBT(itag);
|
||||
tag.setTag("MatT", itag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket () {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 5, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
readFromNBT(pkt.func_148857_g());
|
||||
getWorldObj().func_147479_m(xCoord, yCoord, zCoord); // markBlockForRenderUpdate
|
||||
}
|
||||
}
|
||||
+6
@@ -1,8 +1,10 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.client.renderer;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawersCustom;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockTrimCustom;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityFramingTable;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemCustomDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemCustomTrim;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -53,6 +55,10 @@ public class TileEntityFramingRenderer extends TileEntitySpecialRenderer
|
||||
ItemStack result = ItemCustomDrawers.makeItemStack(block, 1, tileTable.getStackInSlot(1), tileTable.getStackInSlot(2), tileTable.getStackInSlot(3));
|
||||
renderSlot(tileTable, x, y, z, result, 2f, 0f, .25f, 0f);
|
||||
}
|
||||
else if (block instanceof BlockTrimCustom) {
|
||||
ItemStack result = ItemCustomTrim.makeItemStack(block, 1, tileTable.getStackInSlot(1), tileTable.getStackInSlot(2));
|
||||
renderSlot(tileTable, x, y, z, result, 2f, 0f, .25f, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
renderSlot(tileTable, x, y, z, tileTable.getStackInSlot(1), 1.15f, -.225f, .15f, .65f);
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.client.renderer;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockTrimCustom;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityTrim;
|
||||
import com.jaquadro.minecraft.storagedrawers.client.renderer.common.CommonTrimRenderer;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class TrimCustomRenderer implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
private CommonTrimRenderer commonRender = new CommonTrimRenderer();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
if (!(block instanceof BlockTrimCustom))
|
||||
return false;
|
||||
|
||||
return renderWorldBlock(world, x, y, z, (BlockTrimCustom) block, modelId, renderer);
|
||||
}
|
||||
|
||||
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockTrimCustom block, int modelId, RenderBlocks renderer) {
|
||||
TileEntityTrim tile = block.getTileEntity(world, x, y, z);
|
||||
if (tile == null)
|
||||
return false;
|
||||
|
||||
ItemStack materialSide = tile.getMaterialSide();
|
||||
if (materialSide == null)
|
||||
materialSide = new ItemStack(block);
|
||||
|
||||
ItemStack materialTrim = tile.getMaterialTrim();
|
||||
if (materialTrim == null)
|
||||
materialTrim = materialSide;
|
||||
|
||||
IIcon trimIcon = Block.getBlockFromItem(materialTrim.getItem()).getIcon(4, materialTrim.getItemDamage());
|
||||
IIcon panelIcon = Block.getBlockFromItem(materialSide.getItem()).getIcon(4, materialSide.getItemDamage());
|
||||
|
||||
if (trimIcon == null)
|
||||
trimIcon = block.getDefaultTrimIcon();
|
||||
if (panelIcon == null)
|
||||
panelIcon = block.getDefaultFaceIcon();
|
||||
|
||||
commonRender.render(world, x, y, z, block, panelIcon, trimIcon);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory (int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId () {
|
||||
return StorageDrawers.proxy.trimCustomRenderID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.client.renderer;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockTrimCustom;
|
||||
import com.jaquadro.minecraft.storagedrawers.client.renderer.common.CommonTrimRenderer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class TrimItemRender implements IItemRenderer
|
||||
{
|
||||
private CommonTrimRenderer commonRender = new CommonTrimRenderer();
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType (ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper (ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem (ItemRenderType type, ItemStack item, Object... data) {
|
||||
RenderBlocks renderer = getRenderer(data);
|
||||
if (renderer == null)
|
||||
return;
|
||||
|
||||
Block block = Block.getBlockFromItem(item.getItem());
|
||||
if (!(block instanceof BlockTrimCustom))
|
||||
return;
|
||||
|
||||
renderTrim((BlockTrimCustom) block, item, renderer, type);
|
||||
}
|
||||
|
||||
private void renderTrim (BlockTrimCustom block, ItemStack item, RenderBlocks renderer, ItemRenderType renderType) {
|
||||
if (renderType == ItemRenderType.INVENTORY)
|
||||
GL11.glRotatef(90, 0, 1, 0);
|
||||
if (renderType == ItemRenderType.ENTITY)
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
|
||||
if (renderType == ItemRenderType.INVENTORY || renderType == ItemRenderType.ENTITY)
|
||||
GL11.glTranslatef(-.5f, -.5f, -.5f);
|
||||
|
||||
ItemStack materialSide = null;
|
||||
ItemStack materialTrim = null;
|
||||
|
||||
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 (materialSide == null)
|
||||
materialSide = new ItemStack(block);
|
||||
if (materialTrim == null)
|
||||
materialTrim = materialSide;
|
||||
|
||||
IIcon trimIcon = Block.getBlockFromItem(materialTrim.getItem()).getIcon(4, materialTrim.getItemDamage());
|
||||
IIcon panelIcon = Block.getBlockFromItem(materialSide.getItem()).getIcon(4, materialSide.getItemDamage());
|
||||
|
||||
if (trimIcon == null)
|
||||
trimIcon = block.getDefaultTrimIcon();
|
||||
if (panelIcon == null)
|
||||
panelIcon = block.getDefaultFaceIcon();
|
||||
|
||||
commonRender.render(null, 0, 0, 0, block, panelIcon, trimIcon);
|
||||
|
||||
if (renderType == ItemRenderType.INVENTORY || renderType == ItemRenderType.ENTITY)
|
||||
GL11.glTranslatef(.5f, .5f, .5f);
|
||||
}
|
||||
|
||||
private RenderBlocks getRenderer (Object[] data) {
|
||||
for (Object obj : data) {
|
||||
if (obj instanceof RenderBlocks)
|
||||
return (RenderBlocks)obj;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.client.renderer.common;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockTrimCustom;
|
||||
import com.jaquadro.minecraft.storagedrawers.client.renderer.ModularBoxRenderer;
|
||||
import com.jaquadro.minecraft.storagedrawers.client.renderer.PanelBoxRenderer;
|
||||
import com.jaquadro.minecraft.storagedrawers.util.RenderHelper;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class CommonTrimRenderer
|
||||
{
|
||||
private PanelBoxRenderer panelRenderer = new PanelBoxRenderer();
|
||||
|
||||
private double trimWidth;
|
||||
|
||||
private RenderHelper start (IBlockAccess world, int x, int y, int z, BlockTrimCustom block) {
|
||||
trimWidth = .0625f;
|
||||
|
||||
panelRenderer.setTrimWidth(trimWidth);
|
||||
panelRenderer.setTrimDepth(0);
|
||||
panelRenderer.setTrimColor(ModularBoxRenderer.COLOR_WHITE);
|
||||
panelRenderer.setPanelColor(ModularBoxRenderer.COLOR_WHITE);
|
||||
|
||||
RenderHelper renderHelper = RenderHelper.instance;
|
||||
if (world != null)
|
||||
renderHelper.setColorAndBrightness(world, block, x, y, z);
|
||||
|
||||
return renderHelper;
|
||||
}
|
||||
|
||||
public void render (IBlockAccess world, int x, int y, int z, BlockTrimCustom block, IIcon iconSide, IIcon iconTrim) {
|
||||
RenderHelper renderHelper = start(world, x, y, z, block);
|
||||
|
||||
panelRenderer.setTrimIcon(iconTrim);
|
||||
panelRenderer.setPanelIcon(iconSide);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
panelRenderer.renderFacePanel(i, world, block, x, y, z, 0, 0, 0, 1, 1, 1);
|
||||
panelRenderer.renderFaceTrim(i, world, block, x, y, z, 0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ public class ClientProxy extends CommonProxy
|
||||
{
|
||||
public static int renderPass = 0;
|
||||
private DrawersItemRenderer itemRenderer = new DrawersItemRenderer();
|
||||
private TrimItemRender trimItemRenderer = new TrimItemRender();
|
||||
|
||||
@Override
|
||||
public void registerRenderers () {
|
||||
@@ -21,15 +22,19 @@ public class ClientProxy extends CommonProxy
|
||||
controllerRenderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
drawersCustomRenderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
framingTableRenderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
trimCustomRenderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
RenderingRegistry.registerBlockHandler(drawersRenderID, new DrawersRenderer());
|
||||
RenderingRegistry.registerBlockHandler(controllerRenderID, new ControllerRenderer());
|
||||
RenderingRegistry.registerBlockHandler(drawersCustomRenderID, new DrawersCustomRenderer());
|
||||
RenderingRegistry.registerBlockHandler(framingTableRenderID, new FramingTableRenderer());
|
||||
RenderingRegistry.registerBlockHandler(trimCustomRenderID, new TrimCustomRenderer());
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDrawersStandard.class, new TileEntityDrawersRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDrawersComp.class, new TileEntityDrawersRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFramingTable.class, new TileEntityFramingRenderer());
|
||||
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.trimCustom), trimItemRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ public class CommonProxy
|
||||
public int controllerRenderID = -1;
|
||||
public int drawersCustomRenderID = -1;
|
||||
public int framingTableRenderID = -1;
|
||||
public int trimCustomRenderID = -1;
|
||||
|
||||
public void registerRenderers ()
|
||||
{ }
|
||||
|
||||
@@ -25,6 +25,7 @@ public class ModBlocks
|
||||
public static BlockTrim trim;
|
||||
public static BlockSlave controllerSlave;
|
||||
public static BlockFramingTable framingTable;
|
||||
public static BlockTrimCustom trimCustom;
|
||||
|
||||
public static BlockDrawersCustom fullCustom1;
|
||||
public static BlockDrawersCustom fullCustom2;
|
||||
@@ -45,6 +46,7 @@ public class ModBlocks
|
||||
trim = new BlockTrim("trim");
|
||||
controllerSlave = new BlockSlave("controllerSlave");
|
||||
framingTable = new BlockFramingTable("framingTable");
|
||||
trimCustom = new BlockTrimCustom("trimCustom");
|
||||
|
||||
fullCustom1 = new BlockDrawersCustom("fullCustom1", 1, false);
|
||||
fullCustom2 = new BlockDrawersCustom("fullCustom2", 2, false);
|
||||
@@ -92,6 +94,8 @@ public class ModBlocks
|
||||
GameRegistry.registerBlock(halfCustom2, ItemCustomDrawers.class, "halfCustom2");
|
||||
if (config.isBlockEnabled("halfdrawers4"))
|
||||
GameRegistry.registerBlock(halfCustom4, ItemCustomDrawers.class, "halfCustom4");
|
||||
if (config.isBlockEnabled("trim"))
|
||||
GameRegistry.registerBlock(trimCustom, ItemCustomTrim.class, "trimCustom");
|
||||
}
|
||||
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityDrawersStandard.class, getQualifiedName("tileDrawersStandard"),
|
||||
@@ -109,6 +113,8 @@ public class ModBlocks
|
||||
|
||||
GameRegistry.registerTileEntity(TileEntityFramingTable.class, getQualifiedName("framingTable"));
|
||||
|
||||
GameRegistry.registerTileEntity(TileEntityTrim.class, getQualifiedName("trim"));
|
||||
|
||||
StorageDrawers.proxy.registerDrawer(fullDrawers1);
|
||||
StorageDrawers.proxy.registerDrawer(fullDrawers2);
|
||||
StorageDrawers.proxy.registerDrawer(fullDrawers4);
|
||||
|
||||
@@ -153,6 +153,9 @@ public class ModRecipes
|
||||
if (config.isBlockEnabled("halfdrawers4"))
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.halfCustom4, config.getBlockRecipeOutput("halfdrawers4"), 0), "yxy", "xzx", "yxy",
|
||||
'x', "stickWood", 'y', "chestWood", 'z', "slabWood"));
|
||||
if (config.isBlockEnabled("trim"))
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.trimCustom, config.getBlockRecipeOutput("trim"), 0), "yxy", "xyx", "yxy",
|
||||
'x', "stickWood", 'y', "plankWood"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.inventory;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawersCustom;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockTrimCustom;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityFramingTable;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemCustomDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemCustomTrim;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -85,6 +87,12 @@ public class ContainerFramingTable extends Container
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (block instanceof BlockTrimCustom) {
|
||||
if (matSide != null) {
|
||||
craftResult.setInventorySlotContents(0, ItemCustomTrim.makeItemStack(block, 1, matSide, matTrim));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
craftResult.setInventorySlotContents(0, null);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.item;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityTrim;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemCustomTrim extends ItemBlock
|
||||
{
|
||||
public ItemCustomTrim (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;
|
||||
|
||||
TileEntityTrim tile = (TileEntityTrim) 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")));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ItemStack makeItemStack (Block block, int count, ItemStack matSide, ItemStack matTrim) {
|
||||
Item item = Item.getItemFromBlock(block);
|
||||
if (!(item instanceof ItemCustomTrim))
|
||||
return null;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
if (matSide != null)
|
||||
tag.setTag("MatS", getMaterialTag(matSide));
|
||||
|
||||
if (matTrim != null)
|
||||
tag.setTag("MatT", getMaterialTag(matTrim));
|
||||
|
||||
ItemStack stack = new ItemStack(item, count, 0);
|
||||
if (!tag.hasNoTags())
|
||||
stack.setTagCompound(tag);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static NBTTagCompound getMaterialTag (ItemStack mat) {
|
||||
mat = mat.copy();
|
||||
mat.stackSize = 1;
|
||||
|
||||
NBTTagCompound itag = new NBTTagCompound();
|
||||
mat.writeToNBT(itag);
|
||||
|
||||
return itag;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user