Added the start of a generator block
This commit is contained in:
parent
93d020863c
commit
bac2723c43
7 changed files with 836 additions and 0 deletions
42
src/common/SteamPower/turbine/BlockGenerator.java
Normal file
42
src/common/SteamPower/turbine/BlockGenerator.java
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
161
src/common/SteamPower/turbine/BlockSteamPiston.java
Normal file
161
src/common/SteamPower/turbine/BlockSteamPiston.java
Normal file
|
@ -0,0 +1,161 @@
|
|||
package SteamPower.turbine;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.EntityLiving;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.Material;
|
||||
import net.minecraft.src.MathHelper;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
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());
|
||||
}
|
||||
}
|
63
src/common/SteamPower/turbine/TileEntityGen.java
Normal file
63
src/common/SteamPower/turbine/TileEntityGen.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package SteamPower.turbine;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.NetworkManager;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import universalelectricity.extend.IElectricUnit;
|
||||
import universalelectricity.network.IPacketReceiver;
|
||||
import SteamPower.TileEntityMachine;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
405
src/common/SteamPower/turbine/TileEntitySteamPiston.java
Normal file
405
src/common/SteamPower/turbine/TileEntitySteamPiston.java
Normal file
|
@ -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 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 SteamPower.SteamPowerMain;
|
||||
import SteamPower.TileEntityMachine;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
BIN
src/minecraft/EUIClient/Textures/Generator.png
Normal file
BIN
src/minecraft/EUIClient/Textures/Generator.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
136
src/minecraft/SteamPower/ModelGenerator.java
Normal file
136
src/minecraft/SteamPower/ModelGenerator.java
Normal file
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
29
src/minecraft/SteamPower/RenderGenerator.java
Normal file
29
src/minecraft/SteamPower/RenderGenerator.java
Normal file
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue