Found and re-added Tank & Pipe item renderers
This commit is contained in:
parent
f3f6d7858b
commit
7706d5bd65
5 changed files with 354 additions and 166 deletions
|
@ -1,5 +1,8 @@
|
|||
package resonantinduction.mechanical;
|
||||
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import resonantinduction.mechanical.fluid.pipe.ItemPipeRenderer;
|
||||
import resonantinduction.mechanical.fluid.tank.ItemTankRenderer;
|
||||
import resonantinduction.mechanical.render.MechanicalBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
|
@ -10,4 +13,11 @@ public class ClientProxy extends CommonProxy
|
|||
{
|
||||
RenderingRegistry.registerBlockHandler(MechanicalBlockRenderingHandler.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
MinecraftForgeClient.registerItemRenderer(Mechanical.blockTank.blockID, new ItemTankRenderer());
|
||||
MinecraftForgeClient.registerItemRenderer(Mechanical.blockPipe.blockID, new ItemPipeRenderer());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public class Mechanical
|
|||
// #Fluids
|
||||
public static Block blockTank;
|
||||
public static Block blockPipe;
|
||||
public static Block blockReleaseValve;
|
||||
public static Block blockGrate;
|
||||
public static Block blockPump;
|
||||
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package resonantinduction.mechanical.fluid.pipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.mechanical.Mechanical;
|
||||
import resonantinduction.old.client.model.ModelReleaseValve;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ItemPipeRenderer implements IItemRenderer
|
||||
{
|
||||
private ModelReleaseValve valve = new ModelReleaseValve();
|
||||
|
||||
@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)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderPipe.getTexture(item.getItemDamage()));
|
||||
int meta = item.getItemDamage();
|
||||
if (Mechanical.blockReleaseValve != null && item.itemID == Mechanical.blockReleaseValve.blockID)
|
||||
{
|
||||
meta = FluidContainerMaterial.IRON.getMeta();
|
||||
}
|
||||
if (type == ItemRenderType.ENTITY)
|
||||
{
|
||||
GL11.glTranslatef(-.5F, -1F, -.5F);
|
||||
RenderPipe.render(meta, new boolean[] { false, false, false, false, true, true });
|
||||
}
|
||||
else if (type == ItemRenderType.INVENTORY)
|
||||
{
|
||||
GL11.glTranslatef(0F, -1F, 0F);
|
||||
RenderPipe.render(meta, new boolean[] { false, false, false, false, true, true });
|
||||
}
|
||||
else if (type == ItemRenderType.EQUIPPED)
|
||||
{
|
||||
GL11.glTranslatef(-1F, -1.2F, 0.5F);
|
||||
RenderPipe.render(meta, new boolean[] { false, false, true, true, false, false });
|
||||
}
|
||||
else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON)
|
||||
{
|
||||
GL11.glTranslatef(-2F, -1.5F, 0.2F);
|
||||
RenderPipe.render(meta, new boolean[] { false, false, true, true, false, false });
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderPipe.render(item.getItemDamage(), new boolean[] { false, false, true, true, false, false });
|
||||
}
|
||||
if (Mechanical.blockReleaseValve != null && item.itemID == Mechanical.blockReleaseValve.blockID)
|
||||
{
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(Reference.DOMAIN, Reference.MODEL_DIRECTORY + "ReleaseValve.png"));
|
||||
valve.render();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package resonantinduction.mechanical.fluid.tank;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.render.RenderFluidHelper;
|
||||
import resonantinduction.mechanical.Mechanical;
|
||||
import resonantinduction.old.client.model.ModelTankSide;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ItemTankRenderer implements IItemRenderer
|
||||
{
|
||||
private ModelTankSide tank = new ModelTankSide();
|
||||
|
||||
@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)
|
||||
{
|
||||
if (item.itemID == Mechanical.blockTank.blockID)
|
||||
{
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
||||
if (type == ItemRenderType.ENTITY)
|
||||
{
|
||||
GL11.glTranslatef(0F, 0.2F, 0F);
|
||||
}
|
||||
else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON)
|
||||
{
|
||||
GL11.glTranslatef(0.4F, 0.6F, 0.2F);
|
||||
}
|
||||
else if (type == ItemRenderType.EQUIPPED)
|
||||
{
|
||||
GL11.glTranslatef(0.1F, 0.4F, 1.2F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glTranslatef(0.7F, .4F, 0.7F);
|
||||
}
|
||||
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(Reference.DOMAIN, item.getItemDamage() == 1 ? "textures/blocks/obsidian.png" : "textures/blocks/iron_block.png"));
|
||||
GL11.glTranslatef(0.0F, -0.9F, 0.0F);
|
||||
tank.render(0.0625F, false, false, false, false);
|
||||
GL11.glRotatef(90f, 0f, 1f, 0f);
|
||||
tank.render(0.0625F, false, false, false, false);
|
||||
GL11.glRotatef(90f, 0f, 1f, 0f);
|
||||
tank.render(0.0625F, false, false, false, false);
|
||||
GL11.glRotatef(90f, 0f, 1f, 0f);
|
||||
tank.render(0.0625F, false, false, false, false);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
if (item.getTagCompound() != null && item.getTagCompound().hasKey("fluid"))
|
||||
{
|
||||
FluidStack liquid = FluidStack.loadFluidStackFromNBT(item.getTagCompound().getCompoundTag("fluid"));
|
||||
|
||||
if (liquid != null && liquid.amount > 100)
|
||||
{
|
||||
|
||||
int[] displayList = RenderFluidHelper.getFluidDisplayLists(liquid, Minecraft.getMinecraft().theWorld, false);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
//GL11.glScalef(0.80F, 0.9F, 0.80F);
|
||||
if (type == ItemRenderType.ENTITY)
|
||||
{
|
||||
GL11.glTranslatef(-.5F, -0.2F, -.5F);
|
||||
}
|
||||
else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON)
|
||||
{
|
||||
GL11.glTranslatef(-0.1F, 0.2F, -.3F);
|
||||
}
|
||||
else if (type == ItemRenderType.EQUIPPED)
|
||||
{
|
||||
GL11.glScalef(0.9F, 0.9F, 0.9F);
|
||||
GL11.glTranslatef(-0.4F, 0.1F, 0.9F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glScalef(0.80F, 0.9F, 0.80F);
|
||||
GL11.glTranslatef(0.5F, .2F, 0.5F);
|
||||
}
|
||||
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture((RenderFluidHelper.getFluidSheet(liquid)));
|
||||
|
||||
int cap = BlockTank.tankVolume * FluidContainerRegistry.BUCKET_VOLUME;
|
||||
if (liquid.getFluid().isGaseous())
|
||||
{
|
||||
cap = liquid.amount;
|
||||
}
|
||||
GL11.glCallList(displayList[(int) Math.min(((float) liquid.amount / (float) (cap) * (RenderFluidHelper.DISPLAY_STAGES - 1)), displayList.length - 1)]);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,9 +9,7 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.mechanical.Mechanical;
|
||||
import resonantinduction.mechanical.fluid.pipe.RenderPipe;
|
||||
import resonantinduction.mechanical.fluid.pump.RenderPump;
|
||||
import resonantinduction.mechanical.fluid.tank.RenderTank;
|
||||
import resonantinduction.old.client.model.ModelConveyorBelt;
|
||||
import resonantinduction.old.client.model.ModelCrusher;
|
||||
import resonantinduction.old.client.model.ModelGrinder;
|
||||
|
@ -46,26 +44,6 @@ public class MechanicalBlockRenderingHandler implements ISimpleBlockRenderingHan
|
|||
modelConveyorBelt.render(0.0625F, 0, false, false, false, false);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if (block == Mechanical.blockTank)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0F, 1.3F, 0.0F);
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderTank.getTexture(0, 0));
|
||||
RenderTank.MODEL.render(0.0625F, false, false, false, false);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if (block == Mechanical.blockPipe)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0F, 1F, 0.0F);
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderPipe.getTexture(metadata));
|
||||
RenderPipe.MODEL_PIPE.renderFront();
|
||||
RenderPipe.MODEL_PIPE.renderMiddle();
|
||||
RenderPipe.MODEL_PIPE.renderBack();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if (Mechanical.blockPump != null)
|
||||
{
|
||||
GL11.glTranslatef(0.0F, 1.3F, 0.0F);
|
||||
|
|
Loading…
Add table
Reference in a new issue