Clean up and bugs fixes

This commit is contained in:
Rseifert 2012-08-27 19:37:32 -04:00
parent 66fc0aee1b
commit 93d020863c
21 changed files with 155 additions and 850 deletions

View file

@ -3,8 +3,6 @@ package BasicPipes;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import BasicPipes.pipes.api.ILiquidConsumer;
import SteamPower.TileEntityMachine;
import SteamPower.boiler.TileEntityBoiler;
public class TradeHelper {
/**
@ -39,7 +37,7 @@ public class TradeHelper {
return list;
}
/**
*
* Only works for steam Power's boiler. Still needs recode to work for all things
* @param blockEntity - tile entity trading the liquid
* @param type - liquid type see chart for info
* @param rise - does the liquid rise up like a gas
@ -66,17 +64,18 @@ public class TradeHelper {
secondEntity = connectedBlocks[1];
}
//checks wether or not the block bellow it is a tank to move liquid too
if(firstEntity instanceof TileEntityBoiler)
if(firstEntity instanceof ILiquidConsumer)
{
int bWater = ((TileEntityBoiler) firstEntity).getStoredLiquid(1);
int bMax = ((TileEntityBoiler) firstEntity).getLiquidCapacity(1);
int bWater = ((ILiquidConsumer) firstEntity).getStoredLiquid(type);
int bMax = ((ILiquidConsumer) firstEntity).getLiquidCapacity(type);
//checks if that tank has room to get liquid.
if(bWater < bMax)
{
int tradeVol = 0;
int emptyVol = Math.max( bMax - bWater,0);
int tradeVol = Math.min(emptyVol, ammountStored);
int rejected = ((TileEntityBoiler) firstEntity).onReceiveLiquid(1, tradeVol, ForgeDirection.getOrientation(1));
tradeVol = Math.min(emptyVol, ammountStored);
int rejected = ((ILiquidConsumer) firstEntity).onReceiveLiquid(type, tradeVol, ForgeDirection.getOrientation(1));
ammountStored = ammountStored + rejected - tradeVol;
wSum -= tradeVol;
}
@ -97,47 +96,49 @@ public class TradeHelper {
for(int i = 2; i<6;i++)
{
TileEntity entityA = connectedBlocks[i];
if(entityA instanceof TileEntityBoiler)
if(entityA instanceof ILiquidConsumer)
{
//if is a tank add to the sum
wSum += ((TileEntityBoiler) entityA).getStoredLiquid(1);
wSum += ((ILiquidConsumer) entityA).getStoredLiquid(type);
tankCount += 1;
}
}
}
//if this is the bottom tank or bottom tank is full then trade liquid with tanks around it.
for(int i = 2; i<6;i++)
{
int average = wSum / tankCount;// takes the sum and makes it an average
int average = Math.round((float)wSum / (float)tankCount);// takes the sum and makes it an average
int tradeSum = 0;
TileEntity entity = connectedBlocks[i];
if(entity instanceof TileEntityBoiler)
if(entity instanceof ILiquidConsumer)
{
int targetW = ((TileEntityBoiler) entity).getStoredLiquid(1);
int targetW = ((ILiquidConsumer) entity).getStoredLiquid(type);
if(targetW < average)
{
tradeSum = Math.min(average, ammountStored); //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
int rejectedAm = ((ILiquidConsumer) entity).onReceiveLiquid(type, tradeSum, ForgeDirection.getOrientation(i)); //send that ammount with safty incase some comes back
ammountStored =rejectedAm + ammountStored - tradeSum; //counts up current water sum after trade
}
}
}
if(secondEntity instanceof TileEntityBoiler)
if(secondEntity instanceof ILiquidConsumer)
{
int bWater = ((TileEntityBoiler) secondEntity).getStoredLiquid(1);
int bMax = ((TileEntityBoiler) secondEntity).getLiquidCapacity(1);
int bWater = ((ILiquidConsumer) secondEntity).getStoredLiquid(type);
int bMax = ((ILiquidConsumer) secondEntity).getLiquidCapacity(type);
if(bottom && ammountStored > 0)
{
if(bWater < bMax)
{
int emptyVolS = Math.max( bMax - bWater,0);
int tradeVolS = Math.min(emptyVolS, ammountStored);
int rejectedS = ((TileEntityBoiler) secondEntity).addSteam(tradeVolS);
int rejectedS = ((ILiquidConsumer) secondEntity).onReceiveLiquid(type, tradeVolS, ForgeDirection.getOrientation(0));;
ammountStored =rejectedS + ammountStored - tradeVolS;
wSum -= tradeVolS;
}
}
}
}
return ammountStored;
}
/**

View file

@ -15,7 +15,7 @@ import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import SteamPower.boiler.TileEntityBoiler;
import SteamPower.burner.TileEntityFireBox;
import SteamPower.turbine.TileEntityGenerator;
import SteamPower.turbine.TileEntitySteamPiston;
public class BlockMachine extends universalelectricity.extend.BlockMachine
{
@ -31,14 +31,6 @@ public class BlockMachine extends universalelectricity.extend.BlockMachine
}
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
par3List.add(new ItemStack(this, 1, 1));
par3List.add(new ItemStack(this, 1, 2));
par3List.add(new ItemStack(this, 1, 15));
}
@Override
protected int damageDropped(int metadata)
{
return metadata;

View file

@ -1,59 +0,0 @@
package SteamPower;
import java.util.ArrayList;
import net.minecraft.src.*;
public class ItemCoalFuel extends Item
{
public ItemCoalFuel(int par1)
{
super(par1);
this.setItemName("CoalDust");
this.setHasSubtypes(true);
this.setMaxDamage(0);
this.setMaxStackSize(64);
}
@Override
public int getIconFromDamage(int par1)
{
switch(par1)
{
case 0: return 0;
case 1: return 1;
case 2: return 2;
}
return this.iconIndex;
}
@Override
public String getTextureFile() {
// TODO Auto-generated method stub
return "/eui/Items.png";
}
public String getItemName()
{
return "CoalDust";
}
public String getItemNameIS(ItemStack par1ItemStack)
{
int var3 = par1ItemStack.getItemDamage();
switch(var3)
{
case 0: return "CoalNuggets";
case 1: return "CoalPellets";
case 2: return "CoalDust";
}
return this.getItemName();
}
public void addCreativeItems(ArrayList itemList) {
itemList.add(new ItemStack(this, 1,0));
itemList.add(new ItemStack(this, 1,1));
itemList.add(new ItemStack(this, 1,2));
}
}

View file

@ -10,6 +10,7 @@ public class ItemMachine extends ItemBlock {
super(id);
setMaxDamage(0);
setHasSubtypes(true);
this.setIconIndex(21);
this.setTabToDisplayOn(CreativeTabs.tabBlock);
}
@Override
@ -18,10 +19,25 @@ public class ItemMachine extends ItemBlock {
par3List.add(new ItemStack(this, 1, 1));
par3List.add(new ItemStack(this, 1, 2));
par3List.add(new ItemStack(this, 1, 3));
par3List.add(new ItemStack(this, 1, 15));
}
@Override
public String getTextureFile() {
// TODO Auto-generated method stub
return "/EUIClient/Textures/Items.png";
}
@Override
public int getIconFromDamage(int par1)
{
switch(par1)
{
case 1: return 23;
case 2: return 22;
case 15: return 22;
}
return this.iconIndex+par1;
}
@Override
public int getMetadata(int metadata)
{
return metadata;

View file

@ -33,7 +33,7 @@ public class ItemParts extends Item{
@Override
public String getTextureFile() {
// TODO Auto-generated method stub
return "/eui/Items.png";
return "/EUIClient/Textures/Items.png";
}
public String getItemName()
{

View file

@ -1,7 +1,8 @@
package SteamPower;
import java.io.File;
import SteamPower.turbine.BlockEngine;
import SteamPower.turbine.BlockGenerator;
import SteamPower.turbine.BlockSteamPiston;
import SteamPower.turbine.ItemEngine;
import SteamPower.turbine.TileEntitytopGen;
@ -35,6 +36,7 @@ public class SteamPowerMain{
private static int BlockID= configurationProperties();
public static int EngineItemID;
public static int EngineID;
public static int genID;
public static int genOutput;
public static int steamOutBoiler;
public static int pipeLoss;
@ -42,7 +44,8 @@ public class SteamPowerMain{
public static int fireOutput;
public static final String channel = "SPpack";
public static Block machine = new BlockMachine(BlockID).setBlockName("machine");
public static Block engine = new BlockEngine(EngineID).setBlockName("SteamEngien");
public static Block engine = new BlockSteamPiston(EngineID).setBlockName("SteamEngien");
public static Block gen = new BlockGenerator(genID).setBlockName("ElecGen");
public static Item itemEngine = new ItemEngine(EngineItemID).setItemName("SteamEngine");
@Instance
public static SteamPowerMain instance;
@ -56,6 +59,7 @@ public class SteamPowerMain{
BlockID = Integer.parseInt(config.getOrCreateIntProperty("MachinesID", Configuration.CATEGORY_BLOCK, 3030).value);
EngineItemID = Integer.parseInt(config.getOrCreateIntProperty("EngineItem", Configuration.CATEGORY_ITEM, 30308).value);
EngineID = Integer.parseInt(config.getOrCreateIntProperty("SteamEngineID", Configuration.CATEGORY_BLOCK, 3031).value);
genID = Integer.parseInt(config.getOrCreateIntProperty("ElecGenID", Configuration.CATEGORY_BLOCK, 3032).value);
genOutput = Integer.parseInt(config.getOrCreateIntProperty("genOutputWattsmax", Configuration.CATEGORY_GENERAL, 1000).value);
steamOutBoiler = Integer.parseInt(config.getOrCreateIntProperty("steamOutPerCycle", Configuration.CATEGORY_GENERAL, 10).value);
boilerHeat = Integer.parseInt(config.getOrCreateIntProperty("boilerInKJNeed", Configuration.CATEGORY_GENERAL, 4500).value);
@ -71,6 +75,7 @@ public class SteamPowerMain{
proxy.preInit();
GameRegistry.registerBlock(machine, ItemMachine.class);
GameRegistry.registerBlock(engine);
GameRegistry.registerBlock(gen);
}
@Init
public void load(FMLInitializationEvent evt)
@ -80,6 +85,7 @@ public class SteamPowerMain{
GameRegistry.registerTileEntity(TileEntitytopGen.class, "gentop");
//Names...............
LanguageRegistry.addName((new ItemStack(machine, 1, 1)), "Boiler");
LanguageRegistry.addName((new ItemStack(gen, 1, 0)), "Generator");
LanguageRegistry.addName((new ItemStack(machine, 1, 2)), "FireBox");
LanguageRegistry.addName((new ItemStack(itemEngine, 1, 0)), "SteamPiston");
LanguageRegistry.addName((new ItemStack(machine, 1, 15)), "EUVampire");

View file

@ -8,7 +8,8 @@ import SteamPower.boiler.TileEntityBoiler;
import SteamPower.burner.ContainerFireBox;
import SteamPower.burner.TileEntityFireBox;
import SteamPower.turbine.ContainerGenerator;
import SteamPower.turbine.TileEntityGenerator;
import SteamPower.turbine.TileEntityGen;
import SteamPower.turbine.TileEntitySteamPiston;
import SteamPower.turbine.TileEntitytopGen;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
@ -23,8 +24,8 @@ public class SteamProxy implements IGuiHandler{
{
GameRegistry.registerTileEntity(TileEntityBoiler.class, "boiler");
GameRegistry.registerTileEntity(TileEntityFireBox.class, "fireBox");
GameRegistry.registerTileEntity(TileEntityGenerator.class, "generator");
GameRegistry.registerTileEntity(TileEntitySteamPiston.class, "steamPiston");
GameRegistry.registerTileEntity(TileEntityGen.class, "elecGen");
}
public void postInit()
@ -42,7 +43,7 @@ public class SteamProxy implements IGuiHandler{
{
case 0: return new GUIFireBox(player.inventory, ((TileEntityFireBox)tileEntity));
case 1: return new GuiBoiler(player.inventory, ((TileEntityBoiler)tileEntity));
case 2: return new GUIGenerator(player.inventory, ((TileEntityGenerator)tileEntity));
case 2: return new GUIGenerator(player.inventory, ((TileEntitySteamPiston)tileEntity));
}
}
@ -60,7 +61,7 @@ public class SteamProxy implements IGuiHandler{
{
case 0: return new ContainerFireBox(player.inventory, ((TileEntityFireBox)tileEntity));
case 1: return new ContainerBoiler(player.inventory, ((TileEntityBoiler)tileEntity));
case 2: return new ContainerGenerator(player.inventory, ((TileEntityGenerator)tileEntity));
case 2: return new ContainerGenerator(player.inventory, ((TileEntitySteamPiston)tileEntity));
}
}

View file

@ -16,7 +16,7 @@ public class TileEntityMachine extends TileEntityElectricUnit implements IInven
public ItemStack[] storedItems = new ItemStack[this.getInvSize()];
public int getTickInterval()
{
return 10;
return 5;
}
private int getInvSize() {
@ -128,14 +128,11 @@ public class TileEntityMachine extends TileEntityElectricUnit implements IInven
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;
}

View file

@ -20,7 +20,7 @@ public class TileEntityNuller extends TileEntityMachine implements IElectricUnit
}
public int getTickInterval()
{
return 1;
return 10;
}
public boolean canConnect(ForgeDirection side)
{

View file

@ -38,7 +38,7 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
public int heatMax = 10000;
/** The ammount of heat stored */
public int hullHeat = 0;
public int hullHeatMax = 10000;
public int hullHeatMax = 4700;
private int heatTick = 0;
public int tankCount = 0;
private int heatNeeded = SteamPowerMain.boilerHeat; // kilo joules
@ -61,7 +61,8 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
public void handlePacketData(NetworkManager network,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput dataStream) {
try{
try
{
facing = dataStream.readInt();
RunTime = dataStream.readInt();
energyStore = dataStream.readInt();
@ -105,19 +106,6 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
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.
@ -125,21 +113,16 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
@Override
public void onUpdate(float watts, float voltage, ForgeDirection side)
{
super.onUpdate(watts, voltage, side);
//update connection list
//update/resets connection list
TileEntity[] entityList = TradeHelper.getSourounding(this);
tankCount = 0;
for(int c = 0; c< 6; c++)
{
if(entityList[c] instanceof TileEntityBoiler)
{
connectedBlocks[c] = entityList[c];
if(entityList[c] == connectedBlocks[0] || entityList[c] == connectedBlocks[1])
{
}
else
if(c != 0 && c != 1)
{
tankCount++;
}
@ -149,89 +132,42 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
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
hullHeated = false;
if(hullHeat >= hullHeatMax)
{
hullHeated = true;
}
else
{
if(!worldObj.isRemote)
{
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
if(!worldObj.isRemote)
{
heatTick += 1;
}
}
//hull heated ? (do work) : move on
if(hullHeated)
{
if(heatStored > SteamPowerMain.fireOutput)
{
if(waterStored >= 1){
if(heatStored >= heatNeeded)
emptyBuckets();//adds water from container slot
this.waterStored = TradeHelper.shareLiquid(this, 1, false);
this.steamStored = TradeHelper.shareLiquid(this, 0, true);
if(waterStored > 0 && hullHeated && heatStored > heatNeeded)
{
heatStored = Math.max(heatStored - heatNeeded, 0);
--waterStored;
steamStored = Math.min(steamStored + SteamPowerMain.steamOutBoiler,this.steamMax);
}
}
else
{
heatStored = 0;
}
}
}
TileEntity blockE = worldObj.getBlockTileEntity(xCoord, yCoord -1, zCoord);
this.isBeingHeated = false;
if(blockE instanceof TileEntityFireBox)
{
if(!hullHeated || waterStored > 0)
this.isBeingHeated = true;
heatStored = (int) Math.min((heatStored + ((TileEntityFireBox)blockE).onProduceHeat(SteamPowerMain.fireOutput*getTickInterval(), 1)), heatMax);
}
}
super.onUpdate(watts, voltage, side);
}
private void emptyBuckets()
{
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)))
@ -247,10 +183,10 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
}
public int precentHeated() {
int var1;
int var1 = 0;
if(hullHeat < 100)
{
var1 = (int)(100 *(hullHeat/100));
var1 = (int)(100 *(hullHeat/hullHeatMax));
}
else
{
@ -260,11 +196,17 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
}
@Override
public int onReceiveLiquid(int type, int vol, ForgeDirection side) {
if(type == 0)
{
int rejectedSteam = Math.max((this.steamStored + vol) - this.getLiquidCapacity(0), 0);
this.steamStored += vol - rejectedSteam;
return rejectedSteam;
}
if(type == 1)
{
int rejectedElectricity = Math.max((this.waterStored + vol) - this.getLiquidCapacity(1), 0);
this.waterStored += vol - rejectedElectricity;
return rejectedElectricity;
int rejectedWater = Math.max((this.waterStored + vol) - this.getLiquidCapacity(1), 0);
this.waterStored += vol - rejectedWater;
return rejectedWater;
}
return vol;
}

View file

@ -175,7 +175,7 @@ public class TileEntityFireBox extends TileEntityMachine implements IPacketRecei
}
public float onProduceHeat(float jouls, int side) {
// TODO Auto-generated method stub
return Math.min(generateRate,jouls);
return Math.min(generateRate*getTickInterval(),jouls);
}
@Override
public Object[] getSendData()

View file

@ -1,185 +0,0 @@
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

@ -4,9 +4,9 @@ import net.minecraft.src.*;
public class ContainerGenerator extends Container
{
private TileEntityGenerator tileEntity;
private TileEntitySteamPiston tileEntity;
public ContainerGenerator(InventoryPlayer par1InventoryPlayer, TileEntityGenerator tileEntity)
public ContainerGenerator(InventoryPlayer par1InventoryPlayer, TileEntitySteamPiston tileEntity)
{
this.tileEntity = tileEntity;
this.addSlotToContainer(new Slot(tileEntity, 0, 33, 34));

View file

@ -18,12 +18,19 @@ public class ItemEngine extends Item
super(par1);
this.maxStackSize = 5;
this.setTabToDisplayOn(CreativeTabs.tabBlock);
this.setIconIndex(21);
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
par3List.add(new ItemStack(this, 1, 0));
}
@Override
public String getTextureFile() {
// TODO Auto-generated method stub
return "/EUIClient/Textures/Items.png";
}
@Override
public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer ePlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if (par3World.isRemote)
@ -33,24 +40,14 @@ public class ItemEngine extends Item
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.setBlockAndMetadataWithNotify(par4, par5, par6, var11.blockID, 1);
par3World.notifyBlocksOfNeighborChange(par4, par5, par6, var11.blockID);
par3World.setBlockAndMetadataWithNotify(par4, par5+1, par6, var11.blockID, 14);
par3World.notifyBlocksOfNeighborChange(par4, par5, par6, var11.blockID);
@ -60,7 +57,7 @@ public class ItemEngine extends Item
return true;
}
}
}
return false;
}
}

View file

@ -1,405 +0,0 @@
package SteamPower.turbine;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
import universalelectricity.Vector3;
import universalelectricity.electricity.ElectricityManager;
import universalelectricity.extend.IElectricUnit;
import universalelectricity.extend.TileEntityConductor;
import universalelectricity.network.IPacketReceiver;
import BasicPipes.pipes.api.ILiquidConsumer;
import BasicPipes.pipes.api.ILiquidProducer;
import SteamPower.SteamPowerMain;
import SteamPower.TileEntityMachine;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityGenerator extends TileEntityMachine implements IPacketReceiver, IElectricUnit,ILiquidConsumer,ILiquidProducer, IInventory, ISidedInventory
{
//Maximum possible generation rate of watts in SECONDS
public int maxGenerateRate = 1000;
public int waterStored = 0;
public int steamStored = 0;
public int steamConsumed = 0;
public float position = 0;
public int count = 0;
//Current generation rate based on hull heat. In TICKS.
public float generateRate = 0;
//public TileEntityConductor connectedWire = null;
/**
* The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
*/
public int genTime = 0;
/**
* The ItemStacks that hold the items currently being used in the battery box
*/
private ItemStack[] containingItems = new ItemStack[1];
public TileEntityConductor connectedElectricUnit = null;
public boolean isConnected = false;
private boolean posT = true;
@Override
public boolean canConnect(ForgeDirection side)
{
return true;
}
public int getTickInterval()
{
return 10;
}
/**
* Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
* ticks and creates a new spawn inside its implementation.
*/
public void onUpdate(float watts, float voltage, ForgeDirection side)
{
super.onUpdate(watts, voltage, side);
count++;
float cPercent = (generateRate/10);
int cCount = 1;
if(cPercent > 25f)
{
cCount = 2;
}
if(cPercent > 50f)
{
cCount = 3;
}
if(cPercent > 75f)
{
cCount = 4;
}
if(generateRate > 0)
{
if(position < 9f && posT )
{
position+= cCount;
}
else
{
posT = false;
}
if(position > 1f && !posT )
{
position-= cCount;
}
else
{
posT = true;
}
count =0;
}
TileEntity ent = worldObj.getBlockTileEntity(xCoord, yCoord+1, zCoord);
if(ent instanceof TileEntitytopGen)
{
isConnected = true;
}
this.connectedElectricUnit = null;
//Check nearby blocks and see if the conductor is full. If so, then it is connected
for(int i = 0;i<6;i++)
{
TileEntity tileEntity = Vector3.getUEUnitFromSide(this.worldObj, new Vector3(this.xCoord, this.yCoord, this.zCoord),
ForgeDirection.getOrientation(i));
if (tileEntity instanceof TileEntityConductor)
{
if (ElectricityManager.electricityRequired(((TileEntityConductor)tileEntity).connectionID) > 0)
{
this.connectedElectricUnit = (TileEntityConductor)tileEntity;
}
}
}
if(!this.worldObj.isRemote)
{
if(!this.isDisabled())
{
//Adds time to runTime by consuming steam
if(this.genTime <= 0)
{
if(steamStored > 0)
{
--steamStored;
++steamConsumed;
if(steamConsumed >= SteamPowerMain.steamOutBoiler)
{
++waterStored;
steamConsumed = 0;
}
genTime += 65;
}
}
//Empties water from tank to buckets
if (this.containingItems[0] != null)
{
if(this.containingItems[0].getItem().shiftedIndex == Item.bucketEmpty.shiftedIndex)
{
if(this.waterStored > 0)
{
this.containingItems[0] = new ItemStack(Item.bucketWater,1);
--waterStored;
}
}
}
//Starts generating electricity if the device is heated up
if (this.genTime > 0)
{
this.genTime --;
if(this.connectedElectricUnit != null)
{
this.generateRate = (float)Math.min(this.generateRate+Math.min((this.generateRate)*0.01+0.015, 0.05F), this.maxGenerateRate/20);
}
}
if(this.connectedElectricUnit == null || this.genTime <= 0)
{
this.generateRate = (float)Math.max(this.generateRate-0.05, 0);
}
if(this.generateRate > 1)
{
ElectricityManager.produceElectricity(this.connectedElectricUnit, this.generateRate*this.getTickInterval(), this.getVoltage());
}
}
}
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.genTime = par1NBTTagCompound.getInteger("itemCookTime");
this.waterStored = par1NBTTagCompound.getInteger("waterStored");
this.steamConsumed = par1NBTTagCompound.getInteger("steamConsumed");
this.steamStored = par1NBTTagCompound.getInteger("steamStored");
this.generateRate = par1NBTTagCompound.getFloat("generateRate");
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.containingItems = new ItemStack[this.getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
{
NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < this.containingItems.length)
{
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("itemCookTime", (int)this.genTime);
par1NBTTagCompound.setInteger("waterStored", (int)this.waterStored);
par1NBTTagCompound.setInteger("steamConsumed", (int)this.steamConsumed);
par1NBTTagCompound.setInteger("steamStored", (int)this.steamStored);
par1NBTTagCompound.setFloat("generateRate", (int)this.generateRate);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
{
if (this.containingItems[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.containingItems[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
par1NBTTagCompound.setTag("Items", var2);
}
@Override
public int getStartInventorySide(ForgeDirection side)
{
return 0;
}
@Override
public int getSizeInventorySide(ForgeDirection side) { return 0; }
@Override
public int getSizeInventory() { return this.containingItems.length; }
@Override
public ItemStack getStackInSlot(int par1) { return this.containingItems[par1]; }
@Override
public ItemStack decrStackSize(int par1, int par2)
{
if (this.containingItems[par1] != null)
{
ItemStack var3;
if (this.containingItems[par1].stackSize <= par2)
{
var3 = this.containingItems[par1];
this.containingItems[par1] = null;
return var3;
}
else
{
var3 = this.containingItems[par1].splitStack(par2);
if (this.containingItems[par1].stackSize == 0)
{
this.containingItems[par1] = null;
}
return var3;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int par1)
{
if (this.containingItems[par1] != null)
{
ItemStack var2 = this.containingItems[par1];
this.containingItems[par1] = null;
return var2;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
this.containingItems[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInvName() {
return "SteamGen";
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
{
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
}
@Override
public void openChest() { }
@Override
public void closeChest() { }
@Override
public void onDisable(int duration) {
// TODO Auto-generated method stub
}
@Override
public boolean isDisabled() {
// TODO Auto-generated method stub
return false;
}
@Override
public int onProduceLiquid(int type, int Vol, ForgeDirection side) {
if(type == 1)
{
if(this.waterStored > 0)
{
int rejectedSteam = Math.max(Math.max((this.waterStored - Vol), 0),waterStored);
this.waterStored += waterStored - rejectedSteam;
return rejectedSteam;
}
}
return 0;
}
@Override
public boolean canProduceLiquid(int type, ForgeDirection side) {
if(type == 1)
{
return true;
}
return false;
}
@Override
public int onReceiveLiquid(int type, int vol, ForgeDirection side) {
if(type == 0)
{
int rejectedSteam = Math.max((this.steamStored + vol) - 100, 0);
this.steamStored += vol - rejectedSteam;
return rejectedSteam;
}
return vol;
}
@Override
public boolean canRecieveLiquid(int type, ForgeDirection side) {
if(type == 0)
{
return true;
}
return false;
}
@Override
public int getStoredLiquid(int type) {
if(type == 0)
{
return this.steamStored;
}
return 0;
}
@Override
public int getLiquidCapacity(int type) {
if(type == 0)
{
return 100;
}
return 0;
}
@Override
public Object[] getSendData()
{
return new Object[]{(int)facing,(int)waterStored,(int)steamStored,(int)steamConsumed,(float)generateRate,(int)genTime};
}
@Override
public void handlePacketData(NetworkManager network,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput dataStream) {
try
{
facing = dataStream.readInt();
waterStored = dataStream.readInt();
steamStored = dataStream.readInt();
steamConsumed = dataStream.readInt();
generateRate = dataStream.readFloat();
genTime = dataStream.readInt();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

View file

@ -17,16 +17,16 @@ import BasicPipes.pipes.api.ILiquidProducer;
import SteamPower.TileEntityMachine;
public class TileEntitytopGen extends TileEntityMachine implements IElectricUnit,ILiquidConsumer,ILiquidProducer {
public TileEntityGenerator genB = null;
public TileEntitySteamPiston genB = null;
public void onUpdate(float watts, float voltage, ForgeDirection side)
{
if(!this.worldObj.isRemote)
{
super.onUpdate(watts, voltage, side);
TileEntity ent = worldObj.getBlockTileEntity(xCoord, yCoord-1, xCoord);
if(ent instanceof TileEntityGenerator)
if(ent instanceof TileEntitySteamPiston)
{
genB = (TileEntityGenerator)ent;
genB = (TileEntitySteamPiston)ent;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View file

@ -7,16 +7,16 @@ import net.minecraft.src.StatCollector;
import org.lwjgl.opengl.GL11;
import SteamPower.turbine.ContainerGenerator;
import SteamPower.turbine.TileEntityGenerator;
import SteamPower.turbine.TileEntitySteamPiston;
public class GUIGenerator extends GuiContainer
{
private TileEntityGenerator tileEntity;
private TileEntitySteamPiston tileEntity;
private int containerWidth;
private int containerHeight;
public GUIGenerator(InventoryPlayer par1InventoryPlayer, TileEntityGenerator tileEntity)
public GUIGenerator(InventoryPlayer par1InventoryPlayer, TileEntitySteamPiston tileEntity)
{
super(new ContainerGenerator(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity;

View file

@ -5,7 +5,7 @@ import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11;
import SteamPower.turbine.TileEntityGenerator;
import SteamPower.turbine.TileEntitySteamPiston;
public class RenderSteamEngine extends TileEntitySpecialRenderer
{
@ -25,8 +25,8 @@ public class RenderSteamEngine extends TileEntitySpecialRenderer
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;
float p = ((TileEntitySteamPiston)tileEntity).position;
boolean cc = ((TileEntitySteamPiston)tileEntity).isConnected;
int meta = ((TileEntityMachine) tileEntity).getDirection();
switch(meta)
{

View file

@ -5,7 +5,8 @@ import net.minecraft.src.RenderEngine;
import net.minecraftforge.client.MinecraftForgeClient;
import SteamPower.boiler.TileEntityBoiler;
import SteamPower.burner.TileEntityFireBox;
import SteamPower.turbine.TileEntityGenerator;
import SteamPower.turbine.TileEntityGen;
import SteamPower.turbine.TileEntitySteamPiston;
import SteamPower.turbine.TileEntitytopGen;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
@ -22,7 +23,8 @@ public class SteamClientProxy extends SteamProxy{
{
ClientRegistry.registerTileEntity(TileEntityBoiler.class, "boiler", new RenderBoiler(0f));
ClientRegistry.registerTileEntity(TileEntityFireBox.class, "fireBox", new RenderFurnace());
ClientRegistry.registerTileEntity(TileEntityGenerator.class, "generator", new RenderSteamEngine());
ClientRegistry.registerTileEntity(TileEntitySteamPiston.class, "generator", new RenderSteamEngine());
ClientRegistry.registerTileEntity(TileEntityGen.class, "elecGen", new RenderGenerator());
}
public void postInit()
{