This commit is contained in:
Aidan Brady 2013-08-05 11:32:24 -04:00
commit c7592ef4c6
6 changed files with 115 additions and 57 deletions

View file

@ -18,5 +18,8 @@ In order to compile the source code into binary form, you must have a working Mi
4. Zip up everything in the output folder ("reobf") into a jar file. 4. Zip up everything in the output folder ("reobf") into a jar file.
5. Install it into Minecraft just like any other Forge mod. 5. Install it into Minecraft just like any other Forge mod.
### Jenkins
http://calclavia.com:8080/job/Resonant%20Induction/
### License ### License
"Resonant Induction" is under the Educational Public License (http://calclavia.com/license/rpl). "Resonant Induction" is under the Educational Public License (http://calclavia.com/license/rpl).

View file

@ -31,7 +31,7 @@ public class ItemCapacitor extends ItemBase implements IBattery
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{ {
double energyStored = this.getEnergyStored(itemStack); double energyStored = this.getEnergyStored(itemStack);
par3List.add("Energy: " + energyStored + " J"); par3List.add("Energy: " + energyStored + " KJ");
} }
@Override @Override

View file

@ -3,6 +3,11 @@
*/ */
package resonantinduction.multimeter; 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.ITileEntityProvider;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
@ -33,6 +38,55 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider
super("multimeter", id); super("multimeter", id);
} }
/**
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY,
* hitZ, block metadata
*/
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float side, float hitX, float hitY, int hitZ)
{
int metadata = hitZ;
if (par5 == 1 && this.canPlaceOn(par1World, par2, par3 - 1, par4))
{
metadata = 5;
}
if (par5 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true))
{
metadata = 4;
}
if (par5 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true))
{
metadata = 3;
}
if (par5 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true))
{
metadata = 2;
}
if (par5 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true))
{
metadata = 1;
}
return metadata;
}
private boolean canPlaceOn(World par1World, int par2, int par3, int par4)
{
if (par1World.doesBlockHaveSolidTopSurface(par2, par3, par4))
{
return true;
}
else
{
int l = par1World.getBlockId(par2, par3, par4);
return (Block.blocksList[l] != null && Block.blocksList[l].canPlaceTorchOnTop(par1World, par2, par3, par4));
}
}
public static int determineOrientation(World par0World, int par1, int par2, int par3, EntityLivingBase par4EntityLivingBase) public static int determineOrientation(World par0World, int par1, int par2, int par3, EntityLivingBase par4EntityLivingBase)
{ {
if (MathHelper.abs((float) par4EntityLivingBase.posX - par1) < 2.0F && MathHelper.abs((float) par4EntityLivingBase.posZ - par3) < 2.0F) if (MathHelper.abs((float) par4EntityLivingBase.posX - par1) < 2.0F && MathHelper.abs((float) par4EntityLivingBase.posZ - par3) < 2.0F)

View file

@ -29,6 +29,7 @@ public class ItemBlockMultimeter extends ItemBlock
{ {
par2EntityPlayer.addChatMessage("Energy: " + TileEntityMultimeter.getDetectedEnergy(world.getBlockTileEntity(x, y, z)) + " J"); par2EntityPlayer.addChatMessage("Energy: " + TileEntityMultimeter.getDetectedEnergy(world.getBlockTileEntity(x, y, z)) + " J");
} }
return true; return true;
} }

View file

@ -13,6 +13,7 @@ import resonantinduction.PacketHandler;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.base.IPacketReceiver; import resonantinduction.base.IPacketReceiver;
import resonantinduction.base.TileEntityBase; import resonantinduction.base.TileEntityBase;
import resonantinduction.battery.TileEntityBattery;
import resonantinduction.tesla.TileEntityTesla; import resonantinduction.tesla.TileEntityTesla;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
@ -144,6 +145,10 @@ public class TileEntityMultimeter extends TileEntityBase implements IPacketRecei
{ {
return ((TileEntityTesla) tileEntity).getEnergyStored(); return ((TileEntityTesla) tileEntity).getEnergyStored();
} }
else if (tileEntity instanceof TileEntityBattery)
{
return ((TileEntityBattery) tileEntity).getEnergyStored();
}
return 0; return 0;
} }

View file

@ -5,7 +5,6 @@ package resonantinduction.render;
import java.util.Random; import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
@ -23,7 +22,6 @@ import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.base.Vector3;
import resonantinduction.model.ModelBattery; import resonantinduction.model.ModelBattery;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -68,65 +66,62 @@ public class RenderBattery extends TileEntitySpecialRenderer
for (int i = 2; i < 6; i++) for (int i = 2; i < 6; i++)
{ {
ForgeDirection direction = ForgeDirection.getOrientation(i); ForgeDirection direction = ForgeDirection.getOrientation(i);
Block block = Block.blocksList[new Vector3(t).translate(new Vector3(direction)).getBlockID(t.worldObj)];
if (block == null || (block != null && block.isOpaqueCube())) for (int slot = 0; slot < 4; slot++)
{ {
for (int slot = 0; slot < 4; slot++) GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5f, (float) y + 0.7f, (float) z + 0.5f);
float translateX = 0;
float translateY = 0;
switch (slot)
{ {
GL11.glPushMatrix(); case 0:
GL11.glTranslatef((float) x + 0.5f, (float) y + 0.7f, (float) z + 0.5f); translateX = 0.25f;
break;
case 1:
translateX = 0.25f;
translateY = -0.5f;
break;
case 2:
translateX = -0.25f;
translateY = -0.5f;
break;
case 3:
translateX = -0.25f;
break;
}
float translateX = 0; switch (direction)
float translateY = 0; {
case NORTH:
GL11.glTranslatef(-0.5f, 0, 0);
GL11.glTranslatef(0, translateY, translateX);
GL11.glRotatef(90, 0, 1, 0);
break;
case SOUTH:
GL11.glTranslatef(0, 0, -0.5f);
GL11.glTranslatef(translateX, translateY, 0);
break;
case WEST:
GL11.glTranslatef(0.5f, 0, 0);
GL11.glTranslatef(0, translateY, translateX);
GL11.glRotatef(90, 0, 1, 0);
break;
case EAST:
GL11.glTranslatef(0, 0, 0.5f);
GL11.glTranslatef(translateX, translateY, 0);
break;
}
switch (slot) GL11.glScalef(0.5f, 0.5f, 0.5f);
{ this.renderItemSimple(this.fakeBattery);
case 0: GL11.glPopMatrix();
translateX = 0.25f;
break;
case 1:
translateX = 0.25f;
translateY = -0.5f;
break;
case 2:
translateX = -0.25f;
translateY = -0.5f;
break;
case 3:
translateX = -0.25f;
break;
}
switch (direction) if (renderAmount-- <= 0)
{ {
case NORTH: break itemRender;
GL11.glTranslatef(-0.5f, 0, 0);
GL11.glTranslatef(0, translateY, translateX);
GL11.glRotatef(90, 0, 1, 0);
break;
case SOUTH:
GL11.glTranslatef(0, 0, -0.5f);
GL11.glTranslatef(translateX, translateY, 0);
break;
case WEST:
GL11.glTranslatef(0.5f, 0, 0);
GL11.glTranslatef(0, translateY, translateX);
GL11.glRotatef(90, 0, 1, 0);
break;
case EAST:
GL11.glTranslatef(0, 0, 0.5f);
GL11.glTranslatef(translateX, translateY, 0);
break;
}
GL11.glScalef(0.5f, 0.5f, 0.5f);
this.renderItemSimple(this.fakeBattery);
GL11.glPopMatrix();
if (renderAmount-- <= 0)
{
break itemRender;
}
} }
} }
} }