Added plug item and item renderer
This commit is contained in:
parent
6a6ba168c7
commit
b1ed48da37
6 changed files with 150 additions and 0 deletions
|
@ -72,6 +72,7 @@ item.PipeLiquidsVoid=Void Waterproof Pipe
|
||||||
item.PipeItemsSandstone=Sandstone Transport Pipe
|
item.PipeItemsSandstone=Sandstone Transport Pipe
|
||||||
item.PipeLiquidsSandstone=Sandstone Waterproof Pipe
|
item.PipeLiquidsSandstone=Sandstone Waterproof Pipe
|
||||||
item.Facade=Facade
|
item.Facade=Facade
|
||||||
|
item.PipePlug=Pipe Plug
|
||||||
tile.miningWellBlock=Mining Well
|
tile.miningWellBlock=Mining Well
|
||||||
tile.plainPipeBlock=Mining Pipe
|
tile.plainPipeBlock=Mining Pipe
|
||||||
tile.autoWorkbenchBlock=Autocrafting Table
|
tile.autoWorkbenchBlock=Autocrafting Table
|
||||||
|
|
|
@ -37,6 +37,7 @@ import buildcraft.transport.GuiHandler;
|
||||||
import buildcraft.transport.ItemFacade;
|
import buildcraft.transport.ItemFacade;
|
||||||
import buildcraft.transport.ItemGate;
|
import buildcraft.transport.ItemGate;
|
||||||
import buildcraft.transport.ItemPipe;
|
import buildcraft.transport.ItemPipe;
|
||||||
|
import buildcraft.transport.ItemPlug;
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
import buildcraft.transport.PipeIconProvider;
|
import buildcraft.transport.PipeIconProvider;
|
||||||
import buildcraft.transport.PipeTriggerProvider;
|
import buildcraft.transport.PipeTriggerProvider;
|
||||||
|
@ -139,6 +140,7 @@ public class BuildCraftTransport {
|
||||||
public static Item pipePowerGold;
|
public static Item pipePowerGold;
|
||||||
|
|
||||||
public static Item facadeItem;
|
public static Item facadeItem;
|
||||||
|
public static Item plugItem;
|
||||||
|
|
||||||
// public static Item pipeItemsStipes;
|
// public static Item pipeItemsStipes;
|
||||||
public static Item pipeStructureCobblestone;
|
public static Item pipeStructureCobblestone;
|
||||||
|
@ -351,6 +353,10 @@ public class BuildCraftTransport {
|
||||||
Property pipeFacadeId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeFacade.id", DefaultProps.PIPE_FACADE_ID);
|
Property pipeFacadeId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeFacade.id", DefaultProps.PIPE_FACADE_ID);
|
||||||
facadeItem = new ItemFacade(pipeFacadeId.getInt());
|
facadeItem = new ItemFacade(pipeFacadeId.getInt());
|
||||||
facadeItem.setUnlocalizedName("pipeFacade");
|
facadeItem.setUnlocalizedName("pipeFacade");
|
||||||
|
|
||||||
|
Property pipePlugId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipePlug.id", DefaultProps.PIPE_PLUG_ID);
|
||||||
|
plugItem = new ItemPlug(pipePlugId.getInt());
|
||||||
|
plugItem.setUnlocalizedName("pipePlug");
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
BuildCraftCore.mainConfiguration.save();
|
BuildCraftCore.mainConfiguration.save();
|
||||||
|
|
|
@ -54,6 +54,7 @@ public class DefaultProps {
|
||||||
// Moving to safer id range
|
// Moving to safer id range
|
||||||
public static int GATE_AUTARCHIC_ID = 19140;
|
public static int GATE_AUTARCHIC_ID = 19140;
|
||||||
public static int PIPE_FACADE_ID = 19141;
|
public static int PIPE_FACADE_ID = 19141;
|
||||||
|
public static int PIPE_PLUG_ID = 19142;
|
||||||
|
|
||||||
public static int PIPE_ITEMS_WOOD_ID = 19160;
|
public static int PIPE_ITEMS_WOOD_ID = 19160;
|
||||||
public static int PIPE_ITEMS_COBBLESTONE_ID = 19161;
|
public static int PIPE_ITEMS_COBBLESTONE_ID = 19161;
|
||||||
|
|
42
common/buildcraft/transport/ItemPlug.java
Normal file
42
common/buildcraft/transport/ItemPlug.java
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
package buildcraft.transport;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.IconRegister;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import buildcraft.core.CreativeTabBuildCraft;
|
||||||
|
import buildcraft.core.ItemBuildCraft;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
public class ItemPlug extends ItemBuildCraft {
|
||||||
|
|
||||||
|
public ItemPlug(int i) {
|
||||||
|
super(i);
|
||||||
|
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnlocalizedName(ItemStack itemstack) {
|
||||||
|
return "item.PipePlug";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldPassSneakingClickToBlock(World worldObj, int x, int y, int z ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void registerIcons(IconRegister par1IconRegister)
|
||||||
|
{
|
||||||
|
// NOOP
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int getSpriteNumber()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.transport.render.FacadeItemRenderer;
|
import buildcraft.transport.render.FacadeItemRenderer;
|
||||||
import buildcraft.transport.render.PipeItemRenderer;
|
import buildcraft.transport.render.PipeItemRenderer;
|
||||||
import buildcraft.transport.render.PipeWorldRenderer;
|
import buildcraft.transport.render.PipeWorldRenderer;
|
||||||
|
import buildcraft.transport.render.PlugItemRenderer;
|
||||||
import buildcraft.transport.render.RenderPipe;
|
import buildcraft.transport.render.RenderPipe;
|
||||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||||
|
@ -13,6 +14,7 @@ public class TransportProxyClient extends TransportProxy {
|
||||||
public final static PipeItemRenderer pipeItemRenderer = new PipeItemRenderer();
|
public final static PipeItemRenderer pipeItemRenderer = new PipeItemRenderer();
|
||||||
public final static PipeWorldRenderer pipeWorldRenderer = new PipeWorldRenderer();
|
public final static PipeWorldRenderer pipeWorldRenderer = new PipeWorldRenderer();
|
||||||
public final static FacadeItemRenderer facadeItemRenderer = new FacadeItemRenderer();
|
public final static FacadeItemRenderer facadeItemRenderer = new FacadeItemRenderer();
|
||||||
|
public final static PlugItemRenderer plugItemRenderer = new PlugItemRenderer();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerTileEntities() {
|
public void registerTileEntities() {
|
||||||
|
@ -53,6 +55,7 @@ public class TransportProxyClient extends TransportProxy {
|
||||||
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsSandstone.itemID, pipeItemRenderer);
|
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsSandstone.itemID, pipeItemRenderer);
|
||||||
|
|
||||||
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.facadeItem.itemID, facadeItemRenderer);
|
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.facadeItem.itemID, facadeItemRenderer);
|
||||||
|
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.plugItem.itemID, plugItemRenderer);
|
||||||
TransportProxy.pipeModel = RenderingRegistry.getNextAvailableRenderId();
|
TransportProxy.pipeModel = RenderingRegistry.getNextAvailableRenderId();
|
||||||
|
|
||||||
RenderingRegistry.registerBlockHandler(pipeWorldRenderer);
|
RenderingRegistry.registerBlockHandler(pipeWorldRenderer);
|
||||||
|
|
97
common/buildcraft/transport/render/PlugItemRenderer.java
Normal file
97
common/buildcraft/transport/render/PlugItemRenderer.java
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
package buildcraft.transport.render;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Icon;
|
||||||
|
import net.minecraftforge.client.IItemRenderer;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import buildcraft.BuildCraftTransport;
|
||||||
|
import buildcraft.transport.PipeIconProvider;
|
||||||
|
|
||||||
|
public class PlugItemRenderer implements IItemRenderer{
|
||||||
|
|
||||||
|
private void renderPlugItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
|
||||||
|
// Render StructurePipe
|
||||||
|
Block block = BuildCraftTransport.genericPipeBlock;
|
||||||
|
Tessellator tessellator = Tessellator.instance;
|
||||||
|
|
||||||
|
block = BuildCraftTransport.genericPipeBlock;
|
||||||
|
Icon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.PipeStructureCobblestone); // Structure pipe
|
||||||
|
|
||||||
|
block.setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.375F, 0.75F);
|
||||||
|
block.setBlockBoundsForItemRender();
|
||||||
|
render.setRenderBoundsFromBlock(block);
|
||||||
|
GL11.glTranslatef(translateX, translateY, translateZ + 0.25F);
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setNormal(0.0F, -0F, 0.0F);
|
||||||
|
render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||||
|
tessellator.draw();
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||||
|
render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||||
|
tessellator.draw();
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||||
|
render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||||
|
tessellator.draw();
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||||
|
render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||||
|
tessellator.draw();
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||||
|
render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||||
|
tessellator.draw();
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||||
|
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||||
|
tessellator.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||||
|
switch (type) {
|
||||||
|
case ENTITY:
|
||||||
|
return true;
|
||||||
|
case EQUIPPED:
|
||||||
|
return true;
|
||||||
|
case INVENTORY:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||||
|
switch (type) {
|
||||||
|
case ENTITY:
|
||||||
|
GL11.glScalef(0.50F, 0.50F, 0.50F);
|
||||||
|
renderPlugItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F);
|
||||||
|
break;
|
||||||
|
case EQUIPPED:
|
||||||
|
renderPlugItem((RenderBlocks) data[0], item, 0F, 0F, 0f);
|
||||||
|
break;
|
||||||
|
case INVENTORY:
|
||||||
|
GL11.glScalef(1.1F, 1.1F, 1.1F);
|
||||||
|
renderPlugItem((RenderBlocks) data[0], item, -0.3f, -0.35f, -0.7f);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue