diff --git a/BasicPipesVersion.txt b/BasicPipesVersion.txt index bf0d87ab..7c483e8f 100644 --- a/BasicPipesVersion.txt +++ b/BasicPipesVersion.txt @@ -1 +1 @@ -4 \ No newline at end of file +1.7 \ No newline at end of file diff --git a/SteamPowerVersion.txt b/SteamPowerVersion.txt index c7930257..7c483e8f 100644 --- a/SteamPowerVersion.txt +++ b/SteamPowerVersion.txt @@ -1 +1 @@ -7 \ No newline at end of file +1.7 \ No newline at end of file diff --git a/src/common/basicpipes/BasicPipesMain.java b/src/common/basicpipes/BasicPipesMain.java index 8c7b4b2a..acd837e4 100644 --- a/src/common/basicpipes/BasicPipesMain.java +++ b/src/common/basicpipes/BasicPipesMain.java @@ -8,6 +8,7 @@ import net.minecraftforge.common.Configuration; import universalelectricity.BasicComponents; import universalelectricity.network.PacketManager; import basicpipes.conductors.BlockPipe; +import basicpipes.conductors.BlockRod; import basicpipes.conductors.ItemGuage; import basicpipes.conductors.ItemParts; import basicpipes.conductors.ItemPipe; @@ -25,7 +26,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; -@Mod(modid = "basicPipes", name = "Basic Pipes", version = "V4") +@Mod(modid = "basicPipes", name = "Basic Pipes", version = "1.7",dependencies = "after:UniversalElectricity") @NetworkMod(channels = { "Pipes" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class) public class BasicPipesMain{ @@ -44,6 +45,7 @@ public class BasicPipesMain{ public static Block pipe = new BlockPipe(pipeID).setBlockName("pipe"); public static Block machine = new BlockMachine(machineID).setBlockName("pump"); public static Block valve = new BlockValve(valveID).setBlockName("valve"); + public static Block rod = new BlockRod(valveID+1); public static Item parts = new ItemParts(partID); public static Item itemPipes = new ItemPipe(ppipeID); public static Item gauge = new ItemGuage(toolID); @@ -70,6 +72,7 @@ public class BasicPipesMain{ { proxy.preInit(); GameRegistry.registerBlock(pipe); + GameRegistry.registerBlock(rod); GameRegistry.registerBlock(machine,basicpipes.machines.ItemMachine.class); } @Init diff --git a/src/common/basicpipes/PipeProxy.java b/src/common/basicpipes/PipeProxy.java index 8318c60f..c5621d9b 100644 --- a/src/common/basicpipes/PipeProxy.java +++ b/src/common/basicpipes/PipeProxy.java @@ -1,6 +1,7 @@ package basicpipes; import basicpipes.conductors.TileEntityPipe; +import basicpipes.conductors.TileEntityRod; import basicpipes.machines.TileEntityPump; import net.minecraft.src.EntityPlayer; import net.minecraft.src.TileEntity; @@ -19,6 +20,7 @@ public class PipeProxy implements IGuiHandler { GameRegistry.registerTileEntity(TileEntityPipe.class, "pipe"); GameRegistry.registerTileEntity(TileEntityPump.class, "pump"); + GameRegistry.registerTileEntity(TileEntityRod.class, "rod"); } public void postInit() { diff --git a/src/common/basicpipes/conductors/BlockRod.java b/src/common/basicpipes/conductors/BlockRod.java index 48ea564a..e2f39ec9 100644 --- a/src/common/basicpipes/conductors/BlockRod.java +++ b/src/common/basicpipes/conductors/BlockRod.java @@ -1,15 +1,21 @@ package basicpipes.conductors; +import steampower.TileEntityMachine; import net.minecraft.src.Block; +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.EntityLiving; import net.minecraft.src.EntityPlayer; import net.minecraft.src.Material; +import net.minecraft.src.MathHelper; import net.minecraft.src.TileEntity; import net.minecraft.src.World; +import net.minecraftforge.common.ForgeDirection; public class BlockRod extends universalelectricity.prefab.BlockMachine { public BlockRod(int par1) { super("MechanicRod", par1, Material.iron); + this.setCreativeTab(CreativeTabs.tabRedstone); } @Override protected int damageDropped(int metadata) @@ -17,6 +23,21 @@ public class BlockRod extends universalelectricity.prefab.BlockMachine { return 0; } @Override + public void onBlockPlacedBy(World world,int i,int j,int k, EntityLiving player) + { + int angle= MathHelper.floor_double((player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int meta = 0; + ForgeDirection idr; + switch(angle) + { + case 0: meta = 2;break; + case 1: meta = 5;break; + case 2: meta = 3;break; + case 3: meta = 4;break; + } + world.setBlockAndMetadataWithUpdate(i, j, k,blockID, meta, true); + } + @Override public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer) { int meta = world.getBlockMetadata(x, y, z); diff --git a/src/common/basicpipes/conductors/ItemGuage.java b/src/common/basicpipes/conductors/ItemGuage.java index a5af175c..c14c8a9f 100644 --- a/src/common/basicpipes/conductors/ItemGuage.java +++ b/src/common/basicpipes/conductors/ItemGuage.java @@ -7,6 +7,7 @@ import basicpipes.BasicPipesMain; import basicpipes.pipes.api.Liquid; import net.minecraft.src.*; +import net.minecraftforge.common.ForgeDirection; public class ItemGuage extends Item { @@ -65,6 +66,18 @@ public class ItemGuage extends Item player.addChatMessage(print); return true; } + if(blockEntity instanceof TileEntityRod) + { + TileEntityRod rod = (TileEntityRod) blockEntity; + int steam = rod.loadRPM; + int pressure = rod.getRPM(ForgeDirection.getOrientation(par7)); + String print = "Error"; + + print = " " + steam +"Load "+pressure+"RPM"; + + player.addChatMessage(print); + return true; + } } } diff --git a/src/common/basicpipes/conductors/TileEntityRod.java b/src/common/basicpipes/conductors/TileEntityRod.java index ca5bae34..75039ff5 100644 --- a/src/common/basicpipes/conductors/TileEntityRod.java +++ b/src/common/basicpipes/conductors/TileEntityRod.java @@ -16,7 +16,7 @@ import basicpipes.pipes.api.Liquid; public class TileEntityRod extends TileEntity implements IPacketReceiver,IMechenical { private int count = 0; -private float rotation = 0; +public float rotation = 0; public int rpm = 0;//rpm received from producer public int loadRPM = 0; //rpm lost to the load public int currentRPM = 0; @@ -70,11 +70,14 @@ ForgeDirection backD; if(back != null && front != null) { this.rpm = ((IMechenical) back).getRPM(backD); - this.loadRPM = ((IMechenical) front).useRPM(rpm)+10; - this.currentRPM = rpm-loadRPM-10;//minus 10 is what it take to over come the rods friction - if(currentRPM < 0) + if(rpm > 0) { - //TODO add stress to rod and break if left stressed too long + this.loadRPM = ((IMechenical) front).useRPM(rpm)+10; + this.currentRPM = rpm-loadRPM-10;//minus 10 is what it take to over come the rods friction + if(currentRPM < 0) + { + //TODO add stress to rod and break if left stressed too long + } } }else { @@ -97,10 +100,13 @@ ForgeDirection backD; PacketManager.sendTileEntityPacketWithRange(this, BasicPipesMain.channel, 20, this.data()); } - this.rotation = currentRPM * 240; - if(back != null && back instanceof TileEntityRod) + if(currentRPM > 0) { - this.rotation = ((TileEntityRod)front).rotation; + this.rotation = currentRPM * 240; + if(back != null && back instanceof TileEntityRod) + { + this.rotation = ((TileEntityRod)back).getRPM(backD) * 240; + } } } } @@ -126,7 +132,7 @@ ForgeDirection backD; } @Override public int useRPM(int RPM) { - // TODO Auto-generated method stub + //rpm * T / 5252 return 10+loadRPM; } diff --git a/src/common/steampower/SteamPowerMain.java b/src/common/steampower/SteamPowerMain.java index 57cc2973..dd32146b 100644 --- a/src/common/steampower/SteamPowerMain.java +++ b/src/common/steampower/SteamPowerMain.java @@ -24,7 +24,7 @@ import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; -@Mod(modid = "SteamPower", name = "Steam Power", version = "0.0.10") +@Mod(modid = "SteamPower", name = "Steam Power", version = "1.7",dependencies = "after:basicPipes") @NetworkMod(channels = { "SPpack" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class) public class SteamPowerMain{ diff --git a/src/common/steampower/turbine/TileEntitySteamPiston.java b/src/common/steampower/turbine/TileEntitySteamPiston.java index ad35bd3e..f4dfda23 100644 --- a/src/common/steampower/turbine/TileEntitySteamPiston.java +++ b/src/common/steampower/turbine/TileEntitySteamPiston.java @@ -12,17 +12,15 @@ import net.minecraft.src.TileEntity; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ISidedInventory; import steampower.TileEntityMachine; -import universalelectricity.electricity.ElectricityManager; import universalelectricity.network.IPacketReceiver; -import universalelectricity.prefab.TileEntityConductor; -import universalelectricity.prefab.Vector3; import basicpipes.pipes.api.ILiquidConsumer; import basicpipes.pipes.api.ILiquidProducer; +import basicpipes.pipes.api.IMechenical; import basicpipes.pipes.api.Liquid; import com.google.common.io.ByteArrayDataInput; -public class TileEntitySteamPiston extends TileEntityMachine implements IPacketReceiver,ILiquidConsumer,ILiquidProducer, IInventory, ISidedInventory +public class TileEntitySteamPiston extends TileEntityMachine implements IPacketReceiver,ILiquidConsumer,ILiquidProducer, IInventory, ISidedInventory,IMechenical { //Maximum possible generation rate of watts in SECONDS public int maxGenerateRate = 1000; @@ -42,19 +40,8 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR * The ItemStacks that hold the items currently being used in the battery box */ private ItemStack[] containingItems = new ItemStack[1]; - public TileEntityConductor connectedElectricUnit = null; public boolean isConnected = false; private boolean posT = true; - @Override - public boolean canConnect(ForgeDirection side) - { - return true; - } - public int getTickInterval() - { - return 10; - - } /** * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count * ticks and creates a new spawn inside its implementation. @@ -104,28 +91,11 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR { isConnected = true; } - - this.connectedElectricUnit = null; - //Check nearby blocks and see if the conductor is full. If so, then it is connected - for(int i = 0;i<6;i++) - { - TileEntity tileEntity = Vector3.getConnectorFromSide(this.worldObj, new Vector3(this.xCoord, this.yCoord, this.zCoord), - ForgeDirection.getOrientation(i)); - if (tileEntity instanceof TileEntityConductor) - { - if (ElectricityManager.instance.getElectricityRequired(((TileEntityConductor)tileEntity).getConnectionID()) > 0) - { - this.connectedElectricUnit = (TileEntityConductor)tileEntity; - } - } - } - if(!this.worldObj.isRemote) { - if(!this.isDisabled()) - { + //Adds time to runTime by consuming steam if(this.genTime <= 0) { @@ -160,25 +130,19 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR { this.genTime --; - if(this.connectedElectricUnit != null) - { + this.generateRate = (float)Math.min(this.generateRate+Math.min((this.generateRate)*0.01+0.015, 0.05F), this.maxGenerateRate/20); - } + } - if(this.connectedElectricUnit == null || this.genTime <= 0) + if(this.genTime <= 0) { this.generateRate = (float)Math.max(this.generateRate-0.05, 0); } - - if(this.generateRate > 1) - { - ElectricityManager.instance.produceElectricity(this, connectedElectricUnit, this.generateRate*this.getTickInterval(), this.getVoltage()); - } } } } - } + /** * Reads a tile entity from NBT. */ @@ -306,18 +270,6 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR @Override public void closeChest() { } - @Override - public void onDisable(int duration) { - // TODO Auto-generated method stub - - } - - @Override - public boolean isDisabled() { - // TODO Auto-generated method stub - return false; - } - @Override public int onProduceLiquid(Liquid type, int Vol, ForgeDirection side) { if(type == Liquid.WATER) @@ -384,7 +336,7 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR @Override public Object[] getSendData() { - return new Object[]{(int)facing,(int)waterStored,(int)steamStored,(int)steamConsumed,(float)generateRate,(int)genTime}; + return new Object[]{(int)waterStored,(int)steamStored,(int)steamConsumed,(float)generateRate,(int)genTime}; } @Override @@ -393,7 +345,6 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR ByteArrayDataInput dataStream) { try { - facing = dataStream.readInt(); waterStored = dataStream.readInt(); steamStored = dataStream.readInt(); steamConsumed = dataStream.readInt(); @@ -423,4 +374,24 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR } return false; } + @Override + public int getRPM(ForgeDirection side) { + // TODO Auto-generated method stub + return 100; + } + @Override + public boolean canOutputSide(ForgeDirection side) { + // TODO Auto-generated method stub + return true; + } + @Override + public boolean canInputSide(ForgeDirection side) { + // TODO Auto-generated method stub + return false; + } + @Override + public int useRPM(int RPM) { + // TODO Auto-generated method stub + return 0; + } } diff --git a/src/minecraft/basicpipes/ModelGearRod.java b/src/minecraft/basicpipes/ModelGearRod.java new file mode 100644 index 00000000..56201a90 --- /dev/null +++ b/src/minecraft/basicpipes/ModelGearRod.java @@ -0,0 +1,138 @@ +// Date: 9/25/2012 4:29:17 PM +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + + + + + + +package basicpipes; + +import net.minecraft.src.Entity; +import net.minecraft.src.ModelBase; +import net.minecraft.src.ModelRenderer; + +public class ModelGearRod extends ModelBase +{ + //fields + ModelRenderer Rod; + ModelRenderer front; + ModelRenderer back; + ModelRenderer f2; + ModelRenderer b2; + ModelRenderer b3; + ModelRenderer b4; + ModelRenderer b1; + ModelRenderer f1; + ModelRenderer f4; + ModelRenderer f3; + ModelRenderer Rod2; + + public ModelGearRod() + { + textureWidth = 64; + textureHeight = 32; + + Rod = new ModelRenderer(this, 0, 0); + Rod.addBox(-1.5F, -1.5F, 0F, 3, 3, 12); + Rod.setRotationPoint(0F, 16F, -6F); + Rod.setTextureSize(64, 32); + Rod.mirror = true; + setRotation(Rod, 0F, 0F, 0F); + front = new ModelRenderer(this, 35, 0); + front.addBox(-2F, -2F, -2F, 4, 4, 2); + front.setRotationPoint(0F, 16F, -6F); + front.setTextureSize(64, 32); + front.mirror = true; + setRotation(front, 0F, 0F, 0F); + back = new ModelRenderer(this, 35, 0); + back.addBox(-2F, -2F, 0F, 4, 4, 2); + back.setRotationPoint(0F, 16F, 6F); + back.setTextureSize(64, 32); + back.mirror = true; + setRotation(back, 0F, 0F, 0.7853982F); + f2 = new ModelRenderer(this, 0, 17); + f2.addBox(0F, 0F, 0F, 1, 1, 2); + f2.setRotationPoint(1F, 17F, -10F); + f2.setTextureSize(64, 32); + f2.mirror = true; + setRotation(f2, 0F, 0F, 0F); + b2 = new ModelRenderer(this, 0, 17); + b2.addBox(-0.5F, -0.5F, 0F, 1, 1, 2); + b2.setRotationPoint(0F, 18F, 8F); + b2.setTextureSize(64, 32); + b2.mirror = true; + setRotation(b2, 0F, 0F, 0.7853982F); + b3 = new ModelRenderer(this, 0, 17); + b3.addBox(-0.5F, -0.5F, 0F, 1, 1, 2); + b3.setRotationPoint(-2F, 16F, 8F); + b3.setTextureSize(64, 32); + b3.mirror = true; + setRotation(b3, 0F, 0F, 0.7853982F); + b4 = new ModelRenderer(this, 0, 17); + b4.addBox(-0.5F, -0.5F, 0F, 1, 1, 2); + b4.setRotationPoint(2F, 16F, 8F); + b4.setTextureSize(64, 32); + b4.mirror = true; + setRotation(b4, 0F, 0F, 0.7853982F); + b1 = new ModelRenderer(this, 0, 17); + b1.addBox(-0.5F, -0.5F, 0F, 1, 1, 2); + b1.setRotationPoint(0F, 14F, 8F); + b1.setTextureSize(64, 32); + b1.mirror = true; + setRotation(b1, 0F, 0F, 0.7853982F); + f1 = new ModelRenderer(this, 0, 17); + f1.addBox(0F, 0F, 0F, 1, 1, 2); + f1.setRotationPoint(1F, 14F, -10F); + f1.setTextureSize(64, 32); + f1.mirror = true; + setRotation(f1, 0F, 0F, 0F); + f4 = new ModelRenderer(this, 0, 17); + f4.addBox(0F, 0F, 0F, 1, 1, 2); + f4.setRotationPoint(-2F, 17F, -10F); + f4.setTextureSize(64, 32); + f4.mirror = true; + setRotation(f4, 0F, 0F, 0F); + f3 = new ModelRenderer(this, 0, 17); + f3.addBox(0F, 0F, 0F, 1, 1, 2); + f3.setRotationPoint(-2F, 14F, -10F); + f3.setTextureSize(64, 32); + f3.mirror = true; + setRotation(f3, 0F, 0F, 0F); + Rod2 = new ModelRenderer(this, 0, 0); + Rod2.addBox(-1.5F, -1.5F, 0F, 3, 3, 12); + Rod2.setRotationPoint(0F, 16F, -6F); + Rod2.setTextureSize(64, 32); + Rod2.mirror = true; + setRotation(Rod2, 0F, 0F, 0.7853982F); + } + public void render(float f5,float r) + { + Rod.render(f5); + Rod2.render(f5); + Rod.rotateAngleZ+= r; + Rod2.rotateAngleZ+= r; + //TODO add rotation to rods + front.render(f5); + back.render(f5); + f2.render(f5); + b2.render(f5); + b3.render(f5); + b4.render(f5); + b1.render(f5); + f1.render(f5); + f4.render(f5); + f3.render(f5); + + } + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/minecraft/basicpipes/PipeClientProxy.java b/src/minecraft/basicpipes/PipeClientProxy.java index 61e07ace..7d0ede83 100644 --- a/src/minecraft/basicpipes/PipeClientProxy.java +++ b/src/minecraft/basicpipes/PipeClientProxy.java @@ -3,6 +3,7 @@ package basicpipes; import steampower.SteamPowerMain; import basicpipes.PipeProxy; import basicpipes.conductors.TileEntityPipe; +import basicpipes.conductors.TileEntityRod; import basicpipes.machines.TileEntityPump; import net.minecraftforge.client.MinecraftForgeClient; import cpw.mods.fml.client.registry.ClientRegistry; @@ -23,5 +24,6 @@ public class PipeClientProxy extends PipeProxy { ClientRegistry.registerTileEntity(TileEntityPipe.class, "pipe", new RenderPipe()); ClientRegistry.registerTileEntity(TileEntityPump.class, "pump", new RenderPump()); + ClientRegistry.registerTileEntity(TileEntityRod.class, "rod", new RenderGearRod()); } } diff --git a/src/minecraft/basicpipes/RenderGearRod.java b/src/minecraft/basicpipes/RenderGearRod.java new file mode 100644 index 00000000..f306e4dd --- /dev/null +++ b/src/minecraft/basicpipes/RenderGearRod.java @@ -0,0 +1,52 @@ +package basicpipes; + +import net.minecraft.src.TileEntity; +import net.minecraft.src.TileEntitySpecialRenderer; + +import org.lwjgl.opengl.GL11; + +import basicpipes.conductors.TileEntityPipe; +import basicpipes.conductors.TileEntityRod; +import basicpipes.machines.TileEntityPump; +import basicpipes.pipes.api.Liquid; + + +public class RenderGearRod extends TileEntitySpecialRenderer +{ + int type = 0; + private ModelGearRod model; + + public RenderGearRod() + { + model = new ModelGearRod(); + } + + public void renderAModelAt(TileEntityRod tileEntity, double d, double d1, double d2, float f) + { + + int meta = tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); + bindTextureByName("/textures/GearRod.png"); + + GL11.glPushMatrix(); + GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + switch(meta) + { + case 0: GL11.glRotatef(90f, 1f, 0f, 0f);break; + case 1: GL11.glRotatef(-90f, 1f, 0f, 0f);break; + case 2:GL11.glRotatef(0f, 0f, 1f, 0f);break; + case 5:GL11.glRotatef(90f, 0f, 1f, 0f);break; + case 3:GL11.glRotatef(180f, 0f, 1f, 0f);break; + case 4:GL11.glRotatef(270f, 0f, 1f, 0f);break; + } + model.render(0.0625F,tileEntity.rotation); + GL11.glPopMatrix(); + + } + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) { + this.renderAModelAt((TileEntityRod)tileEntity, var2, var4, var6, var8); + } + +} \ No newline at end of file diff --git a/src/minecraft/steampower/GUIGenerator.java b/src/minecraft/steampower/GUIGenerator.java index 612922ff..b73ea08d 100644 --- a/src/minecraft/steampower/GUIGenerator.java +++ b/src/minecraft/steampower/GUIGenerator.java @@ -34,11 +34,12 @@ import universalelectricity.electricity.ElectricInfo.ElectricUnit; String displayText = ""; String displayText2 = ""; String displayText3 = ""; + /** if(tileEntity.connectedElectricUnit == null) { displayText = "Not Connected"; } - else + else*/ if(tileEntity.generateRate*20 <= 0) { if(tileEntity.steamStored> 0) diff --git a/src/minecraft/textures/GearRod.png b/src/minecraft/textures/GearRod.png new file mode 100644 index 00000000..11f4720d Binary files /dev/null and b/src/minecraft/textures/GearRod.png differ