Added model for multimeter
This commit is contained in:
parent
b0ffec41d3
commit
5530ab352b
6 changed files with 148 additions and 3 deletions
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
75
src/resonantinduction/model/ModelMultimeter.java
Normal file
75
src/resonantinduction/model/ModelMultimeter.java
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
package resonantinduction.model;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.ModelBase;
|
||||||
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
|
|
||||||
|
public class ModelMultimeter extends ModelBase
|
||||||
|
{
|
||||||
|
// fields
|
||||||
|
ModelRenderer Base;
|
||||||
|
ModelRenderer secPanel;
|
||||||
|
ModelRenderer arm;
|
||||||
|
ModelRenderer button;
|
||||||
|
ModelRenderer arm2;
|
||||||
|
ModelRenderer infopanel;
|
||||||
|
|
||||||
|
public ModelMultimeter()
|
||||||
|
{
|
||||||
|
textureWidth = 128;
|
||||||
|
textureHeight = 128;
|
||||||
|
|
||||||
|
Base = new ModelRenderer(this, 0, 0);
|
||||||
|
Base.addBox(0F, 0F, 0F, 14, 14, 1);
|
||||||
|
Base.setRotationPoint(-7F, 9F, 7F);
|
||||||
|
Base.setTextureSize(128, 128);
|
||||||
|
Base.mirror = true;
|
||||||
|
setRotation(Base, 0F, 0F, 0F);
|
||||||
|
secPanel = new ModelRenderer(this, 0, 18);
|
||||||
|
secPanel.addBox(0F, 0F, 0F, 4, 8, 1);
|
||||||
|
secPanel.setRotationPoint(-6F, 10F, 6F);
|
||||||
|
secPanel.setTextureSize(128, 128);
|
||||||
|
secPanel.mirror = true;
|
||||||
|
setRotation(secPanel, 0F, 0F, 0F);
|
||||||
|
arm = new ModelRenderer(this, 0, 29);
|
||||||
|
arm.addBox(0F, 0F, 0F, 1, 9, 2);
|
||||||
|
arm.setRotationPoint(-3.5F, 13F, 5.5F);
|
||||||
|
arm.setTextureSize(128, 128);
|
||||||
|
arm.mirror = true;
|
||||||
|
setRotation(arm, 0F, 0F, 0F);
|
||||||
|
button = new ModelRenderer(this, 0, 43);
|
||||||
|
button.addBox(0F, 0F, 0F, 2, 1, 1);
|
||||||
|
button.setRotationPoint(-5F, 11F, 5.5F);
|
||||||
|
button.setTextureSize(128, 128);
|
||||||
|
button.mirror = true;
|
||||||
|
setRotation(button, 0F, 0F, 0F);
|
||||||
|
arm2 = new ModelRenderer(this, 10, 29);
|
||||||
|
arm2.addBox(0F, 0F, 0F, 1, 9, 2);
|
||||||
|
arm2.setRotationPoint(-5.5F, 13F, 5.5F);
|
||||||
|
arm2.setTextureSize(128, 128);
|
||||||
|
arm2.mirror = true;
|
||||||
|
setRotation(arm2, 0F, 0F, 0F);
|
||||||
|
infopanel = new ModelRenderer(this, 33, 0);
|
||||||
|
infopanel.addBox(0F, 0F, 0F, 7, 12, 1);
|
||||||
|
infopanel.setRotationPoint(-1F, 10F, 6.5F);
|
||||||
|
infopanel.setTextureSize(128, 128);
|
||||||
|
infopanel.mirror = true;
|
||||||
|
setRotation(infopanel, 0F, 0F, 0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void render(float f5)
|
||||||
|
{
|
||||||
|
Base.render(f5);
|
||||||
|
secPanel.render(f5);
|
||||||
|
arm.render(f5);
|
||||||
|
button.render(f5);
|
||||||
|
arm2.render(f5);
|
||||||
|
infopanel.render(f5);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||||
|
{
|
||||||
|
model.rotateAngleX = x;
|
||||||
|
model.rotateAngleY = y;
|
||||||
|
model.rotateAngleZ = z;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,8 @@ import static net.minecraftforge.common.ForgeDirection.EAST;
|
||||||
import static net.minecraftforge.common.ForgeDirection.NORTH;
|
import static net.minecraftforge.common.ForgeDirection.NORTH;
|
||||||
import static net.minecraftforge.common.ForgeDirection.SOUTH;
|
import static net.minecraftforge.common.ForgeDirection.SOUTH;
|
||||||
import static net.minecraftforge.common.ForgeDirection.WEST;
|
import static net.minecraftforge.common.ForgeDirection.WEST;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -22,6 +24,7 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import resonantinduction.ResonantInduction;
|
import resonantinduction.ResonantInduction;
|
||||||
import resonantinduction.base.BlockBase;
|
import resonantinduction.base.BlockBase;
|
||||||
|
import resonantinduction.render.BlockRenderingHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A block that detects power.
|
* A block that detects power.
|
||||||
|
@ -103,6 +106,12 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return BlockRenderingHandler.INSTANCE.getRenderId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean renderAsNormalBlock()
|
public boolean renderAsNormalBlock()
|
||||||
|
@ -110,6 +119,12 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World world)
|
public TileEntity createNewTileEntity(World world)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,11 +44,11 @@ public class ItemBlockMultimeter extends ItemBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
|
public boolean onItemUseFirst(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
|
||||||
{
|
{
|
||||||
if (!par2EntityPlayer.isSneaking())
|
if (!par2EntityPlayer.isSneaking())
|
||||||
{
|
{
|
||||||
if (!world.isRemote)
|
//if (!world.isRemote)
|
||||||
{
|
{
|
||||||
par2EntityPlayer.addChatMessage("Energy: " + TileEntityMultimeter.getDetectedEnergy(world.getBlockTileEntity(x, y, z)) + " J");
|
par2EntityPlayer.addChatMessage("Energy: " + TileEntityMultimeter.getDetectedEnergy(world.getBlockTileEntity(x, y, z)) + " J");
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class ItemBlockMultimeter extends ItemBlock
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onItemUse(par1ItemStack, par2EntityPlayer, world, x, y, z, par7, par8, par9, par10);
|
return super.onItemUseFirst(par1ItemStack, par2EntityPlayer, world, x, y, z, par7, par8, par9, par10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getDetection(ItemStack itemStack)
|
public float getDetection(ItemStack itemStack)
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import resonantinduction.battery.BlockBattery;
|
import resonantinduction.battery.BlockBattery;
|
||||||
import resonantinduction.contractor.BlockEMContractor;
|
import resonantinduction.contractor.BlockEMContractor;
|
||||||
|
import resonantinduction.multimeter.BlockMultimeter;
|
||||||
import resonantinduction.tesla.BlockTesla;
|
import resonantinduction.tesla.BlockTesla;
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||||
|
@ -58,6 +59,17 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
|
||||||
RenderBattery.MODEL.render(0.0625f);
|
RenderBattery.MODEL.render(0.0625f);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
else if (block instanceof BlockMultimeter)
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslated(-0.5, 1, -1);
|
||||||
|
// GL11.glTranslated(1.5, 1.5, -0.5);
|
||||||
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||||
|
GL11.glRotatef(-180, 0.0F, 1, 1.0F);
|
||||||
|
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(RenderMultimeter.TEXTURE);
|
||||||
|
RenderMultimeter.MODEL.render(0.0625f);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,10 +3,14 @@ package resonantinduction.render;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import resonantinduction.ResonantInduction;
|
||||||
|
import resonantinduction.contractor.TileEntityEMContractor;
|
||||||
|
import resonantinduction.model.ModelMultimeter;
|
||||||
import resonantinduction.multimeter.TileEntityMultimeter;
|
import resonantinduction.multimeter.TileEntityMultimeter;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
@ -20,12 +24,51 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class RenderMultimeter extends TileEntitySpecialRenderer
|
public class RenderMultimeter extends TileEntitySpecialRenderer
|
||||||
{
|
{
|
||||||
|
public static final ModelMultimeter MODEL = new ModelMultimeter();
|
||||||
|
public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "multimeter.png");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float var8)
|
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float var8)
|
||||||
{
|
{
|
||||||
TileEntityMultimeter tileEntity = (TileEntityMultimeter) t;
|
TileEntityMultimeter tileEntity = (TileEntityMultimeter) t;
|
||||||
ForgeDirection direction = ForgeDirection.getOrientation(tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
ForgeDirection direction = ForgeDirection.getOrientation(tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
||||||
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||||
|
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
||||||
|
/*
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case DOWN:
|
||||||
|
GL11.glRotatef(180, 0, 0, 1);
|
||||||
|
GL11.glTranslatef(0, -2, 0);
|
||||||
|
break;
|
||||||
|
case UP:
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
GL11.glTranslatef(1, 1, 0);
|
||||||
|
GL11.glRotatef(90, 0, 0, 1);
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
GL11.glTranslatef(-1, 1, 0);
|
||||||
|
GL11.glRotatef(-90, 0, 0, 1);
|
||||||
|
break;
|
||||||
|
case WEST:
|
||||||
|
GL11.glTranslatef(0, 1, 1);
|
||||||
|
GL11.glRotatef(-90, 1, 0, 0);
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
GL11.glTranslatef(0, 1, -1);
|
||||||
|
GL11.glRotatef(90, 1, 0, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
this.func_110628_a(TEXTURE);
|
||||||
|
MODEL.render(0.0625f);
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render from side 2 to 6. This means render all sides excluding top and bottom.
|
* Render from side 2 to 6. This means render all sides excluding top and bottom.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue