Generator now works and outputs power

Well since i'm using UE lite i think it outputs power, I have more
testing to too. Right now my only indication is the generator will place
a stone block above it when its genrate is above 0.
This commit is contained in:
Rseifert 2012-10-03 13:43:52 -04:00
parent d2cafa890e
commit 6d73eede9f
5 changed files with 187 additions and 302 deletions

View file

@ -2,9 +2,14 @@ package steampower.turbine;
import java.util.ArrayList;
import steampower.TileEntityMachine;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material;
import net.minecraft.src.MathHelper;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
@ -19,6 +24,27 @@ public class BlockGenerator extends universalelectricity.prefab.BlockMachine {
{
itemList.add(new ItemStack(this, 1,0));
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving par5EntityLiving)
{
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
world.setBlockAndMetadataWithUpdate(x, y, z, blockID, angle, true);
}
@Override
public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer)
{
int angle = MathHelper.floor_double((par5EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int metadata = par1World.getBlockMetadata(x, y, z);
if(metadata < 3)
{
par1World.setBlockAndMetadata(x, y, z, blockID, metadata+angle);
}
else
{
par1World.setBlockAndMetadata(x, y, z, blockID, 0);
}
return true;
}
@Override
public boolean isOpaqueCube()
{

View file

@ -3,15 +3,91 @@ package steampower.turbine;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import steampower.TileEntityMachine;
import universalelectricity.electricity.ElectricityManager;
import universalelectricity.implement.IConductor;
import universalelectricity.implement.IElectricityProducer;
import universalelectricity.network.IPacketReceiver;
import basicpipes.pipes.api.IMechanical;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityGen extends TileEntityMachine implements IPacketReceiver
public class TileEntityGen extends TileEntityMachine implements IPacketReceiver, IMechanical,IElectricityProducer
{
ForgeDirection facing;
public int force = 0;
public int aForce = 0;
public int pos = 0;
public int disableTicks = 0;
public double genAmmount = 0;
public int tCount = 0;
public boolean empProf = false;
IConductor[] wires = {null,null,null,null,null,null};
@Override
public void updateEntity()
{
if(tCount++ >= 10)
{tCount = 0;
super.updateEntity();
this.genAmmount = (force * 1.2)/this.getVoltage();
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
int nMeta = 0;
switch(meta)
{
case 0: nMeta = 2;break;
case 1: nMeta = 4;break;
case 2: nMeta = 3;break;
case 3: nMeta = 5;break;
}
facing = ForgeDirection.getOrientation(nMeta).getOpposite();
if(genAmmount > 0)
{
worldObj.setBlock(xCoord, yCoord+1, zCoord, 1);
}
for(int i = 0; i < 6; i++)
{
ForgeDirection side = ForgeDirection.UNKNOWN;
switch(i)
{
case 0: side = ForgeDirection.UP;break;
//case 1: side = ForgeDirection.DOWN;break;
case 2: side = ForgeDirection.NORTH;break;
case 3: side = ForgeDirection.EAST;break;
case 4: side = ForgeDirection.SOUTH;break;
case 5: side = ForgeDirection.WEST;break;
}
if(side != facing && side != facing.getOpposite())
{
TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ);
if (tileEntity instanceof IConductor)
{
if (ElectricityManager.instance.getElectricityRequired( ((IConductor)tileEntity).getConnectionID()) > 0)
{
this.wires[i] = (IConductor)tileEntity;
ElectricityManager.instance.produceElectricity(this, this.wires[i],genAmmount, this.getVoltage());
}
else
{
this.wires[i] = null;
}
}
else
{
this.wires[i] = null;
}
}
}
}
}
@Override
public void handlePacketData(NetworkManager network,
Packet250CustomPayload packet, EntityPlayer player,
@ -19,36 +95,82 @@ public class TileEntityGen extends TileEntityMachine implements IPacketReceiver
// TODO Auto-generated method stub
}
public float electricityRequest()
{
//------------------------------
//Mechanics
//------------------------------
@Override
public int getForceSide(ForgeDirection side) {
if(side == facing.getOpposite())
{
return aForce;
}
return 0;
}
public boolean canConnect(ForgeDirection side)
{
int face = this.facing;
if(side != ForgeDirection.UP && side != ForgeDirection.DOWN)
{
return true;
}
}
@Override
public int getForce() {
// TODO Auto-generated method stub
return this.force;
}
@Override
public boolean canOutputSide(ForgeDirection side) {
if(side == facing.getOpposite())
{
return true;
}
return false;
}
public boolean canReceiveFromSide(ForgeDirection side)
{
return false;
}
public double getVoltage()
{
return 120;
}
public int getTickInterval()
{
return 10;
}
}
@Override
public boolean canInputSide(ForgeDirection side) {
if(side == facing)
{
return true;
}
return false;
}
@Override
public int applyForce(int force) {
this.force = force;
return force;
}
@Override
public int getAnimationPos() {
return pos;
}
//------------------------------
//Electric
//------------------------------
@Override
public void onDisable(int duration)
{
this.disableTicks = duration;
}
@Override
public boolean isDisabled() {
if(disableTicks-- <= 0)
{
return false;
}
return true;
}
@Override
public double getVoltage() {
return 120;
}
@Override
public boolean canConnect(ForgeDirection side) {
if(side != ForgeDirection.DOWN && side != facing && side != facing.getOpposite())
{
return true;
}
return false;
}
}

View file

@ -1,242 +0,0 @@
// Date: 8/14/2012 3:20:15 AM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX
package steampower;
import net.minecraft.src.Entity;
import net.minecraft.src.ModelBase;
import net.minecraft.src.ModelRenderer;
public class ModelToyEngine extends ModelBase
{
//fields
ModelRenderer BASE;
ModelRenderer PISTON_WALL_1;
ModelRenderer PISTON_HEAD_MOVES;
ModelRenderer PISTON_TURNER_MOVES;
ModelRenderer PISTON_ARM_MOVES;
ModelRenderer GEAR_A_NECK;
ModelRenderer PISTON_WALL_2;
ModelRenderer PISTON_WALL_3;
ModelRenderer PISTON_WALL_4;
ModelRenderer PISTON_SUPPORT_1;
ModelRenderer PISTON_SUPPORT_2;
ModelRenderer FORCE_CONDUCTOR_BOX;
ModelRenderer GEAR_A_TEETH_1_ROTATES;
ModelRenderer GEAR_A_TEETH_2_ROTATES;
ModelRenderer GEAR_A_TEETH_3_ROTATES;
ModelRenderer FORCE_TRANSMITTER_ROTATES;
ModelRenderer GEAR_B_TEETH_1_ROTATES;
ModelRenderer GEAR_B_TEETH_2_ROTATES;
ModelRenderer GEAR_B_TEETH_3_ROTATES;
ModelRenderer SUPPORT_PLATE;
ModelRenderer ORNAMENT_1;
ModelRenderer ORNAMENT_2;
ModelRenderer LEVER_1_CAN_BE_TURNED;
ModelRenderer LEVER_2_CAN_BE_TURNED;
public ModelToyEngine()
{
textureWidth = 128;
textureHeight = 128;
BASE = new ModelRenderer(this, 0, 0);
BASE.addBox(0F, 0F, 0F, 16, 1, 16);
BASE.setRotationPoint(-8F, 23F, -8F);
BASE.setTextureSize(128, 128);
BASE.mirror = true;
setRotation(BASE, 0F, 0F, 0F);
PISTON_WALL_1 = new ModelRenderer(this, 0, 18);
PISTON_WALL_1.addBox(0F, 0F, 0F, 7, 1, 4);
PISTON_WALL_1.setRotationPoint(0F, 22F, 1F);
PISTON_WALL_1.setTextureSize(128, 128);
PISTON_WALL_1.mirror = true;
setRotation(PISTON_WALL_1, 1.570796F, 0F, 0F);
PISTON_HEAD_MOVES = new ModelRenderer(this, 0, 24);
PISTON_HEAD_MOVES.addBox(0F, -2F, -2F, 4, 4, 4);
PISTON_HEAD_MOVES.setRotationPoint(0F, 20F, 4F);
PISTON_HEAD_MOVES.setTextureSize(128, 128);
PISTON_HEAD_MOVES.mirror = true;
setRotation(PISTON_HEAD_MOVES, 0F, 0F, 0F);
PISTON_TURNER_MOVES = new ModelRenderer(this, 0, 33);
PISTON_TURNER_MOVES.addBox(0F, -1F, -1F, 1, 2, 2);
PISTON_TURNER_MOVES.setRotationPoint(-1F, 20F, 4F);
PISTON_TURNER_MOVES.setTextureSize(128, 128);
PISTON_TURNER_MOVES.mirror = true;
setRotation(PISTON_TURNER_MOVES, 0F, 0F, 0F);
PISTON_ARM_MOVES = new ModelRenderer(this, 0, 38);
PISTON_ARM_MOVES.addBox(0F, 0F, -1F, 4, 1, 1);
PISTON_ARM_MOVES.setRotationPoint(-5F, 19F, 4F);
PISTON_ARM_MOVES.setTextureSize(128, 128);
PISTON_ARM_MOVES.mirror = true;
setRotation(PISTON_ARM_MOVES, 0F, 0F, 0F);
GEAR_A_NECK = new ModelRenderer(this, 65, 25);
GEAR_A_NECK.addBox(-1F, -1F, 0F, 2, 2, 1);
GEAR_A_NECK.setRotationPoint(-4F, 19F, -4F);
GEAR_A_NECK.setTextureSize(128, 128);
GEAR_A_NECK.mirror = true;
setRotation(GEAR_A_NECK, 0F, 0F, 0F);
PISTON_WALL_2 = new ModelRenderer(this, 0, 18);
PISTON_WALL_2.addBox(0F, 0F, 0F, 7, 1, 4);
PISTON_WALL_2.setRotationPoint(0F, 17F, 2F);
PISTON_WALL_2.setTextureSize(128, 128);
PISTON_WALL_2.mirror = true;
setRotation(PISTON_WALL_2, 0F, 0F, 0F);
PISTON_WALL_3 = new ModelRenderer(this, 0, 18);
PISTON_WALL_3.addBox(0F, 0F, 0F, 7, 1, 4);
PISTON_WALL_3.setRotationPoint(0F, 22F, 2F);
PISTON_WALL_3.setTextureSize(128, 128);
PISTON_WALL_3.mirror = true;
setRotation(PISTON_WALL_3, 0F, 0F, 0F);
PISTON_WALL_4 = new ModelRenderer(this, 0, 18);
PISTON_WALL_4.addBox(0F, 0F, 0F, 7, 1, 4);
PISTON_WALL_4.setRotationPoint(0F, 22F, 6F);
PISTON_WALL_4.setTextureSize(128, 128);
PISTON_WALL_4.mirror = true;
setRotation(PISTON_WALL_4, 1.570796F, 0F, 0F);
PISTON_SUPPORT_1 = new ModelRenderer(this, 0, 41);
PISTON_SUPPORT_1.addBox(0F, 0F, 0F, 1, 8, 6);
PISTON_SUPPORT_1.setRotationPoint(7F, 15F, 1F);
PISTON_SUPPORT_1.setTextureSize(128, 128);
PISTON_SUPPORT_1.mirror = true;
setRotation(PISTON_SUPPORT_1, 0F, 0F, 0F);
PISTON_SUPPORT_2 = new ModelRenderer(this, 0, 57);
PISTON_SUPPORT_2.addBox(0F, 0F, 0F, 1, 4, 4);
PISTON_SUPPORT_2.setRotationPoint(7F, 12F, 4F);
PISTON_SUPPORT_2.setTextureSize(128, 128);
PISTON_SUPPORT_2.mirror = true;
setRotation(PISTON_SUPPORT_2, -0.7853982F, 0F, 0F);
FORCE_CONDUCTOR_BOX = new ModelRenderer(this, 65, 0);
FORCE_CONDUCTOR_BOX.addBox(0F, 0F, 0F, 4, 5, 6);
FORCE_CONDUCTOR_BOX.setRotationPoint(-6F, 18F, -3F);
FORCE_CONDUCTOR_BOX.setTextureSize(128, 128);
FORCE_CONDUCTOR_BOX.mirror = true;
setRotation(FORCE_CONDUCTOR_BOX, 0F, 0F, 0F);
GEAR_A_TEETH_1_ROTATES = new ModelRenderer(this, 93, 0);
GEAR_A_TEETH_1_ROTATES.addBox(-3F, -1F, 0F, 6, 2, 1);
GEAR_A_TEETH_1_ROTATES.setRotationPoint(-4F, 19F, -5F);
GEAR_A_TEETH_1_ROTATES.setTextureSize(128, 128);
GEAR_A_TEETH_1_ROTATES.mirror = true;
setRotation(GEAR_A_TEETH_1_ROTATES, 0F, 0F, 0F);
GEAR_A_TEETH_2_ROTATES = new ModelRenderer(this, 93, 0);
GEAR_A_TEETH_2_ROTATES.addBox(-3F, -1F, 0F, 6, 2, 1);
GEAR_A_TEETH_2_ROTATES.setRotationPoint(-4F, 19F, -5F);
GEAR_A_TEETH_2_ROTATES.setTextureSize(128, 128);
GEAR_A_TEETH_2_ROTATES.mirror = true;
setRotation(GEAR_A_TEETH_2_ROTATES, 0F, 0F, 1.047198F);
GEAR_A_TEETH_3_ROTATES = new ModelRenderer(this, 93, 0);
GEAR_A_TEETH_3_ROTATES.addBox(-3F, -1F, 0F, 6, 2, 1);
GEAR_A_TEETH_3_ROTATES.setRotationPoint(-4F, 19F, -5F);
GEAR_A_TEETH_3_ROTATES.setTextureSize(128, 128);
GEAR_A_TEETH_3_ROTATES.mirror = true;
setRotation(GEAR_A_TEETH_3_ROTATES, 0F, 0F, -1.047198F);
FORCE_TRANSMITTER_ROTATES = new ModelRenderer(this, 65, 25);
FORCE_TRANSMITTER_ROTATES.addBox(-1F, -1F, 0F, 2, 2, 1);
FORCE_TRANSMITTER_ROTATES.setRotationPoint(0F, 17F, -8F);
FORCE_TRANSMITTER_ROTATES.setTextureSize(128, 128);
FORCE_TRANSMITTER_ROTATES.mirror = true;
setRotation(FORCE_TRANSMITTER_ROTATES, 0F, 0F, 0F);
GEAR_B_TEETH_1_ROTATES = new ModelRenderer(this, 93, 5);
GEAR_B_TEETH_1_ROTATES.addBox(-3F, -1F, 0F, 6, 2, 3);
GEAR_B_TEETH_1_ROTATES.setRotationPoint(0F, 17F, -7F);
GEAR_B_TEETH_1_ROTATES.setTextureSize(128, 128);
GEAR_B_TEETH_1_ROTATES.mirror = true;
setRotation(GEAR_B_TEETH_1_ROTATES, 0F, 0F, 0F);
GEAR_B_TEETH_2_ROTATES = new ModelRenderer(this, 93, 5);
GEAR_B_TEETH_2_ROTATES.addBox(-3F, -1F, 0F, 6, 2, 3);
GEAR_B_TEETH_2_ROTATES.setRotationPoint(0F, 17F, -7F);
GEAR_B_TEETH_2_ROTATES.setTextureSize(128, 128);
GEAR_B_TEETH_2_ROTATES.mirror = true;
setRotation(GEAR_B_TEETH_2_ROTATES, 0F, 0F, 1.047198F);
GEAR_B_TEETH_3_ROTATES = new ModelRenderer(this, 93, 5);
GEAR_B_TEETH_3_ROTATES.addBox(-3F, -1F, 0F, 6, 2, 3);
GEAR_B_TEETH_3_ROTATES.setRotationPoint(0F, 17F, -7F);
GEAR_B_TEETH_3_ROTATES.setTextureSize(128, 128);
GEAR_B_TEETH_3_ROTATES.mirror = true;
setRotation(GEAR_B_TEETH_3_ROTATES, 0F, 0F, -1.047198F);
SUPPORT_PLATE = new ModelRenderer(this, 65, 12);
SUPPORT_PLATE.addBox(0F, 0F, 0F, 9, 8, 4);
SUPPORT_PLATE.setRotationPoint(-1F, 15F, -4F);
SUPPORT_PLATE.setTextureSize(128, 128);
SUPPORT_PLATE.mirror = true;
setRotation(SUPPORT_PLATE, 0F, 0F, 0F);
ORNAMENT_1 = new ModelRenderer(this, 86, 0);
ORNAMENT_1.addBox(0F, 0F, 0F, 1, 4, 2);
ORNAMENT_1.setRotationPoint(6F, 19F, -5F);
ORNAMENT_1.setTextureSize(128, 128);
ORNAMENT_1.mirror = true;
setRotation(ORNAMENT_1, -0.2094395F, 0F, 0F);
ORNAMENT_2 = new ModelRenderer(this, 86, 0);
ORNAMENT_2.addBox(0F, 0F, 0F, 1, 4, 2);
ORNAMENT_2.setRotationPoint(4F, 19F, -5F);
ORNAMENT_2.setTextureSize(128, 128);
ORNAMENT_2.mirror = true;
setRotation(ORNAMENT_2, -0.2094395F, 0F, 0F);
LEVER_1_CAN_BE_TURNED = new ModelRenderer(this, 0, 0);
LEVER_1_CAN_BE_TURNED.addBox(0F, -6F, 0F, 1, 6, 1);
LEVER_1_CAN_BE_TURNED.setRotationPoint(6F, 16F, -3F);
LEVER_1_CAN_BE_TURNED.setTextureSize(128, 128);
LEVER_1_CAN_BE_TURNED.mirror = true;
setRotation(LEVER_1_CAN_BE_TURNED, 0F, 0F, 0F);
LEVER_2_CAN_BE_TURNED = new ModelRenderer(this, 0, 0);
LEVER_2_CAN_BE_TURNED.addBox(0F, -6F, 0F, 1, 6, 1);
LEVER_2_CAN_BE_TURNED.setRotationPoint(4F, 16F, -3F);
LEVER_2_CAN_BE_TURNED.setTextureSize(128, 128);
LEVER_2_CAN_BE_TURNED.mirror = true;
setRotation(LEVER_2_CAN_BE_TURNED, 0F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5);
genRender(f5);
}
public void genRender(float f5)
{
BASE.render(f5);
PISTON_WALL_1.render(f5);
PISTON_HEAD_MOVES.render(f5);
PISTON_TURNER_MOVES.render(f5);
PISTON_ARM_MOVES.render(f5);
GEAR_A_NECK.render(f5);
PISTON_WALL_2.render(f5);
PISTON_WALL_3.render(f5);
PISTON_WALL_4.render(f5);
PISTON_SUPPORT_1.render(f5);
PISTON_SUPPORT_2.render(f5);
FORCE_CONDUCTOR_BOX.render(f5);
GEAR_A_TEETH_1_ROTATES.render(f5);
GEAR_A_TEETH_2_ROTATES.render(f5);
GEAR_A_TEETH_3_ROTATES.render(f5);
FORCE_TRANSMITTER_ROTATES.render(f5);
GEAR_B_TEETH_1_ROTATES.render(f5);
GEAR_B_TEETH_2_ROTATES.render(f5);
GEAR_B_TEETH_3_ROTATES.render(f5);
SUPPORT_PLATE.render(f5);
ORNAMENT_1.render(f5);
ORNAMENT_2.render(f5);
LEVER_1_CAN_BE_TURNED.render(f5);
LEVER_2_CAN_BE_TURNED.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5);
}
}

View file

@ -22,6 +22,14 @@ public class RenderGenerator extends TileEntitySpecialRenderer
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
int meta = tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
switch(meta)
{
case 0:GL11.glRotatef(0f, 0f, 1f, 0f);break;
case 1:GL11.glRotatef(90f, 0f, 1f, 0f);break;
case 2:GL11.glRotatef(180f, 0f, 1f, 0f);break;
case 3:GL11.glRotatef(270f, 0f, 1f, 0f);break;
}
model.RenderMain(0.0625F);
GL11.glPopMatrix();
}

View file

@ -1,29 +0,0 @@
package steampower;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11;
public class RenderToyEngine extends TileEntitySpecialRenderer
{
int type = 0;
private ModelToyEngine model;
public RenderToyEngine()
{
model = new ModelToyEngine();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float d3) {
bindTextureByName(SteamPowerMain.textureFile+"tankTexture.png");
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
model.genRender(0.0625F);
GL11.glPopMatrix();
}
}