Update of code

I really should have update git after i changed packages. Now there so
many changes i really don't care to sort threw them. Main changes though
are boiler tank model/code changed to show corner block when more than
one boil is placed togther. Steam engine was changed to steam piston set
and shows animation when running. FireBox now shows flames on the
correct side. All models rotate as well but only when first placed. No
wrench rotation support will be added. A lot of code cleanup and bug
fixes including an infinite water loop in the boiler tanks.
This commit is contained in:
Rseifert 2012-08-27 07:59:13 -04:00
parent 5a0fd88182
commit 40f0710849
40 changed files with 1736 additions and 1237 deletions

View file

@ -1,136 +0,0 @@
package EUI.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;
public class TileEntityMachine extends TileEntityElectricUnit
{
public int facing = 0;
private int count = 0;
public TileEntity getSteamMachine(int i)
{
int x = this.xCoord;
int y = this.yCoord;
int z = this.zCoord;
switch(i)
{
case 0: y = y - 1;break;
case 1: y = y + 1;break;
case 2: z = z + 1;break;
case 3: z = z - 1;break;
case 4: x = x + 1;break;
case 5: x = x - 1;break;
}
TileEntity aEntity = worldObj.getBlockTileEntity(x, y, z);
if(aEntity instanceof TileEntityMachine)
{
return aEntity;
}
return null;
}
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);
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
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;
}
public int getSizeInventory() {
// TODO Auto-generated method stub
return 0;
}
public ItemStack getStackInSlot(int var6) {
// TODO Auto-generated method stub
return null;
}
@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);
count++;
if(count >= 10)
{
if(!worldObj.isRemote)
{
PacketManager.sendTileEntityPacket(this, SteamPower.channel, getSendData());
}
count = 0;
}
}
}

View file

@ -1,540 +0,0 @@
package EUI.SteamPower.boiler;
import com.google.common.io.ByteArrayDataInput;
import universalelectricity.network.IPacketReceiver;
import EUI.BasicPipes.pipes.api.ILiquidConsumer;
import EUI.BasicPipes.pipes.api.ILiquidProducer;
import EUI.SteamPower.SteamPower;
import EUI.SteamPower.TileEntityMachine;
import EUI.SteamPower.burner.TileEntityFireBox;
import net.minecraft.src.*;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiver, IInventory, ISidedInventory,ILiquidProducer, ILiquidConsumer
{
/**
* The ItemStacks that hold the items currently being used in the furnace
*/
private ItemStack[] furnaceItemStacks = new ItemStack[1];
/** 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 = 10000;
private int heatTick = 0;
int count = 0;
boolean hullHeated = false;
TileEntity[] connectedBlocks = {null, null, null, null, null, null};
int steamMax = 140;
public boolean isBeingHeated = false;
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
{
return this.furnaceItemStacks.length;
}
/**
* Returns the stack in slot i
*/
public ItemStack getStackInSlot(int par1)
{
return this.furnaceItemStacks[par1];
}
public ItemStack decrStackSize(int par1, int par2)
{
if (this.furnaceItemStacks[par1] != null)
{
ItemStack var3;
if (this.furnaceItemStacks[par1].stackSize <= par2)
{
var3 = this.furnaceItemStacks[par1];
this.furnaceItemStacks[par1] = null;
return var3;
}
else
{
var3 = this.furnaceItemStacks[par1].splitStack(par2);
if (this.furnaceItemStacks[par1].stackSize == 0)
{
this.furnaceItemStacks[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.furnaceItemStacks[par1] != null)
{
ItemStack var2 = this.furnaceItemStacks[par1];
this.furnaceItemStacks[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.furnaceItemStacks[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
/**
* Returns the name of the inventory.
*/
public String getInvName()
{
return "container.boiler";
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.furnaceItemStacks = 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.furnaceItemStacks.length)
{
this.furnaceItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
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);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.furnaceItemStacks.length; ++var3)
{
if (this.furnaceItemStacks[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.furnaceItemStacks[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
par1NBTTagCompound.setTag("Items", var2);
}
/**
* 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;
}
/**
* 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.
*/
private boolean getIsHeated() {
TileEntity blockEntity = worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
if(blockEntity instanceof TileEntityFireBox)
{
return true;
}
else
{
return false;
}
}
@Override
public void updateEntity(){
count++;
if(count >= 20){
isBeingHeated = getIsHeated();
addWater();//adds water from container slot
shareWater();
count = 0;
}
//changed hullHeat max depending on contents of boiler
if(waterStored > 0)
{
hullHeatMax = 4700;
if(hullHeat > hullHeatMax)
{
hullHeat = 4700;
}
}
else
{
hullHeatMax = 10000;
}
//Checks if the hull is heated
if(hullHeat >= hullHeatMax)
{
hullHeated = true;
}
else
{
hullHeat = Math.min(hullHeat + heatStored, hullHeatMax);
}
//checks if heat level hit max
if(hullHeat >= 10000)
{
if(heatTick >= 1200)
{
// TODO remove block and set fire
heatTick = 0;
}
else
{
heatTick += 1;
}
}
int heatNeeded = SteamPower.boilerHeat; // kilo joules
//if hull heated do work
if(hullHeated)
{
if(heatStored > SteamPower.fireOutput)
{
if(waterStored >= 1){
if(heatStored >= heatNeeded)
{
heatStored = Math.max(heatStored - heatNeeded, 0);
--waterStored;
steamStored = Math.min(steamStored + SteamPower.steamOutBoiler,this.steamMax);
}
}
else
{
heatStored = 0;
}
}
}
TileEntity blockE = worldObj.getBlockTileEntity(xCoord, yCoord -1, zCoord);
if(blockE instanceof TileEntityFireBox)
{
if(!hullHeated || waterStored > 0)
{
heatStored = (int) Math.min((heatStored + ((TileEntityFireBox)blockE).onProduceHeat(SteamPower.fireOutput, 1)), heatMax);
}
}
}
public void shareWater()
{
int wSum = getStoredLiquid(1); //pre-sets the sum to the first tanks current volume
int tankCount = 1; //amount of tanks around this tank, used to get avarage liquid ammount
boolean bottom = false; // whether or not this tanks need to worry about what is bellow it
TileEntity entityBellow = worldObj.getBlockTileEntity(this.xCoord,this.yCoord-1, this.zCoord);
TileEntity entityAbove = worldObj.getBlockTileEntity(this.xCoord,this.yCoord+1, this.zCoord);
//checks wether or not the block bellow it is a tank to move liquid too
if(entityBellow instanceof TileEntityBoiler)
{
int bWater = ((TileEntityBoiler) entityBellow).getStoredLiquid(1);
int bMax = ((TileEntityBoiler) entityBellow).getLiquidCapacity(1);
//checks if that tank has room to get liquid.
if(bWater < bMax)
{
int emptyVol = Math.max( bMax - bWater,0);
int tradeVol = Math.min(emptyVol, waterStored);
int rejected = ((TileEntityBoiler) entityBellow).onReceiveLiquid(1, tradeVol, ForgeDirection.getOrientation(1));
waterStored = Math.max(waterStored - rejected,0);
wSum -= rejected;
}
else
{
bottom = true;
}
}
else
{
//there was no tank bellow this tank
bottom = true;
}
//if this is the bottom tank or bottom tank is full then trade liquid with tanks around it.
if(bottom)
{
//get average water around center tank
for(int i = 0; i<4;i++)
{
int x = this.xCoord;
int z = this.zCoord;
//switch to check each side TODO rewrite for side values
switch(i)
{
case 0: --x;
case 1: ++x;
case 2: --z;
case 3: ++z;
}
TileEntity entity = worldObj.getBlockTileEntity(x,this.yCoord, z);
if(entity instanceof TileEntityBoiler)
{
//if is a tank add to the sum
wSum += ((TileEntityBoiler) entity).getStoredLiquid(1);
tankCount += 1;
}
}
}
//transfers water
for(int i = 0; i<4;i++)
{
int average = wSum / tankCount;// takes the sum and makes it an average
int x2 = this.xCoord;
int z2 = this.zCoord;
int tradeSum = 0;
//switch to check each side TODO rewrite for side values
switch(i)
{
case 0: --x2;
case 1: ++x2;
case 2: --z2;
case 3: ++z2;
}
TileEntity entity = worldObj.getBlockTileEntity(x2,this.yCoord, z2);
if(entity instanceof TileEntityBoiler)
{
int targetW = ((TileEntityBoiler) entity).getStoredLiquid(1);
if(targetW < average)
{
tradeSum = Math.min(average, waterStored); //gets the ammount to give to the target tank
int rejectedAm = ((TileEntityBoiler) entity).onReceiveLiquid(1, tradeSum, ForgeDirection.getOrientation(i)); //send that ammount with safty incase some comes back
waterStored =rejectedAm + waterStored - tradeSum; //counts up current water sum after trade
}
}
}
if(entityAbove instanceof TileEntityBoiler)
{
int bWater = ((TileEntityBoiler) entityAbove).getStoredLiquid(1);
int bMax = ((TileEntityBoiler) entityAbove).getLiquidCapacity(1);
if(bottom && waterStored > 0)
{
if(bWater < bMax)
{
int emptyVolS = Math.max( bMax - bWater,0);
int tradeVolS = Math.min(emptyVolS, steamStored);
int rejectedS = ((TileEntityBoiler) entityAbove).addSteam(tradeVolS);
waterStored = Math.max(waterStored - rejectedS,0);
wSum -= rejectedS;
}
}
}
}
public int addSteam(int watt) {
int rejectedElectricity = Math.max((this.steamStored + watt) - steamMax, 0);
this.steamStored += watt - rejectedElectricity;
return rejectedElectricity;
}
private void addWater() {
if (this.furnaceItemStacks[0] != null)
{
if(this.furnaceItemStacks[0].isItemEqual(new ItemStack(Item.bucketWater,1)))
{
if((int)waterStored < getLiquidCapacity(1))
{
++waterStored;
this.furnaceItemStacks[0] = new ItemStack(Item.bucketEmpty,1);
this.onInventoryChanged();
}
}
}
}
/**
* 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;
}
public void openChest() {}
public void closeChest() {}
public int precentHeated() {
int var1;
if(hullHeat < 100)
{
var1 = (int)(100 *(hullHeat/100));
}
else
{
var1 = 100;
}
return var1;
}
@Override
public int onReceiveLiquid(int type, int vol, ForgeDirection side) {
if(type == 1)
{
int rejectedElectricity = Math.max((this.waterStored + vol) - this.getLiquidCapacity(1), 0);
this.waterStored += vol - rejectedElectricity;
return rejectedElectricity;
}
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;
}
@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;
}
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();
}
}
}

View file

@ -1,301 +0,0 @@
package EUI.SteamPower.burner;
import com.google.common.io.ByteArrayDataInput;
import universalelectricity.network.IPacketReceiver;
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 EUI.SteamPower.SteamPower;
import EUI.SteamPower.TileEntityMachine;
import EUI.SteamPower.api.IHeatProducer;
import EUI.SteamPower.boiler.*;
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;
public ItemStack[] containingItems = new ItemStack[1];
public void updateEntity()
{if (!this.worldObj.isRemote){
if(count == 20)
{
addConnection();
sharCoal();
count = 0;
}
count++;
maxGenerateRate = SteamPower.fireOutput + (connectedUnits*5);
TileEntity blockEntity = worldObj.getBlockTileEntity(this.xCoord, this.yCoord + 1, this.zCoord);
if(blockEntity instanceof TileEntityBoiler)
{
isConnected = true;
}
else
{
isConnected = false;
}
//The top slot is for recharging items. Check if the item is a electric item. If so, recharge it.
if (this.containingItems[0] != null && isConnected)
{
if (this.containingItems[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.containingItems[0] != null)
{
if(this.containingItems[0].getItem().shiftedIndex == Item.coal.shiftedIndex && this.containingItems[0].stackSize > 0)
{
if(connectedConsumer.containingItems[0] != null)
{
if(connectedConsumer.containingItems[0].getItem().shiftedIndex == Item.coal.shiftedIndex)
{
if(connectedConsumer.containingItems[0].getItem().shiftedIndex == Item.coal.shiftedIndex)
{
int CSum = Math.round(this.containingItems[0].stackSize + connectedConsumer.containingItems[0].stackSize)/2;
if(this.containingItems[0].stackSize > connectedConsumer.containingItems[0].stackSize)
{
int transferC = 0;
transferC = Math.round(CSum - connectedConsumer.containingItems[0].stackSize);
connectedConsumer.containingItems[0].stackSize = connectedConsumer.containingItems[0].stackSize + transferC;
this.containingItems[0].stackSize = this.containingItems[0].stackSize - transferC;
}
}
}
}
else
{
connectedConsumer.containingItems[0] = new ItemStack(this.containingItems[0].getItem());
this.containingItems[0].stackSize -= 1;
}
}
}
}
}
}
public void addConnection()
{
connectedUnits = 0;
for(int i = 0; i<6; i++)
{
TileEntity aEntity = getSteamMachine(i);
if(aEntity instanceof TileEntityFireBox && i != 0 && i != 1)
{
this.connectedBlocks[i] = aEntity;
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");
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.itemCookTime);
par1NBTTagCompound.setInteger("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)
{
if (side == ForgeDirection.DOWN)
{
return 1;
}
if (side == ForgeDirection.UP)
{
return 0;
}
return 2;
}
@Override
public int getSizeInventorySide(ForgeDirection side) { return getSizeInventory(); }
@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 "FireBox";
}
@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 float onProduceHeat(float jouls, int side) {
// TODO Auto-generated method stub
return Math.min(generateRate,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();
}
}
}

View file

@ -1,21 +1,21 @@
package EUI.SteamPower; package SteamPower;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import universalelectricity.basiccomponents.BasicComponents; import net.minecraft.src.CreativeTabs;
import net.minecraft.src.EntityItem;
import EUI.SteamPower.boiler.TileEntityBoiler; import net.minecraft.src.EntityLiving;
import EUI.SteamPower.burner.TileEntityFireBox; import net.minecraft.src.EntityPlayer;
import EUI.SteamPower.turbine.TileEntityGenerator; import net.minecraft.src.ItemStack;
import net.minecraft.client.Minecraft; import net.minecraft.src.Material;
import net.minecraft.src.*; import net.minecraft.src.MathHelper;
import EUI.SteamPower.*; import net.minecraft.src.NBTTagCompound;
import EUIClient.SteamPower.GUIFireBox; import net.minecraft.src.TileEntity;
import EUIClient.SteamPower.GUIGenerator; import net.minecraft.src.World;
import EUIClient.SteamPower.GuiBoiler; import SteamPower.boiler.TileEntityBoiler;
import net.minecraftforge.common.ForgeDirection; import SteamPower.burner.TileEntityFireBox;
import SteamPower.turbine.TileEntityGenerator;
public class BlockMachine extends universalelectricity.extend.BlockMachine public class BlockMachine extends universalelectricity.extend.BlockMachine
{ {
@ -36,7 +36,6 @@ public class BlockMachine extends universalelectricity.extend.BlockMachine
par3List.add(new ItemStack(this, 1, 1)); par3List.add(new ItemStack(this, 1, 1));
par3List.add(new ItemStack(this, 1, 2)); par3List.add(new ItemStack(this, 1, 2));
par3List.add(new ItemStack(this, 1, 3));
par3List.add(new ItemStack(this, 1, 15)); par3List.add(new ItemStack(this, 1, 15));
} }
@Override @Override
@ -60,22 +59,22 @@ public class BlockMachine extends universalelectricity.extend.BlockMachine
float var10 = 0.52F; float var10 = 0.52F;
float var11 = par5Random.nextFloat() * 0.6F - 0.3F; float var11 = par5Random.nextFloat() * 0.6F - 0.3F;
if (var6 == 5) if (var6 == 4)
{ {
par1World.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); 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); par1World.spawnParticle("flame", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
} }
else if (var6 == 4) else if (var6 == 2)
{ {
par1World.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); 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); par1World.spawnParticle("flame", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
} }
else if (var6 == 3) else if (var6 == 1)
{ {
par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D); 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); par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
} }
else if (var6 == 2) else if (var6 == 3)
{ {
par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D); 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); par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
@ -83,45 +82,7 @@ public class BlockMachine extends universalelectricity.extend.BlockMachine
} }
} }
} }
@Override
public int getBlockTexture(IBlockAccess par1iBlockAccess, int x, int y, int z, int side)
{
TileEntity tileEntity = par1iBlockAccess.getBlockTileEntity(x, y, z);
int metadata = par1iBlockAccess.getBlockMetadata(x, y, z);
if(metadata > -1 && tileEntity != null)
{
if (side == 1)
{
switch(metadata)
{
case 0: return 6;
case 1: return 4;
case 2: return 7;
case 3: return 4;
}
}
//If it is the back side
else if(side == ((TileEntityMachine) tileEntity).getDirection());
{
switch(metadata)
{
case 0: return 5;
case 2: return 8;
case 3: return 4;
}
}
switch(metadata)
{
case 1: return 0;
case 2: return 2;
}
}
return 1;
}
@Override @Override
public boolean onUseWrench(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) public boolean onUseWrench(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
{ {
@ -130,10 +91,10 @@ public class BlockMachine extends universalelectricity.extend.BlockMachine
//Reorient the block //Reorient the block
switch(tileEntity.getDirection()) switch(tileEntity.getDirection())
{ {
case 2: tileEntity.setDirection(5); break; case 1: tileEntity.setDirection(2); break;
case 5: tileEntity.setDirection(3); break; case 2: tileEntity.setDirection(3); break;
case 3: tileEntity.setDirection(4); break; case 3: tileEntity.setDirection(4); break;
case 4: tileEntity.setDirection(2); break; case 4: tileEntity.setDirection(1); break;
} }
return true; return true;
@ -159,17 +120,12 @@ public class BlockMachine extends universalelectricity.extend.BlockMachine
if(blockEntity instanceof TileEntityBoiler) if(blockEntity instanceof TileEntityBoiler)
{ {
TileEntity var6 = (TileEntityBoiler)par1World.getBlockTileEntity(x, y, z); TileEntity var6 = (TileEntityBoiler)par1World.getBlockTileEntity(x, y, z);
par5EntityPlayer.openGui(SteamPower.instance, 1, par1World, x, y, z); par5EntityPlayer.openGui(SteamPowerMain.instance, 1, par1World, x, y, z);
} }
if(blockEntity instanceof TileEntityFireBox) if(blockEntity instanceof TileEntityFireBox)
{ {
TileEntity var6 = (TileEntityFireBox)par1World.getBlockTileEntity(x, y, z); TileEntity var6 = (TileEntityFireBox)par1World.getBlockTileEntity(x, y, z);
par5EntityPlayer.openGui(SteamPower.instance, 0, par1World, x, y, z); par5EntityPlayer.openGui(SteamPowerMain.instance, 0, par1World, x, y, z);
}
if(blockEntity instanceof TileEntityGenerator)
{
TileEntity var6 = (TileEntityGenerator)par1World.getBlockTileEntity(x, y, z);
par5EntityPlayer.openGui(SteamPower.instance, 2, par1World, x, y, z);
} }
} }
@ -183,7 +139,6 @@ public class BlockMachine extends universalelectricity.extend.BlockMachine
{ {
case 1: return new TileEntityBoiler(); case 1: return new TileEntityBoiler();
case 2: return new TileEntityFireBox(); case 2: return new TileEntityFireBox();
case 3: return new TileEntityGenerator();
case 15: return new TileEntityNuller(); case 15: return new TileEntityNuller();
} }
return null; return null;
@ -201,10 +156,10 @@ public class BlockMachine extends universalelectricity.extend.BlockMachine
switch (angle) switch (angle)
{ {
case 0: tileEntity.setDirection(5); break; case 0: tileEntity.setDirection(1); break;
case 1: tileEntity.setDirection(3); break; case 1: tileEntity.setDirection(2); break;
case 2: tileEntity.setDirection(4); break; case 2: tileEntity.setDirection(3); break;
case 3: tileEntity.setDirection(2); break; case 3: tileEntity.setDirection(4); break;
} }
} }
/** /**
@ -266,6 +221,7 @@ public class BlockMachine extends universalelectricity.extend.BlockMachine
super.breakBlock(par1World, par2, par3, par4, par5, par6); super.breakBlock(par1World, par2, par3, par4, par5, par6);
} }
@Override @Override
public String getTextureFile() public String getTextureFile()
{ {
@ -286,4 +242,5 @@ public class BlockMachine extends universalelectricity.extend.BlockMachine
{ {
return -1; return -1;
} }
} }

View file

@ -1,4 +1,4 @@
package EUI.SteamPower; package SteamPower;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -1,4 +1,4 @@
package EUI.SteamPower; package SteamPower;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -1,4 +1,4 @@
package EUI.SteamPower; package SteamPower;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -1,24 +1,25 @@
package EUI.SteamPower; package SteamPower;
import java.io.File;
import SteamPower.turbine.BlockEngine;
import SteamPower.turbine.ItemEngine;
import SteamPower.turbine.TileEntitytopGen;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.src.Block; import net.minecraft.src.Block;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack; import net.minecraft.src.ItemStack;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
import universalelectricity.UniversalElectricity;
import java.util.ArrayList; import universalelectricity.basiccomponents.BasicComponents;
import java.util.Map; import universalelectricity.network.PacketManager;
import java.io.*; import BasicPipes.BasicPipesMain;
import EUI.BasicPipes.BasicPipes;
import EUI.SteamPower.boiler.TileEntityBoiler;
import EUI.SteamPower.burner.TileEntityFireBox;
import EUI.SteamPower.turbine.TileEntityGenerator;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance; 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.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@ -26,33 +27,35 @@ import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "SteamPower", name = "Steam Power", version = "V8")
import universalelectricity.UniversalElectricity;
import universalelectricity.basiccomponents.BasicComponents;
import universalelectricity.network.PacketManager;
@Mod(modid = "SteamPower", name = "Steam Power", version = "V4")
@NetworkMod(channels = { "SPpack" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class) @NetworkMod(channels = { "SPpack" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class)
public class SteamPower{ public class SteamPowerMain{
static Configuration config = new Configuration((new File(Minecraft.getMinecraftDir(), "config/EUIndustry/SteamPower.cfg"))); static Configuration config = new Configuration((new File(Minecraft.getMinecraftDir(), "config/EUIndustry/SteamPower.cfg")));
private static int BlockID= configurationProperties(); private static int BlockID= configurationProperties();
public static int EngineItemID;
public static int EngineID;
public static int genOutput; public static int genOutput;
public static int steamOutBoiler; public static int steamOutBoiler;
public static int pipeLoss; public static int pipeLoss;
public static int boilerHeat; public static int boilerHeat;
public static int fireOutput; public static int fireOutput;
public static final String channel = "SPpack"; public static final String channel = "SPpack";
public static Block machine = new EUI.SteamPower.BlockMachine(BlockID).setBlockName("machine"); public static Block machine = new BlockMachine(BlockID).setBlockName("machine");
public static Block engine = new BlockEngine(EngineID).setBlockName("SteamEngien");
public static Item itemEngine = new ItemEngine(EngineItemID).setItemName("SteamEngine");
@Instance @Instance
public static SteamPower instance; public static SteamPowerMain instance;
@SidedProxy(clientSide = "EUIClient.SteamPower.SteamClientProxy", serverSide = "EUI.SteamPower.SteamProxy") @SidedProxy(clientSide = "SteamPower.SteamClientProxy", serverSide = "SteamPower.SteamProxy")
public static SteamProxy proxy; public static SteamProxy proxy;
public static String textureFile = "/EUIClient/Textures/"; public static String textureFile = "/EUIClient/Textures/";
public static int configurationProperties() public static int configurationProperties()
{ {
config.load(); config.load();
BlockID = Integer.parseInt(config.getOrCreateIntProperty("MachinesID", Configuration.CATEGORY_BLOCK, 3030).value); 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);
genOutput = Integer.parseInt(config.getOrCreateIntProperty("genOutputWattsmax", Configuration.CATEGORY_GENERAL, 1000).value); genOutput = Integer.parseInt(config.getOrCreateIntProperty("genOutputWattsmax", Configuration.CATEGORY_GENERAL, 1000).value);
steamOutBoiler = Integer.parseInt(config.getOrCreateIntProperty("steamOutPerCycle", Configuration.CATEGORY_GENERAL, 10).value); steamOutBoiler = Integer.parseInt(config.getOrCreateIntProperty("steamOutPerCycle", Configuration.CATEGORY_GENERAL, 10).value);
boilerHeat = Integer.parseInt(config.getOrCreateIntProperty("boilerInKJNeed", Configuration.CATEGORY_GENERAL, 4500).value); boilerHeat = Integer.parseInt(config.getOrCreateIntProperty("boilerInKJNeed", Configuration.CATEGORY_GENERAL, 4500).value);
@ -67,16 +70,18 @@ public class SteamPower{
NetworkRegistry.instance().registerGuiHandler(this, this.proxy); NetworkRegistry.instance().registerGuiHandler(this, this.proxy);
proxy.preInit(); proxy.preInit();
GameRegistry.registerBlock(machine, ItemMachine.class); GameRegistry.registerBlock(machine, ItemMachine.class);
GameRegistry.registerBlock(engine);
} }
@Init @Init
public void load(FMLInitializationEvent evt) public void load(FMLInitializationEvent evt)
{ {
proxy.init(); proxy.init();
GameRegistry.registerTileEntity(TileEntityNuller.class, "EUNuller"); GameRegistry.registerTileEntity(TileEntityNuller.class, "EUNuller");
GameRegistry.registerTileEntity(TileEntitytopGen.class, "gentop");
//Names............... //Names...............
LanguageRegistry.addName((new ItemStack(machine, 1, 1)), "Boiler"); LanguageRegistry.addName((new ItemStack(machine, 1, 1)), "Boiler");
LanguageRegistry.addName((new ItemStack(machine, 1, 2)), "FireBox"); LanguageRegistry.addName((new ItemStack(machine, 1, 2)), "FireBox");
LanguageRegistry.addName((new ItemStack(machine, 1, 3)), "SteamGen"); LanguageRegistry.addName((new ItemStack(itemEngine, 1, 0)), "SteamPiston");
LanguageRegistry.addName((new ItemStack(machine, 1, 15)), "EUVampire"); LanguageRegistry.addName((new ItemStack(machine, 1, 15)), "EUVampire");
@ -84,8 +89,8 @@ public class SteamPower{
@PostInit @PostInit
public void postInit(FMLPostInitializationEvent event) public void postInit(FMLPostInitializationEvent event)
{ {
proxy.postInit(); proxy.postInit();
UniversalElectricity.registerMod(this,"SteamPower", "0.5.1");
//Crafting //Crafting
/** /**
* case 0: return new TileEntityGrinder(); <-Removed * case 0: return new TileEntityGrinder(); <-Removed
@ -96,15 +101,15 @@ public class SteamPower{
case 15: return new TileEntityNuller();<-Just for testing Not craftable case 15: return new TileEntityNuller();<-Just for testing Not craftable
*/ */
GameRegistry.addRecipe(new ItemStack(machine, 1, 1), new Object [] {"@T@", "OVO", "@T@", GameRegistry.addRecipe(new ItemStack(machine, 1, 1), new Object [] {"@T@", "OVO", "@T@",
'T',new ItemStack(BasicPipes.parts, 1,5), 'T',new ItemStack(BasicPipesMain.parts, 1,5),
'@',new ItemStack(BasicComponents.itemSteelPlate), '@',new ItemStack(BasicComponents.itemSteelPlate),
'O',new ItemStack(BasicPipes.parts, 1,1), 'O',new ItemStack(BasicPipesMain.parts, 1,1),
'V',new ItemStack(BasicPipes.parts, 1,6)}); 'V',new ItemStack(BasicPipesMain.parts, 1,6)});
GameRegistry.addRecipe(new ItemStack(machine, 1, 2), new Object [] { "@", "F", GameRegistry.addRecipe(new ItemStack(machine, 1, 2), new Object [] { "@", "F",
'F',Block.stoneOvenIdle, 'F',Block.stoneOvenIdle,
'@',new ItemStack(BasicComponents.itemSteelPlate)}); '@',new ItemStack(BasicComponents.itemSteelPlate)});
GameRegistry.addRecipe(new ItemStack(machine, 1, 3), new Object [] {"@T@", "PMP", "@T@", GameRegistry.addRecipe(new ItemStack(itemEngine, 1, 0), new Object [] {"@T@", "PMP", "@T@",
'T',new ItemStack(BasicPipes.parts, 1,0), 'T',new ItemStack(BasicPipesMain.parts, 1,0),
'@',new ItemStack(BasicComponents.itemSteelPlate), '@',new ItemStack(BasicComponents.itemSteelPlate),
'P',Block.pistonBase, 'P',Block.pistonBase,
'M',new ItemStack(BasicComponents.itemMotor)}); 'M',new ItemStack(BasicComponents.itemMotor)});

View file

@ -1,21 +1,17 @@
package EUI.SteamPower; package SteamPower;
import universalelectricity.basiccomponents.GUIBatteryBox;
import universalelectricity.basiccomponents.TileEntityBatteryBox;
import EUI.SteamPower.boiler.ContainerBoiler;
import EUI.SteamPower.boiler.TileEntityBoiler;
import EUI.SteamPower.burner.ContainerFireBox;
import EUI.SteamPower.burner.TileEntityFireBox;
import EUI.SteamPower.turbine.ContainerGenerator;
import EUI.SteamPower.turbine.TileEntityGenerator;
import EUIClient.SteamPower.GUIFireBox;
import EUIClient.SteamPower.GUIGenerator;
import EUIClient.SteamPower.GuiBoiler;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.src.EntityPlayer; import net.minecraft.src.EntityPlayer;
import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntity;
import net.minecraft.src.World; 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.TileEntityGenerator;
import SteamPower.turbine.TileEntitytopGen;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
public class SteamProxy implements IGuiHandler{ public class SteamProxy implements IGuiHandler{
@ -29,6 +25,7 @@ public class SteamProxy implements IGuiHandler{
GameRegistry.registerTileEntity(TileEntityFireBox.class, "fireBox"); GameRegistry.registerTileEntity(TileEntityFireBox.class, "fireBox");
GameRegistry.registerTileEntity(TileEntityGenerator.class, "generator"); GameRegistry.registerTileEntity(TileEntityGenerator.class, "generator");
} }
public void postInit() public void postInit()
{ {

View file

@ -0,0 +1,261 @@
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 10;
}
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);
count++;
if(!worldObj.isRemote)
{
PacketManager.sendTileEntityPacket(this, SteamPowerMain.channel, getSendData());
}
count = 0;
}
//////////////////////////
//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
}
}

View file

@ -1,4 +1,4 @@
package EUI.SteamPower; package SteamPower;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import universalelectricity.extend.IElectricUnit; import universalelectricity.extend.IElectricUnit;

View file

@ -1,4 +1,4 @@
package EUI.SteamPower.api; package SteamPower.ap;
/** /**
* The IHeatConsumer interface is an interface that must be applied to all tile entities that can receive heat joules. * The IHeatConsumer interface is an interface that must be applied to all tile entities that can receive heat joules.

View file

@ -1,4 +1,4 @@
package EUI.SteamPower.api; package SteamPower.ap;
public interface IHeatProducer public interface IHeatProducer

View file

@ -1,4 +1,4 @@
package EUI.SteamPower.boiler; package SteamPower.boiler;
import net.minecraft.src.*; import net.minecraft.src.*;
public class ContainerBoiler extends Container public class ContainerBoiler extends Container

View file

@ -0,0 +1,329 @@
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 universalelectricity.network.IPacketReceiver;
import BasicPipes.TradeHelper;
import BasicPipes.pipes.api.ILiquidConsumer;
import BasicPipes.pipes.api.ILiquidProducer;
import SteamPower.SteamPowerMain;
import SteamPower.TileEntityMachine;
import SteamPower.burner.TileEntityFireBox;
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 = 10000;
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);
}
private boolean getIsHeated() {
TileEntity blockEntity = worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
if(blockEntity instanceof TileEntityFireBox)
{
return true;
}
else
{
return false;
}
}
/**
* 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)
{
super.onUpdate(watts, voltage, side);
//update 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(entityList[c] == connectedBlocks[0] || entityList[c] == connectedBlocks[1])
{
}
else
{
tankCount++;
}
}
else
{
connectedBlocks[c] = null;
}
}
isBeingHeated = getIsHeated();
if(!worldObj.isRemote)
{
addWater();//adds water from container slot
this.waterStored = TradeHelper.shareLiquid(this, 1, false);
this.steamStored = TradeHelper.shareLiquid(this, 0, true);
//changed hullHeat max depending on contents of boiler
if(waterStored > 0)
{
hullHeatMax = 4700;
if(hullHeat > hullHeatMax)
{
hullHeat = 4700;
}
}
else
{
hullHeatMax = 10000;
}
//Checks if the hull is heated
if(hullHeat >= hullHeatMax)
{
hullHeated = true;
}
else
{
hullHeat = Math.min(hullHeat + heatStored, hullHeatMax);
}
//checks if heat level hit max
if(hullHeat >= 10000)
{
if(heatTick >= 1200)
{
// TODO remove block and set fire
heatTick = 0;
}
else
{
heatTick += 1;
}
}
//hull heated ? (do work) : move on
if(hullHeated)
{
if(heatStored > SteamPowerMain.fireOutput)
{
if(waterStored >= 1){
if(heatStored >= heatNeeded)
{
heatStored = Math.max(heatStored - heatNeeded, 0);
--waterStored;
steamStored = Math.min(steamStored + SteamPowerMain.steamOutBoiler,this.steamMax);
}
}
else
{
heatStored = 0;
}
}
}
TileEntity blockE = worldObj.getBlockTileEntity(xCoord, yCoord -1, zCoord);
if(blockE instanceof TileEntityFireBox)
{
if(!hullHeated || waterStored > 0)
{
heatStored = (int) Math.min((heatStored + ((TileEntityFireBox)blockE).onProduceHeat(SteamPowerMain.fireOutput, 1)), heatMax);
}
}
}
}
public int addSteam(int watt) {
int rejectedElectricity = Math.max((this.steamStored + watt) - steamMax, 0);
this.steamStored += watt - rejectedElectricity;
return rejectedElectricity;
}
private void addWater() {
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;
if(hullHeat < 100)
{
var1 = (int)(100 *(hullHeat/100));
}
else
{
var1 = 100;
}
return var1;
}
@Override
public int onReceiveLiquid(int type, int vol, ForgeDirection side) {
if(type == 1)
{
int rejectedElectricity = Math.max((this.waterStored + vol) - this.getLiquidCapacity(1), 0);
this.waterStored += vol - rejectedElectricity;
return rejectedElectricity;
}
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;
}
}

View file

@ -1,4 +1,4 @@
package EUI.SteamPower.burner; package SteamPower.burner;
import net.minecraft.src.*; import net.minecraft.src.*;

View file

@ -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.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.network.IPacketReceiver;
import BasicPipes.TradeHelper;
import SteamPower.TileEntityMachine;
import SteamPower.ap.IHeatProducer;
import SteamPower.boiler.TileEntityBoiler;
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 = SteamPower.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,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();
}
}
}

View file

@ -0,0 +1,185 @@
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 BlockEngine extends universalelectricity.extend.BlockMachine{
public BlockEngine(int par1) {
super("SteamEngine", par1, Material.iron);
}
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
par3List.add(new ItemStack(this, 1, 0));
}
@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;
}
@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 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 TileEntityGenerator)
{
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;
}
}
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 TileEntityGenerator();
}
if(metadata == 14)
{
return new TileEntitytopGen();
}
if(metadata == 15)
{
return null;
}
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 < 4)
{
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());
}
}

View file

@ -1,4 +1,4 @@
package EUI.SteamPower.turbine; package SteamPower.turbine;
import net.minecraft.src.*; import net.minecraft.src.*;

View file

@ -0,0 +1,66 @@
package SteamPower.turbine;
import java.util.List;
import SteamPower.SteamPowerMain;
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.Material;
import net.minecraft.src.MathHelper;
import net.minecraft.src.World;
public class ItemEngine extends Item
{
public ItemEngine(int par1)
{
super(par1);
this.maxStackSize = 5;
this.setTabToDisplayOn(CreativeTabs.tabBlock);
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
par3List.add(new ItemStack(this, 1, 0));
}
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(par3World.getBlockId(par4, par5, par6) == var11.blockID && par3World.getBlockMetadata(par4, par5, par6) == 15)
{
par3World.editingBlocks = true;
par3World.setBlockAndMetadataWithUpdate(par4, par5, par6, var11.blockID, 14,true);
par3World.notifyBlocksOfNeighborChange(par4, par5, par6, var11.blockID);
ePlayer.sendChatToPlayer(""+par3World.getBlockMetadata(par4, par5, par6));
par3World.editingBlocks = false;
}
else
{
if (ePlayer.canPlayerEdit(par4, par5, par6))
{
++par5;
if (var11.canPlaceBlockAt(par3World, par4, par5, par6))
{
par3World.editingBlocks = true;
par3World.setBlockAndMetadataWithNotify(par4, par5, par6, var11.blockID, angle);
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;
}
}

View file

@ -1,6 +1,4 @@
package EUI.SteamPower.turbine; package SteamPower.turbine;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.src.EntityPlayer; import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory; import net.minecraft.src.IInventory;
@ -13,16 +11,17 @@ import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory; import net.minecraftforge.common.ISidedInventory;
import universalelectricity.UniversalElectricity;
import universalelectricity.Vector3; import universalelectricity.Vector3;
import universalelectricity.electricity.ElectricityManager; import universalelectricity.electricity.ElectricityManager;
import universalelectricity.extend.IElectricUnit; import universalelectricity.extend.IElectricUnit;
import universalelectricity.extend.TileEntityConductor; import universalelectricity.extend.TileEntityConductor;
import universalelectricity.network.IPacketReceiver; import universalelectricity.network.IPacketReceiver;
import EUI.BasicPipes.pipes.api.ILiquidConsumer; import BasicPipes.pipes.api.ILiquidConsumer;
import EUI.BasicPipes.pipes.api.ILiquidProducer; import BasicPipes.pipes.api.ILiquidProducer;
import EUI.SteamPower.SteamPower; import SteamPower.SteamPowerMain;
import EUI.SteamPower.TileEntityMachine; import SteamPower.TileEntityMachine;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityGenerator extends TileEntityMachine implements IPacketReceiver, IElectricUnit,ILiquidConsumer,ILiquidProducer, IInventory, ISidedInventory public class TileEntityGenerator extends TileEntityMachine implements IPacketReceiver, IElectricUnit,ILiquidConsumer,ILiquidProducer, IInventory, ISidedInventory
{ {
@ -31,69 +30,115 @@ public class TileEntityGenerator extends TileEntityMachine implements IPacketRec
public int waterStored = 0; public int waterStored = 0;
public int steamStored = 0; public int steamStored = 0;
public int steamConsumed = 0; public int steamConsumed = 0;
public float position = 0;
public int count = 0;
//Current generation rate based on hull heat. In TICKS. //Current generation rate based on hull heat. In TICKS.
public float generateRate = 0; public float generateRate = 0;
//public TileEntityConductor connectedWire = null; //public TileEntityConductor connectedWire = null;
/** /**
* The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for * The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
*/ */
public int itemCookTime = 0; public int genTime = 0;
/** /**
* The ItemStacks that hold the items currently being used in the battery box * The ItemStacks that hold the items currently being used in the battery box
*/ */
private ItemStack[] containingItems = new ItemStack[1]; private ItemStack[] containingItems = new ItemStack[1];
public TileEntityConductor connectedElectricUnit = null; public TileEntityConductor connectedElectricUnit = null;
public boolean isConnected = false;
private boolean posT = true;
@Override @Override
public boolean canConnect(ForgeDirection side) public boolean canConnect(ForgeDirection side)
{ {
return true; 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 * 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. * ticks and creates a new spawn inside its implementation.
*/ */
public void onUpdate(float watts, float voltage, ForgeDirection side) public void onUpdate(float watts, float voltage, ForgeDirection side)
{ if(!this.worldObj.isRemote) {
{
super.onUpdate(watts, voltage, side); super.onUpdate(watts, voltage, side);
count++;
//Check nearby blocks and see if the conductor is full. If so, then it is connected float cPercent = (generateRate/10);
TileEntity tileEntity = Vector3.getUEUnitFromSide(this.worldObj, new Vector3(this.xCoord, this.yCoord, this.zCoord), ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite()); int cCount = 1;
if(cPercent > 25f)
if(tileEntity instanceof TileEntityConductor)
{ {
if(ElectricityManager.electricityRequired(((TileEntityConductor)tileEntity).connectionID) > 0) cCount = 2;
}
if(cPercent > 50f)
{
cCount = 3;
}
if(cPercent > 75f)
{
cCount = 4;
}
if(generateRate > 0)
{
if(position < 9f && posT )
{ {
this.connectedElectricUnit = (TileEntityConductor)tileEntity; position+= cCount;
} }
else else
{ {
this.connectedElectricUnit = null; posT = false;
} }
if(position > 1f && !posT )
{
position-= cCount;
}
else
{
posT = true;
}
count =0;
} }
else TileEntity ent = worldObj.getBlockTileEntity(xCoord, yCoord+1, zCoord);
if(ent instanceof TileEntitytopGen)
{ {
this.connectedElectricUnit = null; 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()) if(!this.isDisabled())
{ {
//Adds time to runTime by consuming steam //Adds time to runTime by consuming steam
if(this.itemCookTime <= 0) if(this.genTime <= 0)
{ {
if(steamStored > 0) if(steamStored > 0)
{ {
--steamStored; --steamStored;
++steamConsumed; ++steamConsumed;
if(steamConsumed == SteamPower.steamOutBoiler) if(steamConsumed >= SteamPowerMain.steamOutBoiler)
{ {
++waterStored; ++waterStored;
steamConsumed = 0; steamConsumed = 0;
} }
itemCookTime += 65; genTime += 65;
} }
} }
@ -111,17 +156,17 @@ public class TileEntityGenerator extends TileEntityMachine implements IPacketRec
} }
//Starts generating electricity if the device is heated up //Starts generating electricity if the device is heated up
if (this.itemCookTime > 0) if (this.genTime > 0)
{ {
this.itemCookTime --; this.genTime --;
if(this.connectedElectricUnit != null) if(this.connectedElectricUnit != null)
{ {
this.generateRate = (float)Math.min(this.generateRate+Math.min((this.generateRate)*0.001+0.0015, 0.05F), this.maxGenerateRate/20); 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.itemCookTime <= 0) if(this.connectedElectricUnit == null || this.genTime <= 0)
{ {
this.generateRate = (float)Math.max(this.generateRate-0.05, 0); this.generateRate = (float)Math.max(this.generateRate-0.05, 0);
} }
@ -139,7 +184,7 @@ public class TileEntityGenerator extends TileEntityMachine implements IPacketRec
public void readFromNBT(NBTTagCompound par1NBTTagCompound) public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{ {
super.readFromNBT(par1NBTTagCompound); super.readFromNBT(par1NBTTagCompound);
this.itemCookTime = par1NBTTagCompound.getInteger("itemCookTime"); this.genTime = par1NBTTagCompound.getInteger("itemCookTime");
this.waterStored = par1NBTTagCompound.getInteger("waterStored"); this.waterStored = par1NBTTagCompound.getInteger("waterStored");
this.steamConsumed = par1NBTTagCompound.getInteger("steamConsumed"); this.steamConsumed = par1NBTTagCompound.getInteger("steamConsumed");
this.steamStored = par1NBTTagCompound.getInteger("steamStored"); this.steamStored = par1NBTTagCompound.getInteger("steamStored");
@ -162,7 +207,7 @@ public class TileEntityGenerator extends TileEntityMachine implements IPacketRec
public void writeToNBT(NBTTagCompound par1NBTTagCompound) public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{ {
super.writeToNBT(par1NBTTagCompound); super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("itemCookTime", (int)this.itemCookTime); par1NBTTagCompound.setInteger("itemCookTime", (int)this.genTime);
par1NBTTagCompound.setInteger("waterStored", (int)this.waterStored); par1NBTTagCompound.setInteger("waterStored", (int)this.waterStored);
par1NBTTagCompound.setInteger("steamConsumed", (int)this.steamConsumed); par1NBTTagCompound.setInteger("steamConsumed", (int)this.steamConsumed);
par1NBTTagCompound.setInteger("steamStored", (int)this.steamStored); par1NBTTagCompound.setInteger("steamStored", (int)this.steamStored);
@ -273,13 +318,14 @@ public class TileEntityGenerator extends TileEntityMachine implements IPacketRec
} }
@Override @Override
public int onProduceLiquid(int type, int maxVol, ForgeDirection side) { public int onProduceLiquid(int type, int Vol, ForgeDirection side) {
if(type == 1) if(type == 1)
{ {
if(this.waterStored > 0) if(this.waterStored > 0)
{ {
--waterStored; int rejectedSteam = Math.max(Math.max((this.waterStored - Vol), 0),waterStored);
return 1; this.waterStored += waterStored - rejectedSteam;
return rejectedSteam;
} }
} }
return 0; return 0;
@ -334,7 +380,7 @@ public class TileEntityGenerator extends TileEntityMachine implements IPacketRec
@Override @Override
public Object[] getSendData() public Object[] getSendData()
{ {
return new Object[]{(int)facing,(int)waterStored,(int)steamStored,(int)steamConsumed,(int)generateRate,(int)itemCookTime}; return new Object[]{(int)facing,(int)waterStored,(int)steamStored,(int)steamConsumed,(float)generateRate,(int)genTime};
} }
@Override @Override
@ -347,8 +393,8 @@ public class TileEntityGenerator extends TileEntityMachine implements IPacketRec
waterStored = dataStream.readInt(); waterStored = dataStream.readInt();
steamStored = dataStream.readInt(); steamStored = dataStream.readInt();
steamConsumed = dataStream.readInt(); steamConsumed = dataStream.readInt();
generateRate = dataStream.readInt(); generateRate = dataStream.readFloat();
itemCookTime = dataStream.readInt(); genTime = dataStream.readInt();
} }
catch(Exception e) catch(Exception e)
{ {

View file

@ -0,0 +1,69 @@
package SteamPower.turbine;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
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.extend.IElectricUnit;
import universalelectricity.network.IPacketReceiver;
import BasicPipes.pipes.api.ILiquidConsumer;
import BasicPipes.pipes.api.ILiquidProducer;
import SteamPower.TileEntityMachine;
public class TileEntitytopGen extends TileEntityMachine implements IElectricUnit,ILiquidConsumer,ILiquidProducer {
public TileEntityGenerator 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 TileEntityGenerator)
{
genB = (TileEntityGenerator)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;
}
}

View file

@ -1,30 +0,0 @@
package EUIClient.SteamPower;
import org.lwjgl.opengl.GL11;
import EUI.SteamPower.SteamPower;
import net.minecraft.src.*;
public class RenderBoiler extends TileEntitySpecialRenderer
{
int type = 0;
private ModelTank model;
public RenderBoiler(float par1)
{
model = new ModelTank(par1);
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float d3) {
bindTextureByName(SteamPower.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.generalRender(0.0625F);
GL11.glPopMatrix();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -1,15 +1,16 @@
package EUIClient.SteamPower; 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 org.lwjgl.opengl.GL11;
import EUI.SteamPower.SteamPower; import SteamPower.burner.ContainerFireBox;
import EUI.SteamPower.burner.ContainerFireBox; import SteamPower.burner.TileEntityFireBox;
import EUI.SteamPower.burner.TileEntityFireBox;
import java.math.*;
import java.text.DecimalFormat;
import java.lang.Integer;
import net.minecraft.src.*;
public class GUIFireBox extends GuiContainer public class GUIFireBox extends GuiContainer
{ {
@ -36,11 +37,11 @@ public class GUIFireBox extends GuiContainer
{ {
displayText = "No Boiler"; displayText = "No Boiler";
} }
else if(tileEntity.containingItems[0] != null) else if(tileEntity.storedItems[0] != null)
{ {
if(tileEntity.containingItems[0].getItem().shiftedIndex != Item.coal.shiftedIndex) if(tileEntity.storedItems[0].getItem().shiftedIndex != Item.coal.shiftedIndex)
{ {
displayText = "No Coal"; displayText = "No Fuel";
} }
else{ else{
if(tileEntity.generateRate*20 < 20) if(tileEntity.generateRate*20 < 20)
@ -62,7 +63,7 @@ public class GUIFireBox extends GuiContainer
*/ */
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{ {
int var4 = this.mc.renderEngine.getTexture(SteamPower.textureFile+"SteamGUI.png"); int var4 = this.mc.renderEngine.getTexture(SteamPowerMain.textureFile+"SteamGUI.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4); this.mc.renderEngine.bindTexture(var4);
containerWidth = (this.width - this.xSize) / 2; containerWidth = (this.width - this.xSize) / 2;

View file

@ -1,14 +1,13 @@
package EUIClient.SteamPower; package SteamPower;
import net.minecraft.src.GuiContainer;
import net.minecraft.src.InventoryPlayer;
import net.minecraft.src.StatCollector;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import EUI.SteamPower.SteamPower; import SteamPower.turbine.ContainerGenerator;
import EUI.SteamPower.turbine.ContainerGenerator; import SteamPower.turbine.TileEntityGenerator;
import EUI.SteamPower.turbine.TileEntityGenerator;
import java.math.*;
import java.lang.Integer;
import net.minecraft.src.*;
public class GUIGenerator extends GuiContainer public class GUIGenerator extends GuiContainer
{ {
@ -35,9 +34,10 @@ import net.minecraft.src.*;
String displayText3 = ""; String displayText3 = "";
if(tileEntity.connectedElectricUnit == null) if(tileEntity.connectedElectricUnit == null)
{ {
displayText = "Not Connected"; displayText = "Not Connected";
} }
else if(tileEntity.generateRate*20 <= 0) else
if(tileEntity.generateRate*20 <= 0)
{ {
if(tileEntity.steamStored> 0) if(tileEntity.steamStored> 0)
{ {
@ -48,6 +48,7 @@ import net.minecraft.src.*;
displayText = "No Steam"; displayText = "No Steam";
} }
} }
else if(tileEntity.generateRate*20 < 20) else if(tileEntity.generateRate*20 < 20)
{ {
displayText = "Warming UP: "+(int)(tileEntity.generateRate*100)+"%"; displayText = "Warming UP: "+(int)(tileEntity.generateRate*100)+"%";
@ -69,7 +70,7 @@ import net.minecraft.src.*;
*/ */
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{ {
int var4 = this.mc.renderEngine.getTexture(SteamPower.textureFile+"SteamGUI.png"); int var4 = this.mc.renderEngine.getTexture(SteamPowerMain.textureFile+"SteamGUI.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4); this.mc.renderEngine.bindTexture(var4);
containerWidth = (this.width - this.xSize) / 2; containerWidth = (this.width - this.xSize) / 2;

View file

@ -1,13 +1,14 @@
package EUIClient.SteamPower; package SteamPower;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import net.minecraft.src.*; import net.minecraft.src.GuiContainer;
import net.minecraft.src.InventoryPlayer;
import net.minecraft.src.StatCollector;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import EUI.SteamPower.SteamPower; import SteamPower.boiler.ContainerBoiler;
import EUI.SteamPower.boiler.ContainerBoiler; import SteamPower.boiler.TileEntityBoiler;
import EUI.SteamPower.boiler.TileEntityBoiler;
public class GuiBoiler extends GuiContainer public class GuiBoiler extends GuiContainer
{ {
@ -37,7 +38,7 @@ public class GuiBoiler extends GuiContainer
*/ */
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{ {
int var4 = this.mc.renderEngine.getTexture(SteamPower.textureFile+"BoilerGui.png"); int var4 = this.mc.renderEngine.getTexture(SteamPowerMain.textureFile+"BoilerGui.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4); this.mc.renderEngine.bindTexture(var4);
int var5 = (this.width - this.xSize) / 2; int var5 = (this.width - this.xSize) / 2;

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -9,7 +9,7 @@
package EUIClient.SteamPower; package SteamPower;
import net.minecraft.src.Entity; import net.minecraft.src.Entity;
import net.minecraft.src.ModelBase; import net.minecraft.src.ModelBase;

View file

@ -9,7 +9,7 @@
package EUIClient.SteamPower; package SteamPower;
import net.minecraft.src.Entity; import net.minecraft.src.Entity;
import net.minecraft.src.ModelBase; import net.minecraft.src.ModelBase;
@ -17,7 +17,7 @@ import net.minecraft.src.ModelRenderer;
public class ModelTank extends ModelBase public class ModelTank extends ModelBase
{ {
//fields //One Block Tank
ModelRenderer TANK_WALL_1; ModelRenderer TANK_WALL_1;
ModelRenderer TANK_WALL_2; ModelRenderer TANK_WALL_2;
ModelRenderer TANK_WALL_3; ModelRenderer TANK_WALL_3;
@ -121,7 +121,6 @@ public class ModelTank extends ModelBase
{ {
super.render(entity, f, f1, f2, f3, f4, f5); super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5);
generalRender(f5);
} }
public void generalRender(float f5) public void generalRender(float f5)
{ {

View file

@ -9,13 +9,13 @@
package EUIClient.SteamPower; package SteamPower;
import net.minecraft.src.Entity; import net.minecraft.src.Entity;
import net.minecraft.src.ModelBase; import net.minecraft.src.ModelBase;
import net.minecraft.src.ModelRenderer; import net.minecraft.src.ModelRenderer;
public class ModelEngine extends ModelBase public class ModelToyEngine extends ModelBase
{ {
//fields //fields
ModelRenderer BASE; ModelRenderer BASE;
@ -43,7 +43,7 @@ public class ModelEngine extends ModelBase
ModelRenderer LEVER_1_CAN_BE_TURNED; ModelRenderer LEVER_1_CAN_BE_TURNED;
ModelRenderer LEVER_2_CAN_BE_TURNED; ModelRenderer LEVER_2_CAN_BE_TURNED;
public ModelEngine() public ModelToyEngine()
{ {
textureWidth = 128; textureWidth = 128;
textureHeight = 128; textureHeight = 128;

View file

@ -0,0 +1,62 @@
package SteamPower;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11;
import BasicPipes.TradeHelper;
import SteamPower.boiler.TileEntityBoiler;
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();
}
}

View file

@ -1,10 +1,10 @@
package EUIClient.SteamPower; package SteamPower;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import EUI.SteamPower.SteamPower;
import net.minecraft.src.*;
public class RenderFurnace extends TileEntitySpecialRenderer public class RenderFurnace extends TileEntitySpecialRenderer
{ {
int type = 0; int type = 0;
@ -18,10 +18,18 @@ public class RenderFurnace extends TileEntitySpecialRenderer
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float d3) { public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float d3) {
bindTextureByName(SteamPower.textureFile+"Furnace.png"); bindTextureByName(SteamPowerMain.textureFile+"Furnace.png");
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F); 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); model.genRender(0.0625F);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }

View file

@ -0,0 +1,49 @@
package SteamPower;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11;
import SteamPower.turbine.TileEntityGenerator;
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 = ((TileEntityGenerator)tileEntity).position;
boolean cc = ((TileEntityGenerator)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();
}
}

View file

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

View file

@ -1,21 +1,14 @@
package EUIClient.SteamPower; package SteamPower;
import EUI.SteamPower.SteamProxy; import net.minecraft.src.RenderEngine;
import EUI.SteamPower.TileEntityNuller;
import EUI.SteamPower.boiler.TileEntityBoiler;
import EUI.SteamPower.burner.TileEntityFireBox;
import EUI.SteamPower.turbine.TileEntityGenerator;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ModelBiped;
import net.minecraft.src.RenderBiped;
import net.minecraft.src.RenderBlocks;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.MinecraftForgeClient;
import SteamPower.boiler.TileEntityBoiler;
import SteamPower.burner.TileEntityFireBox;
import SteamPower.turbine.TileEntityGenerator;
import SteamPower.turbine.TileEntitytopGen;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
public class SteamClientProxy extends SteamProxy{ public class SteamClientProxy extends SteamProxy{