This commit is contained in:
Aidan Brady 2013-08-05 12:36:07 -04:00
commit bb9c3b6c32
8 changed files with 232 additions and 126 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -183,11 +183,11 @@ public class ResonantInduction
metadata.modId = ID;
metadata.name = NAME;
metadata.description = "Resonant Induction is a Minecraft mod focusing on the manipulation of electricity and wireless technology. Ever wanted blazing electrical shocks flying off your evil lairs? You've came to the right place!";
metadata.url = "http://universalelectricity.com";
metadata.url = "http://universalelectricity.com/resonant-induction";
metadata.version = VERSION + BUILD_VERSION;
metadata.authorList = Arrays.asList(new String[] { "Calclavia", "Aidancbrady" });
metadata.logoFile = "/";
metadata.credits = "Thanks to Archadia for the assets.";
metadata.credits = "Thanks to Archadia for the awesome assets!";
metadata.autogenerated = true;
}

View 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;
}
}

View file

@ -3,25 +3,17 @@
*/
package resonantinduction.multimeter;
import static net.minecraftforge.common.ForgeDirection.EAST;
import static net.minecraftforge.common.ForgeDirection.NORTH;
import static net.minecraftforge.common.ForgeDirection.SOUTH;
import static net.minecraftforge.common.ForgeDirection.WEST;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.ResonantInduction;
import resonantinduction.base.BlockBase;
import resonantinduction.render.BlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* A block that detects power.
@ -31,11 +23,10 @@ import resonantinduction.base.BlockBase;
*/
public class BlockMultimeter extends BlockBase implements ITileEntityProvider
{
private Icon machineIcon;
public BlockMultimeter(int id)
{
super("multimeter", id);
this.func_111022_d(ResonantInduction.PREFIX + "machine");
}
/**
@ -44,25 +35,7 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider
*/
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int side, float hitX, float hitY, float hitZ, int metadata)
{
return ForgeDirection.getOrientation(side).ordinal();
}
@Override
public Icon getIcon(int side, int metadata)
{
if (side == metadata)
{
return this.blockIcon;
}
return this.machineIcon;
}
@Override
public void registerIcons(IconRegister iconRegister)
{
super.registerIcons(iconRegister);
this.machineIcon = iconRegister.registerIcon(ResonantInduction.PREFIX + "machine");
return ForgeDirection.getOrientation(side).getOpposite().ordinal();
}
@Override
@ -104,12 +77,25 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider
return true;
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType()
{
return BlockRenderingHandler.INSTANCE.getRenderId();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public TileEntity createNewTileEntity(World world)
{

View file

@ -44,11 +44,11 @@ public class ItemBlockMultimeter extends ItemBlock
}
@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 (!world.isRemote)
//if (!world.isRemote)
{
par2EntityPlayer.addChatMessage("Energy: " + TileEntityMultimeter.getDetectedEnergy(world.getBlockTileEntity(x, y, z)) + " J");
}
@ -56,7 +56,7 @@ public class ItemBlockMultimeter extends ItemBlock
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)

View file

@ -11,6 +11,7 @@ import org.lwjgl.opengl.GL11;
import resonantinduction.battery.BlockBattery;
import resonantinduction.contractor.BlockEMContractor;
import resonantinduction.multimeter.BlockMultimeter;
import resonantinduction.tesla.BlockTesla;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
@ -58,6 +59,15 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
RenderBattery.MODEL.render(0.0625f);
GL11.glPopMatrix();
}
else if (block instanceof BlockMultimeter)
{
GL11.glPushMatrix();
GL11.glRotatef(180, 0, 1, 0);
GL11.glTranslated(0, -1, -0.7);
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(RenderMultimeter.TEXTURE);
RenderMultimeter.MODEL.render(0.0625f);
GL11.glPopMatrix();
}
}
@Override

View file

@ -3,10 +3,14 @@ package resonantinduction.render;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction;
import resonantinduction.contractor.TileEntityEMContractor;
import resonantinduction.model.ModelMultimeter;
import resonantinduction.multimeter.TileEntityMultimeter;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -20,103 +24,134 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
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
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float var8)
{
TileEntityMultimeter tileEntity = (TileEntityMultimeter) t;
ForgeDirection direction = ForgeDirection.getOrientation(tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
/**
* Render from side 2 to 6. This means render all sides excluding top and bottom.
*/
for (int side = 0; side < 6; side++)
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
GL11.glRotatef(90, 0, 0, 1);
GL11.glTranslated(0, -1, 0);
switch (direction)
{
if (direction.ordinal() != side)
{
GL11.glPushMatrix();
GL11.glPolygonOffset(-10, -10);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
float dx = 1F / 16;
float dz = 1F / 16;
float displayWidth = 1 - 2F / 16;
float displayHeight = 1 - 2F / 16;
GL11.glTranslatef((float) x, (float) y, (float) z);
switch (side)
{
case 1:
break;
case 0:
GL11.glTranslatef(1, 1, 0);
GL11.glRotatef(180, 1, 0, 0);
GL11.glRotatef(180, 0, 1, 0);
break;
case 3:
GL11.glTranslatef(0, 1, 0);
GL11.glRotatef(0, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case 2:
GL11.glTranslatef(1, 1, 1);
GL11.glRotatef(180, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case 5:
GL11.glTranslatef(0, 1, 1);
GL11.glRotatef(90, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case 4:
GL11.glTranslatef(1, 1, 0);
GL11.glRotatef(-90, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
}
GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2);
case UP:
GL11.glRotatef(90, 0, 1, 0);
break;
case DOWN:
GL11.glRotatef(-90, 0, 1, 0);
break;
case NORTH:
GL11.glRotatef(180, 0, 1, 0);
GL11.glRotatef(180, 0, 0, 1);
GL11.glTranslatef(0, -2, 0);
break;
case SOUTH:
break;
case WEST:
GL11.glTranslatef(0, 1, 1);
GL11.glRotatef(-90, 1, 0, 0);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
FontRenderer fontRenderer = this.getFontRenderer();
String joules = Math.round(tileEntity.getDetectedEnergy()) + " J";
int stringWidth = Math.max(fontRenderer.getStringWidth(joules), 0);
// maxWidth += 8;
int lineHeight = fontRenderer.FONT_HEIGHT + 2;
int requiredHeight = lineHeight * 1;
/**
* Create an average scale.
*/
float scaleX = displayWidth / stringWidth;
float scaleY = displayHeight / requiredHeight;
float scale = (float) (Math.min(scaleX, scaleY) * 0.8);
GL11.glScalef(scale, -scale, scale);
GL11.glDepthMask(false);
int realHeight = (int) Math.floor(displayHeight / scale);
int realWidth = (int) Math.floor(displayWidth / scale);
int offsetY = (realHeight - requiredHeight) / 2;
int offsetX = (realWidth - stringWidth) / 2;
GL11.glDisable(GL11.GL_LIGHTING);
fontRenderer.drawString(joules, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 0 * lineHeight, 1);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDepthMask(true);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
GL11.glPopMatrix();
}
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();
GL11.glPushMatrix();
GL11.glPolygonOffset(-10, -10);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
float dx = 1F / 16;
float dz = 1F / 16;
float displayWidth = 1 - 2F / 16;
float displayHeight = 1 - 2F / 16;
GL11.glTranslatef((float) x, (float) y, (float) z);
switch (direction)
{
case UP:
GL11.glTranslatef(1, 1, 0);
GL11.glRotatef(180, 1, 0, 0);
GL11.glRotatef(180, 0, 1, 0);
GL11.glTranslatef(0, -0.9f, -0.1f);
break;
case DOWN:
GL11.glRotatef(180, 0, 1, 0);
GL11.glTranslatef(-1, -0.9f, -1.1f);
break;
case SOUTH:
GL11.glTranslatef(1, 1, 1);
GL11.glRotatef(180, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
GL11.glTranslatef(0, -0.9f, -0.1f);
break;
case NORTH:
GL11.glTranslatef(0, 1, 0);
GL11.glRotatef(0, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
GL11.glTranslatef(0, -0.9f, -0.1f);
break;
case EAST:
GL11.glTranslatef(1, 1, 0);
GL11.glRotatef(-90, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
GL11.glTranslatef(0, -0.9f, -0.1f);
break;
case WEST:
GL11.glTranslatef(0, 1, 1);
GL11.glRotatef(90, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
GL11.glTranslatef(0, -0.9f, -0.1f);
break;
}
GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2);
GL11.glRotatef(-90, 1, 0, 0);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
FontRenderer fontRenderer = this.getFontRenderer();
String joules = Math.round(tileEntity.getDetectedEnergy()) + " J";
int stringWidth = Math.max(fontRenderer.getStringWidth(joules), 0);
// maxWidth += 8;
int lineHeight = fontRenderer.FONT_HEIGHT + 2;
int requiredHeight = lineHeight * 1;
/**
* Create an average scale.
*/
float scaleX = displayWidth / stringWidth;
float scaleY = displayHeight / requiredHeight;
float scale = (float) (Math.min(scaleX, scaleY) * 0.8);
GL11.glScalef(scale, -scale, scale);
GL11.glDepthMask(false);
int realHeight = (int) Math.floor(displayHeight / scale);
int realWidth = (int) Math.floor(displayWidth / scale);
int offsetY = (realHeight - requiredHeight) / 2;
int offsetX = (realWidth - stringWidth) / 2;
GL11.glDisable(GL11.GL_LIGHTING);
fontRenderer.drawString(joules, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 0 * lineHeight, 1);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDepthMask(true);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
GL11.glPopMatrix();
}
}