From 3b8c25aa55bd781a7f292cc72b25afc1f87843fd Mon Sep 17 00:00:00 2001 From: Rseifert Date: Tue, 28 Aug 2012 10:13:18 -0400 Subject: [PATCH] dido --- src/common/steampower/BlockMachine.java | 236 ++++++++++ src/common/steampower/ItemMachine.java | 65 +++ src/common/steampower/ItemParts.java | 70 +++ src/common/steampower/SteamPowerMain.java | 121 ++++++ src/common/steampower/SteamProxy.java | 69 +++ src/common/steampower/TileEntityMachine.java | 258 +++++++++++ src/common/steampower/TileEntityNuller.java | 29 ++ src/common/steampower/ap/IHeatConsumer.java | 22 + src/common/steampower/ap/IHeatProducer.java | 14 + .../steampower/boiler/ContainerBoiler.java | 59 +++ .../steampower/boiler/TileEntityBoiler.java | 271 ++++++++++++ .../steampower/burner/ContainerFireBox.java | 42 ++ .../steampower/burner/TileEntityFireBox.java | 203 +++++++++ .../steampower/turbine/BlockGenerator.java | 42 ++ .../steampower/turbine/BlockSteamPiston.java | 158 +++++++ .../turbine/ContainerGenerator.java | 45 ++ src/common/steampower/turbine/ItemEngine.java | 62 +++ .../steampower/turbine/TileEntityGen.java | 62 +++ .../turbine/TileEntitySteamPiston.java | 405 ++++++++++++++++++ .../steampower/turbine/TileEntitytopGen.java | 60 +++ src/minecraft/steampower/GUIFireBox.java | 92 ++++ src/minecraft/steampower/GUIGenerator.java | 80 ++++ src/minecraft/steampower/GuiBoiler.java | 89 ++++ src/minecraft/steampower/ModelCenterTank.java | 59 +++ src/minecraft/steampower/ModelCornerTank.java | 100 +++++ src/minecraft/steampower/ModelEngine.java | 115 +++++ src/minecraft/steampower/ModelFurnace.java | 82 ++++ src/minecraft/steampower/ModelGenerator.java | 136 ++++++ src/minecraft/steampower/ModelTank.java | 154 +++++++ src/minecraft/steampower/ModelToyEngine.java | 242 +++++++++++ src/minecraft/steampower/RenderBoiler.java | 62 +++ src/minecraft/steampower/RenderFurnace.java | 37 ++ src/minecraft/steampower/RenderGenerator.java | 29 ++ .../steampower/RenderSteamEngine.java | 49 +++ src/minecraft/steampower/RenderToyEngine.java | 29 ++ .../steampower/SteamClientProxy.java | 31 ++ 36 files changed, 3679 insertions(+) create mode 100644 src/common/steampower/BlockMachine.java create mode 100644 src/common/steampower/ItemMachine.java create mode 100644 src/common/steampower/ItemParts.java create mode 100644 src/common/steampower/SteamPowerMain.java create mode 100644 src/common/steampower/SteamProxy.java create mode 100644 src/common/steampower/TileEntityMachine.java create mode 100644 src/common/steampower/TileEntityNuller.java create mode 100644 src/common/steampower/ap/IHeatConsumer.java create mode 100644 src/common/steampower/ap/IHeatProducer.java create mode 100644 src/common/steampower/boiler/ContainerBoiler.java create mode 100644 src/common/steampower/boiler/TileEntityBoiler.java create mode 100644 src/common/steampower/burner/ContainerFireBox.java create mode 100644 src/common/steampower/burner/TileEntityFireBox.java create mode 100644 src/common/steampower/turbine/BlockGenerator.java create mode 100644 src/common/steampower/turbine/BlockSteamPiston.java create mode 100644 src/common/steampower/turbine/ContainerGenerator.java create mode 100644 src/common/steampower/turbine/ItemEngine.java create mode 100644 src/common/steampower/turbine/TileEntityGen.java create mode 100644 src/common/steampower/turbine/TileEntitySteamPiston.java create mode 100644 src/common/steampower/turbine/TileEntitytopGen.java create mode 100644 src/minecraft/steampower/GUIFireBox.java create mode 100644 src/minecraft/steampower/GUIGenerator.java create mode 100644 src/minecraft/steampower/GuiBoiler.java create mode 100644 src/minecraft/steampower/ModelCenterTank.java create mode 100644 src/minecraft/steampower/ModelCornerTank.java create mode 100644 src/minecraft/steampower/ModelEngine.java create mode 100644 src/minecraft/steampower/ModelFurnace.java create mode 100644 src/minecraft/steampower/ModelGenerator.java create mode 100644 src/minecraft/steampower/ModelTank.java create mode 100644 src/minecraft/steampower/ModelToyEngine.java create mode 100644 src/minecraft/steampower/RenderBoiler.java create mode 100644 src/minecraft/steampower/RenderFurnace.java create mode 100644 src/minecraft/steampower/RenderGenerator.java create mode 100644 src/minecraft/steampower/RenderSteamEngine.java create mode 100644 src/minecraft/steampower/RenderToyEngine.java create mode 100644 src/minecraft/steampower/SteamClientProxy.java diff --git a/src/common/steampower/BlockMachine.java b/src/common/steampower/BlockMachine.java new file mode 100644 index 00000000..9c89dfea --- /dev/null +++ b/src/common/steampower/BlockMachine.java @@ -0,0 +1,236 @@ +package steampower; + +import java.util.Random; + +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.EntityItem; +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.NBTTagCompound; +import net.minecraft.src.TileEntity; +import net.minecraft.src.World; +import steampower.boiler.TileEntityBoiler; +import steampower.burner.TileEntityFireBox; + +public class BlockMachine extends universalelectricity.extend.BlockMachine +{ + + private Random furnaceRand = new Random(); + private static boolean keepFurnaceInventory = true; + + public BlockMachine(int par1) + { + super("machine", par1, Material.iron); + this.setRequiresSelfNotify(); + this.setCreativeTab(CreativeTabs.tabBlock); + + } + @Override + protected int damageDropped(int metadata) + { + return metadata; + } + @Override + public void randomDisplayTick(World par1World, int x, int y, int z, Random par5Random) + { + TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z); + + if(tileEntity instanceof TileEntityFireBox) + { + if(((TileEntityFireBox)tileEntity).generateRate > 0) + { + int var6 = ((TileEntityFireBox) tileEntity).getDirection(); + float var7 = (float)x + 0.5F; + float var8 = (float)y + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F; + float var9 = (float)z + 0.5F; + float var10 = 0.52F; + float var11 = par5Random.nextFloat() * 0.6F - 0.3F; + + if (var6 == 4) + { + par1World.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("flame", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + } + else if (var6 == 2) + { + par1World.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("flame", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + } + else if (var6 == 1) + { + par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D); + } + else if (var6 == 3) + { + par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D); + } + } + } + } + + @Override + public boolean onUseWrench(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) + { + TileEntityMachine tileEntity = (TileEntityMachine)par1World.getBlockTileEntity(par2, par3, par4); + + //Reorient the block + switch(tileEntity.getDirection()) + { + case 1: tileEntity.setDirection(2); break; + case 2: tileEntity.setDirection(3); break; + case 3: tileEntity.setDirection(4); break; + case 4: tileEntity.setDirection(1); break; + } + + return true; + } + /** + * Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the + * block. + */ + @Override + public boolean onMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer) + { + if (par1World.isRemote) + { + return true; + } + else + { + TileEntity blockEntity = (TileEntity)par1World.getBlockTileEntity(x, y, z); + + if (blockEntity != null) + { + + if(blockEntity instanceof TileEntityBoiler) + { + TileEntity var6 = (TileEntityBoiler)par1World.getBlockTileEntity(x, y, z); + par5EntityPlayer.openGui(SteamPowerMain.instance, 1, par1World, x, y, z); + } + if(blockEntity instanceof TileEntityFireBox) + { + TileEntity var6 = (TileEntityFireBox)par1World.getBlockTileEntity(x, y, z); + par5EntityPlayer.openGui(SteamPowerMain.instance, 0, par1World, x, y, z); + } + } + + return true; + } + } + @Override + public TileEntity createNewTileEntity(World var1,int meta) + { + switch(meta) + { + case 1: return new TileEntityBoiler(); + case 2: return new TileEntityFireBox(); + case 15: return new TileEntityNuller(); + } + return null; + } + + /** + * Called when the block is placed in the world. + */ + @Override + public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLiving par5EntityLiving) + { + int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int metadata = par1World.getBlockMetadata(x, y, z); + TileEntityMachine tileEntity = (TileEntityMachine)par1World.getBlockTileEntity(x, y, z); + + switch (angle) + { + case 0: tileEntity.setDirection(1); break; + case 1: tileEntity.setDirection(2); break; + case 2: tileEntity.setDirection(3); break; + case 3: tileEntity.setDirection(4); break; + } + } + /** + * Called whenever the block is removed. + */ + @Override + public void breakBlock(World par1World, int par2, int par3, int par4,int par5, int par6){ + if (!keepFurnaceInventory) + { + TileEntityMachine var5 = null; + TileEntity entityBox = par1World.getBlockTileEntity(par2, par3, par4); + if(entityBox instanceof TileEntityFireBox) + { + var5 = (TileEntityFireBox)entityBox; + } + else if(entityBox instanceof TileEntityBoiler) + { + var5 = (TileEntityBoiler)entityBox; + } + if (var5 != null) + { + for (int var6 = 0; var6 < var5.getSizeInventory(); ++var6) + { + ItemStack var7 = var5.getStackInSlot(var6); + + if (var7 != null) + { + float var8 = this.furnaceRand.nextFloat() * 0.8F + 0.1F; + float var9 = this.furnaceRand.nextFloat() * 0.8F + 0.1F; + float var10 = this.furnaceRand.nextFloat() * 0.8F + 0.1F; + + while (var7.stackSize > 0) + { + int var11 = this.furnaceRand.nextInt(21) + 10; + + if (var11 > var7.stackSize) + { + var11 = var7.stackSize; + } + + var7.stackSize -= var11; + EntityItem var12 = new EntityItem(par1World, (double)((float)par2 + var8), (double)((float)par3 + var9), (double)((float)par4 + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage())); + + if (var7.hasTagCompound()) + { + var12.item.setTagCompound((NBTTagCompound)var7.getTagCompound().copy()); + } + + float var13 = 0.05F; + var12.motionX = (double)((float)this.furnaceRand.nextGaussian() * var13); + var12.motionY = (double)((float)this.furnaceRand.nextGaussian() * var13 + 0.2F); + var12.motionZ = (double)((float)this.furnaceRand.nextGaussian() * var13); + par1World.spawnEntityInWorld(var12); + } + } + } + } + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public String getTextureFile() + { + return "/EUIClient/textures/blocks/blocks.png"; + } + @Override + public boolean isOpaqueCube() + { + return false; + } + @Override + public boolean renderAsNormalBlock() + { + return false; + } + @Override + public int getRenderType() + { + return -1; + } + +} diff --git a/src/common/steampower/ItemMachine.java b/src/common/steampower/ItemMachine.java new file mode 100644 index 00000000..3086957d --- /dev/null +++ b/src/common/steampower/ItemMachine.java @@ -0,0 +1,65 @@ +package steampower; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.src.*; + +public class ItemMachine extends ItemBlock { + + public ItemMachine(int id) { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + this.setIconIndex(21); + this.setTabToDisplayOn(CreativeTabs.tabBlock); + } + @Override + public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + + par3List.add(new ItemStack(this, 1, 1)); + par3List.add(new ItemStack(this, 1, 2)); + par3List.add(new ItemStack(this, 1, 15)); + } + @Override + public String getTextureFile() { + // TODO Auto-generated method stub + return "/EUIClient/Textures/Items.png"; + } + @Override + public int getIconFromDamage(int par1) + { + switch(par1) + { + case 1: return 23; + case 2: return 22; + case 15: return 22; + } + return this.iconIndex+par1; + } + @Override + public int getMetadata(int metadata) + { + return metadata; + } + @Override + public String getItemName() + { + return "Machine"; + } + @Override + public String getItemNameIS(ItemStack par1ItemStack) + { + int var3 = par1ItemStack.getItemDamage(); + switch(var3) + { + case 0: return "CoalProcessor"; + case 1: return "Boiler"; + case 2: return "FireBox"; + case 3: return "SteamGen"; + case 15: return "EnergyNuller"; + } + return this.getItemName(); + } + } + diff --git a/src/common/steampower/ItemParts.java b/src/common/steampower/ItemParts.java new file mode 100644 index 00000000..f1c358b3 --- /dev/null +++ b/src/common/steampower/ItemParts.java @@ -0,0 +1,70 @@ +package steampower; + +import java.util.ArrayList; + +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; + +public class ItemParts extends Item{ + + public ItemParts(int par1) + { + super(par1); + this.setItemName("Parts"); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setMaxStackSize(64); + } + @Override + public int getIconFromDamage(int par1) + { + switch(par1) + { + case 0: return 3; + case 1: return 4; + case 2: return 5; + case 3: return 6; + case 4: return 7; + case 5: return 8; + case 6: return 9; + } + return this.iconIndex; + } + @Override + public String getTextureFile() { + // TODO Auto-generated method stub + return "/EUIClient/Textures/Items.png"; + } + public String getItemName() + { + return "parts"; + } + + + + public String getItemNameIS(ItemStack par1ItemStack) + { + int var3 = par1ItemStack.getItemDamage(); + switch(var3) + { + case 1: return "Tank"; + case 3: return "Valve"; + case 4: return "Tube"; + case 5: return "Seal"; + case 6: return "Rivits"; + } + return this.getItemName(); + } + public void addCreativeItems(ArrayList itemList) + { + itemList.add(new ItemStack(this, 1,1)); + itemList.add(new ItemStack(this, 1,3)); + itemList.add(new ItemStack(this, 1,4)); + itemList.add(new ItemStack(this, 1,5)); + itemList.add(new ItemStack(this, 1,6)); + + } +} + + + diff --git a/src/common/steampower/SteamPowerMain.java b/src/common/steampower/SteamPowerMain.java new file mode 100644 index 00000000..92cae543 --- /dev/null +++ b/src/common/steampower/SteamPowerMain.java @@ -0,0 +1,121 @@ +package steampower; +import java.io.File; + +import net.minecraft.src.Block; +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; +import net.minecraftforge.common.Configuration; +import steampower.turbine.BlockGenerator; +import steampower.turbine.BlockSteamPiston; +import steampower.turbine.ItemEngine; +import steampower.turbine.TileEntitytopGen; +import universalelectricity.basiccomponents.BasicComponents; +import universalelectricity.network.PacketManager; +import basicpipes.BasicPipesMain; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.Init; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.Mod.PostInit; +import cpw.mods.fml.common.Mod.PreInit; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +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 = "V8") +@NetworkMod(channels = { "SPpack" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class) + +public class SteamPowerMain{ + static Configuration config = new Configuration((new File(cpw.mods.fml.common.Loader.instance().getConfigDir(), "/EUIndustry/SteamPower.cfg"))); + private static int BlockID= configurationProperties(); + public static int EngineItemID; + public static int EngineID; + public static int genID; + public static int genOutput; + public static int steamOutBoiler; + public static int pipeLoss; + public static int boilerHeat; + public static int fireOutput; + public static final String channel = "SPpack"; + public static Block machine = new BlockMachine(BlockID).setBlockName("machine"); + public static Block engine = new BlockSteamPiston(EngineID).setBlockName("SteamEngien"); + public static Block gen = new BlockGenerator(genID).setBlockName("ElecGen"); + public static Item itemEngine = new ItemEngine(EngineItemID).setItemName("SteamEngine"); + @Instance + public static SteamPowerMain instance; + + @SidedProxy(clientSide = "SteamPower.SteamClientProxy", serverSide = "SteamPower.SteamProxy") + public static SteamProxy proxy; + public static String textureFile = "/EUIClient/Textures/"; + public static int configurationProperties() + { + config.load(); + BlockID = Integer.parseInt(config.getOrCreateIntProperty("MachinesID", Configuration.CATEGORY_BLOCK, 3030).value); + EngineItemID = Integer.parseInt(config.getOrCreateIntProperty("EngineItem", Configuration.CATEGORY_ITEM, 30308).value); + EngineID = Integer.parseInt(config.getOrCreateIntProperty("SteamEngineID", Configuration.CATEGORY_BLOCK, 3031).value); + genID = Integer.parseInt(config.getOrCreateIntProperty("ElecGenID", Configuration.CATEGORY_BLOCK, 3032).value); + genOutput = Integer.parseInt(config.getOrCreateIntProperty("genOutputWattsmax", Configuration.CATEGORY_GENERAL, 1000).value); + steamOutBoiler = Integer.parseInt(config.getOrCreateIntProperty("steamOutPerCycle", Configuration.CATEGORY_GENERAL, 10).value); + boilerHeat = Integer.parseInt(config.getOrCreateIntProperty("boilerInKJNeed", Configuration.CATEGORY_GENERAL, 4500).value); + fireOutput = Integer.parseInt(config.getOrCreateIntProperty("fireBoxOutKJMax", Configuration.CATEGORY_GENERAL,250).value); + config.save(); + return BlockID; + } + @PreInit + public void preInit(FMLPreInitializationEvent event) + { + instance = this; + NetworkRegistry.instance().registerGuiHandler(this, this.proxy); + proxy.preInit(); + GameRegistry.registerBlock(machine, ItemMachine.class); + GameRegistry.registerBlock(engine); + GameRegistry.registerBlock(gen); + } + @Init + public void load(FMLInitializationEvent evt) + { + proxy.init(); + GameRegistry.registerTileEntity(TileEntityNuller.class, "EUNuller"); + GameRegistry.registerTileEntity(TileEntitytopGen.class, "gentop"); + //Names............... + LanguageRegistry.addName((new ItemStack(machine, 1, 1)), "Boiler"); + LanguageRegistry.addName((new ItemStack(gen, 1, 0)), "Generator"); + LanguageRegistry.addName((new ItemStack(machine, 1, 2)), "FireBox"); + LanguageRegistry.addName((new ItemStack(itemEngine, 1, 0)), "SteamPiston"); + LanguageRegistry.addName((new ItemStack(machine, 1, 15)), "EUVampire"); + + + } + @PostInit + public void postInit(FMLPostInitializationEvent event) + { + + proxy.postInit(); + //Crafting + /** + * case 0: return new TileEntityGrinder(); <-Removed + case 1: return new TileEntityBoiler(); + case 2: return new TileEntityFireBox(); + case 3: return new TileEntityGenerator(); + case 14: return new TileEntityCondenser();<-Removed + case 15: return new TileEntityNuller();<-Just for testing Not craftable + */ + GameRegistry.addRecipe(new ItemStack(machine, 1, 1), new Object [] {"@T@", "OVO", "@T@", + 'T',new ItemStack(BasicPipesMain.parts, 1,5), + '@',new ItemStack(BasicComponents.itemSteelPlate), + 'O',new ItemStack(BasicPipesMain.parts, 1,1), + 'V',new ItemStack(BasicPipesMain.parts, 1,6)}); + GameRegistry.addRecipe(new ItemStack(machine, 1, 2), new Object [] { "@", "F", + 'F',Block.stoneOvenIdle, + '@',new ItemStack(BasicComponents.itemSteelPlate)}); + GameRegistry.addRecipe(new ItemStack(itemEngine, 1, 0), new Object [] {"@T@", "PMP", "@T@", + 'T',new ItemStack(BasicPipesMain.parts, 1,0), + '@',new ItemStack(BasicComponents.itemSteelPlate), + 'P',Block.pistonBase, + 'M',new ItemStack(BasicComponents.itemMotor)}); + } + +} diff --git a/src/common/steampower/SteamProxy.java b/src/common/steampower/SteamProxy.java new file mode 100644 index 00000000..69b7d6c2 --- /dev/null +++ b/src/common/steampower/SteamProxy.java @@ -0,0 +1,69 @@ +package steampower; + +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.TileEntity; +import net.minecraft.src.World; +import steampower.boiler.ContainerBoiler; +import steampower.boiler.TileEntityBoiler; +import steampower.burner.ContainerFireBox; +import steampower.burner.TileEntityFireBox; +import steampower.turbine.ContainerGenerator; +import steampower.turbine.TileEntityGen; +import steampower.turbine.TileEntitySteamPiston; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.registry.GameRegistry; + +public class SteamProxy implements IGuiHandler{ + + public void preInit() + { + + } + public void init() + { + GameRegistry.registerTileEntity(TileEntityBoiler.class, "boiler"); + GameRegistry.registerTileEntity(TileEntityFireBox.class, "fireBox"); + GameRegistry.registerTileEntity(TileEntitySteamPiston.class, "steamPiston"); + GameRegistry.registerTileEntity(TileEntityGen.class, "elecGen"); + + } + public void postInit() + { + + } + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); + + if (tileEntity != null) + { + switch(ID) + { + case 0: return new GUIFireBox(player.inventory, ((TileEntityFireBox)tileEntity)); + case 1: return new GuiBoiler(player.inventory, ((TileEntityBoiler)tileEntity)); + case 2: return new GUIGenerator(player.inventory, ((TileEntitySteamPiston)tileEntity)); + } + } + + return null; + } + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); + + if (tileEntity != null) + { + switch(ID) + { + case 0: return new ContainerFireBox(player.inventory, ((TileEntityFireBox)tileEntity)); + case 1: return new ContainerBoiler(player.inventory, ((TileEntityBoiler)tileEntity)); + case 2: return new ContainerGenerator(player.inventory, ((TileEntitySteamPiston)tileEntity)); + } + } + + return null; + } +} diff --git a/src/common/steampower/TileEntityMachine.java b/src/common/steampower/TileEntityMachine.java new file mode 100644 index 00000000..206bc85b --- /dev/null +++ b/src/common/steampower/TileEntityMachine.java @@ -0,0 +1,258 @@ +package steampower; + +import com.google.common.io.ByteArrayDataInput; + +import universalelectricity.electricity.TileEntityElectricUnit; +import universalelectricity.extend.IRotatable; +import universalelectricity.network.IPacketReceiver; +import universalelectricity.network.PacketManager; +import net.minecraft.src.*; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.ISidedInventory; +public class TileEntityMachine extends TileEntityElectricUnit implements IInventory, ISidedInventory +{ + public int facing = 0; + private int count = 0; + public ItemStack[] storedItems = new ItemStack[this.getInvSize()]; + public int getTickInterval() + { + return 5; + + } + private int getInvSize() { + return 1; + } + public int getDirection() + { + return this.facing; + } + + public void setDirection(int i) + { + this.facing = i; + } + + @Override + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("facing", this.facing); + //inventory + NBTTagList var2 = new NBTTagList(); + + for (int var3 = 0; var3 < this.storedItems.length; ++var3) + { + if (this.storedItems[var3] != null) + { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte)var3); + this.storedItems[var3].writeToNBT(var4); + var2.appendTag(var4); + } + } + + par1NBTTagCompound.setTag("Items", var2); + } + + @Override + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readFromNBT(par1NBTTagCompound); + //inventory + NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); + this.storedItems = new ItemStack[this.getSizeInventory()]; + + for (int var3 = 0; var3 < var2.tagCount(); ++var3) + { + NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); + byte var5 = var4.getByte("Slot"); + + if (var5 >= 0 && var5 < this.storedItems.length) + { + this.storedItems[var5] = ItemStack.loadItemStackFromNBT(var4); + } + } + //vars + this.facing = par1NBTTagCompound.getInteger("facing"); + } + + @Override + public float electricityRequest() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean canReceiveFromSide(ForgeDirection side) { + // TODO Auto-generated method stub + return false; + } + @Override + public boolean canUpdate() + { + return true; + } + public Object[] getSendData() + { + return new Object[]{}; + } + public int getNumSide(ForgeDirection side) + { + if(side == ForgeDirection.DOWN) + { + return 0; + } + if(side == ForgeDirection.UP) + { + return 1; + } + if(side == ForgeDirection.NORTH) + { + return 2; + } + if(side == ForgeDirection.SOUTH) + { + return 3; + } + if(side == ForgeDirection.WEST) + { + return 4; + } + if(side == ForgeDirection.EAST) + { + return 5; + } + return 0; + } + + public void onUpdate(float watts, float voltage, ForgeDirection side) + { + super.onUpdate(watts, voltage, side); + + if(!worldObj.isRemote) + { + PacketManager.sendTileEntityPacket(this, SteamPowerMain.channel, getSendData()); + } + } + + + ////////////////////////// + //I Inventory shit + ///////////////////////// + public int getSizeInventory() + { + return this.storedItems.length; + } + + /** + * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't + * this more of a set than a get?* + */ + public int getInventoryStackLimit() + { + return 64; + } + + + /** + * Do not make give this method the name canInteractWith because it clashes with Container + */ + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + /** + * Returns the stack in slot i + */ + public ItemStack getStackInSlot(int par1) + { + return this.storedItems[par1]; + } + + public ItemStack decrStackSize(int par1, int par2) + { + if (this.storedItems[par1] != null) + { + ItemStack var3; + + if (this.storedItems[par1].stackSize <= par2) + { + var3 = this.storedItems[par1]; + this.storedItems[par1] = null; + return var3; + } + else + { + var3 = this.storedItems[par1].splitStack(par2); + + if (this.storedItems[par1].stackSize == 0) + { + this.storedItems[par1] = null; + } + + return var3; + } + } + else + { + return null; + } + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - + * like when you close a workbench GUI. + */ + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.storedItems[par1] != null) + { + ItemStack var2 = this.storedItems[par1]; + this.storedItems[par1] = null; + return var2; + } + else + { + return null; + } + } + + /** + * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). + */ + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.storedItems[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + } + @Override + public int getStartInventorySide(ForgeDirection side) { + // TODO Auto-generated method stub + return 0; + } + @Override + public int getSizeInventorySide(ForgeDirection side) { + // TODO Auto-generated method stub + return 0; + } + @Override + public String getInvName() { + // TODO Auto-generated method stub + return "SteamMachine"; + } + @Override + public void openChest() { + // TODO Auto-generated method stub + + } + @Override + public void closeChest() { + // TODO Auto-generated method stub + + } +} \ No newline at end of file diff --git a/src/common/steampower/TileEntityNuller.java b/src/common/steampower/TileEntityNuller.java new file mode 100644 index 00000000..fb48d77f --- /dev/null +++ b/src/common/steampower/TileEntityNuller.java @@ -0,0 +1,29 @@ +package steampower; + +import net.minecraftforge.common.ForgeDirection; +import universalelectricity.extend.IElectricUnit; + +public class TileEntityNuller extends TileEntityMachine implements IElectricUnit { + + public float electricityRequest() + { + return 100; + } + @Override + public boolean canReceiveFromSide(ForgeDirection side) + { + return true; + } + public float getVoltage() + { + return 1000; + } + public int getTickInterval() + { + return 10; + } + public boolean canConnect(ForgeDirection side) + { + return true; + } +} diff --git a/src/common/steampower/ap/IHeatConsumer.java b/src/common/steampower/ap/IHeatConsumer.java new file mode 100644 index 00000000..9f9c25a2 --- /dev/null +++ b/src/common/steampower/ap/IHeatConsumer.java @@ -0,0 +1,22 @@ +package steampower.ap; + +/** + * The IHeatConsumer interface is an interface that must be applied to all tile entities that can receive heat joules. + * @author Darkguardsman code sourced from Calclavia + * + */ +public interface IHeatConsumer +{ + /** + * onRecieveSteam is called whenever a Steam transmitter sends a packet of electricity to the consumer (which is this block). + * @param vol - The amount of steam this block received + * @param side - The side of the block in which the electricity came from. + * @return vol - The amount of rejected steam to be sent to back + */ + public float onReceiveHeat(float jouls, int side); + + /** + * @return Return the stored electricity in this consumer. Called by conductors to spread electricity to this unit. + */ + public float getStoredHeat(); +} \ No newline at end of file diff --git a/src/common/steampower/ap/IHeatProducer.java b/src/common/steampower/ap/IHeatProducer.java new file mode 100644 index 00000000..1c13a5c9 --- /dev/null +++ b/src/common/steampower/ap/IHeatProducer.java @@ -0,0 +1,14 @@ +package steampower.ap; + + +public interface IHeatProducer +{ + /** + * onProduceElectricity is called when a conductor is connected to the producer block in which the conductor will demand power from the producer + * block. + * @param jouls - The maximum jouls can be transfered + * @param side - The side of block in which the conductor is on + * @return jouls - Return jouls to consumer + */ + public float onProduceHeat(float jouls, int side); +} \ No newline at end of file diff --git a/src/common/steampower/boiler/ContainerBoiler.java b/src/common/steampower/boiler/ContainerBoiler.java new file mode 100644 index 00000000..b508543f --- /dev/null +++ b/src/common/steampower/boiler/ContainerBoiler.java @@ -0,0 +1,59 @@ +package steampower.boiler; +import net.minecraft.src.*; + +public class ContainerBoiler extends Container +{ + private TileEntityBoiler boiler; + private int lastCookTime = 0; + private int lastBurnTime = 0; + private int lastItemBurnTime = 0; + + public ContainerBoiler(InventoryPlayer par1InventoryPlayer, TileEntityBoiler par2TileEntityboiler) + { + this.boiler = par2TileEntityboiler; + this.addSlotToContainer(new Slot(par2TileEntityboiler, 0, 56, 17)); + int var3; + + for (var3 = 0; var3 < 3; ++var3) + { + for (int var4 = 0; var4 < 9; ++var4) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + } + } + + for (var3 = 0; var3 < 9; ++var3) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142)); + } + } + + + + public void updateProgressBar(int par1, int par2) + { + if (par1 == 0) + { + // this.boiler.furnaceCookTime = par2; + } + + if (par1 == 1) + { + //this.boiler.boilerRunTime = par2; + } + + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.boiler.isUseableByPlayer(par1EntityPlayer); + } + + /** + * Called to transfer a stack from one inventory to the other eg. when shift clicking. + */ + public ItemStack transferStackInSlot(int par1) + { + return null; + } +} diff --git a/src/common/steampower/boiler/TileEntityBoiler.java b/src/common/steampower/boiler/TileEntityBoiler.java new file mode 100644 index 00000000..84eb4133 --- /dev/null +++ b/src/common/steampower/boiler/TileEntityBoiler.java @@ -0,0 +1,271 @@ +package steampower.boiler; +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; +import net.minecraft.src.NBTTagCompound; +import net.minecraft.src.NetworkManager; +import net.minecraft.src.Packet250CustomPayload; +import net.minecraft.src.TileEntity; +import net.minecraftforge.common.ForgeDirection; +import steampower.SteamPowerMain; +import steampower.TileEntityMachine; +import steampower.burner.TileEntityFireBox; +import universalelectricity.network.IPacketReceiver; +import basicpipes.TradeHelper; +import basicpipes.pipes.api.ILiquidConsumer; +import basicpipes.pipes.api.ILiquidProducer; + +import com.google.common.io.ByteArrayDataInput; + +public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiver,ILiquidProducer, ILiquidConsumer +{ + + /** + * The ItemStacks that hold the items currently being used in the furnace + */ + + + /** The number of ticks that the boiler will keep burning */ + public int RunTime = 0; + /** The ammount of energy stored before being add to run Timer */ + public int energyStore = 0; + /** The ammount of water stored */ + public int waterStored = 0; + /** The ammount of steam stored */ + public int steamStored = 0; + /** The ammount of heat stored */ + public int heatStored = 0; + public int heatMax = 10000; + /** The ammount of heat stored */ + public int hullHeat = 0; + public int hullHeatMax = 4700; + private int heatTick = 0; + public int tankCount = 0; + private int heatNeeded = SteamPowerMain.boilerHeat; // kilo joules + int count = 0; + boolean hullHeated = false; + public TileEntity[] connectedBlocks = {null, null, null, null, null, null}; + int steamMax = 140; + public boolean isBeingHeated = false; + public String getInvName() + { + return "container.boiler"; + } + public Object[] getSendData() + { + return new Object[]{(int)facing,(int)RunTime,(int)energyStore,(int)waterStored, + (int)steamStored,(int)heatStored,(int)hullHeat,(int)heatTick}; + } + + @Override + public void handlePacketData(NetworkManager network, + Packet250CustomPayload packet, EntityPlayer player, + ByteArrayDataInput dataStream) { + try + { + facing = dataStream.readInt(); + RunTime = dataStream.readInt(); + energyStore = dataStream.readInt(); + waterStored = dataStream.readInt(); + steamStored = dataStream.readInt(); + heatStored = dataStream.readInt(); + hullHeat = dataStream.readInt(); + heatTick = dataStream.readInt(); + } + catch(Exception e) + { + e.printStackTrace(); + } + + } + /** + * Reads a tile entity from NBT. + */ + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readFromNBT(par1NBTTagCompound); + this.RunTime = par1NBTTagCompound.getShort("BurnTime"); + this.energyStore = par1NBTTagCompound.getInteger("energyStore"); + this.steamStored = par1NBTTagCompound.getInteger("steamStore"); + this.heatStored = par1NBTTagCompound.getInteger("heatStore"); + this.waterStored = par1NBTTagCompound.getInteger("waterStore"); + this.hullHeat = par1NBTTagCompound.getInteger("hullHeat"); + } + + /** + * Writes a tile entity to NBT. + */ + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeToNBT(par1NBTTagCompound); + par1NBTTagCompound.setShort("BurnTime", (short)this.RunTime); + par1NBTTagCompound.setInteger("energyStore", (int)this.energyStore); + par1NBTTagCompound.setInteger("steamStore", (int)this.steamStored); + par1NBTTagCompound.setInteger("heatStore", (int)this.heatStored); + par1NBTTagCompound.setInteger("waterStore", (int)this.waterStored); + par1NBTTagCompound.setInteger("hullHeat", (int)this.hullHeat); + + } + /** + * 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. + */ + @Override + public void onUpdate(float watts, float voltage, ForgeDirection side) + { + + //update/resets connection list + TileEntity[] entityList = TradeHelper.getSourounding(this); + tankCount = 0; + for(int c = 0; c< 6; c++) + { + if(entityList[c] instanceof TileEntityBoiler) + { + connectedBlocks[c] = entityList[c]; + if(c != 0 && c != 1) + { + tankCount++; + } + } + else + { + connectedBlocks[c] = null; + } + } + + hullHeated = false; + if(hullHeat >= hullHeatMax) + { + hullHeated = true; + } + else + { + if(!worldObj.isRemote) + { + hullHeat = Math.min(hullHeat + heatStored, hullHeatMax); + } + } + if(!worldObj.isRemote) + { + emptyBuckets();//adds water from container slot + this.waterStored = TradeHelper.shareLiquid(this, 1, false); + this.steamStored = TradeHelper.shareLiquid(this, 0, true); + if(waterStored > 0 && hullHeated && heatStored > heatNeeded) + { + heatStored = Math.max(heatStored - heatNeeded, 0); + --waterStored; + steamStored = Math.min(steamStored + SteamPowerMain.steamOutBoiler,this.steamMax); + } + TileEntity blockE = worldObj.getBlockTileEntity(xCoord, yCoord -1, zCoord); + this.isBeingHeated = false; + if(blockE instanceof TileEntityFireBox) + { + this.isBeingHeated = true; + heatStored = (int) Math.min((heatStored + ((TileEntityFireBox)blockE).onProduceHeat(SteamPowerMain.fireOutput*getTickInterval(), 1)), heatMax); + } + } + super.onUpdate(watts, voltage, side); + } + private void emptyBuckets() + { + if (storedItems[0] != null) + { + if(storedItems[0].isItemEqual(new ItemStack(Item.bucketWater,1))) + { + if((int)waterStored < getLiquidCapacity(1)) + { + ++waterStored; + this.storedItems[0] = new ItemStack(Item.bucketEmpty,1); + this.onInventoryChanged(); + } + } + } + + } + public int precentHeated() { + int var1 = 0; + if(hullHeat < 100) + { + var1 = (int)(100 *(hullHeat/hullHeatMax)); + } + else + { + var1 = 100; + } + return var1; + } + @Override + public int onReceiveLiquid(int type, int vol, ForgeDirection side) { + if(type == 0) + { + int rejectedSteam = Math.max((this.steamStored + vol) - this.getLiquidCapacity(0), 0); + this.steamStored += vol - rejectedSteam; + return rejectedSteam; + } + if(type == 1) + { + int rejectedWater = Math.max((this.waterStored + vol) - this.getLiquidCapacity(1), 0); + this.waterStored += vol - rejectedWater; + return rejectedWater; + } + return vol; + } + + @Override + public boolean canRecieveLiquid(int type,ForgeDirection side) { + if(type == 1) + { + return true; + } + return false; + } + + @Override + public int getStoredLiquid(int type) { + if(type == 1) + { + return this.waterStored; + } + if(type == 0) + { + return this.steamStored; + } + return 0; + } + + @Override + public int getLiquidCapacity(int type) { + if(type ==1) + { + return 14; + } + if(type == 0) + { + return steamMax; + } + return 0; + } + @Override + public int onProduceLiquid(int type, int maxVol, ForgeDirection side) { + if(type == 0) + { + if(steamStored > 1) + { + this.steamStored -= 1; + return 1; + } + } + return 0; + } + + @Override + public boolean canProduceLiquid(int type, ForgeDirection side) { + if(type == 0) + { + return true; + } + return false; + } + + + } diff --git a/src/common/steampower/burner/ContainerFireBox.java b/src/common/steampower/burner/ContainerFireBox.java new file mode 100644 index 00000000..19b934ec --- /dev/null +++ b/src/common/steampower/burner/ContainerFireBox.java @@ -0,0 +1,42 @@ +package steampower.burner; + +import net.minecraft.src.*; + +public class ContainerFireBox extends Container +{ + private TileEntityFireBox tileEntity; + + public ContainerFireBox(InventoryPlayer par1InventoryPlayer, TileEntityFireBox tileEntity) + { + this.tileEntity = tileEntity; + this.addSlotToContainer(new Slot(tileEntity, 0, 33, 34)); + int var3; + + for (var3 = 0; var3 < 3; ++var3) + { + for (int var4 = 0; var4 < 9; ++var4) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + } + } + + for (var3 = 0; var3 < 9; ++var3) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142)); + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.tileEntity.isUseableByPlayer(par1EntityPlayer); + } + + /** + * Called to transfer a stack from one inventory to the other eg. when shift clicking. + */ + public ItemStack transferStackInSlot(int par1) + { + + return null; + } +} diff --git a/src/common/steampower/burner/TileEntityFireBox.java b/src/common/steampower/burner/TileEntityFireBox.java new file mode 100644 index 00000000..cf2b74c6 --- /dev/null +++ b/src/common/steampower/burner/TileEntityFireBox.java @@ -0,0 +1,203 @@ +package steampower.burner; + +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.IInventory; +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; +import net.minecraft.src.NBTTagCompound; +import net.minecraft.src.NetworkManager; +import net.minecraft.src.Packet250CustomPayload; +import net.minecraft.src.TileEntity; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.ISidedInventory; +import steampower.SteamPowerMain; +import steampower.TileEntityMachine; +import steampower.ap.IHeatProducer; +import steampower.boiler.TileEntityBoiler; +import universalelectricity.network.IPacketReceiver; +import basicpipes.TradeHelper; + +import com.google.common.io.ByteArrayDataInput; + +public class TileEntityFireBox extends TileEntityMachine implements IPacketReceiver,IInventory, ISidedInventory, IHeatProducer +{ + //max heat generated per second + + public boolean isConnected = false; + public TileEntity[] connectedBlocks = {null, null, null, null, null, null}; + private int connectedUnits = 0; + public static int maxGenerateRate = 250; + //Current generation rate based on hull heat. In TICKS. + public int generateRate = 0; + int count = 0; + public int itemCookTime = 0; + private int getInvSize() { + return 1; + } + public int getTickInterval() + { + return 5; + + } + public void onUpdate(float watts, float voltage, ForgeDirection side) + { + super.onUpdate(watts, voltage, side); + addConnection(); + if(!worldObj.isRemote) + { + sharCoal(); + } + TileEntity blockEntity = worldObj.getBlockTileEntity(this.xCoord, this.yCoord + 1, this.zCoord); + if(blockEntity instanceof TileEntityBoiler) + { + isConnected = true; + } + else + { + isConnected = false; + } + if (!this.worldObj.isRemote){ + + + maxGenerateRate = SteamPowerMain.fireOutput + (connectedUnits*5); + + //The top slot is for recharging items. Check if the item is a electric item. If so, recharge it. + if (this.storedItems[0] != null && isConnected) + { + if (this.storedItems[0].getItem().shiftedIndex == Item.coal.shiftedIndex) + { + if(this.itemCookTime <= 0) + { + itemCookTime = Math.max(1600 - (int)(this.generateRate*20), 400); + this.decrStackSize(0, 1); + } + } + } + + } + //Starts generating electricity if the device is heated up + if (this.itemCookTime > 0) + { + this.itemCookTime --; + if(isConnected) + { + this.generateRate = Math.min(this.generateRate+Math.min((this.generateRate)+1, 1), this.maxGenerateRate/20); + } + } + //Loose heat when the generator is not connected or if there is no coal in the inventory. + if(this.itemCookTime <= 0 || !isConnected) + { + this.generateRate = Math.max(this.generateRate-5, 0); + } + } + + //gets all connected fireBoxes and shares its supply of coal + public void sharCoal(){ + for(int i =0; i<6;i++) + { + + if(connectedBlocks[i] instanceof TileEntityFireBox) + { + TileEntityFireBox connectedConsumer = (TileEntityFireBox) connectedBlocks[i]; + if(this.storedItems[0] != null) + { + if(this.storedItems[0].getItem().shiftedIndex == Item.coal.shiftedIndex && this.storedItems[0].stackSize > 0) + { + if(connectedConsumer.storedItems[0] != null) + { + if(connectedConsumer.storedItems[0].getItem().shiftedIndex == Item.coal.shiftedIndex) + { + if(connectedConsumer.storedItems[0].getItem().shiftedIndex == Item.coal.shiftedIndex) + { + int CSum = Math.round(this.storedItems[0].stackSize + connectedConsumer.storedItems[0].stackSize)/2; + if(this.storedItems[0].stackSize > connectedConsumer.storedItems[0].stackSize) + { + int transferC = 0; + transferC = Math.round(CSum - connectedConsumer.storedItems[0].stackSize); + connectedConsumer.storedItems[0].stackSize = connectedConsumer.storedItems[0].stackSize + transferC; + this.storedItems[0].stackSize = this.storedItems[0].stackSize - transferC; + } + } + } + } + else + { + connectedConsumer.storedItems[0] = new ItemStack(this.storedItems[0].getItem()); + this.storedItems[0].stackSize -= 1; + } + } + } + } + } + + + } + public void addConnection() + { + connectedUnits = 0; + TileEntity[] aEntity = TradeHelper.getSourounding(this); + for(int i = 0; i<6; i++) + { + + + if(aEntity[i] instanceof TileEntityFireBox && i != 0 && i != 1) + { + this.connectedBlocks[i] = aEntity[i]; + connectedUnits += 1; + } + else + { + this.connectedBlocks[i] = null; + } + } + } + /** + * Reads a tile entity from NBT. + */ + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readFromNBT(par1NBTTagCompound); + this.itemCookTime = par1NBTTagCompound.getInteger("itemCookTime"); + this.generateRate = par1NBTTagCompound.getInteger("generateRate"); + } + /** + * Writes a tile entity to NBT. + */ + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("itemCookTime", (int)this.itemCookTime); + par1NBTTagCompound.setInteger("generateRate", (int)this.generateRate); + } + @Override + public String getInvName() { + return "FireBox"; + } + public float onProduceHeat(float jouls, int side) { + // TODO Auto-generated method stub + return Math.min(generateRate*getTickInterval(),jouls); + } + @Override + public Object[] getSendData() + { + return new Object[]{(int)facing,(int)connectedUnits,(int)generateRate,(int)itemCookTime}; + } + + @Override + public void handlePacketData(NetworkManager network, + Packet250CustomPayload packet, EntityPlayer player, + ByteArrayDataInput dataStream) { + try + { + facing = dataStream.readInt(); + connectedUnits = dataStream.readInt(); + generateRate = dataStream.readInt(); + itemCookTime = dataStream.readInt(); + } + catch(Exception e) + { + e.printStackTrace(); + } + + } +} diff --git a/src/common/steampower/turbine/BlockGenerator.java b/src/common/steampower/turbine/BlockGenerator.java new file mode 100644 index 00000000..2575f7d1 --- /dev/null +++ b/src/common/steampower/turbine/BlockGenerator.java @@ -0,0 +1,42 @@ +package steampower.turbine; + +import java.util.ArrayList; + +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.ItemStack; +import net.minecraft.src.Material; +import net.minecraft.src.TileEntity; +import net.minecraft.src.World; + +public class BlockGenerator extends universalelectricity.extend.BlockMachine { + + public BlockGenerator(int id) { + super("Generator", id, Material.iron); + this.setCreativeTab(CreativeTabs.tabBlock); + } + @Override + public void addCreativeItems(ArrayList itemList) + { + itemList.add(new ItemStack(this, 1,0)); + } + @Override + public boolean isOpaqueCube() + { + return false; + } + @Override + public boolean renderAsNormalBlock() + { + return false; + } + @Override + public int getRenderType() + { + return -1; + } + @Override + public TileEntity createNewTileEntity(World world) + { + return new TileEntityGen(); + } +} diff --git a/src/common/steampower/turbine/BlockSteamPiston.java b/src/common/steampower/turbine/BlockSteamPiston.java new file mode 100644 index 00000000..e7be1d43 --- /dev/null +++ b/src/common/steampower/turbine/BlockSteamPiston.java @@ -0,0 +1,158 @@ +package steampower.turbine; + +import java.util.Random; + +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 steampower.SteamPowerMain; +import steampower.TileEntityMachine; + +public class BlockSteamPiston extends universalelectricity.extend.BlockMachine{ + + public BlockSteamPiston(int par1) { + super("SteamEngine", par1, Material.iron); + + } + @Override + public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer) + { + if (par1World.isRemote) + { + return true; + } + else + { + TileEntity blockEntity = (TileEntity)par1World.getBlockTileEntity(x, y, z); + + if (blockEntity != null) + { + + if(blockEntity instanceof TileEntitySteamPiston) + { + par5EntityPlayer.openGui(SteamPowerMain.instance, 2, par1World, x, y, z); + } + if(blockEntity instanceof TileEntitytopGen) + { + par5EntityPlayer.openGui(SteamPowerMain.instance, 2, par1World, x, y-1, z); + } + } + return true; + } + } + @Override + public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLiving par5EntityLiving) + { + int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int metadata = par1World.getBlockMetadata(x, y, z); + TileEntityMachine tileEntity = (TileEntityMachine)par1World.getBlockTileEntity(x, y, z); + + switch (angle) + { + case 0: tileEntity.setDirection(1); break; + case 1: tileEntity.setDirection(2); break; + case 2: tileEntity.setDirection(3); break; + case 3: tileEntity.setDirection(4); break; + } + } + public TileEntity createNewTileEntity(World var1) + { + return null; + } + public void breakBlock(World world, int x, int y, int z,int par5, int par6) + { + super.breakBlock(world, x, y, z, par5, par6); + int meta = world.getBlockMetadata(x, y, z); + if(meta < 4) + { + if(world.getBlockId(x, y+1, z) == this.blockID) + { + if(world.getBlockMetadata(x, y, z)> 4) + { + world.setBlockAndMetadataWithUpdate(x, y, z, 0, 0, true); + } + } + } + else + if(meta > 4) + { + if(world.getBlockId(x, y-1, z) == this.blockID) + { + if(world.getBlockMetadata(x, y, z)< 4) + { + world.setBlockAndMetadataWithUpdate(x, y, z, 0, 0, true); + } + } + } + } + @Override + public boolean isOpaqueCube() + { + return false; + } + @Override + public boolean renderAsNormalBlock() + { + return false; + } + @Override + public int getRenderType() + { + return -1; + } + @Override + public TileEntity createNewTileEntity(World world, int metadata) + { + if(metadata < 4) + { + return new TileEntitySteamPiston(); + } + if(metadata == 14) + { + return new TileEntitytopGen(); + } + return null; + } + public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) + { + int meta = par1World.getBlockMetadata(par2, par3, par4); + boolean var7 = false; + if (meta == 1) + { + if (par1World.getBlockId(par2, par3 + 1, par4) != this.blockID) + { + par1World.setBlockWithNotify(par2, par3, par4, 0); + var7 = true; + } + } + else + { + if (par1World.getBlockId(par2, par3 - 1, par4) != this.blockID) + { + par1World.setBlockWithNotify(par2, par3, par4, 0); + } + } + if (var7) + { + if (!par1World.isRemote) + { + this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0); + } + } + } + @Override + public int idDropped(int par1, Random par2Random, int par3) + { + return SteamPowerMain.itemEngine.shiftedIndex; + } + @Override + public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) + { + int var5 = par1World.getBlockId(par2, par3, par4); + int var6 = par1World.getBlockId(par2, par3+1, par4); + return (var5 == 0 || blocksList[var5].blockMaterial.isGroundCover()) && (var6 == 0 || blocksList[var6].blockMaterial.isGroundCover()); + } +} diff --git a/src/common/steampower/turbine/ContainerGenerator.java b/src/common/steampower/turbine/ContainerGenerator.java new file mode 100644 index 00000000..ac9dbfc4 --- /dev/null +++ b/src/common/steampower/turbine/ContainerGenerator.java @@ -0,0 +1,45 @@ +package steampower.turbine; + +import net.minecraft.src.Container; +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.InventoryPlayer; +import net.minecraft.src.ItemStack; +import net.minecraft.src.Slot; + +public class ContainerGenerator extends Container +{ + private TileEntitySteamPiston tileEntity; + + public ContainerGenerator(InventoryPlayer par1InventoryPlayer, TileEntitySteamPiston tileEntity) + { + this.tileEntity = tileEntity; + this.addSlotToContainer(new Slot(tileEntity, 0, 33, 34)); + int var3; + + for (var3 = 0; var3 < 3; ++var3) + { + for (int var4 = 0; var4 < 9; ++var4) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + } + } + + for (var3 = 0; var3 < 9; ++var3) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142)); + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.tileEntity.isUseableByPlayer(par1EntityPlayer); + } + + /** + * Called to transfer a stack from one inventory to the other eg. when shift clicking. + */ + public ItemStack transferStackInSlot(int par1) + { + return null; + } +} diff --git a/src/common/steampower/turbine/ItemEngine.java b/src/common/steampower/turbine/ItemEngine.java new file mode 100644 index 00000000..364e5863 --- /dev/null +++ b/src/common/steampower/turbine/ItemEngine.java @@ -0,0 +1,62 @@ +package steampower.turbine; +import java.util.List; + +import net.minecraft.src.Block; +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; +import net.minecraft.src.MathHelper; +import net.minecraft.src.World; +import steampower.SteamPowerMain; + +public class ItemEngine extends Item +{ + public ItemEngine(int par1) + { + super(par1); + this.maxStackSize = 5; + this.setTabToDisplayOn(CreativeTabs.tabBlock); + this.setIconIndex(21); + } + @Override + public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + par3List.add(new ItemStack(this, 1, 0)); + } + @Override + public String getTextureFile() { + // TODO Auto-generated method stub + return "/EUIClient/Textures/Items.png"; + } + @Override + public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer ePlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par3World.isRemote) + { + return false; + } + + Block var11 = SteamPowerMain.engine; + int angle = MathHelper.floor_double((ePlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + if (ePlayer.canPlayerEdit(par4, par5, par6)) + { + ++par5; + if (var11.canPlaceBlockAt(par3World, par4, par5, par6)) + { + par3World.editingBlocks = true; + par3World.setBlockAndMetadataWithNotify(par4, par5, par6, var11.blockID, 1); + par3World.notifyBlocksOfNeighborChange(par4, par5, par6, var11.blockID); + par3World.setBlockAndMetadataWithNotify(par4, par5+1, par6, var11.blockID, 14); + par3World.notifyBlocksOfNeighborChange(par4, par5, par6, var11.blockID); + ePlayer.sendChatToPlayer(""+par3World.getBlockMetadata(par4, par5, par6)); + par3World.editingBlocks = false; + --par1ItemStack.stackSize; + return true; + } + } + + return false; + } +} diff --git a/src/common/steampower/turbine/TileEntityGen.java b/src/common/steampower/turbine/TileEntityGen.java new file mode 100644 index 00000000..0817f203 --- /dev/null +++ b/src/common/steampower/turbine/TileEntityGen.java @@ -0,0 +1,62 @@ +package steampower.turbine; + +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.NetworkManager; +import net.minecraft.src.Packet250CustomPayload; +import net.minecraftforge.common.ForgeDirection; +import steampower.TileEntityMachine; +import universalelectricity.extend.IElectricUnit; +import universalelectricity.network.IPacketReceiver; + +import com.google.common.io.ByteArrayDataInput; + +public class TileEntityGen extends TileEntityMachine implements IPacketReceiver,IElectricUnit +{ + + @Override + public void handlePacketData(NetworkManager network, + Packet250CustomPayload packet, EntityPlayer player, + ByteArrayDataInput dataStream) { + // TODO Auto-generated method stub + + } + public void onUpdate(float watts, float voltage, ForgeDirection side) + { + super.onUpdate(watts, voltage, side); + if(!worldObj.isRemote) + { + + } + } + + + public float electricityRequest() + { + return 0; + + } + public boolean canConnect(ForgeDirection side) + { + int face = this.facing; + if(side != ForgeDirection.UP && side != ForgeDirection.DOWN) + { + return true; + } + return false; + + } + public boolean canReceiveFromSide(ForgeDirection side) + { + return false; + } + public float getVoltage() + { + return 120; + } + + public int getTickInterval() + { + return 10; + } + +} diff --git a/src/common/steampower/turbine/TileEntitySteamPiston.java b/src/common/steampower/turbine/TileEntitySteamPiston.java new file mode 100644 index 00000000..510f269f --- /dev/null +++ b/src/common/steampower/turbine/TileEntitySteamPiston.java @@ -0,0 +1,405 @@ +package steampower.turbine; + +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.IInventory; +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; +import net.minecraft.src.NBTTagCompound; +import net.minecraft.src.NBTTagList; +import net.minecraft.src.NetworkManager; +import net.minecraft.src.Packet250CustomPayload; +import net.minecraft.src.TileEntity; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.ISidedInventory; +import steampower.SteamPowerMain; +import steampower.TileEntityMachine; +import universalelectricity.Vector3; +import universalelectricity.electricity.ElectricityManager; +import universalelectricity.extend.IElectricUnit; +import universalelectricity.extend.TileEntityConductor; +import universalelectricity.network.IPacketReceiver; +import basicpipes.pipes.api.ILiquidConsumer; +import basicpipes.pipes.api.ILiquidProducer; + +import com.google.common.io.ByteArrayDataInput; + +public class TileEntitySteamPiston extends TileEntityMachine implements IPacketReceiver, IElectricUnit,ILiquidConsumer,ILiquidProducer, IInventory, ISidedInventory +{ + //Maximum possible generation rate of watts in SECONDS + public int maxGenerateRate = 1000; + public int waterStored = 0; + public int steamStored = 0; + public int steamConsumed = 0; + public float position = 0; + public int count = 0; + //Current generation rate based on hull heat. In TICKS. + public float generateRate = 0; + //public TileEntityConductor connectedWire = null; + /** + * The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for + */ + public int genTime = 0; + /** + * 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. + */ + public void onUpdate(float watts, float voltage, ForgeDirection side) + { + super.onUpdate(watts, voltage, side); + count++; + float cPercent = (generateRate/10); + int cCount = 1; + if(cPercent > 25f) + { + cCount = 2; + } + if(cPercent > 50f) + { + cCount = 3; + } + if(cPercent > 75f) + { + cCount = 4; + } + if(generateRate > 0) + { + + if(position < 9f && posT ) + { + position+= cCount; + } + else + { + posT = false; + } + if(position > 1f && !posT ) + { + position-= cCount; + } + else + { + posT = true; + } + count =0; + } + TileEntity ent = worldObj.getBlockTileEntity(xCoord, yCoord+1, zCoord); + if(ent instanceof TileEntitytopGen) + { + 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.getUEUnitFromSide(this.worldObj, new Vector3(this.xCoord, this.yCoord, this.zCoord), + ForgeDirection.getOrientation(i)); + if (tileEntity instanceof TileEntityConductor) + { + if (ElectricityManager.electricityRequired(((TileEntityConductor)tileEntity).connectionID) > 0) + { + this.connectedElectricUnit = (TileEntityConductor)tileEntity; + } + } + } + + if(!this.worldObj.isRemote) + { + + + if(!this.isDisabled()) + { + //Adds time to runTime by consuming steam + if(this.genTime <= 0) + { + if(steamStored > 0) + { + --steamStored; + ++steamConsumed; + if(steamConsumed >= SteamPowerMain.steamOutBoiler) + { + ++waterStored; + steamConsumed = 0; + } + genTime += 65; + } + } + + //Empties water from tank to buckets + if (this.containingItems[0] != null) + { + if(this.containingItems[0].getItem().shiftedIndex == Item.bucketEmpty.shiftedIndex) + { + if(this.waterStored > 0) + { + this.containingItems[0] = new ItemStack(Item.bucketWater,1); + --waterStored; + } + } + } + + //Starts generating electricity if the device is heated up + if (this.genTime > 0) + { + 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) + { + this.generateRate = (float)Math.max(this.generateRate-0.05, 0); + } + + if(this.generateRate > 1) + { + ElectricityManager.produceElectricity(this.connectedElectricUnit, this.generateRate*this.getTickInterval(), this.getVoltage()); + } + } + } + } + /** + * Reads a tile entity from NBT. + */ + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readFromNBT(par1NBTTagCompound); + this.genTime = par1NBTTagCompound.getInteger("itemCookTime"); + this.waterStored = par1NBTTagCompound.getInteger("waterStored"); + this.steamConsumed = par1NBTTagCompound.getInteger("steamConsumed"); + this.steamStored = par1NBTTagCompound.getInteger("steamStored"); + this.generateRate = par1NBTTagCompound.getFloat("generateRate"); + NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); + this.containingItems = new ItemStack[this.getSizeInventory()]; + for (int var3 = 0; var3 < var2.tagCount(); ++var3) + { + NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); + byte var5 = var4.getByte("Slot"); + if (var5 >= 0 && var5 < this.containingItems.length) + { + this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4); + } + } + } + /** + * Writes a tile entity to NBT. + */ + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("itemCookTime", (int)this.genTime); + par1NBTTagCompound.setInteger("waterStored", (int)this.waterStored); + par1NBTTagCompound.setInteger("steamConsumed", (int)this.steamConsumed); + par1NBTTagCompound.setInteger("steamStored", (int)this.steamStored); + par1NBTTagCompound.setFloat("generateRate", (int)this.generateRate); + NBTTagList var2 = new NBTTagList(); + for (int var3 = 0; var3 < this.containingItems.length; ++var3) + { + if (this.containingItems[var3] != null) + { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte)var3); + this.containingItems[var3].writeToNBT(var4); + var2.appendTag(var4); + } + } + par1NBTTagCompound.setTag("Items", var2); + } + @Override + public int getStartInventorySide(ForgeDirection side) + { + return 0; + } + @Override + public int getSizeInventorySide(ForgeDirection side) { return 0; } + @Override + public int getSizeInventory() { return this.containingItems.length; } + @Override + public ItemStack getStackInSlot(int par1) { return this.containingItems[par1]; } + @Override + public ItemStack decrStackSize(int par1, int par2) + { + if (this.containingItems[par1] != null) + { + ItemStack var3; + if (this.containingItems[par1].stackSize <= par2) + { + var3 = this.containingItems[par1]; + this.containingItems[par1] = null; + return var3; + } + else + { + var3 = this.containingItems[par1].splitStack(par2); + if (this.containingItems[par1].stackSize == 0) + { + this.containingItems[par1] = null; + } + return var3; + } + } + else + { + return null; + } + } + @Override + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.containingItems[par1] != null) + { + ItemStack var2 = this.containingItems[par1]; + this.containingItems[par1] = null; + return var2; + } + else + { + return null; + } + } + @Override + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.containingItems[par1] = par2ItemStack; + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + } + @Override + public String getInvName() { + return "SteamGen"; + } + @Override + public int getInventoryStackLimit() + { + return 64; + } + @Override + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + @Override + public void openChest() { } + @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(int type, int Vol, ForgeDirection side) { + if(type == 1) + { + if(this.waterStored > 0) + { + int rejectedSteam = Math.max(Math.max((this.waterStored - Vol), 0),waterStored); + this.waterStored += waterStored - rejectedSteam; + return rejectedSteam; + } + } + return 0; + } + + @Override + public boolean canProduceLiquid(int type, ForgeDirection side) { + if(type == 1) + { + return true; + } + return false; + } + + @Override + public int onReceiveLiquid(int type, int vol, ForgeDirection side) { + if(type == 0) + { + int rejectedSteam = Math.max((this.steamStored + vol) - 100, 0); + this.steamStored += vol - rejectedSteam; + return rejectedSteam; + } + return vol; + } + + @Override + public boolean canRecieveLiquid(int type, ForgeDirection side) { + if(type == 0) + { + return true; + } + return false; + } + + @Override + public int getStoredLiquid(int type) { + if(type == 0) + { + return this.steamStored; + } + return 0; + } + + @Override + public int getLiquidCapacity(int type) { + if(type == 0) + { + return 100; + } + return 0; + } + @Override + public Object[] getSendData() + { + return new Object[]{(int)facing,(int)waterStored,(int)steamStored,(int)steamConsumed,(float)generateRate,(int)genTime}; + } + + @Override + public void handlePacketData(NetworkManager network, + Packet250CustomPayload packet, EntityPlayer player, + ByteArrayDataInput dataStream) { + try + { + facing = dataStream.readInt(); + waterStored = dataStream.readInt(); + steamStored = dataStream.readInt(); + steamConsumed = dataStream.readInt(); + generateRate = dataStream.readFloat(); + genTime = dataStream.readInt(); + } + catch(Exception e) + { + e.printStackTrace(); + } + + } +} diff --git a/src/common/steampower/turbine/TileEntitytopGen.java b/src/common/steampower/turbine/TileEntitytopGen.java new file mode 100644 index 00000000..ac0eb25c --- /dev/null +++ b/src/common/steampower/turbine/TileEntitytopGen.java @@ -0,0 +1,60 @@ +package steampower.turbine; + +import net.minecraft.src.TileEntity; +import net.minecraftforge.common.ForgeDirection; +import steampower.TileEntityMachine; +import universalelectricity.extend.IElectricUnit; +import basicpipes.pipes.api.ILiquidConsumer; +import basicpipes.pipes.api.ILiquidProducer; + +public class TileEntitytopGen extends TileEntityMachine implements IElectricUnit,ILiquidConsumer,ILiquidProducer { +public TileEntitySteamPiston genB = null; + public void onUpdate(float watts, float voltage, ForgeDirection side) + { + if(!this.worldObj.isRemote) + { + super.onUpdate(watts, voltage, side); + TileEntity ent = worldObj.getBlockTileEntity(xCoord, yCoord-1, xCoord); + if(ent instanceof TileEntitySteamPiston) + { + genB = (TileEntitySteamPiston)ent; + } + } + } + @Override + public int onProduceLiquid(int type, int maxVol, ForgeDirection side) { + // TODO Auto-generated method stub + return genB !=null ? genB.onProduceLiquid(type, maxVol, side) : 0; + } + + @Override + public boolean canProduceLiquid(int type, ForgeDirection side) { + // TODO Auto-generated method stub + return genB !=null ? genB.canProduceLiquid(type, side) : false; + } + + @Override + public int onReceiveLiquid(int type, int vol, ForgeDirection side) { + // TODO Auto-generated method stub + return genB !=null ? genB.onReceiveLiquid(type, vol, side) : vol; + } + + @Override + public boolean canRecieveLiquid(int type, ForgeDirection side) { + // TODO Auto-generated method stub + return genB !=null ? genB.canRecieveLiquid(type, side): false; + } + + @Override + public int getStoredLiquid(int type) { + // TODO Auto-generated method stub + return genB !=null ? genB.getStoredLiquid(type): 0; + } + + @Override + public int getLiquidCapacity(int type) { + // TODO Auto-generated method stub + return genB !=null ? genB.getLiquidCapacity(type): 0; + } + +} diff --git a/src/minecraft/steampower/GUIFireBox.java b/src/minecraft/steampower/GUIFireBox.java new file mode 100644 index 00000000..71b1253e --- /dev/null +++ b/src/minecraft/steampower/GUIFireBox.java @@ -0,0 +1,92 @@ +package steampower; + +import java.text.DecimalFormat; + +import net.minecraft.src.GuiContainer; +import net.minecraft.src.InventoryPlayer; +import net.minecraft.src.Item; +import net.minecraft.src.StatCollector; + +import org.lwjgl.opengl.GL11; + +import steampower.burner.ContainerFireBox; +import steampower.burner.TileEntityFireBox; + +public class GUIFireBox extends GuiContainer +{ + private TileEntityFireBox tileEntity; + + private int containerWidth; + private int containerHeight; + + public GUIFireBox(InventoryPlayer par1InventoryPlayer, TileEntityFireBox tileEntity) + { + super(new ContainerFireBox(par1InventoryPlayer, tileEntity)); + this.tileEntity = tileEntity; + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + protected void drawGuiContainerForegroundLayer() + { + this.fontRenderer.drawString("FireBox", 55, 6, 4210752); + this.fontRenderer.drawString("HeatOut", 90, 33, 4210752); + String displayText = ""; + if(!tileEntity.isConnected) + { + displayText = "No Boiler"; + } + else if(tileEntity.storedItems[0] != null) + { + if(tileEntity.storedItems[0].getItem().shiftedIndex != Item.coal.shiftedIndex) + { + displayText = "No Fuel"; + } + else{ + if(tileEntity.generateRate*20 < 20) + { + displayText = "Hull Heat: "+(tileEntity.generateRate*100)+"%"; + } + else + { + displayText = getWattDisplay((tileEntity.generateRate*20)); + } + } + } + this.fontRenderer.drawString(displayText, (int)(105-displayText.length()*1.25), 45, 4210752); + this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + int var4 = this.mc.renderEngine.getTexture(SteamPowerMain.textureFile+"SteamGUI.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(var4); + containerWidth = (this.width - this.xSize) / 2; + containerHeight = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize); + } + public static String getWattDisplay(int watts) + { + String displayWatt; + if(watts > 1000) + { + displayWatt = roundTwoDecimals((double)watts/1000)+" MJ"; + } + else + { + displayWatt = watts+" KJ"; + } + + return displayWatt; + } + public static double roundTwoDecimals(double d) + { + DecimalFormat twoDForm = new DecimalFormat("#.##"); + return Double.valueOf(twoDForm.format(d)); + } +} diff --git a/src/minecraft/steampower/GUIGenerator.java b/src/minecraft/steampower/GUIGenerator.java new file mode 100644 index 00000000..3680d240 --- /dev/null +++ b/src/minecraft/steampower/GUIGenerator.java @@ -0,0 +1,80 @@ +package steampower; + +import net.minecraft.src.GuiContainer; +import net.minecraft.src.InventoryPlayer; +import net.minecraft.src.StatCollector; + +import org.lwjgl.opengl.GL11; + +import steampower.turbine.ContainerGenerator; +import steampower.turbine.TileEntitySteamPiston; + + public class GUIGenerator extends GuiContainer + { + private TileEntitySteamPiston tileEntity; + + private int containerWidth; + private int containerHeight; + + public GUIGenerator(InventoryPlayer par1InventoryPlayer, TileEntitySteamPiston tileEntity) + { + super(new ContainerGenerator(par1InventoryPlayer, tileEntity)); + this.tileEntity = tileEntity; + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + protected void drawGuiContainerForegroundLayer() + { + this.fontRenderer.drawString("Steam Engine MkI", 55, 6, 4210752); + this.fontRenderer.drawString("MeterReadings", 90, 33, 4210752); + String displayText = ""; + String displayText2 = ""; + String displayText3 = ""; + if(tileEntity.connectedElectricUnit == null) + { + displayText = "Not Connected"; + } + else + if(tileEntity.generateRate*20 <= 0) + { + if(tileEntity.steamStored> 0) + { + displayText = "Power Full"; + } + if(tileEntity.steamStored<= 0) + { + displayText = "No Steam"; + } + } + + else if(tileEntity.generateRate*20 < 20) + { + displayText = "Warming UP: "+(int)(tileEntity.generateRate*100)+"%"; + } + else + { + displayText = universalelectricity.UniversalElectricity.getWattDisplay((int)(tileEntity.generateRate*20)); + } + displayText2 = "water" + "-" + tileEntity.waterStored; + displayText3 = "steam" + "-" + tileEntity.steamStored; + this.fontRenderer.drawString(displayText, (int)(105-displayText.length()*1), 45, 4210752); + this.fontRenderer.drawString(displayText2, (int)(105-displayText.length()*1), 55, 4210752); + this.fontRenderer.drawString(displayText3, (int)(105-displayText.length()*1), 65, 4210752); + this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + int var4 = this.mc.renderEngine.getTexture(SteamPowerMain.textureFile+"SteamGUI.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(var4); + containerWidth = (this.width - this.xSize) / 2; + containerHeight = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize); + } + } diff --git a/src/minecraft/steampower/GuiBoiler.java b/src/minecraft/steampower/GuiBoiler.java new file mode 100644 index 00000000..16f47ba6 --- /dev/null +++ b/src/minecraft/steampower/GuiBoiler.java @@ -0,0 +1,89 @@ +package steampower; +import java.text.DecimalFormat; + +import net.minecraft.src.GuiContainer; +import net.minecraft.src.InventoryPlayer; +import net.minecraft.src.StatCollector; + +import org.lwjgl.opengl.GL11; + +import steampower.boiler.ContainerBoiler; +import steampower.boiler.TileEntityBoiler; + +public class GuiBoiler extends GuiContainer +{ + private TileEntityBoiler boilerInventory; + + public GuiBoiler(InventoryPlayer par1InventoryPlayer, TileEntityBoiler par2TileEntityGrinder) + { + super(new ContainerBoiler(par1InventoryPlayer, par2TileEntityGrinder)); + this.boilerInventory = par2TileEntityGrinder; + } + + /** + * Draw the foreground layer for the GuiContainer (everythin in front of the items) + */ + protected void drawGuiContainerForegroundLayer() + { + this.fontRenderer.drawString("Boiler", 60, 6, 4210752); + this.fontRenderer.drawString("Inventory", 8, this.ySize - 96 + 2, 4210752); if(boilerInventory.hullHeat >=10000) + { + this.fontRenderer.drawString("Heat Danger", (int)(105), 50, 4210752); + } + this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + int var4 = this.mc.renderEngine.getTexture(SteamPowerMain.textureFile+"BoilerGui.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(var4); + int var5 = (this.width - this.xSize) / 2; + int var6 = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize-1, this.ySize); + int var7; + int var8; + int var9; + int var10; + if (this.boilerInventory.waterStored > 0) + { + var7 = boilerInventory.getStoredLiquid(1)*4 + 1; + this.drawTexturedModalRect(var5 + 29, var6 + 72 - var7, 176, 148 - var7, 23, var7); + } + if (this.boilerInventory.steamStored > 0) + { + var8 = boilerInventory.steamStored/14*4 + 1; + this.drawTexturedModalRect(var5 + 108, var6 + 72 - var8, 176, 90 - var8, 23, var8); + } + + float precentH = Math.min(boilerInventory.hullHeat/1000 + 1, 10); + var9 = (int) Math.min(precentH*3.0F,30); + this.drawTexturedModalRect(var5 + 59, var6 + 70 - var9, 199, 71 - var9, 9, var9); + float precentSH = this.boilerInventory.heatStored/1000; + var10 = (int) Math.round(precentSH*5.33); + this.drawTexturedModalRect(var5 + 78, var6 + 16, 176, 14, var10, 16); + + } + public static String getWattDisplay(int watts) + { + String displayWatt; + if(watts > 1000) + { + displayWatt = roundTwoDecimals((double)watts/1000)+" MJ"; + } + else + { + displayWatt = watts+" kJ"; + } + + return displayWatt; + } + public static double roundTwoDecimals(double d) + { + DecimalFormat twoDForm = new DecimalFormat("#.##"); + return Double.valueOf(twoDForm.format(d)); + } +} diff --git a/src/minecraft/steampower/ModelCenterTank.java b/src/minecraft/steampower/ModelCenterTank.java new file mode 100644 index 00000000..fabbd6a3 --- /dev/null +++ b/src/minecraft/steampower/ModelCenterTank.java @@ -0,0 +1,59 @@ +// Date: 8/14/2012 1:48:41 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 ModelCenterTank extends ModelBase +{ + + ModelRenderer Block; + + public ModelCenterTank(float par1) + { + textureWidth = 128; + textureHeight = 128; + + + //block + Block = new ModelRenderer(this, 0, 0); + Block.addBox(0F, 0F, 0F, 16, 16, 16); + Block.setRotationPoint(-8F, 8F, -8F); + Block.setTextureSize(128, 32); + Block.mirror = true; + setRotation(Block, 0F, 0F, 0F); + } + public void renderBlock(float f5) + { + Block.render(f5); + } + 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); + } + + 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); + } + +} diff --git a/src/minecraft/steampower/ModelCornerTank.java b/src/minecraft/steampower/ModelCornerTank.java new file mode 100644 index 00000000..e4089d3a --- /dev/null +++ b/src/minecraft/steampower/ModelCornerTank.java @@ -0,0 +1,100 @@ +// Date: 8/14/2012 1:48:41 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 ModelCornerTank extends ModelBase +{ + //Corner + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape6; + ModelRenderer Shape7; + ModelRenderer Shape4; + + public ModelCornerTank(float par1) + { + textureWidth = 128; + textureHeight = 128; + + + //corner + Shape1 = new ModelRenderer(this, 0, 1); + Shape1.addBox(0F, 0F, 0F, 1, 16, 20); + Shape1.setRotationPoint(7F, 8F, -7F); + Shape1.setTextureSize(128, 128); + Shape1.mirror = true; + setRotation(Shape1, 0F, -0.7853982F, 0F); + Shape2 = new ModelRenderer(this, 44, 0); + Shape2.addBox(0F, 0F, 0F, 2, 16, 2); + Shape2.setRotationPoint(-8F, 8F, 6F); + Shape2.setTextureSize(128, 128); + Shape2.mirror = true; + setRotation(Shape2, 0F, 0F, 0F); + Shape3 = new ModelRenderer(this, 44, 0); + Shape3.addBox(0F, 0F, 0F, 2, 16, 2); + Shape3.setRotationPoint(6F, 8F, -8F); + Shape3.setTextureSize(128, 128); + Shape3.mirror = true; + setRotation(Shape3, 0F, 0F, 0F); + Shape6 = new ModelRenderer(this, 0, 44); + Shape6.addBox(0F, 0F, 0F, 1, 15, 13); + Shape6.setRotationPoint(-8F, 9F, -7F); + Shape6.setTextureSize(128, 128); + Shape6.mirror = true; + setRotation(Shape6, 0F, 0F, 0F); + Shape7 = new ModelRenderer(this, 0, 73); + Shape7.addBox(0F, 0F, 0F, 14, 15, 1); + Shape7.setRotationPoint(-8F, 9F, -8F); + Shape7.setTextureSize(128, 128); + Shape7.mirror = true; + setRotation(Shape7, 0F, 0F, 0F); + Shape4 = new ModelRenderer(this, 0, 92); + Shape4.addBox(0F, 0F, 0F, 16, 1, 16); + Shape4.setRotationPoint(-8F, 8F, -8F); + Shape4.setTextureSize(128, 128); + Shape4.mirror = true; + setRotation(Shape4, 0F, 0F, 0F); + } + public void renderCorner(float f5) + { + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + Shape6.render(f5); + Shape7.render(f5); + Shape4.render(f5); + } + @Override + 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); + } + + 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); + } + +} diff --git a/src/minecraft/steampower/ModelEngine.java b/src/minecraft/steampower/ModelEngine.java new file mode 100644 index 00000000..22e04461 --- /dev/null +++ b/src/minecraft/steampower/ModelEngine.java @@ -0,0 +1,115 @@ +// Date: 8/24/2012 1:44:37 PM +// 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 ModelEngine extends ModelBase +{ + //fields + ModelRenderer Base; + ModelRenderer top; + ModelRenderer TopPiston; + ModelRenderer BottomPiston; + ModelRenderer center; + ModelRenderer C1; + ModelRenderer C2; + + public ModelEngine() + { + textureWidth = 64; + textureHeight = 64; + + Base = new ModelRenderer(this, 0, 20); + Base.addBox(-6F, 0F, -6F, 12, 8, 12); + Base.setRotationPoint(0F, 16F, 0F); + Base.setTextureSize(64, 64); + Base.mirror = true; + setRotation(Base, 0F, 0F, 0F); + top = new ModelRenderer(this, 0, 0); + top.addBox(-6F, 0F, -6F, 12, 8, 12); + top.setRotationPoint(0F, -8F, 0F); + top.setTextureSize(64, 64); + top.mirror = true; + setRotation(top, 0F, 0F, 0F); + TopPiston = new ModelRenderer(this, 0, 52); + TopPiston.addBox(-2F, 0F, -2F, 4, 8, 4); + TopPiston.setRotationPoint(0F, 0F, 0F); + TopPiston.setTextureSize(64, 64); + TopPiston.mirror = true; + setRotation(TopPiston, 0F, 0F, 0F); + BottomPiston = new ModelRenderer(this, 16, 52); + BottomPiston.addBox(-2F, 0F, -2F, 4, 8, 4); + BottomPiston.setRotationPoint(0F, 8F, 0F); + BottomPiston.setTextureSize(64, 64); + BottomPiston.mirror = true; + setRotation(BottomPiston, 0F, 0F, 0F); + center = new ModelRenderer(this, 32, 52); + center.addBox(-3F, 0F, -3F, 6, 6, 6); + //center.setRotationPoint(0F, 5F, 0F); + center.setTextureSize(64, 64); + center.mirror = true; + setRotation(center, 0F, 0F, 0F); + C1 = new ModelRenderer(this, 0, 41); + C1.addBox(-2F, -3F, 0F, 4, 6, 3); + C1.setRotationPoint(0F, 8F, 3F); + C1.setTextureSize(64, 64); + C1.mirror = true; + setRotation(C1, 0F, 0F, 0F); + C2 = new ModelRenderer(this, 15, 41); + C2.addBox(-2F, -3F, -3F, 4, 6, 3); + C2.setRotationPoint(0F, 8F, -3F); + C2.setTextureSize(64, 64); + C2.mirror = true; + setRotation(C2, 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); + //renderBot(f5); + //renderTop(f5); + } + public void renderBot(float f5) + { + Base.render(f5); + BottomPiston.render(f5); + } + public void renderTop(float f5) + { + top.render(f5); + TopPiston.render(f5); + C1.render(f5); + C2.render(f5); + } + public void renderMid(float f5,float p) + { + + center.setRotationPoint(0F, p, 0F); + center.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); + } + +} diff --git a/src/minecraft/steampower/ModelFurnace.java b/src/minecraft/steampower/ModelFurnace.java new file mode 100644 index 00000000..19d53f42 --- /dev/null +++ b/src/minecraft/steampower/ModelFurnace.java @@ -0,0 +1,82 @@ +// Date: 8/14/2012 3:02:31 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 ModelFurnace extends ModelBase +{ + //fields + ModelRenderer Body; + ModelRenderer top; + ModelRenderer bottom; + ModelRenderer Shape1; + + public ModelFurnace() + { + textureWidth = 256; + textureHeight = 256; + + Body = new ModelRenderer(this, 0, 0); + Body.addBox(-8F, -8F, -8F, 14, 14, 12); + Body.setRotationPoint(1F, 18F, 1F); + Body.setTextureSize(256, 256); + Body.mirror = true; + setRotation(Body, 0F, 0F, 0F); + top = new ModelRenderer(this, 80, 20); + top.addBox(-8F, 0F, -8F, 16, 2, 16); + top.setRotationPoint(0F, 8F, 0F); + top.setTextureSize(256, 256); + top.mirror = true; + setRotation(top, 0F, 0F, 0F); + bottom = new ModelRenderer(this, 80, 0); + bottom.addBox(-8F, 22F, -8F, 16, 2, 16); + bottom.setRotationPoint(0F, 0F, 0F); + bottom.setTextureSize(256, 256); + bottom.mirror = true; + setRotation(bottom, 0F, 0F, 0F); + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.addBox(-4F, -4F, 0F, 10, 8, 1); + Shape1.setRotationPoint(-1F, 16F, 5F); + Shape1.setTextureSize(256, 256); + Shape1.mirror = true; + setRotation(Shape1, 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) + { + Body.render(f5); + top.render(f5); + bottom.render(f5); + Shape1.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); + } + +} diff --git a/src/minecraft/steampower/ModelGenerator.java b/src/minecraft/steampower/ModelGenerator.java new file mode 100644 index 00000000..aefb0173 --- /dev/null +++ b/src/minecraft/steampower/ModelGenerator.java @@ -0,0 +1,136 @@ +// Date: 8/27/2012 3:20:21 PM +// 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 ModelGenerator extends ModelBase +{ + //fields + ModelRenderer BasePlate; + ModelRenderer LeftConnection; + ModelRenderer RightConnection; + ModelRenderer Mid; + ModelRenderer Mid2; + ModelRenderer front; + ModelRenderer front2; + ModelRenderer front3; + ModelRenderer Mid3; + ModelRenderer FrontConnector; + + public ModelGenerator() + { + textureWidth = 128; + textureHeight = 128; + + BasePlate = new ModelRenderer(this, 0, 0); + BasePlate.addBox(-7F, 0F, -7F, 14, 1, 14); + BasePlate.setRotationPoint(0F, 23F, 0F); + BasePlate.setTextureSize(128, 128); + BasePlate.mirror = true; + setRotation(BasePlate, 0F, 0F, 0F); + LeftConnection = new ModelRenderer(this, 0, 112); + LeftConnection.addBox(-2F, -2F, -2F, 2, 4, 4); + LeftConnection.setRotationPoint(-6F, 16F, 0F); + LeftConnection.setTextureSize(128, 128); + LeftConnection.mirror = true; + setRotation(LeftConnection, 0F, 0F, 0F); + RightConnection = new ModelRenderer(this, 12, 112); + RightConnection.addBox(0F, -2F, -2F, 2, 4, 4); + RightConnection.setRotationPoint(6F, 16F, 0F); + RightConnection.setTextureSize(128, 128); + RightConnection.mirror = true; + setRotation(RightConnection, 0F, 0F, 0F); + Mid = new ModelRenderer(this, 0, 29); + Mid.addBox(-4F, 0F, -6F, 8, 12, 12); + Mid.setRotationPoint(0F, 10F, 0F); + Mid.setTextureSize(128, 128); + Mid.mirror = true; + setRotation(Mid, 0F, 0F, 0F); + Mid2 = new ModelRenderer(this, 0, 53); + Mid2.addBox(-6F, 0F, -6F, 12, 8, 12); + Mid2.setRotationPoint(0F, 12F, 0F); + Mid2.setTextureSize(128, 128); + Mid2.mirror = true; + setRotation(Mid2, 0F, 0F, 0F); + front = new ModelRenderer(this, 20, 15); + front.addBox(-2F, -4F, 0F, 4, 8, 1); + front.setRotationPoint(0F, 16F, -7F); + front.setTextureSize(128, 128); + front.mirror = true; + setRotation(front, 0F, 0F, 0F); + front2 = new ModelRenderer(this, 0, 24); + front2.addBox(-4F, -2F, 0F, 8, 4, 1); + front2.setRotationPoint(0F, 16F, -7F); + front2.setTextureSize(128, 128); + front2.mirror = true; + setRotation(front2, 0F, 0F, 0F); + front3 = new ModelRenderer(this, 0, 16); + front3.addBox(-3F, -3F, 0F, 6, 6, 1); + front3.setRotationPoint(0F, 16F, -7F); + front3.setTextureSize(128, 128); + front3.mirror = true; + setRotation(front3, 0F, 0F, 0F); + Mid3 = new ModelRenderer(this, 40, 29); + Mid3.addBox(-5F, -1F, -6F, 10, 10, 12); + Mid3.setRotationPoint(0F, 12F, 0F); + Mid3.setTextureSize(128, 128); + Mid3.mirror = true; + setRotation(Mid3, 0F, 0F, 0F); + FrontConnector = new ModelRenderer(this, 0, 120); + FrontConnector.addBox(-2F, 0F, -2F, 4, 4, 4); + FrontConnector.setRotationPoint(0F, 14F, -6F); + FrontConnector.setTextureSize(128, 128); + FrontConnector.mirror = true; + setRotation(FrontConnector, 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); + + } + public void RenderMain(float f5) + { + BasePlate.render(f5); + Mid.render(f5); + Mid2.render(f5); + front.render(f5); + front2.render(f5); + front3.render(f5); + Mid3.render(f5); + FrontConnector.render(f5); + } + public void RenderLeft(float f5) + { + LeftConnection.render(f5); + } + public void RenderRight(float f5) + { + RightConnection.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); + } + +} diff --git a/src/minecraft/steampower/ModelTank.java b/src/minecraft/steampower/ModelTank.java new file mode 100644 index 00000000..65a916af --- /dev/null +++ b/src/minecraft/steampower/ModelTank.java @@ -0,0 +1,154 @@ +// Date: 8/14/2012 1:48:41 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 ModelTank extends ModelBase +{ + //One Block Tank + ModelRenderer TANK_WALL_1; + ModelRenderer TANK_WALL_2; + ModelRenderer TANK_WALL_3; + ModelRenderer TANK_WALL_4; + ModelRenderer TANK_SUPPORT_1; + ModelRenderer TANK_TOP_1; + ModelRenderer TANK_WALL_5; + ModelRenderer TANK_SUPPORT_2; + ModelRenderer TANK_SUPPORT_3; + ModelRenderer TANK_WALL_6; + ModelRenderer TANK_TOP_2; + ModelRenderer TANK_TOP_3; + ModelRenderer TANK_VALVE; + + public ModelTank(float par1) + { + textureWidth = 128; + textureHeight = 128; + + TANK_WALL_1 = new ModelRenderer(this, 0, 49); + TANK_WALL_1.addBox(0F, 0F, 0F, 1, 12, 8,par1); + TANK_WALL_1.setRotationPoint(6F, 12F, -4F); + TANK_WALL_1.setTextureSize(128, 128); + TANK_WALL_1.mirror = true; + setRotation(TANK_WALL_1, 0F, 0F, 0F); + TANK_WALL_2 = new ModelRenderer(this, 0, 70); + TANK_WALL_2.addBox(0F, 0F, 0F, 1, 12, 7,par1); + TANK_WALL_2.setRotationPoint(-8F, 12F, -4F); + TANK_WALL_2.setTextureSize(128, 128); + TANK_WALL_2.mirror = true; + setRotation(TANK_WALL_2, 0F, 0F, 0F); + TANK_WALL_3 = new ModelRenderer(this, 0, 34); + TANK_WALL_3.addBox(0F, 0F, 0F, 8, 12, 1,par1); + TANK_WALL_3.setRotationPoint(0F, 12F, 8F); + TANK_WALL_3.setTextureSize(128, 128); + TANK_WALL_3.mirror = true; + setRotation(TANK_WALL_3, 0F, 2.617994F, 0F); + TANK_WALL_4 = new ModelRenderer(this, 0, 34); + TANK_WALL_4.addBox(0F, 0F, 0F, 8, 12, 1,par1); + TANK_WALL_4.setRotationPoint(0F, 12F, -8F); + TANK_WALL_4.setTextureSize(128, 128); + TANK_WALL_4.mirror = true; + setRotation(TANK_WALL_4, 0F, -0.5235988F, 0F); + TANK_SUPPORT_1 = new ModelRenderer(this, 43, 22); + TANK_SUPPORT_1.addBox(-1F, 0F, -8F, 2, 14, 16,par1); + TANK_SUPPORT_1.setRotationPoint(0F, 10F, 0F); + TANK_SUPPORT_1.setTextureSize(128, 128); + TANK_SUPPORT_1.mirror = true; + setRotation(TANK_SUPPORT_1, 0F, 0F, 0F); + TANK_TOP_1 = new ModelRenderer(this, 43, 11); + TANK_TOP_1.addBox(-8F, 0F, -4F, 16, 2, 8,par1); + TANK_TOP_1.setRotationPoint(0F, 10F, 0F); + TANK_TOP_1.setTextureSize(128, 128); + TANK_TOP_1.mirror = true; + setRotation(TANK_TOP_1, 0F, 0F, 0F); + TANK_WALL_5 = new ModelRenderer(this, 0, 34); + TANK_WALL_5.addBox(0F, 0F, 0F, 8, 12, 1,par1); + TANK_WALL_5.setRotationPoint(0F, 12F, -7F); + TANK_WALL_5.setTextureSize(128, 128); + TANK_WALL_5.mirror = true; + setRotation(TANK_WALL_5, 0F, -2.617994F, 0F); + TANK_SUPPORT_2 = new ModelRenderer(this, 0, 0); + TANK_SUPPORT_2.addBox(-1F, 0F, -9F, 2, 14, 18,par1); + TANK_SUPPORT_2.setRotationPoint(0F, 10F, 0F); + TANK_SUPPORT_2.setTextureSize(128, 128); + TANK_SUPPORT_2.mirror = true; + setRotation(TANK_SUPPORT_2, 0F, 1.047198F, 0F); + TANK_SUPPORT_3 = new ModelRenderer(this, 0, 0); + TANK_SUPPORT_3.addBox(-1F, 0F, -9F, 2, 14, 18,par1); + TANK_SUPPORT_3.setRotationPoint(0F, 10F, 0F); + TANK_SUPPORT_3.setTextureSize(128, 128); + TANK_SUPPORT_3.mirror = true; + setRotation(TANK_SUPPORT_3, 0F, -1.047198F, 0F); + TANK_WALL_6 = new ModelRenderer(this, 0, 34); + TANK_WALL_6.addBox(0F, 0F, 0F, 8, 12, 1,par1); + TANK_WALL_6.setRotationPoint(0F, 12F, 7F); + TANK_WALL_6.setTextureSize(128, 128); + TANK_WALL_6.mirror = true; + setRotation(TANK_WALL_6, 0F, 0.5235988F, 0F); + TANK_TOP_2 = new ModelRenderer(this, 43, 0); + TANK_TOP_2.addBox(-6F, 0F, -4F, 12, 2, 8,par1); + TANK_TOP_2.setRotationPoint(0F, 10F, 0F); + TANK_TOP_2.setTextureSize(128, 128); + TANK_TOP_2.mirror = true; + setRotation(TANK_TOP_2, 0F, 1.047198F, 0F); + TANK_TOP_3 = new ModelRenderer(this, 43, 0); + TANK_TOP_3.addBox(-6F, 0F, -4F, 12, 2, 8,par1); + TANK_TOP_3.setRotationPoint(0F, 10F, 0F); + TANK_TOP_3.setTextureSize(128, 128); + TANK_TOP_3.mirror = true; + setRotation(TANK_TOP_3, 0F, -1.047198F, 0F); + TANK_VALVE = new ModelRenderer(this, 84, 0); + TANK_VALVE.addBox(0F, 0F, 0F, 2, 1, 2,par1); + TANK_VALVE.setRotationPoint(-1F, 9F, -1F); + TANK_VALVE.setTextureSize(128, 128); + TANK_VALVE.mirror = true; + setRotation(TANK_VALVE, 0F, 0F, 0F); + } + @Override + 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); + } + public void generalRender(float f5) + { + TANK_WALL_1.render(f5); + TANK_WALL_2.render(f5); + TANK_WALL_3.render(f5); + TANK_WALL_4.render(f5); + TANK_SUPPORT_1.render(f5); + TANK_TOP_1.render(f5); + TANK_WALL_5.render(f5); + TANK_SUPPORT_2.render(f5); + TANK_SUPPORT_3.render(f5); + TANK_WALL_6.render(f5); + TANK_TOP_2.render(f5); + TANK_TOP_3.render(f5); + TANK_VALVE.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); + } + +} diff --git a/src/minecraft/steampower/ModelToyEngine.java b/src/minecraft/steampower/ModelToyEngine.java new file mode 100644 index 00000000..c465a858 --- /dev/null +++ b/src/minecraft/steampower/ModelToyEngine.java @@ -0,0 +1,242 @@ +// 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); + } + +} diff --git a/src/minecraft/steampower/RenderBoiler.java b/src/minecraft/steampower/RenderBoiler.java new file mode 100644 index 00000000..15cacbbf --- /dev/null +++ b/src/minecraft/steampower/RenderBoiler.java @@ -0,0 +1,62 @@ +package steampower; + +import net.minecraft.src.TileEntity; +import net.minecraft.src.TileEntitySpecialRenderer; + +import org.lwjgl.opengl.GL11; + +import steampower.boiler.TileEntityBoiler; +import basicpipes.TradeHelper; + +public class RenderBoiler extends TileEntitySpecialRenderer +{ + int type = 0; + private ModelTank model; + private ModelCenterTank model2; + private ModelCornerTank model3; + + public RenderBoiler(float par1) + { + model = new ModelTank(par1); + model2 = new ModelCenterTank(par1); + model3 = new ModelCornerTank(par1); + } + + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float d3) { + + GL11.glPushMatrix(); + GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + TileEntity[] connected = ((TileEntityBoiler)tileEntity).connectedBlocks; + int meta = 0; + if(connected[5] == null && connected[3] == null && connected[4] == null && connected[2] == null || ((TileEntityBoiler)tileEntity).tankCount < 2 ) + { + bindTextureByName(SteamPowerMain.textureFile+"tankTexture.png"); + model.generalRender(0.0625F); + } + else + if(TradeHelper.corner(tileEntity) == 0 || ((TileEntityBoiler)tileEntity).tankCount > 2) + { + bindTextureByName(SteamPowerMain.textureFile+"tankBlock.png"); + model2.renderBlock(0.0625F); + } + else + { + int corner = TradeHelper.corner(tileEntity); + bindTextureByName(SteamPowerMain.textureFile+"CornerTank.png"); + switch(corner) + { + case 1: GL11.glRotatef(270f, 0f, 1f, 0f);break; + case 2: GL11.glRotatef(0f, 0f, 1f, 0f);break; + case 3: GL11.glRotatef(90f, 0f, 1f, 0f);break; + case 4: GL11.glRotatef(180f, 0f, 1f, 0f);break; + } + model3.renderCorner(0.0625f); + + } + GL11.glPopMatrix(); + } + +} \ No newline at end of file diff --git a/src/minecraft/steampower/RenderFurnace.java b/src/minecraft/steampower/RenderFurnace.java new file mode 100644 index 00000000..2aace235 --- /dev/null +++ b/src/minecraft/steampower/RenderFurnace.java @@ -0,0 +1,37 @@ +package steampower; + +import net.minecraft.src.TileEntity; +import net.minecraft.src.TileEntitySpecialRenderer; + +import org.lwjgl.opengl.GL11; + +public class RenderFurnace extends TileEntitySpecialRenderer +{ + int type = 0; + private ModelFurnace model; + + public RenderFurnace() + { + model = new ModelFurnace(); + } + + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float d3) { + bindTextureByName(SteamPowerMain.textureFile+"Furnace.png"); + GL11.glPushMatrix(); + GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + int meta = ((TileEntityMachine) tileEntity).getDirection(); + switch(meta) + { + case 1:GL11.glRotatef(0f, 0f, 1f, 0f);break; + case 2: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.genRender(0.0625F); + GL11.glPopMatrix(); + } + +} \ No newline at end of file diff --git a/src/minecraft/steampower/RenderGenerator.java b/src/minecraft/steampower/RenderGenerator.java new file mode 100644 index 00000000..d5f3a83b --- /dev/null +++ b/src/minecraft/steampower/RenderGenerator.java @@ -0,0 +1,29 @@ +package steampower; + +import net.minecraft.src.TileEntity; +import net.minecraft.src.TileEntitySpecialRenderer; + +import org.lwjgl.opengl.GL11; + +public class RenderGenerator extends TileEntitySpecialRenderer +{ + int type = 0; + private ModelGenerator model; + + public RenderGenerator() + { + model = new ModelGenerator(); + } + + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float d3) { + bindTextureByName(SteamPowerMain.textureFile+"Generator.png"); + GL11.glPushMatrix(); + GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + model.RenderMain(0.0625F); + GL11.glPopMatrix(); + } + +} \ No newline at end of file diff --git a/src/minecraft/steampower/RenderSteamEngine.java b/src/minecraft/steampower/RenderSteamEngine.java new file mode 100644 index 00000000..a8f66ae9 --- /dev/null +++ b/src/minecraft/steampower/RenderSteamEngine.java @@ -0,0 +1,49 @@ +package steampower; + +import net.minecraft.src.TileEntity; +import net.minecraft.src.TileEntitySpecialRenderer; + +import org.lwjgl.opengl.GL11; + +import steampower.turbine.TileEntitySteamPiston; + +public class RenderSteamEngine extends TileEntitySpecialRenderer +{ + int type = 0; + private ModelEngine model; + + public RenderSteamEngine() + { + model = new ModelEngine(); + } + + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float d3) { + bindTextureByName(SteamPowerMain.textureFile+"Engine.png"); + GL11.glPushMatrix(); + GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + + float p = ((TileEntitySteamPiston)tileEntity).position; + boolean cc = ((TileEntitySteamPiston)tileEntity).isConnected; + int meta = ((TileEntityMachine) tileEntity).getDirection(); + switch(meta) + { + case 1:GL11.glRotatef(0f, 0f, 1f, 0f);break; + case 2: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; + } + if(cc) + { + model.renderTop(0.0625F); + model.renderMid(0.0625F,p); + } + model.renderBot(0.0625F); + + + GL11.glPopMatrix(); + } + +} \ No newline at end of file diff --git a/src/minecraft/steampower/RenderToyEngine.java b/src/minecraft/steampower/RenderToyEngine.java new file mode 100644 index 00000000..5f84187c --- /dev/null +++ b/src/minecraft/steampower/RenderToyEngine.java @@ -0,0 +1,29 @@ +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(); + } + +} \ No newline at end of file diff --git a/src/minecraft/steampower/SteamClientProxy.java b/src/minecraft/steampower/SteamClientProxy.java new file mode 100644 index 00000000..ee65ad79 --- /dev/null +++ b/src/minecraft/steampower/SteamClientProxy.java @@ -0,0 +1,31 @@ +package steampower; + + +import net.minecraftforge.client.MinecraftForgeClient; +import steampower.boiler.TileEntityBoiler; +import steampower.burner.TileEntityFireBox; +import steampower.turbine.TileEntityGen; +import steampower.turbine.TileEntitySteamPiston; +import cpw.mods.fml.client.registry.ClientRegistry; + +public class SteamClientProxy extends SteamProxy{ + + public void preInit() + { + MinecraftForgeClient.preloadTexture("/EUIClient/textures/blocks.png"); + MinecraftForgeClient.preloadTexture("/EUIClient/textures/Items.png"); + } + @Override + public void init() + { + ClientRegistry.registerTileEntity(TileEntityBoiler.class, "boiler", new RenderBoiler(0f)); + ClientRegistry.registerTileEntity(TileEntityFireBox.class, "fireBox", new RenderFurnace()); + ClientRegistry.registerTileEntity(TileEntitySteamPiston.class, "generator", new RenderSteamEngine()); + ClientRegistry.registerTileEntity(TileEntityGen.class, "elecGen", new RenderGenerator()); + } + public void postInit() + { + + } + +}