v4.0.5 Beta #1

*Update FML
*Fix server side errors
*Updated machine code
*Bugfixes
This commit is contained in:
Aidan Brady 2012-08-30 19:27:35 -04:00
parent cb4e028169
commit a7c52eefe7
17 changed files with 887 additions and 1984 deletions

View file

@ -55,17 +55,6 @@ public class BlockBase extends Block
return false;
}
public void addCreativeItems(ArrayList itemList)
{
if(blockID != ObsidianIngots.platinumOreID)
{
itemList.add(new ItemStack(this));
}
else {
//Do nothing
}
}
public String getTextureFile() {
return "/obsidian/terrain.png";
}

View file

@ -10,96 +10,29 @@ import net.minecraft.src.*;
public class BlockCombiner extends BlockContainer
{
private Random combinerRand = new Random();
public Random machineRand = new Random();
private static int currentFrontTextureIndex = 0;
public static boolean isActive = false;
public static int currentFrontTextureIndex = 0;
public BlockCombiner(int par1)
{
super(par1, Material.iron);
}
private void setDefaultDirection(World world, int par2, int par3, int par4)
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving)
{
if (!world.isRemote)
{
int var5 = world.getBlockId(par2, par3, par4 - 1);
int var6 = world.getBlockId(par2, par3, par4 + 1);
int var7 = world.getBlockId(par2 - 1, par3, par4);
int var8 = world.getBlockId(par2 + 1, par3, par4);
byte var9 = 3;
int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int change = 3;
if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
switch(side)
{
var9 = 3;
case 0: change = 2; break;
case 1: change = 5; break;
case 2: change = 3; break;
case 3: change = 4; break;
}
if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
{
var9 = 2;
}
if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
{
var9 = 5;
}
if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
{
var9 = 4;
}
world.setBlockMetadataWithNotify(par2, par3, par4, var9);
}
}
public void onBlockPlacedBy(World world, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (var6 == 0)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 2);
}
if (var6 == 1)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 5);
}
if (var6 == 2)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 3);
}
if (var6 == 3)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 4);
}
}
public int idDropped(int par1, Random random, int par3)
{
return blockID;
}
public void onBlockAdded(World world, int par2, int par3, int par4)
{
TileEntityCombiner tileEntity = (TileEntityCombiner)world.getBlockTileEntity(par2, par3, par4);
if(tileEntity != null)
{
tileEntity.machineBurnTime = 0;
}
setDefaultDirection(world, par2, par3, par4);
super.onBlockAdded(world, par2, par3, par4);
}
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
if(isActive) return 14;
else return 0;
world.setBlockMetadataWithNotify(x, y, z, change);
}
@SideOnly(Side.CLIENT)
@ -109,29 +42,32 @@ public class BlockCombiner extends BlockContainer
if(side == metadata)
{
return isActive ? currentFrontTextureIndex : 17;
return ObsidianUtils.isActive(world, x, y, z) ? currentFrontTextureIndex : 17;
}
else {
return 16;
}
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int par2, int par3, int par4, Random par5Random)
public static void updateTexture(World world, int x, int y, int z)
{
if(currentFrontTextureIndex < 15 && currentFrontTextureIndex > -1)
{
currentFrontTextureIndex++;
world.markBlockAsNeedsUpdate(par2, par3, par4);
}
else if(currentFrontTextureIndex == 15)
{
currentFrontTextureIndex = 0;
world.markBlockAsNeedsUpdate(par2, par3, par4);
}
world.markBlockAsNeedsUpdate(x, y, z);
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int par2, int par3, int par4, Random par5Random)
{
int metadata = world.getBlockMetadata(par2, par3, par4);
if (isActive)
if (ObsidianUtils.isActive(world, par2, par3, par4))
{
float var7 = (float)par2 + 0.5F;
float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
@ -200,8 +136,6 @@ public class BlockCombiner extends BlockContainer
public static void updateBlock(boolean active, World world, int x, int y, int z)
{
isActive = active;
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
world.markBlockAsNeedsUpdate(x, y, z);
@ -226,13 +160,13 @@ public class BlockCombiner extends BlockContainer
if (var7 != null)
{
float var8 = this.combinerRand.nextFloat() * 0.8F + 0.1F;
float var9 = this.combinerRand.nextFloat() * 0.8F + 0.1F;
float var10 = this.combinerRand.nextFloat() * 0.8F + 0.1F;
float var8 = this.machineRand.nextFloat() * 0.8F + 0.1F;
float var9 = this.machineRand.nextFloat() * 0.8F + 0.1F;
float var10 = this.machineRand.nextFloat() * 0.8F + 0.1F;
while (var7.stackSize > 0)
{
int var11 = this.combinerRand.nextInt(21) + 10;
int var11 = this.machineRand.nextInt(21) + 10;
if (var11 > var7.stackSize)
{
@ -248,9 +182,9 @@ public class BlockCombiner extends BlockContainer
}
float var13 = 0.05F;
var12.motionX = (double)((float)this.combinerRand.nextGaussian() * var13);
var12.motionY = (double)((float)this.combinerRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)this.combinerRand.nextGaussian() * var13);
var12.motionX = (double)((float)this.machineRand.nextGaussian() * var13);
var12.motionY = (double)((float)this.machineRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)this.machineRand.nextGaussian() * var13);
world.spawnEntityInWorld(var12);
}
}
@ -260,17 +194,13 @@ public class BlockCombiner extends BlockContainer
super.breakBlock(world, par2, par3, par4, i1, i2);
}
public void addCreativeItems(ArrayList itemList)
{
itemList.add(new ItemStack(this));
}
public String getTextureFile()
{
return "/obsidian/Combiner.png";
}
public TileEntity createNewTileEntity(World var1) {
public TileEntity createNewTileEntity(World var1)
{
return new TileEntityCombiner();
}
}

View file

@ -10,94 +10,27 @@ import net.minecraft.src.*;
public class BlockCrusher extends BlockContainer
{
private Random crusherRand = new Random();
public static boolean isActive = false;
private Random machineRand = new Random();
public BlockCrusher(int par1)
{
super(par1, Material.iron);
}
private void setDefaultDirection(World world, int par2, int par3, int par4)
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving)
{
if (!world.isRemote)
{
int var5 = world.getBlockId(par2, par3, par4 - 1);
int var6 = world.getBlockId(par2, par3, par4 + 1);
int var7 = world.getBlockId(par2 - 1, par3, par4);
int var8 = world.getBlockId(par2 + 1, par3, par4);
byte var9 = 3;
int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int change = 3;
if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
switch(side)
{
var9 = 3;
case 0: change = 2; break;
case 1: change = 5; break;
case 2: change = 3; break;
case 3: change = 4; break;
}
if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
{
var9 = 2;
}
if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
{
var9 = 5;
}
if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
{
var9 = 4;
}
world.setBlockMetadataWithNotify(par2, par3, par4, var9);
}
}
public void onBlockPlacedBy(World world, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (var6 == 0)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 2);
}
if (var6 == 1)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 5);
}
if (var6 == 2)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 3);
}
if (var6 == 3)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 4);
}
}
public int idDropped(int par1, Random random, int par3)
{
return blockID;
}
public void onBlockAdded(World world, int par2, int par3, int par4)
{
TileEntityCrusher tileEntity = (TileEntityCrusher)world.getBlockTileEntity(par2, par3, par4);
if(tileEntity != null)
{
tileEntity.machineBurnTime = 0;
}
setDefaultDirection(world, par2, par3, par4);
super.onBlockAdded(world, par2, par3, par4);
}
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
if(isActive) return 14;
else return 0;
world.setBlockMetadataWithNotify(x, y, z, change);
}
@SideOnly(Side.CLIENT)
@ -107,7 +40,7 @@ public class BlockCrusher extends BlockContainer
if(side == metadata)
{
return isActive ? 16 : 17;
return ObsidianUtils.isActive(world, x, y, z) ? 16 : 17;
}
else {
return 2;
@ -118,7 +51,7 @@ public class BlockCrusher extends BlockContainer
public void randomDisplayTick(World world, int par2, int par3, int par4, Random par5Random)
{
int metadata = world.getBlockMetadata(par2, par3, par4);
if (isActive)
if (ObsidianUtils.isActive(world, par2, par3, par4))
{
float var7 = (float)par2 + 0.5F;
float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
@ -187,8 +120,6 @@ public class BlockCrusher extends BlockContainer
public static void updateBlock(boolean active, World world, int x, int y, int z)
{
isActive = active;
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
world.markBlockAsNeedsUpdate(x, y, z);
@ -201,11 +132,6 @@ public class BlockCrusher extends BlockContainer
}
}
public TileEntity getBlockEntity()
{
return new TileEntityCrusher();
}
public void breakBlock(World world, int par2, int par3, int par4, int i1, int i2)
{
TileEntityCrusher var5 = (TileEntityCrusher)world.getBlockTileEntity(par2, par3, par4);
@ -218,13 +144,13 @@ public class BlockCrusher extends BlockContainer
if (var7 != null)
{
float var8 = this.crusherRand.nextFloat() * 0.8F + 0.1F;
float var9 = this.crusherRand.nextFloat() * 0.8F + 0.1F;
float var10 = this.crusherRand.nextFloat() * 0.8F + 0.1F;
float var8 = this.machineRand.nextFloat() * 0.8F + 0.1F;
float var9 = this.machineRand.nextFloat() * 0.8F + 0.1F;
float var10 = this.machineRand.nextFloat() * 0.8F + 0.1F;
while (var7.stackSize > 0)
{
int var11 = this.crusherRand.nextInt(21) + 10;
int var11 = this.machineRand.nextInt(21) + 10;
if (var11 > var7.stackSize)
{
@ -240,9 +166,9 @@ public class BlockCrusher extends BlockContainer
}
float var13 = 0.05F;
var12.motionX = (double)((float)this.crusherRand.nextGaussian() * var13);
var12.motionY = (double)((float)this.crusherRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)this.crusherRand.nextGaussian() * var13);
var12.motionX = (double)((float)this.machineRand.nextGaussian() * var13);
var12.motionY = (double)((float)this.machineRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)this.machineRand.nextGaussian() * var13);
world.spawnEntityInWorld(var12);
}
}
@ -252,11 +178,6 @@ public class BlockCrusher extends BlockContainer
super.breakBlock(world, par2, par3, par4, i1, i2);
}
public void addCreativeItems(ArrayList itemList)
{
itemList.add(new ItemStack(this));
}
public String getTextureFile()
{
return "/obsidian/terrain.png";

View file

@ -10,97 +10,27 @@ import net.minecraft.src.*;
public class BlockEnrichmentChamber extends BlockContainer
{
private Random chamberRand = new Random();
public static boolean isActive = false;
private Random machineRand = new Random();
public BlockEnrichmentChamber(int par1)
{
super(par1, Material.iron);
}
/**
* Called when the block is placed in the world.
*/
public void onBlockPlacedBy(World world, int par2, int par3, int par4, EntityLiving par5EntityLiving)
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving)
{
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int change = 3;
if (var6 == 0)
switch(side)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 2);
case 0: change = 2; break;
case 1: change = 5; break;
case 2: change = 3; break;
case 3: change = 4; break;
}
if (var6 == 1)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 5);
}
if (var6 == 2)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 3);
}
if (var6 == 3)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 4);
}
}
private void setDefaultDirection(World world, int par2, int par3, int par4)
{
if (!world.isRemote)
{
int var5 = world.getBlockId(par2, par3, par4 - 1);
int var6 = world.getBlockId(par2, par3, par4 + 1);
int var7 = world.getBlockId(par2 - 1, par3, par4);
int var8 = world.getBlockId(par2 + 1, par3, par4);
byte var9 = 3;
if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
{
var9 = 3;
}
if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
{
var9 = 2;
}
if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
{
var9 = 5;
}
if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
{
var9 = 4;
}
world.setBlockMetadataWithNotify(par2, par3, par4, var9);
}
}
public int idDropped(int par1, Random random, int par3)
{
return blockID;
}
public void onBlockAdded(World world, int par2, int par3, int par4)
{
TileEntityEnrichmentChamber tileEntity = (TileEntityEnrichmentChamber)world.getBlockTileEntity(par2, par3, par4);
if(tileEntity != null)
{
tileEntity.machineBurnTime = 0;
}
setDefaultDirection(world, par2, par3, par4);
super.onBlockAdded(world, par2, par3, par4);
}
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
if(isActive) return 14;
else return 0;
world.setBlockMetadataWithNotify(x, y, z, change);
}
@SideOnly(Side.CLIENT)
@ -110,7 +40,7 @@ public class BlockEnrichmentChamber extends BlockContainer
if(side == metadata)
{
return isActive ? 8 : 9;
return ObsidianUtils.isActive(world, x, y, z) ? 8 : 9;
}
else {
return 2;
@ -121,7 +51,7 @@ public class BlockEnrichmentChamber extends BlockContainer
public void randomDisplayTick(World world, int par2, int par3, int par4, Random par5Random)
{
int metadata = world.getBlockMetadata(par2, par3, par4);
if (isActive)
if (ObsidianUtils.isActive(world, par2, par3, par4))
{
float var7 = (float)par2 + 0.5F;
float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
@ -190,8 +120,6 @@ public class BlockEnrichmentChamber extends BlockContainer
public static void updateBlock(boolean active, World world, int x, int y, int z)
{
isActive = active;
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
world.markBlockAsNeedsUpdate(x, y, z);
@ -204,12 +132,7 @@ public class BlockEnrichmentChamber extends BlockContainer
}
}
public TileEntity getBlockEntity()
{
return new TileEntityEnrichmentChamber();
}
public void onBlockRemoval(World world, int par2, int par3, int par4, int i1, int i2)
public void breakBlock(World world, int par2, int par3, int par4, int i1, int i2)
{
TileEntityEnrichmentChamber var5 = (TileEntityEnrichmentChamber)world.getBlockTileEntity(par2, par3, par4);
@ -221,13 +144,13 @@ public class BlockEnrichmentChamber extends BlockContainer
if (var7 != null)
{
float var8 = this.chamberRand.nextFloat() * 0.8F + 0.1F;
float var9 = this.chamberRand.nextFloat() * 0.8F + 0.1F;
float var10 = this.chamberRand.nextFloat() * 0.8F + 0.1F;
float var8 = this.machineRand.nextFloat() * 0.8F + 0.1F;
float var9 = this.machineRand.nextFloat() * 0.8F + 0.1F;
float var10 = this.machineRand.nextFloat() * 0.8F + 0.1F;
while (var7.stackSize > 0)
{
int var11 = this.chamberRand.nextInt(21) + 10;
int var11 = this.machineRand.nextInt(21) + 10;
if (var11 > var7.stackSize)
{
@ -243,9 +166,9 @@ public class BlockEnrichmentChamber extends BlockContainer
}
float var13 = 0.05F;
var12.motionX = (double)((float)this.chamberRand.nextGaussian() * var13);
var12.motionY = (double)((float)this.chamberRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)this.chamberRand.nextGaussian() * var13);
var12.motionX = (double)((float)this.machineRand.nextGaussian() * var13);
var12.motionY = (double)((float)this.machineRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)this.machineRand.nextGaussian() * var13);
world.spawnEntityInWorld(var12);
}
}
@ -255,11 +178,6 @@ public class BlockEnrichmentChamber extends BlockContainer
super.breakBlock(world, par2, par3, par4, i1, i2);
}
public void addCreativeItems(ArrayList itemList)
{
itemList.add(new ItemStack(this));
}
public TileEntity createNewTileEntity(World var1)
{
return new TileEntityEnrichmentChamber();

View file

@ -137,11 +137,6 @@ public class BlockObsidianTNT extends Block
return null;
}
public void addCreativeItems(ArrayList itemList)
{
itemList.add(new ItemStack(this));
}
public String getTextureFile()
{
return "/obsidian/terrain.png";

View file

@ -10,96 +10,29 @@ import net.minecraft.src.*;
public class BlockPlatinumCompressor extends BlockContainer
{
private Random compressorRand = new Random();
public Random machineRand = new Random();
private static int currentTextureIndex;
public static boolean isActive = false;
public static int currentTextureIndex;
public BlockPlatinumCompressor(int par1)
{
super(par1, Material.iron);
}
private void setDefaultDirection(World world, int par2, int par3, int par4)
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving)
{
if (!world.isRemote)
{
int var5 = world.getBlockId(par2, par3, par4 - 1);
int var6 = world.getBlockId(par2, par3, par4 + 1);
int var7 = world.getBlockId(par2 - 1, par3, par4);
int var8 = world.getBlockId(par2 + 1, par3, par4);
byte var9 = 3;
int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int change = 3;
if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
switch(side)
{
var9 = 3;
case 0: change = 2; break;
case 1: change = 5; break;
case 2: change = 3; break;
case 3: change = 4; break;
}
if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
{
var9 = 2;
}
if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
{
var9 = 5;
}
if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
{
var9 = 4;
}
world.setBlockMetadataWithNotify(par2, par3, par4, var9);
}
}
public void onBlockPlacedBy(World world, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (var6 == 0)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 2);
}
if (var6 == 1)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 5);
}
if (var6 == 2)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 3);
}
if (var6 == 3)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 4);
}
}
public int idDropped(int par1, Random random, int par3)
{
return blockID;
}
public void onBlockAdded(World world, int par2, int par3, int par4)
{
TileEntityPlatinumCompressor tileEntity = (TileEntityPlatinumCompressor)world.getBlockTileEntity(par2, par3, par4);
if(tileEntity != null)
{
tileEntity.machineBurnTime = 0;
}
setDefaultDirection(world, par2, par3, par4);
super.onBlockAdded(world, par2, par3, par4);
}
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
if(isActive) return 14;
else return 0;
world.setBlockMetadataWithNotify(x, y, z, change);
}
@SideOnly(Side.CLIENT)
@ -109,29 +42,32 @@ public class BlockPlatinumCompressor extends BlockContainer
if(side == metadata)
{
return isActive ? currentTextureIndex : 17;
return ObsidianUtils.isActive(world, x, y, z) ? currentTextureIndex : 17;
}
else {
return 16;
}
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int par2, int par3, int par4, Random par5Random)
public static void updateTexture(World world, int x, int y, int z)
{
if(currentTextureIndex < 15 && currentTextureIndex > -1)
{
currentTextureIndex++;
world.markBlockAsNeedsUpdate(par2, par3, par4);
}
else if(currentTextureIndex == 15)
{
currentTextureIndex = 0;
world.markBlockAsNeedsUpdate(par2, par3, par4);
}
world.markBlockAsNeedsUpdate(x, y, z);
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int par2, int par3, int par4, Random par5Random)
{
int metadata = world.getBlockMetadata(par2, par3, par4);
if (isActive)
if (ObsidianUtils.isActive(world, par2, par3, par4))
{
float var7 = (float)par2 + 0.5F;
float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
@ -200,8 +136,6 @@ public class BlockPlatinumCompressor extends BlockContainer
public static void updateBlock(boolean active, World world, int x, int y, int z)
{
isActive = active;
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
world.markBlockAsNeedsUpdate(x, y, z);
@ -231,13 +165,13 @@ public class BlockPlatinumCompressor extends BlockContainer
if (var7 != null)
{
float var8 = this.compressorRand.nextFloat() * 0.8F + 0.1F;
float var9 = this.compressorRand.nextFloat() * 0.8F + 0.1F;
float var10 = this.compressorRand.nextFloat() * 0.8F + 0.1F;
float var8 = this.machineRand.nextFloat() * 0.8F + 0.1F;
float var9 = this.machineRand.nextFloat() * 0.8F + 0.1F;
float var10 = this.machineRand.nextFloat() * 0.8F + 0.1F;
while (var7.stackSize > 0)
{
int var11 = this.compressorRand.nextInt(21) + 10;
int var11 = this.machineRand.nextInt(21) + 10;
if (var11 > var7.stackSize)
{
@ -253,9 +187,9 @@ public class BlockPlatinumCompressor extends BlockContainer
}
float var13 = 0.05F;
var12.motionX = (double)((float)this.compressorRand.nextGaussian() * var13);
var12.motionY = (double)((float)this.compressorRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)this.compressorRand.nextGaussian() * var13);
var12.motionX = (double)((float)this.machineRand.nextGaussian() * var13);
var12.motionY = (double)((float)this.machineRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)this.machineRand.nextGaussian() * var13);
world.spawnEntityInWorld(var12);
}
}
@ -265,11 +199,6 @@ public class BlockPlatinumCompressor extends BlockContainer
super.breakBlock(world, par2, par3, par4, i1, i2);
}
public void addCreativeItems(ArrayList itemList)
{
itemList.add(new ItemStack(this));
}
public String getTextureFile()
{
return "/obsidian/Compressor.png";

View file

@ -11,101 +11,31 @@ import net.minecraftforge.common.ForgeDirection;
public class BlockTheoreticalElementizer extends BlockContainer
{
private Random elementizerRand = new Random();
private Random machineRand = new Random();
public int currentFrontTextureIndex = 0;
public int currentBackTextureIndex = 16;
public int currentSideTextureIndex = 32;
public static boolean isActive = false;
public static int currentFrontTextureIndex = 0;
public static int currentBackTextureIndex = 16;
public static int currentSideTextureIndex = 32;
public BlockTheoreticalElementizer(int par1)
{
super(par1, Material.iron);
}
/**
* Called when the block is placed in the world.
*/
public void onBlockPlacedBy(World world, int par2, int par3, int par4, EntityLiving par5EntityLiving)
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving)
{
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int change = 3;
if (var6 == 0)
switch(side)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 2);
case 0: change = 2; break;
case 1: change = 5; break;
case 2: change = 3; break;
case 3: change = 4; break;
}
if (var6 == 1)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 5);
}
if (var6 == 2)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 3);
}
if (var6 == 3)
{
world.setBlockMetadataWithNotify(par2, par3, par4, 4);
}
}
private void setDefaultDirection(World world, int par2, int par3, int par4)
{
if (!world.isRemote)
{
int var5 = world.getBlockId(par2, par3, par4 - 1);
int var6 = world.getBlockId(par2, par3, par4 + 1);
int var7 = world.getBlockId(par2 - 1, par3, par4);
int var8 = world.getBlockId(par2 + 1, par3, par4);
byte var9 = 3;
if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
{
var9 = 3;
}
if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
{
var9 = 2;
}
if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
{
var9 = 5;
}
if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
{
var9 = 4;
}
world.setBlockMetadataWithNotify(par2, par3, par4, var9);
}
}
public int idDropped(int par1, Random random, int par3)
{
return blockID;
}
public void onBlockAdded(World world, int par2, int par3, int par4)
{
TileEntityTheoreticalElementizer tileEntity = (TileEntityTheoreticalElementizer)world.getBlockTileEntity(par2, par3, par4);
if(tileEntity != null)
{
tileEntity.machineBurnTime = 0;
}
setDefaultDirection(world, par2, par3, par4);
super.onBlockAdded(world, par2, par3, par4);
}
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
if(isActive) return 14;
else return 0;
world.setBlockMetadataWithNotify(x, y, z, change);
}
@SideOnly(Side.CLIENT)
@ -115,24 +45,24 @@ public class BlockTheoreticalElementizer extends BlockContainer
if(side == 0 || side == 1)
{
return isActive ? 52 : 50;
return ObsidianUtils.isActive(world, x, y, z) ? 52 : 50;
}
else {
if(side == metadata)
{
return isActive ? currentFrontTextureIndex : 48;
return ObsidianUtils.isActive(world, x, y, z) ? currentFrontTextureIndex : 48;
}
else if(side == ForgeDirection.getOrientation(metadata).getOpposite().ordinal())
{
return isActive ? currentBackTextureIndex : 49;
return ObsidianUtils.isActive(world, x, y, z) ? currentBackTextureIndex : 49;
}
else {
return isActive ? currentSideTextureIndex : 51;
return ObsidianUtils.isActive(world, x, y, z) ? currentSideTextureIndex : 51;
}
}
}
public void updateTexture(World world, int x, int y, int z)
public static void updateTexture(World world, int x, int y, int z)
{
if(currentFrontTextureIndex < 15 && currentFrontTextureIndex > -1)
{
@ -162,16 +92,14 @@ public class BlockTheoreticalElementizer extends BlockContainer
}
world.markBlockAsNeedsUpdate(x, y, z);
world.updateAllLightTypes(x, y, z);
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int par2, int par3, int par4, Random par5Random)
{
int metadata = world.getBlockMetadata(par2, par3, par4);
if (isActive)
if (ObsidianUtils.isActive(world, par2, par3, par4))
{
updateTexture(world, par2, par3, par4);
float var7 = (float)par2 + 0.5F;
float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
float var9 = (float)par4 + 0.5F;
@ -243,8 +171,6 @@ public class BlockTheoreticalElementizer extends BlockContainer
public static void updateBlock(boolean active, World world, int x, int y, int z)
{
isActive = active;
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
world.markBlockAsNeedsUpdate(x, y, z);
@ -269,13 +195,13 @@ public class BlockTheoreticalElementizer extends BlockContainer
if (var7 != null)
{
float var8 = this.elementizerRand.nextFloat() * 0.8F + 0.1F;
float var9 = this.elementizerRand.nextFloat() * 0.8F + 0.1F;
float var10 = this.elementizerRand.nextFloat() * 0.8F + 0.1F;
float var8 = this.machineRand.nextFloat() * 0.8F + 0.1F;
float var9 = this.machineRand.nextFloat() * 0.8F + 0.1F;
float var10 = this.machineRand.nextFloat() * 0.8F + 0.1F;
while (var7.stackSize > 0)
{
int var11 = this.elementizerRand.nextInt(21) + 10;
int var11 = this.machineRand.nextInt(21) + 10;
if (var11 > var7.stackSize)
{
@ -291,23 +217,19 @@ public class BlockTheoreticalElementizer extends BlockContainer
}
float var13 = 0.05F;
var12.motionX = (double)((float)this.elementizerRand.nextGaussian() * var13);
var12.motionY = (double)((float)this.elementizerRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)this.elementizerRand.nextGaussian() * var13);
var12.motionX = (double)((float)this.machineRand.nextGaussian() * var13);
var12.motionY = (double)((float)this.machineRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)this.machineRand.nextGaussian() * var13);
world.spawnEntityInWorld(var12);
}
}
}
var5.invalidate();
}
super.breakBlock(world, par2, par3, par4, i1, i2);
}
public void addCreativeItems(ArrayList itemList)
{
itemList.add(new ItemStack(this));
}
public String getTextureFile()
{
return "/obsidian/Elementizer.png";

View file

@ -17,12 +17,20 @@ import cpw.mods.fml.common.network.IGuiHandler;
* @author AidanBrady
*
*/
public abstract class CommonProxy
public class CommonProxy
{
/**
* Register and load client-only render information.
*/
public abstract void registerRenderInformation();
public void registerRenderInformation()
{
}
public int getArmorIndex(String string)
{
return 0;
}
/**
* Set and load the mod's common properties.
@ -32,7 +40,7 @@ public abstract class CommonProxy
Properties properties = new Properties();
try
{
File config = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/config/ObsidianIngots.txt").toString());
File config = ObsidianIngots.configuration;
if(config.exists())
{
properties.load(new FileInputStream(config));
@ -84,12 +92,18 @@ public abstract class CommonProxy
/**
* Load and initiate utilities for the mod.
*/
public abstract void loadUtilities();
public void loadUtilities()
{
}
/**
* Set up and load the client-only tick handler.
*/
public abstract void loadTickHandler();
public void loadTickHandler()
{
}
/**
* Get the actual interface for a GUI. Client-only.
@ -101,7 +115,10 @@ public abstract class CommonProxy
* @param z - gui's z position
* @return the GuiScreen of the interface
*/
public abstract Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z);
public Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z)
{
return null;
}
/**
* Get the container for a GUI. Common.

View file

@ -5,6 +5,8 @@ import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.Socket;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
@ -51,6 +53,8 @@ public class ObsidianIngots
/** Obsidian Ingots hooks instance */
public static ObsidianHooks hooks;
public static File configuration;
//Initial Declarations
public static Version versionNumber = new Version(4, 0, 4);
public static String latestVersionNumber;
@ -707,10 +711,10 @@ public class ObsidianIngots
*/
public void addItems()
{
RedstoneHelmet = (new ItemObsidianArmor(11235, armorREDSTONE, RenderingRegistry.addNewArmourRendererPrefix("redstone"), 0)).setItemName("RedstoneHelmet");
RedstoneBody = (new ItemObsidianArmor(11236, armorREDSTONE, RenderingRegistry.addNewArmourRendererPrefix("redstone"), 1)).setItemName("RedstoneBody");
RedstoneLegs = (new ItemObsidianArmor(11237, armorREDSTONE, RenderingRegistry.addNewArmourRendererPrefix("redstone"), 2)).setItemName("RedstoneLegs");
RedstoneBoots = (new ItemObsidianArmor(11238, armorREDSTONE, RenderingRegistry.addNewArmourRendererPrefix("redstone"), 3)).setItemName("RedstoneBoots");
RedstoneHelmet = (new ItemObsidianArmor(11235, armorREDSTONE, proxy.getArmorIndex("redstone"), 0)).setItemName("RedstoneHelmet");
RedstoneBody = (new ItemObsidianArmor(11236, armorREDSTONE, proxy.getArmorIndex("redstone"), 1)).setItemName("RedstoneBody");
RedstoneLegs = (new ItemObsidianArmor(11237, armorREDSTONE, proxy.getArmorIndex("redstone"), 2)).setItemName("RedstoneLegs");
RedstoneBoots = (new ItemObsidianArmor(11238, armorREDSTONE, proxy.getArmorIndex("redstone"), 3)).setItemName("RedstoneBoots");
RedstoneIngot = new ItemObsidian(11239).setItemName("RedstoneIngot").setTabToDisplayOn(CreativeTabs.tabMaterials);
RedstonePaxel = new ItemObsidianPaxel(11240, toolREDSTONE2).setItemName("RedstonePaxel");
RedstonePickaxe = new ItemObsidianPickaxe(11241, toolREDSTONE).setItemName("RedstonePickaxe");
@ -718,10 +722,10 @@ public class ObsidianIngots
RedstoneSpade = new ItemObsidianSpade(11243, toolREDSTONE).setItemName("RedstoneSpade");
RedstoneHoe = new ItemObsidianHoe(11244, toolREDSTONE).setItemName("RedstoneHoe");
RedstoneSword = new ItemObsidianSword(11245, toolREDSTONE).setItemName("RedstoneSword");
PlatinumHelmet = (new ItemObsidianArmor(11246, EnumArmorMaterial.DIAMOND, RenderingRegistry.addNewArmourRendererPrefix("platinum"), 0)).setItemName("PlatinumHelmet");
PlatinumBody = (new ItemObsidianArmor(11247, EnumArmorMaterial.DIAMOND, RenderingRegistry.addNewArmourRendererPrefix("platinum"), 1)).setItemName("PlatinumBody");
PlatinumLegs = (new ItemObsidianArmor(11248, EnumArmorMaterial.DIAMOND, RenderingRegistry.addNewArmourRendererPrefix("platinum"), 2)).setItemName("PlatinumLegs");
PlatinumBoots = (new ItemObsidianArmor(11249, EnumArmorMaterial.DIAMOND, RenderingRegistry.addNewArmourRendererPrefix("platinum"), 3)).setItemName("PlatinumBoots");
PlatinumHelmet = (new ItemObsidianArmor(11246, EnumArmorMaterial.DIAMOND, proxy.getArmorIndex("platinum"), 0)).setItemName("PlatinumHelmet");
PlatinumBody = (new ItemObsidianArmor(11247, EnumArmorMaterial.DIAMOND, proxy.getArmorIndex("platinum"), 1)).setItemName("PlatinumBody");
PlatinumLegs = (new ItemObsidianArmor(11248, EnumArmorMaterial.DIAMOND, proxy.getArmorIndex("platinum"), 2)).setItemName("PlatinumLegs");
PlatinumBoots = (new ItemObsidianArmor(11249, EnumArmorMaterial.DIAMOND, proxy.getArmorIndex("platinum"), 3)).setItemName("PlatinumBoots");
PlatinumIngot = new ItemObsidian(11250).setItemName("PlatinumIngot").setTabToDisplayOn(CreativeTabs.tabMaterials);
PlatinumPaxel = new ItemObsidianPaxel(11251, toolPLATINUM2).setItemName("PlatinumPaxel");
PlatinumPickaxe = new ItemObsidianPickaxe(11252, toolPLATINUM).setItemName("PlatinumPickaxe");
@ -729,10 +733,10 @@ public class ObsidianIngots
PlatinumSpade = new ItemObsidianSpade(11254, toolPLATINUM).setItemName("PlatinumSpade");
PlatinumHoe = new ItemObsidianHoe(11255, toolPLATINUM).setItemName("PlatinumHoe");
PlatinumSword = new ItemObsidianSword(11256, toolPLATINUM).setItemName("PlatinumSword");
ObsidianHelmet = (new ItemObsidianArmor(11257, armorOBSIDIAN, RenderingRegistry.addNewArmourRendererPrefix("obsidian"), 0)).setItemName("ObsidianHelmet");
ObsidianBody = (new ItemObsidianArmor(11258, armorOBSIDIAN, RenderingRegistry.addNewArmourRendererPrefix("obsidian"), 1)).setItemName("ObsidianBody");
ObsidianLegs = (new ItemObsidianArmor(11259, armorOBSIDIAN, RenderingRegistry.addNewArmourRendererPrefix("obsidian"), 2)).setItemName("ObsidianLegs");
ObsidianBoots = (new ItemObsidianArmor(11260, armorOBSIDIAN, RenderingRegistry.addNewArmourRendererPrefix("obsidian"), 3)).setItemName("ObsidianBoots");
ObsidianHelmet = (new ItemObsidianArmor(11257, armorOBSIDIAN, proxy.getArmorIndex("obsidian"), 0)).setItemName("ObsidianHelmet");
ObsidianBody = (new ItemObsidianArmor(11258, armorOBSIDIAN, proxy.getArmorIndex("obsidian"), 1)).setItemName("ObsidianBody");
ObsidianLegs = (new ItemObsidianArmor(11259, armorOBSIDIAN, proxy.getArmorIndex("obsidian"), 2)).setItemName("ObsidianLegs");
ObsidianBoots = (new ItemObsidianArmor(11260, armorOBSIDIAN, proxy.getArmorIndex("obsidian"), 3)).setItemName("ObsidianBoots");
ObsidianIngot = new ItemObsidian(11261).setItemName("ObsidianIngot").setTabToDisplayOn(CreativeTabs.tabMaterials);
ObsidianPaxel = new ItemObsidianPaxel(11262, toolOBSIDIAN2).setItemName("ObsidianPaxel");
ObsidianPickaxe = new ItemObsidianPickaxe(11263, toolOBSIDIAN).setItemName("ObsidianPickaxe");
@ -746,10 +750,10 @@ public class ObsidianIngots
LazuliSpade = new ItemObsidianSpade(11271, toolLAZULI).setItemName("LazuliSpade");
LazuliHoe = new ItemObsidianHoe(11272, toolLAZULI).setItemName("LazuliHoe");
LazuliSword = new ItemObsidianSword(11273, toolLAZULI).setItemName("LazuliSword");
LazuliHelmet = (new ItemObsidianArmor(11274, armorLAZULI, RenderingRegistry.addNewArmourRendererPrefix("lazuli"), 0)).setItemName("LazuliHelmet");
LazuliBody = (new ItemObsidianArmor(11275, armorLAZULI, RenderingRegistry.addNewArmourRendererPrefix("lazuli"), 1)).setItemName("LazuliBody");
LazuliLegs = (new ItemObsidianArmor(11276, armorLAZULI, RenderingRegistry.addNewArmourRendererPrefix("lazuli"), 2)).setItemName("LazuliLegs");
LazuliBoots = (new ItemObsidianArmor(11277, armorLAZULI, RenderingRegistry.addNewArmourRendererPrefix("lazuli"), 3)).setItemName("LazuliBoots");
LazuliHelmet = (new ItemObsidianArmor(11274, armorLAZULI, proxy.getArmorIndex("lazuli"), 0)).setItemName("LazuliHelmet");
LazuliBody = (new ItemObsidianArmor(11275, armorLAZULI, proxy.getArmorIndex("lazuli"), 1)).setItemName("LazuliBody");
LazuliLegs = (new ItemObsidianArmor(11276, armorLAZULI, proxy.getArmorIndex("lazuli"), 2)).setItemName("LazuliLegs");
LazuliBoots = (new ItemObsidianArmor(11277, armorLAZULI, proxy.getArmorIndex("lazuli"), 3)).setItemName("LazuliBoots");
ObsidianArrow = new ItemObsidian(11278).setItemName("ObsidianArrow").setTabToDisplayOn(CreativeTabs.tabCombat);
ObsidianBow = new ItemObsidianBow(11279).setItemName("ObsidianBow");
if(extrasEnabled == true)
@ -782,10 +786,10 @@ public class ObsidianIngots
GlowstoneSpade = new ItemObsidianSpade(11305, toolGLOWSTONE).setItemName("GlowstoneSpade");
GlowstoneHoe = new ItemObsidianHoe(11306, toolGLOWSTONE).setItemName("GlowstoneHoe");
GlowstoneSword = new ItemObsidianSword(11307, toolGLOWSTONE).setItemName("GlowstoneSword");
GlowstoneHelmet = new ItemObsidianArmor(11308, armorGLOWSTONE, RenderingRegistry.addNewArmourRendererPrefix("glowstone"), 0).setItemName("GlowstoneHelmet");
GlowstoneBody = new ItemObsidianArmor(11309, armorGLOWSTONE, RenderingRegistry.addNewArmourRendererPrefix("glowstone"), 1).setItemName("GlowstoneBody");
GlowstoneLegs = new ItemObsidianArmor(11310, armorGLOWSTONE, RenderingRegistry.addNewArmourRendererPrefix("glowstone"), 2).setItemName("GlowstoneLegs");
GlowstoneBoots = new ItemObsidianArmor(11311, armorGLOWSTONE, RenderingRegistry.addNewArmourRendererPrefix("glowstone"), 3).setItemName("GlowstoneBoots");
GlowstoneHelmet = new ItemObsidianArmor(11308, armorGLOWSTONE, proxy.getArmorIndex("glowstone"), 0).setItemName("GlowstoneHelmet");
GlowstoneBody = new ItemObsidianArmor(11309, armorGLOWSTONE, proxy.getArmorIndex("glowstone"), 1).setItemName("GlowstoneBody");
GlowstoneLegs = new ItemObsidianArmor(11310, armorGLOWSTONE, proxy.getArmorIndex("glowstone"), 2).setItemName("GlowstoneLegs");
GlowstoneBoots = new ItemObsidianArmor(11311, armorGLOWSTONE, proxy.getArmorIndex("glowstone"), 3).setItemName("GlowstoneBoots");
GlowstoneKnife = new ItemObsidianKnife(11312, toolGLOWSTONE).setItemName("GlowstoneKnife");
}
@ -885,6 +889,7 @@ public class ObsidianIngots
@PreInit
public void preInit(FMLPreInitializationEvent event)
{
configuration = event.getSuggestedConfigurationFile();
//Register the mod's ore handler
GameRegistry.registerWorldGenerator(new OreHandler());
//Register the mod's GUI handler

View file

@ -12,7 +12,6 @@ import java.net.Socket;
import java.net.URISyntaxException;
import java.net.URL;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.server.FMLServerHandler;
@ -130,21 +129,6 @@ public class ObsidianUtils
System.out.println("[ObsidianIngots] Sent '" + i + "' packet to server");
}
/**
* Checks if the game is running on multiplayer.
* @return if world is multiplayer
*/
public static boolean isMultiplayer()
{
if(!FMLClientHandler.instance().getClient().isSingleplayer())
{
return true;
}
else {
return false;
}
}
/**
* Checks if the mod is running on the latest version.
* @return if mod is latest version
@ -197,4 +181,22 @@ public class ObsidianUtils
world.spawnParticle("hugeexplosion", entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D);
world.playSoundAtEntity(entityplayer, "random.explode", 1.0F, 1.0F);
}
/**
* Checks if a machine is in it's active state.
* @param world
* @param x
* @param y
* @param z
* @return if machine is active
*/
public static boolean isActive(IBlockAccess world, int x, int y, int z)
{
TileEntityMachine tileEntity = (TileEntityMachine)world.getBlockTileEntity(x, y, z);
if(tileEntity != null)
{
return tileEntity.isActive;
}
return false;
}
}

View file

@ -4,329 +4,135 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
import net.minecraft.src.*;
public class TileEntityCombiner extends TileEntity implements IInventory, ISidedInventory
public class TileEntityCombiner extends TileEntityMachine
{
/**
* The ItemStacks that hold the items currently being used in the furnace
*/
private ItemStack[] machineItemStacks = new ItemStack[3];
/** The number of ticks that the furnace will keep burning */
public int machineBurnTime = 0;
/**
* The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
*/
public int currentItemBurnTime = 0;
/** The number of ticks that the current item has been cooking for */
public int machineCookTime = 0;
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
public TileEntityCombiner()
{
return this.machineItemStacks.length;
super(200, "Combiner");
}
/**
* Returns the stack in slot i
*/
public ItemStack getStackInSlot(int par1)
{
return this.machineItemStacks[par1];
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
* stack.
*/
public ItemStack decrStackSize(int par1, int par2)
{
if (this.machineItemStacks[par1] != null)
{
ItemStack var3;
if (this.machineItemStacks[par1].stackSize <= par2)
{
var3 = this.machineItemStacks[par1];
this.machineItemStacks[par1] = null;
return var3;
}
else
{
var3 = this.machineItemStacks[par1].splitStack(par2);
if (this.machineItemStacks[par1].stackSize == 0)
{
this.machineItemStacks[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.machineItemStacks[par1] != null)
{
ItemStack var2 = this.machineItemStacks[par1];
this.machineItemStacks[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.machineItemStacks[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
/**
* Returns the name of the inventory.
*/
public String getInvName()
{
return "Combiner";
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.machineItemStacks = 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.machineItemStacks.length)
{
this.machineItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
this.machineBurnTime = par1NBTTagCompound.getShort("BurnTime");
this.machineCookTime = par1NBTTagCompound.getShort("CookTime");
this.currentItemBurnTime = getItemBurnTime(this.machineItemStacks[1]);
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)this.machineBurnTime);
par1NBTTagCompound.setShort("CookTime", (short)this.machineCookTime);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.machineItemStacks.length; ++var3)
{
if (this.machineItemStacks[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.machineItemStacks[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;
}
/**
* Returns an integer between 0 and the passed value representing how close the current item is to being completely
* cooked
*/
public int getCookProgressScaled(int par1)
{
return this.machineCookTime * par1 / 200;
}
/**
* Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel
* item, where 0 means that the item is exhausted and the passed value means that the item is fresh
*/
public int getBurnTimeRemainingScaled(int par1)
{
if (this.currentItemBurnTime == 0)
{
this.currentItemBurnTime = 200;
}
return this.machineBurnTime * par1 / this.currentItemBurnTime;
}
/**
* Returns true if the furnace is currently burning
*/
public boolean isBurning()
{
return this.machineBurnTime > 0;
}
/**
* 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 updateEntity()
{
boolean var1 = this.machineBurnTime > 0;
BlockCombiner.updateTexture(worldObj, xCoord, yCoord, zCoord);
boolean var1 = machineBurnTime > 0;
boolean var2 = false;
if (this.machineBurnTime > 0)
if(machineBurnTime > 0)
{
--this.machineBurnTime;
isActive = true;
}
if(machineBurnTime == 0 && !canSmelt())
{
isActive = false;
}
if(machineBurnTime == 0 && machineItemStacks[1] == null)
{
isActive = false;
}
if(machineBurnTime == 0 && machineItemStacks[0] == null)
{
isActive = false;
}
if (!this.worldObj.isRemote)
if (machineBurnTime > 0)
{
if (this.machineBurnTime == 0 && this.canSmelt())
{
this.currentItemBurnTime = this.machineBurnTime = getItemBurnTime(this.machineItemStacks[1]);
--machineBurnTime;
}
if (this.machineBurnTime > 0)
if (!worldObj.isRemote)
{
if (machineBurnTime == 0 && canSmelt())
{
currentItemBurnTime = machineBurnTime = getItemBurnTime(machineItemStacks[1]);
if (machineBurnTime > 0)
{
var2 = true;
if (this.machineItemStacks[1] != null)
if (machineItemStacks[1] != null)
{
--this.machineItemStacks[1].stackSize;
--machineItemStacks[1].stackSize;
if (this.machineItemStacks[1].stackSize == 0)
if (machineItemStacks[1].stackSize == 0)
{
this.machineItemStacks[1] = null;
machineItemStacks[1] = null;
}
}
}
}
if (this.isBurning() && this.canSmelt())
if (isBurning() && canSmelt())
{
++this.machineCookTime;
++machineCookTime;
if (this.machineCookTime == 200)
if (machineCookTime == 200)
{
this.machineCookTime = 0;
this.smeltItem();
machineCookTime = 0;
smeltItem();
var2 = true;
}
}
else
{
this.machineCookTime = 0;
machineCookTime = 0;
}
if (var1 != this.machineBurnTime > 0)
if (var1 != machineBurnTime > 0)
{
var2 = true;
BlockCombiner.updateBlock(machineBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
BlockCombiner.updateBlock(machineBurnTime > 0, worldObj, xCoord, yCoord, zCoord);
}
}
if (var2)
{
this.onInventoryChanged();
onInventoryChanged();
}
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
}
/**
* Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
*/
private boolean canSmelt()
public boolean canSmelt()
{
if (this.machineItemStacks[0] == null)
if (machineItemStacks[0] == null)
{
return false;
}
else
{
ItemStack var1 = CombinerRecipes.smelting().getSmeltingResult(this.machineItemStacks[0]);
ItemStack var1 = CombinerRecipes.smelting().getSmeltingResult(machineItemStacks[0]);
if (var1 == null) return false;
if (this.machineItemStacks[2] == null) return true;
if (!this.machineItemStacks[2].isItemEqual(var1)) return false;
if (machineItemStacks[2] == null) return true;
if (!machineItemStacks[2].isItemEqual(var1)) return false;
int result = machineItemStacks[2].stackSize + var1.stackSize;
return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize());
}
}
/**
* Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
*/
public void smeltItem()
{
if (this.canSmelt())
if (canSmelt())
{
ItemStack var1 = CombinerRecipes.smelting().getSmeltingResult(this.machineItemStacks[0]);
ItemStack var1 = CombinerRecipes.smelting().getSmeltingResult(machineItemStacks[0]);
if (this.machineItemStacks[2] == null)
if (machineItemStacks[2] == null)
{
this.machineItemStacks[2] = var1.copy();
machineItemStacks[2] = var1.copy();
}
else if (this.machineItemStacks[2].isItemEqual(var1))
else if (machineItemStacks[2].isItemEqual(var1))
{
//==========================================================
//Adding extra importance here, so this really small bug
//fix stops slipping through the cracks.
//
//Makes it so that items that result in multiple items are
//smelted correctly each time.
//
//
//
this.machineItemStacks[2].stackSize += var1.stackSize;
//==========================================================
machineItemStacks[2].stackSize += var1.stackSize;
}
--this.machineItemStacks[0].stackSize;
--machineItemStacks[0].stackSize;
if (this.machineItemStacks[0].stackSize <= 0)
if (machineItemStacks[0].stackSize <= 0)
{
this.machineItemStacks[0] = null;
machineItemStacks[0] = null;
}
}
}
/**
* Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
* fuel
*/
public static int getItemBurnTime(ItemStack par1ItemStack)
{
if (par1ItemStack == null)
@ -341,37 +147,51 @@ public class TileEntityCombiner extends TileEntity implements IInventory, ISided
return 0;
}
/**
* Return true if item is a fuel source (getItemBurnTime() > 0).
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
machineItemStacks = new ItemStack[getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
{
NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < machineItemStacks.length)
{
machineItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
machineBurnTime = par1NBTTagCompound.getShort("BurnTime");
machineCookTime = par1NBTTagCompound.getShort("CookTime");
currentItemBurnTime = getItemBurnTime(machineItemStacks[1]);
}
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)machineBurnTime);
par1NBTTagCompound.setShort("CookTime", (short)machineCookTime);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < machineItemStacks.length; ++var3)
{
if (machineItemStacks[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
machineItemStacks[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
par1NBTTagCompound.setTag("Items", var2);
}
public static boolean isItemFuel(ItemStack par0ItemStack)
{
return getItemBurnTime(par0ItemStack) > 0;
}
/**
* 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() {}
@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 1;
}
}

View file

@ -4,329 +4,133 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
import net.minecraft.src.*;
public class TileEntityCrusher extends TileEntity implements IInventory, ISidedInventory
public class TileEntityCrusher extends TileEntityMachine
{
/**
* The ItemStacks that hold the items currently being used in the furnace
*/
private ItemStack[] machineItemStacks = new ItemStack[3];
/** The number of ticks that the furnace will keep burning */
public int machineBurnTime = 0;
/**
* The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
*/
public int currentItemBurnTime = 0;
/** The number of ticks that the current item has been cooking for */
public int machineCookTime = 0;
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
public TileEntityCrusher()
{
return this.machineItemStacks.length;
super(200, "Crusher");
}
/**
* Returns the stack in slot i
*/
public ItemStack getStackInSlot(int par1)
{
return this.machineItemStacks[par1];
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
* stack.
*/
public ItemStack decrStackSize(int par1, int par2)
{
if (this.machineItemStacks[par1] != null)
{
ItemStack var3;
if (this.machineItemStacks[par1].stackSize <= par2)
{
var3 = this.machineItemStacks[par1];
this.machineItemStacks[par1] = null;
return var3;
}
else
{
var3 = this.machineItemStacks[par1].splitStack(par2);
if (this.machineItemStacks[par1].stackSize == 0)
{
this.machineItemStacks[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.machineItemStacks[par1] != null)
{
ItemStack var2 = this.machineItemStacks[par1];
this.machineItemStacks[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.machineItemStacks[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
/**
* Returns the name of the inventory.
*/
public String getInvName()
{
return "Crusher";
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.machineItemStacks = 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.machineItemStacks.length)
{
this.machineItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
this.machineBurnTime = par1NBTTagCompound.getShort("BurnTime");
this.machineCookTime = par1NBTTagCompound.getShort("CookTime");
this.currentItemBurnTime = getItemBurnTime(this.machineItemStacks[1]);
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)this.machineBurnTime);
par1NBTTagCompound.setShort("CookTime", (short)this.machineCookTime);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.machineItemStacks.length; ++var3)
{
if (this.machineItemStacks[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.machineItemStacks[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;
}
/**
* Returns an integer between 0 and the passed value representing how close the current item is to being completely
* cooked
*/
public int getCookProgressScaled(int par1)
{
return this.machineCookTime * par1 / 200;
}
/**
* Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel
* item, where 0 means that the item is exhausted and the passed value means that the item is fresh
*/
public int getBurnTimeRemainingScaled(int par1)
{
if (this.currentItemBurnTime == 0)
{
this.currentItemBurnTime = 200;
}
return this.machineBurnTime * par1 / this.currentItemBurnTime;
}
/**
* Returns true if the furnace is currently burning
*/
public boolean isBurning()
{
return this.machineBurnTime > 0;
}
/**
* 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 updateEntity()
{
boolean var1 = this.machineBurnTime > 0;
boolean var1 = machineBurnTime > 0;
boolean var2 = false;
if (this.machineBurnTime > 0)
if(machineBurnTime > 0)
{
--this.machineBurnTime;
isActive = true;
}
if(machineBurnTime == 0 && !canSmelt())
{
isActive = false;
}
if(machineBurnTime == 0 && machineItemStacks[1] == null)
{
isActive = false;
}
if(machineBurnTime == 0 && machineItemStacks[0] == null)
{
isActive = false;
}
if (!this.worldObj.isRemote)
if (machineBurnTime > 0)
{
if (this.machineBurnTime == 0 && this.canSmelt())
{
this.currentItemBurnTime = this.machineBurnTime = getItemBurnTime(this.machineItemStacks[1]);
--machineBurnTime;
}
if (this.machineBurnTime > 0)
if (!worldObj.isRemote)
{
if (machineBurnTime == 0 && canSmelt())
{
currentItemBurnTime = machineBurnTime = getItemBurnTime(machineItemStacks[1]);
if (machineBurnTime > 0)
{
var2 = true;
if (this.machineItemStacks[1] != null)
if (machineItemStacks[1] != null)
{
--this.machineItemStacks[1].stackSize;
--machineItemStacks[1].stackSize;
if (this.machineItemStacks[1].stackSize == 0)
if (machineItemStacks[1].stackSize == 0)
{
this.machineItemStacks[1] = null;
machineItemStacks[1] = null;
}
}
}
}
if (this.isBurning() && this.canSmelt())
if (isBurning() && canSmelt())
{
++this.machineCookTime;
++machineCookTime;
if (this.machineCookTime == 200)
if (machineCookTime == 200)
{
this.machineCookTime = 0;
this.smeltItem();
machineCookTime = 0;
smeltItem();
var2 = true;
}
}
else
{
this.machineCookTime = 0;
machineCookTime = 0;
}
if (var1 != this.machineBurnTime > 0)
if (var1 != machineBurnTime > 0)
{
var2 = true;
BlockCrusher.updateBlock(machineBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
BlockCrusher.updateBlock(machineBurnTime > 0, worldObj, xCoord, yCoord, zCoord);
}
}
if (var2)
{
this.onInventoryChanged();
onInventoryChanged();
}
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
}
/**
* Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
*/
private boolean canSmelt()
public boolean canSmelt()
{
if (this.machineItemStacks[0] == null)
if (machineItemStacks[0] == null)
{
return false;
}
else
{
ItemStack var1 = CrusherRecipes.smelting().getSmeltingResult(this.machineItemStacks[0]);
ItemStack var1 = CrusherRecipes.smelting().getSmeltingResult(machineItemStacks[0]);
if (var1 == null) return false;
if (this.machineItemStacks[2] == null) return true;
if (!this.machineItemStacks[2].isItemEqual(var1)) return false;
if (machineItemStacks[2] == null) return true;
if (!machineItemStacks[2].isItemEqual(var1)) return false;
int result = machineItemStacks[2].stackSize + var1.stackSize;
return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize());
}
}
/**
* Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
*/
public void smeltItem()
{
if (this.canSmelt())
if (canSmelt())
{
ItemStack var1 = CrusherRecipes.smelting().getSmeltingResult(this.machineItemStacks[0]);
ItemStack var1 = CrusherRecipes.smelting().getSmeltingResult(machineItemStacks[0]);
if (this.machineItemStacks[2] == null)
if (machineItemStacks[2] == null)
{
this.machineItemStacks[2] = var1.copy();
machineItemStacks[2] = var1.copy();
}
else if (this.machineItemStacks[2].isItemEqual(var1))
else if (machineItemStacks[2].isItemEqual(var1))
{
//==========================================================
//Adding extra importance here, so this really small bug
//fix stops slipping through the cracks.
//
//Makes it so that items that result in multiple items are
//smelted correctly each time.
//
//
//
this.machineItemStacks[2].stackSize += var1.stackSize;
//==========================================================
machineItemStacks[2].stackSize += var1.stackSize;
}
--this.machineItemStacks[0].stackSize;
--machineItemStacks[0].stackSize;
if (this.machineItemStacks[0].stackSize <= 0)
if (machineItemStacks[0].stackSize <= 0)
{
this.machineItemStacks[0] = null;
machineItemStacks[0] = null;
}
}
}
/**
* Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
* fuel
*/
public static int getItemBurnTime(ItemStack par1ItemStack)
{
if (par1ItemStack == null)
@ -343,37 +147,51 @@ public class TileEntityCrusher extends TileEntity implements IInventory, ISidedI
return 0;
}
/**
* Return true if item is a fuel source (getItemBurnTime() > 0).
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
machineItemStacks = new ItemStack[getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
{
NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < machineItemStacks.length)
{
machineItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
machineBurnTime = par1NBTTagCompound.getShort("BurnTime");
machineCookTime = par1NBTTagCompound.getShort("CookTime");
currentItemBurnTime = getItemBurnTime(machineItemStacks[1]);
}
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)machineBurnTime);
par1NBTTagCompound.setShort("CookTime", (short)machineCookTime);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < machineItemStacks.length; ++var3)
{
if (machineItemStacks[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
machineItemStacks[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
par1NBTTagCompound.setTag("Items", var2);
}
public static boolean isItemFuel(ItemStack par0ItemStack)
{
return getItemBurnTime(par0ItemStack) > 0;
}
/**
* 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() {}
@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 1;
}
}

View file

@ -6,329 +6,133 @@ import net.minecraftforge.common.ISidedInventory;
import net.minecraftforge.common.ForgeDirection;
import net.minecraft.src.*;
public class TileEntityEnrichmentChamber extends TileEntity implements IInventory, ISidedInventory
public class TileEntityEnrichmentChamber extends TileEntityMachine
{
/**
* The ItemStacks that hold the items currently being used in the furnace
*/
private ItemStack[] machineItemStacks = new ItemStack[3];
/** The number of ticks that the furnace will keep burning */
public int machineBurnTime = 0;
/**
* The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
*/
public int currentItemBurnTime = 0;
/** The number of ticks that the current item has been cooking for */
public int machineCookTime = 0;
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
public TileEntityEnrichmentChamber()
{
return this.machineItemStacks.length;
super(200, "Enrichment Chamber");
}
/**
* Returns the stack in slot i
*/
public ItemStack getStackInSlot(int par1)
{
return this.machineItemStacks[par1];
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
* stack.
*/
public ItemStack decrStackSize(int par1, int par2)
{
if (this.machineItemStacks[par1] != null)
{
ItemStack var3;
if (this.machineItemStacks[par1].stackSize <= par2)
{
var3 = this.machineItemStacks[par1];
this.machineItemStacks[par1] = null;
return var3;
}
else
{
var3 = this.machineItemStacks[par1].splitStack(par2);
if (this.machineItemStacks[par1].stackSize == 0)
{
this.machineItemStacks[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.machineItemStacks[par1] != null)
{
ItemStack var2 = this.machineItemStacks[par1];
this.machineItemStacks[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.machineItemStacks[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
/**
* Returns the name of the inventory.
*/
public String getInvName()
{
return "Enrichment Chamber";
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.machineItemStacks = 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.machineItemStacks.length)
{
this.machineItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
this.machineBurnTime = par1NBTTagCompound.getShort("BurnTime");
this.machineCookTime = par1NBTTagCompound.getShort("CookTime");
this.currentItemBurnTime = getItemBurnTime(this.machineItemStacks[1]);
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)this.machineBurnTime);
par1NBTTagCompound.setShort("CookTime", (short)this.machineCookTime);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.machineItemStacks.length; ++var3)
{
if (this.machineItemStacks[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.machineItemStacks[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;
}
/**
* Returns an integer between 0 and the passed value representing how close the current item is to being completely
* cooked
*/
public int getCookProgressScaled(int par1)
{
return this.machineCookTime * par1 / 200;
}
/**
* Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel
* item, where 0 means that the item is exhausted and the passed value means that the item is fresh
*/
public int getBurnTimeRemainingScaled(int par1)
{
if (this.currentItemBurnTime == 0)
{
this.currentItemBurnTime = 200;
}
return this.machineBurnTime * par1 / this.currentItemBurnTime;
}
/**
* Returns true if the furnace is currently burning
*/
public boolean isBurning()
{
return this.machineBurnTime > 0;
}
/**
* 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 updateEntity()
{
boolean var1 = this.machineBurnTime > 0;
boolean var1 = machineBurnTime > 0;
boolean var2 = false;
if (this.machineBurnTime > 0)
if(machineBurnTime > 0)
{
--this.machineBurnTime;
isActive = true;
}
if(machineBurnTime == 0 && !canSmelt())
{
isActive = false;
}
if(machineBurnTime == 0 && machineItemStacks[1] == null)
{
isActive = false;
}
if(machineBurnTime == 0 && machineItemStacks[0] == null)
{
isActive = false;
}
if (!this.worldObj.isRemote)
if (machineBurnTime > 0)
{
if (this.machineBurnTime == 0 && this.canSmelt())
{
this.currentItemBurnTime = this.machineBurnTime = getItemBurnTime(this.machineItemStacks[1]);
--machineBurnTime;
}
if (this.machineBurnTime > 0)
if (!worldObj.isRemote)
{
if (machineBurnTime == 0 && canSmelt())
{
currentItemBurnTime = machineBurnTime = getItemBurnTime(machineItemStacks[1]);
if (machineBurnTime > 0)
{
var2 = true;
if (this.machineItemStacks[1] != null)
if (machineItemStacks[1] != null)
{
--this.machineItemStacks[1].stackSize;
--machineItemStacks[1].stackSize;
if (this.machineItemStacks[1].stackSize == 0)
if (machineItemStacks[1].stackSize == 0)
{
this.machineItemStacks[1] = null;
machineItemStacks[1] = null;
}
}
}
}
if (this.isBurning() && this.canSmelt())
if (isBurning() && canSmelt())
{
++this.machineCookTime;
++machineCookTime;
if (this.machineCookTime == 200)
if (machineCookTime == 200)
{
this.machineCookTime = 0;
this.smeltItem();
machineCookTime = 0;
smeltItem();
var2 = true;
}
}
else
{
this.machineCookTime = 0;
machineCookTime = 0;
}
if (var1 != this.machineBurnTime > 0)
if (var1 != machineBurnTime > 0)
{
var2 = true;
BlockEnrichmentChamber.updateBlock(machineBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
BlockEnrichmentChamber.updateBlock(machineBurnTime > 0, worldObj, xCoord, yCoord, zCoord);
}
}
if (var2)
{
this.onInventoryChanged();
onInventoryChanged();
}
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
}
/**
* Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
*/
private boolean canSmelt()
public boolean canSmelt()
{
if (this.machineItemStacks[0] == null)
if (machineItemStacks[0] == null)
{
return false;
}
else
{
ItemStack var1 = EnrichmentChamberRecipes.smelting().getSmeltingResult(this.machineItemStacks[0]);
ItemStack var1 = EnrichmentChamberRecipes.smelting().getSmeltingResult(machineItemStacks[0]);
if (var1 == null) return false;
if (this.machineItemStacks[2] == null) return true;
if (!this.machineItemStacks[2].isItemEqual(var1)) return false;
if (machineItemStacks[2] == null) return true;
if (!machineItemStacks[2].isItemEqual(var1)) return false;
int result = machineItemStacks[2].stackSize + var1.stackSize;
return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize());
}
}
/**
* Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
*/
public void smeltItem()
{
if (this.canSmelt())
if (canSmelt())
{
ItemStack var1 = EnrichmentChamberRecipes.smelting().getSmeltingResult(this.machineItemStacks[0]);
ItemStack var1 = EnrichmentChamberRecipes.smelting().getSmeltingResult(machineItemStacks[0]);
if (this.machineItemStacks[2] == null)
if (machineItemStacks[2] == null)
{
this.machineItemStacks[2] = var1.copy();
machineItemStacks[2] = var1.copy();
}
else if (this.machineItemStacks[2].isItemEqual(var1))
else if (machineItemStacks[2].isItemEqual(var1))
{
//==========================================================
//Adding extra importance here, so this really small bug
//fix stops slipping through the cracks.
//
//Makes it so that items that result in multiple items are
//smelted correctly each time.
//
//
//
this.machineItemStacks[2].stackSize += var1.stackSize;
//==========================================================
machineItemStacks[2].stackSize += var1.stackSize;
}
--this.machineItemStacks[0].stackSize;
--machineItemStacks[0].stackSize;
if (this.machineItemStacks[0].stackSize <= 0)
if (machineItemStacks[0].stackSize <= 0)
{
this.machineItemStacks[0] = null;
machineItemStacks[0] = null;
}
}
}
/**
* Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
* fuel
*/
public static int getItemBurnTime(ItemStack par1ItemStack)
{
if (par1ItemStack == null)
@ -343,37 +147,51 @@ public class TileEntityEnrichmentChamber extends TileEntity implements IInventor
return 0;
}
/**
* Return true if item is a fuel source (getItemBurnTime() > 0).
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
machineItemStacks = new ItemStack[getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
{
NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < machineItemStacks.length)
{
machineItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
machineBurnTime = par1NBTTagCompound.getShort("BurnTime");
machineCookTime = par1NBTTagCompound.getShort("CookTime");
currentItemBurnTime = getItemBurnTime(machineItemStacks[1]);
}
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)machineBurnTime);
par1NBTTagCompound.setShort("CookTime", (short)machineCookTime);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < machineItemStacks.length; ++var3)
{
if (machineItemStacks[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
machineItemStacks[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
par1NBTTagCompound.setTag("Items", var2);
}
public static boolean isItemFuel(ItemStack par0ItemStack)
{
return getItemBurnTime(par0ItemStack) > 0;
}
/**
* 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() {}
@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 1;
}
}

View file

@ -0,0 +1,166 @@
package net.uberkat.obsidian.common;
import net.minecraft.src.*;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
public class TileEntityMachine extends TileEntity implements IInventory, ISidedInventory
{
/** The ItemStacks that hold the items currently being used in the furnace */
protected ItemStack[] machineItemStacks = new ItemStack[3];
/** The number of ticks that the furnace will keep burning */
public int machineBurnTime = 0;
/** The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for */
public int currentItemBurnTime = 0;
/** The number of ticks that the current item has been cooking for */
public int machineCookTime = 0;
/** The number of ticks it takes to cook an item */
public int maxBurnTime = 0;
/** The full name of this tile entity */
public String fullName;
/** Whether the machine is in it's active state or not */
public boolean isActive;
public TileEntityMachine(int time, String name)
{
maxBurnTime = time;
fullName = name;
}
public int getStartInventorySide(ForgeDirection side)
{
if (side == ForgeDirection.DOWN) return 1;
if (side == ForgeDirection.UP) return 0;
return 2;
}
public int getSizeInventorySide(ForgeDirection side)
{
return 1;
}
public int getSizeInventory()
{
return machineItemStacks.length;
}
public ItemStack getStackInSlot(int var1)
{
return machineItemStacks[var1];
}
public ItemStack decrStackSize(int par1, int par2)
{
if (machineItemStacks[par1] != null)
{
ItemStack var3;
if (machineItemStacks[par1].stackSize <= par2)
{
var3 = machineItemStacks[par1];
machineItemStacks[par1] = null;
return var3;
}
else
{
var3 = machineItemStacks[par1].splitStack(par2);
if (machineItemStacks[par1].stackSize == 0)
{
machineItemStacks[par1] = null;
}
return var3;
}
}
else
{
return null;
}
}
public ItemStack getStackInSlotOnClosing(int par1)
{
if (machineItemStacks[par1] != null)
{
ItemStack var2 = machineItemStacks[par1];
machineItemStacks[par1] = null;
return var2;
}
else
{
return null;
}
}
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
machineItemStacks[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > getInventoryStackLimit())
{
par2ItemStack.stackSize = getInventoryStackLimit();
}
}
public String getInvName()
{
return fullName;
}
public int getInventoryStackLimit()
{
return 64;
}
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
{
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64.0D;
}
public int getBurnTimeRemainingScaled(int par1)
{
if (currentItemBurnTime == 0)
{
currentItemBurnTime = maxBurnTime;
}
return machineBurnTime * par1 / currentItemBurnTime;
}
public boolean isBurning()
{
return machineBurnTime > 0;
}
public int getCookProgressScaled(int par1)
{
return machineCookTime * par1 / maxBurnTime;
}
public void smeltItem()
{
}
protected boolean canSmelt()
{
return false;
}
public void openChest()
{
}
public void closeChest()
{
}
}

View file

@ -6,329 +6,139 @@ import net.minecraft.src.*;
import net.minecraftforge.common.ISidedInventory;
import net.minecraftforge.common.ForgeDirection;
public class TileEntityPlatinumCompressor extends TileEntity implements IInventory, ISidedInventory
public class TileEntityPlatinumCompressor extends TileEntityMachine
{
/**
* The ItemStacks that hold the items currently being used in the furnace
*/
private ItemStack[] machineItemStacks = new ItemStack[3];
/** The number of ticks that the furnace will keep burning */
public int machineBurnTime = 0;
/**
* The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
*/
public int currentItemBurnTime = 0;
/** The number of ticks that the current item has been cooking for */
public int machineCookTime = 0;
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
public TileEntityPlatinumCompressor()
{
return this.machineItemStacks.length;
super(200, "Platinum Compressor");
}
/**
* Returns the stack in slot i
*/
public ItemStack getStackInSlot(int par1)
{
return this.machineItemStacks[par1];
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
* stack.
*/
public ItemStack decrStackSize(int par1, int par2)
{
if (this.machineItemStacks[par1] != null)
{
ItemStack var3;
if (this.machineItemStacks[par1].stackSize <= par2)
{
var3 = this.machineItemStacks[par1];
this.machineItemStacks[par1] = null;
return var3;
}
else
{
var3 = this.machineItemStacks[par1].splitStack(par2);
if (this.machineItemStacks[par1].stackSize == 0)
{
this.machineItemStacks[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.machineItemStacks[par1] != null)
{
ItemStack var2 = this.machineItemStacks[par1];
this.machineItemStacks[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.machineItemStacks[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
/**
* Returns the name of the inventory.
*/
public String getInvName()
{
return "Platinum Compressor";
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.machineItemStacks = 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.machineItemStacks.length)
{
this.machineItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
this.machineBurnTime = par1NBTTagCompound.getShort("BurnTime");
this.machineCookTime = par1NBTTagCompound.getShort("CookTime");
this.currentItemBurnTime = getItemBurnTime(this.machineItemStacks[1]);
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)this.machineBurnTime);
par1NBTTagCompound.setShort("CookTime", (short)this.machineCookTime);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.machineItemStacks.length; ++var3)
{
if (this.machineItemStacks[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.machineItemStacks[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;
}
/**
* Returns an integer between 0 and the passed value representing how close the current item is to being completely
* cooked
*/
public int getCookProgressScaled(int par1)
{
return this.machineCookTime * par1 / 200;
}
/**
* Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel
* item, where 0 means that the item is exhausted and the passed value means that the item is fresh
*/
public int getBurnTimeRemainingScaled(int par1)
{
if (this.currentItemBurnTime == 0)
{
this.currentItemBurnTime = 200;
}
return this.machineBurnTime * par1 / this.currentItemBurnTime;
}
/**
* Returns true if the furnace is currently burning
*/
public boolean isBurning()
{
return this.machineBurnTime > 0;
}
/**
* 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 updateEntity()
{
boolean var1 = this.machineBurnTime > 0;
BlockPlatinumCompressor.updateTexture(worldObj, xCoord, yCoord, zCoord);
boolean var1 = machineBurnTime > 0;
boolean var2 = false;
if (this.machineBurnTime > 0)
if(machineBurnTime > 0)
{
--this.machineBurnTime;
isActive = true;
}
if(machineBurnTime == 0 && !canSmelt())
{
isActive = false;
}
if(machineBurnTime == 0 && machineItemStacks[1] == null)
{
isActive = false;
}
if(machineBurnTime == 0 && machineItemStacks[0] == null)
{
isActive = false;
}
if (!this.worldObj.isRemote)
if (machineBurnTime > 0)
{
if (this.machineBurnTime == 0 && this.canSmelt())
{
this.currentItemBurnTime = this.machineBurnTime = getItemBurnTime(this.machineItemStacks[1]);
--machineBurnTime;
}
if (this.machineBurnTime > 0)
if (!worldObj.isRemote)
{
if (machineBurnTime == 0 && canSmelt())
{
currentItemBurnTime = machineBurnTime = getItemBurnTime(machineItemStacks[1]);
if (machineBurnTime > 0)
{
var2 = true;
if (this.machineItemStacks[1] != null)
if (machineItemStacks[1] != null)
{
--this.machineItemStacks[1].stackSize;
--machineItemStacks[1].stackSize;
if (this.machineItemStacks[1].stackSize == 0)
if (machineItemStacks[1].stackSize == 0)
{
this.machineItemStacks[1] = null;
machineItemStacks[1] = null;
}
}
}
}
if (this.isBurning() && this.canSmelt())
if (isBurning() && canSmelt())
{
++this.machineCookTime;
++machineCookTime;
if (this.machineCookTime == 200)
if (machineCookTime == 200)
{
this.machineCookTime = 0;
this.smeltItem();
machineCookTime = 0;
smeltItem();
var2 = true;
}
}
else
{
this.machineCookTime = 0;
machineCookTime = 0;
}
if (var1 != this.machineBurnTime > 0)
if (var1 != machineBurnTime > 0)
{
var2 = true;
BlockPlatinumCompressor.updateBlock(machineBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
BlockPlatinumCompressor.updateBlock(machineBurnTime > 0, worldObj, xCoord, yCoord, zCoord);
}
}
if (var2)
{
this.onInventoryChanged();
onInventoryChanged();
}
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
}
/**
* Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
*/
private boolean canSmelt()
public boolean canSmelt()
{
if (this.machineItemStacks[0] == null)
if (machineItemStacks[0] == null)
{
return false;
}
else if(machineItemStacks[1] == null && currentItemBurnTime == 0)
{
return false;
}
else
{
ItemStack var1 = PlatinumCompressorRecipes.smelting().getSmeltingResult(this.machineItemStacks[0]);
ItemStack var1 = PlatinumCompressorRecipes.smelting().getSmeltingResult(machineItemStacks[0]);
if (var1 == null) return false;
if (this.machineItemStacks[2] == null) return true;
if (!this.machineItemStacks[2].isItemEqual(var1)) return false;
if (machineItemStacks[2] == null) return true;
if (!machineItemStacks[2].isItemEqual(var1)) return false;
int result = machineItemStacks[2].stackSize + var1.stackSize;
return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize());
}
}
/**
* Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
*/
public void smeltItem()
{
if (this.canSmelt())
if (canSmelt())
{
ItemStack var1 = PlatinumCompressorRecipes.smelting().getSmeltingResult(this.machineItemStacks[0]);
ItemStack var1 = PlatinumCompressorRecipes.smelting().getSmeltingResult(machineItemStacks[0]);
if (this.machineItemStacks[2] == null)
if (machineItemStacks[2] == null)
{
this.machineItemStacks[2] = var1.copy();
machineItemStacks[2] = var1.copy();
}
else if (this.machineItemStacks[2].isItemEqual(var1))
else if (machineItemStacks[2].isItemEqual(var1))
{
//==========================================================
//Adding extra importance here, so this really small bug
//fix stops slipping through the cracks.
//
//Makes it so that items that result in multiple items are
//smelted correctly each time.
//
//
//
this.machineItemStacks[2].stackSize += var1.stackSize;
//==========================================================
machineItemStacks[2].stackSize += var1.stackSize;
}
--this.machineItemStacks[0].stackSize;
--machineItemStacks[0].stackSize;
if (this.machineItemStacks[0].stackSize <= 0)
if (machineItemStacks[0].stackSize <= 0)
{
this.machineItemStacks[0] = null;
machineItemStacks[0] = null;
}
}
}
/**
* Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
* fuel
*/
public static int getItemBurnTime(ItemStack par1ItemStack)
{
if (par1ItemStack == null)
@ -344,37 +154,51 @@ public class TileEntityPlatinumCompressor extends TileEntity implements IInvento
return 0;
}
/**
* Return true if item is a fuel source (getItemBurnTime() > 0).
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
machineItemStacks = new ItemStack[getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
{
NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < machineItemStacks.length)
{
machineItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
machineBurnTime = par1NBTTagCompound.getShort("BurnTime");
machineCookTime = par1NBTTagCompound.getShort("CookTime");
currentItemBurnTime = getItemBurnTime(machineItemStacks[1]);
}
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)machineBurnTime);
par1NBTTagCompound.setShort("CookTime", (short)machineCookTime);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < machineItemStacks.length; ++var3)
{
if (machineItemStacks[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
machineItemStacks[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
par1NBTTagCompound.setTag("Items", var2);
}
public static boolean isItemFuel(ItemStack par0ItemStack)
{
return getItemBurnTime(par0ItemStack) > 0;
}
/**
* 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() {}
@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 1;
}
}

View file

@ -9,316 +9,124 @@ import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
import net.minecraft.src.*;
public class TileEntityTheoreticalElementizer extends TileEntity implements IInventory, ISidedInventory
public class TileEntityTheoreticalElementizer extends TileEntityMachine
{
/**
* The ItemStacks that hold the items currently being used in the furnace
*/
private ItemStack[] machineItemStacks = new ItemStack[3];
/** The number of ticks that the furnace will keep burning */
public int machineBurnTime = 0;
/**
* The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
*/
public int currentItemBurnTime = 0;
/** The number of ticks that the current item has been cooking for */
public int machineCookTime = 0;
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
public TileEntityTheoreticalElementizer()
{
return this.machineItemStacks.length;
super(1000, "Theoretical Elementizer");
}
/**
* Returns the stack in slot i
*/
public ItemStack getStackInSlot(int par1)
{
return this.machineItemStacks[par1];
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
* stack.
*/
public ItemStack decrStackSize(int par1, int par2)
{
if (this.machineItemStacks[par1] != null)
{
ItemStack var3;
if (this.machineItemStacks[par1].stackSize <= par2)
{
var3 = this.machineItemStacks[par1];
this.machineItemStacks[par1] = null;
return var3;
}
else
{
var3 = this.machineItemStacks[par1].splitStack(par2);
if (this.machineItemStacks[par1].stackSize == 0)
{
this.machineItemStacks[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.machineItemStacks[par1] != null)
{
ItemStack var2 = this.machineItemStacks[par1];
this.machineItemStacks[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.machineItemStacks[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
/**
* Returns the name of the inventory.
*/
public String getInvName()
{
return "Theoretical Elementizer";
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.machineItemStacks = 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.machineItemStacks.length)
{
this.machineItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
this.machineBurnTime = par1NBTTagCompound.getShort("BurnTime");
this.machineCookTime = par1NBTTagCompound.getShort("CookTime");
this.currentItemBurnTime = getItemBurnTime(this.machineItemStacks[1]);
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)this.machineBurnTime);
par1NBTTagCompound.setShort("CookTime", (short)this.machineCookTime);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.machineItemStacks.length; ++var3)
{
if (this.machineItemStacks[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.machineItemStacks[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;
}
@SideOnly(Side.CLIENT)
/**
* Returns an integer between 0 and the passed value representing how close the current item is to being completely
* cooked
*/
public int getCookProgressScaled(int par1)
{
return this.machineCookTime * par1 / 1000;
}
@SideOnly(Side.CLIENT)
/**
* Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel
* item, where 0 means that the item is exhausted and the passed value means that the item is fresh
*/
public int getBurnTimeRemainingScaled(int par1)
{
if (this.currentItemBurnTime == 0)
{
this.currentItemBurnTime = 1000;
}
return this.machineBurnTime * par1 / this.currentItemBurnTime;
}
/**
* Returns true if the furnace is currently burning
*/
public boolean isBurning()
{
return this.machineBurnTime > 0;
}
/**
* 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 updateEntity()
{
boolean var1 = this.machineBurnTime > 0;
BlockTheoreticalElementizer.updateTexture(worldObj, xCoord, yCoord, zCoord);
boolean var1 = machineBurnTime > 0;
boolean var2 = false;
if (this.machineBurnTime > 0)
if(machineBurnTime > 0)
{
--this.machineBurnTime;
isActive = true;
}
else if(machineBurnTime == 0 && !canSmelt())
{
isActive = false;
}
if (!this.worldObj.isRemote)
if (machineBurnTime > 0)
{
if (this.machineBurnTime == 0 && this.canSmelt())
{
this.currentItemBurnTime = this.machineBurnTime = getItemBurnTime(this.machineItemStacks[1]);
--machineBurnTime;
}
if (this.machineBurnTime > 0)
if (!worldObj.isRemote)
{
if (machineBurnTime == 0 && canSmelt())
{
currentItemBurnTime = machineBurnTime = getItemBurnTime(machineItemStacks[1]);
if (machineBurnTime > 0)
{
var2 = true;
if (this.machineItemStacks[1] != null)
if (machineItemStacks[1] != null)
{
--this.machineItemStacks[1].stackSize;
--machineItemStacks[1].stackSize;
if (this.machineItemStacks[1].stackSize == 0)
if (machineItemStacks[1].stackSize == 0)
{
this.machineItemStacks[1] = null;
machineItemStacks[1] = null;
}
}
}
}
if (this.isBurning() && this.canSmelt())
if (isBurning() && canSmelt())
{
++this.machineCookTime;
++machineCookTime;
if (this.machineCookTime == 1000)
if (machineCookTime == maxBurnTime)
{
this.machineCookTime = 0;
this.smeltItem();
machineCookTime = 0;
smeltItem();
var2 = true;
}
}
else
{
this.machineCookTime = 0;
machineCookTime = 0;
}
if (var1 != this.machineBurnTime > 0)
if (var1 != machineBurnTime > 0)
{
var2 = true;
BlockTheoreticalElementizer.updateBlock(machineBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
BlockTheoreticalElementizer.updateBlock(machineBurnTime > 0, worldObj, xCoord, yCoord, zCoord);
}
}
if (var2)
{
this.onInventoryChanged();
onInventoryChanged();
}
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
}
/**
* Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
*/
private boolean canSmelt()
public boolean canSmelt()
{
if (this.machineItemStacks[0] == null)
if (machineItemStacks[0] == null)
{
return false;
}
else if(machineItemStacks[2] != null)
{
return false;
}
else
{
if (machineItemStacks[0].getItem().shiftedIndex != ObsidianIngots.EnrichedAlloy.shiftedIndex) return false;
if (this.machineItemStacks[2] == null) return true;
if (machineItemStacks[2] == null) return true;
}
return false;
}
/**
* Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
*/
public void smeltItem()
{
if (this.canSmelt())
if (canSmelt())
{
ItemStack itemstack = new ItemStack(getRandomMagicItem(), 1);
if (this.machineItemStacks[2] == null)
if (machineItemStacks[2] == null)
{
this.machineItemStacks[2] = itemstack.copy();
machineItemStacks[2] = itemstack.copy();
}
--this.machineItemStacks[0].stackSize;
--machineItemStacks[0].stackSize;
if (this.machineItemStacks[0].stackSize <= 0)
if (machineItemStacks[0].stackSize <= 0)
{
this.machineItemStacks[0] = null;
machineItemStacks[0] = null;
}
}
}
/**
* Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
* fuel
*/
public static int getItemBurnTime(ItemStack par1ItemStack)
{
if (par1ItemStack == null)
@ -333,22 +141,54 @@ public class TileEntityTheoreticalElementizer extends TileEntity implements IInv
return 0;
}
/**
* Return true if item is a fuel source (getItemBurnTime() > 0).
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
machineItemStacks = new ItemStack[getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
{
NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < machineItemStacks.length)
{
machineItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
machineBurnTime = par1NBTTagCompound.getShort("BurnTime");
machineCookTime = par1NBTTagCompound.getShort("CookTime");
currentItemBurnTime = getItemBurnTime(machineItemStacks[1]);
}
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)machineBurnTime);
par1NBTTagCompound.setShort("CookTime", (short)machineCookTime);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < machineItemStacks.length; ++var3)
{
if (machineItemStacks[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
machineItemStacks[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
par1NBTTagCompound.setTag("Items", var2);
}
public static boolean isItemFuel(ItemStack par0ItemStack)
{
return getItemBurnTime(par0ItemStack) > 0;
}
/**
* 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 Item getRandomMagicItem()
{
Random rand = new Random();
@ -358,22 +198,4 @@ public class TileEntityTheoreticalElementizer extends TileEntity implements IInv
if(random == 2) return ObsidianIngots.WeatherOrb;
return ObsidianIngots.EnrichedAlloy;
}
public void openChest() {}
public void closeChest() {}
@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 1;
}
}

View file

@ -6,6 +6,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Side;
@ -40,6 +41,12 @@ import net.uberkat.obsidian.common.TileEntityTheoreticalElementizer;
*/
public class ClientProxy extends CommonProxy
{
@Override
public int getArmorIndex(String string)
{
return RenderingRegistry.addNewArmourRendererPrefix(string);
}
public void registerRenderInformation()
{
System.out.println("[ObsidianIngots] Beginning render initiative...");