v4.2.2 Beta #5

*Touched up on parameter/variable names again.
*Renamed ObsidianUtils method 'doExplosion' to 'doFakeEntityExplosion.'
*Added method 'doFakeBlockExplosion' to ObsidianUtils.
*Code cleanup.
*Removed GuiEnrichmentChamber, GuiPlatinumCompressor, GuiCombiner, and
GuiCrusher classes.
*Added GuiElectricMachine and GuiAdvancedElectricMachine classes.
*Renamed 'INetworkedMachine' to 'ITileNetwork.'
*Touched up on BC Power Unit system.
*Updated TileEntities to use new GUI System
*Merged several TEEM and TEAEM fields and methods into TEBM.
*Updated MachineryManager -- added 'destroyAll' method.
*Updated throwing knives, removed unneeded PhysicsHelper.
*More javadocs.
This commit is contained in:
Aidan Brady 2012-10-17 14:46:27 -04:00
parent 25a47a34c1
commit c8454c1808
25 changed files with 241 additions and 388 deletions

View file

@ -54,31 +54,31 @@ public class BlockMachine extends BlockContainer
TileEntityBasicMachine tileEntity = (TileEntityBasicMachine)world.getBlockTileEntity(x, y, z);
if (isActive(world, x, y, z))
{
float var7 = (float)x + 0.5F;
float var8 = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F;
float var9 = (float)z + 0.5F;
float var10 = 0.52F;
float var11 = random.nextFloat() * 0.6F - 0.3F;
float xRandom = (float)x + 0.5F;
float yRandom = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F;
float zRandom = (float)z + 0.5F;
float iRandom = 0.52F;
float jRandom = random.nextFloat() * 0.6F - 0.3F;
if (tileEntity.facing == 4)
{
world.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", (double)(xRandom - iRandom), (double)yRandom, (double)(zRandom + jRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (double)(xRandom - iRandom), (double)yRandom, (double)(zRandom + jRandom), 0.0D, 0.0D, 0.0D);
}
else if (tileEntity.facing == 5)
{
world.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", (double)(xRandom + iRandom), (double)yRandom, (double)(zRandom + jRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (double)(xRandom + iRandom), (double)yRandom, (double)(zRandom + jRandom), 0.0D, 0.0D, 0.0D);
}
else if (tileEntity.facing == 2)
{
world.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", (double)(xRandom + jRandom), (double)yRandom, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (double)(xRandom + jRandom), (double)yRandom, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D);
}
else if (tileEntity.facing == 3)
{
world.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", (double)(xRandom + jRandom), (double)yRandom, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (double)(xRandom + jRandom), (double)yRandom, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D);
}
}
}
@ -251,46 +251,46 @@ public class BlockMachine extends BlockContainer
public void breakBlock(World world, int x, int y, int z, int i1, int i2)
{
TileEntityBasicMachine var5 = (TileEntityBasicMachine)world.getBlockTileEntity(x, y, z);
TileEntityBasicMachine tileEntity = (TileEntityBasicMachine)world.getBlockTileEntity(x, y, z);
if (var5 != null)
if (tileEntity != null)
{
for (int var6 = 0; var6 < var5.getSizeInventory(); ++var6)
for (int i = 0; i < tileEntity.getSizeInventory(); ++i)
{
ItemStack var7 = var5.getStackInSlot(var6);
ItemStack slotStack = tileEntity.getStackInSlot(i);
if (var7 != null)
if (slotStack != null)
{
float var8 = machineRand.nextFloat() * 0.8F + 0.1F;
float var9 = machineRand.nextFloat() * 0.8F + 0.1F;
float var10 = machineRand.nextFloat() * 0.8F + 0.1F;
float xRandom = machineRand.nextFloat() * 0.8F + 0.1F;
float yRandom = machineRand.nextFloat() * 0.8F + 0.1F;
float zRandom = machineRand.nextFloat() * 0.8F + 0.1F;
while (var7.stackSize > 0)
while (slotStack.stackSize > 0)
{
int var11 = machineRand.nextInt(21) + 10;
int j = machineRand.nextInt(21) + 10;
if (var11 > var7.stackSize)
if (j > slotStack.stackSize)
{
var11 = var7.stackSize;
j = slotStack.stackSize;
}
var7.stackSize -= var11;
EntityItem var12 = new EntityItem(world, (double)((float)x + var8), (double)((float)y + var9), (double)((float)z + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage()));
slotStack.stackSize -= j;
EntityItem item = new EntityItem(world, (double)((float)x + xRandom), (double)((float)y + yRandom), (double)((float)z + zRandom), new ItemStack(slotStack.itemID, j, slotStack.getItemDamage()));
if (var7.hasTagCompound())
if (slotStack.hasTagCompound())
{
var12.item.setTagCompound((NBTTagCompound)var7.getTagCompound().copy());
item.item.setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy());
}
float var13 = 0.05F;
var12.motionX = (double)((float)machineRand.nextGaussian() * var13);
var12.motionY = (double)((float)machineRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)machineRand.nextGaussian() * var13);
world.spawnEntityInWorld(var12);
float k = 0.05F;
item.motionX = (double)((float)machineRand.nextGaussian() * k);
item.motionY = (double)((float)machineRand.nextGaussian() * k + 0.2F);
item.motionZ = (double)((float)machineRand.nextGaussian() * k);
world.spawnEntityInWorld(item);
}
}
}
var5.invalidate();
tileEntity.invalidate();
}
super.breakBlock(world, x, y, z, i1, i2);

View file

@ -7,7 +7,6 @@ public class ItemObsidianKnife extends ItemObsidian
{
private EnumToolMaterial enumToolMaterial;
protected int weaponDamage;
protected float knockBack;
protected float strVsBlock;
protected int entityDamage;
protected int blockDamage;
@ -20,7 +19,6 @@ public class ItemObsidianKnife extends ItemObsidian
maxStackSize = 1;
setMaxDamage((int)((float)enumtoolmaterial.getMaxUses() * 0.5F));
weaponDamage = (int)((float)3 + (float)enumtoolmaterial.getDamageVsEntity() * 1.5F);
knockBack = 0.2F + (enumtoolmaterial != EnumToolMaterial.GOLD ? 0.0F : 0.2F);
strVsBlock = 1;
entityDamage = 2;
blockDamage = 2;
@ -95,7 +93,7 @@ public class ItemObsidianKnife extends ItemObsidian
return weaponDamage;
}
public boolean onBlockDestroyed(ItemStack itemstack, int i, int j, int k, int l, EntityLiving entityliving)
public boolean onBlockDestroyed(ItemStack itemstack, World world, int i, int j, int k, int l, EntityLiving entityliving)
{
itemstack.damageItem(blockDamage, entityliving);
return true;
@ -103,11 +101,6 @@ public class ItemObsidianKnife extends ItemObsidian
public boolean hitEntity(ItemStack itemstack, EntityLiving entityliving, EntityLiving entityliving1)
{
if (knockBack != 0.0F)
{
PhysicsHelper.knockBack(entityliving, entityliving1, knockBack);
}
itemstack.damageItem(entityDamage, entityliving1);
return true;
}

View file

@ -75,6 +75,24 @@ public class MachineryManager
}
}
/**
* Destroys all machines registered, as well as removing them from the manager's ArrayList.
* @param explode - whether or not to show fake explosion
*/
public void destroyAll(boolean explode)
{
for(TileEntityBasicMachine machine : machines)
{
if(explode)
{
ObsidianUtils.doFakeBlockExplosion(machine.worldObj, machine.xCoord, machine.yCoord, machine.zCoord);
}
machine.worldObj.setBlockAndMetadataWithNotify(machine.xCoord, machine.yCoord, machine.zCoord, 0, 0);
machine.worldObj.removeBlockTileEntity(machine.xCoord, machine.yCoord, machine.zCoord);
remove(machine);
}
}
/**
* Resets the manager -- removing all machines from the ArrayList
*/

View file

@ -20,7 +20,7 @@ import net.minecraft.src.*;
import net.uberkat.obsidian.client.ThreadSendData;
/**
* Official Obsidian Ingots utilities. All miscellaneous methods are located here.
* Utilities used by Obsidian Ingots. All miscellaneous methods are located here.
* @author AidanBrady
*
*/
@ -213,13 +213,26 @@ public class ObsidianUtils
}
/**
* Creates a fake explosion, with only sounds and effects. No damage is caused to either blocks or the player.
* Creates a fake explosion at the declared player, with only sounds and effects. No damage is caused to either blocks or the player.
* @param entityplayer - player to explode
*/
public static void doExplosion(EntityPlayer entityplayer)
public static void doFakeEntityExplosion(EntityPlayer entityplayer)
{
World world = entityplayer.worldObj;
world.spawnParticle("hugeexplosion", entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D);
world.playSoundAtEntity(entityplayer, "random.explode", 1.0F, 1.0F);
}
/**
* Creates a fake explosion at the declared coords, with only sounds and effects. No damage is caused to either blocks or the player.
* @param world - world where the explosion will occur
* @param x - x coord
* @param y - y coord
* @param z - z coord
*/
public static void doFakeBlockExplosion(World world, int x, int y, int z)
{
world.spawnParticle("hugeexplosion", x, y, z, 0.0D, 0.0D, 0.0D);
world.playSound(x, y, z, "random.explode", 1.0F, 1.0F);
}
}

View file

@ -6,7 +6,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import obsidian.api.INetworkedMachine;
import obsidian.api.ITileNetwork;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
@ -79,9 +79,9 @@ public class PacketHandler implements IPacketHandler
World world = ((EntityPlayer)player).worldObj;
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity instanceof INetworkedMachine)
if(tileEntity instanceof ITileNetwork)
{
((INetworkedMachine)tileEntity).handlePacketData(manager, packet, ((EntityPlayer)player), dataStream);
((ITileNetwork)tileEntity).handlePacketData(manager, packet, ((EntityPlayer)player), dataStream);
}
} catch (Exception e)
{

View file

@ -1,50 +0,0 @@
package net.uberkat.obsidian.common;
import net.minecraft.src.*;
/**
* Simple physics handler that allows weapons, specifically knives, to knock back entities on contact.
* @author AidanBrady
*
*/
public class PhysicsHelper
{
/**
* Knock back an entity with the specified force.
* @param entityliving
* @param entityliving1
* @param f
*/
public static void knockBack(EntityLiving entityliving, EntityLiving entityliving1, float f)
{
entityliving.motionX = 0.0D;
entityliving.motionY = 0.0D;
entityliving.motionZ = 0.0D;
float f1 = 2.5F;
if ((entityliving1 instanceof EntityPlayer) && entityliving1.isSprinting())
{
entityliving.addVelocity(-Math.sin(Math.toRadians(entityliving1.rotationYaw)) * (double)f * (double)f1, 0.1F * f * f1, Math.cos(Math.toRadians(entityliving1.rotationYaw)) * (double)f * (double)f1);
}
double d = entityliving1.posX - entityliving.posX;
double d1;
for (d1 = entityliving1.posZ - entityliving.posZ; d * d + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D)
{
d = (Math.random() - Math.random()) * 0.01D;
}
entityliving.attackedAtYaw = (float)((Math.atan2(d1, d) * 180D) / Math.PI) - entityliving.rotationYaw;
float f2 = MathHelper.sqrt_double(d * d + d1 * d1);
float f3 = f;
entityliving.motionX -= (d / (double)f2) * (double)f3;
entityliving.motionY += 0.40000000000000002D;
entityliving.motionZ -= (d1 / (double)f2) * (double)f3;
if (entityliving.motionY > 0.40000000000000002D)
{
entityliving.motionY = 0.40000000000000002D;
}
}
}

View file

@ -24,9 +24,6 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
/** The inventory slot itemstacks used by this machine. */
public ItemStack[] inventory = new ItemStack[4];
/** The full name of this machine. */
public String fullName;
/** How much energy this machine uses per tick. */
public int ENERGY_PER_TICK;
@ -56,16 +53,17 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
* and the energy slot (3). The machine will not run if it does not have enough electricity, or if it doesn't have enough
* fuel ticks.
*
* @param name - display name of the machine.
* @param name - full name of this machine
* @param path - GUI texture path of this machine
* @param perTick - how much energy this machine uses per tick.
* @param secondaryPerTick - how much secondary energy (fuel) this machine uses per tick.
* @param ticksRequired - how many ticks it takes to smelt an item.
* @param maxEnergy - maximum amount of energy this machine can hold.
* @param maxSecondaryEnergy - maximum amount of secondary energy (fuel) this machine can hold.
*/
public TileEntityAdvancedElectricMachine(String name, int perTick, int secondaryPerTick, int ticksRequired, int maxEnergy, int maxSecondaryEnergy)
public TileEntityAdvancedElectricMachine(String name, String path, int perTick, int secondaryPerTick, int ticksRequired, int maxEnergy, int maxSecondaryEnergy)
{
fullName = name;
super(name, path);
ENERGY_PER_TICK = perTick;
SECONDARY_ENERGY_PER_TICK = secondaryPerTick;
TICKS_REQUIRED = ticksRequired;
@ -321,52 +319,52 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
}
}
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
super.readFromNBT(nbtTags);
NBTTagList tagList = nbtTags.getTagList("Items");
inventory = new ItemStack[getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
for (int slots = 0; slots < tagList.tagCount(); ++slots)
{
NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(slots);
byte slotID = tagCompound.getByte("Slot");
if (var5 >= 0 && var5 < inventory.length)
if (slotID >= 0 && slotID < inventory.length)
{
inventory[var5] = ItemStack.loadItemStackFromNBT(var4);
inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound);
}
}
operatingTicks = par1NBTTagCompound.getInteger("operatingTicks");
energyStored = par1NBTTagCompound.getInteger("energyStored");
secondaryEnergyStored = par1NBTTagCompound.getInteger("secondaryEnergyStored");
prevActive = isActive = par1NBTTagCompound.getBoolean("isActive");
facing = par1NBTTagCompound.getInteger("facing");
operatingTicks = nbtTags.getInteger("operatingTicks");
energyStored = nbtTags.getInteger("energyStored");
secondaryEnergyStored = nbtTags.getInteger("secondaryEnergyStored");
prevActive = isActive = nbtTags.getBoolean("isActive");
facing = nbtTags.getInteger("facing");
}
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("operatingTicks", operatingTicks);
par1NBTTagCompound.setInteger("energyStored", energyStored);
par1NBTTagCompound.setInteger("secondaryEnergyStored", secondaryEnergyStored);
par1NBTTagCompound.setBoolean("isActive", isActive);
par1NBTTagCompound.setInteger("facing", facing);
NBTTagList var2 = new NBTTagList();
super.writeToNBT(nbtTags);
nbtTags.setInteger("operatingTicks", operatingTicks);
nbtTags.setInteger("energyStored", energyStored);
nbtTags.setInteger("secondaryEnergyStored", secondaryEnergyStored);
nbtTags.setBoolean("isActive", isActive);
nbtTags.setInteger("facing", facing);
NBTTagList tagList = new NBTTagList();
for (int var3 = 0; var3 < inventory.length; ++var3)
for (int slots = 0; slots < inventory.length; ++slots)
{
if (inventory[var3] != null)
if (inventory[slots] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
inventory[var3].writeToNBT(var4);
var2.appendTag(var4);
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setByte("Slot", (byte)slots);
inventory[slots].writeToNBT(tagCompound);
tagList.appendTag(tagCompound);
}
}
par1NBTTagCompound.setTag("Items", var2);
nbtTags.setTag("Items", tagList);
}
public int getStartInventorySide(ForgeDirection side)
@ -386,9 +384,9 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
return inventory.length;
}
public ItemStack getStackInSlot(int var1)
public ItemStack getStackInSlot(int par1)
{
return inventory[var1];
return inventory[par1];
}
public ItemStack decrStackSize(int par1, int par2)
@ -445,25 +443,6 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
}
}
public String getInvName()
{
return fullName;
}
public int getInventoryStackLimit()
{
return 64;
}
public boolean isUseableByPlayer(EntityPlayer var1)
{
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : var1.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64.0D;
}
public void openChest() {}
public void closeChest() {}
/**
* Sets the energy to a new amount.
* @param energy - amount to store

View file

@ -30,11 +30,22 @@ public abstract class TileEntityBasicMachine extends TileEntity implements IElec
/** Whether or not this machine has initialized and registered with other mods. */
public boolean initialized;
/** The full name of this machine. */
public String fullName;
/** The GUI texture path for this machine. */
public String guiTexturePath;
/**
* The most basic of machines - a simple tile entity with a facing, active state, initialized state, and animated texture.
* @param name - full name of this machine
* @param path - GUI texture path of this machine
*/
public TileEntityBasicMachine()
public TileEntityBasicMachine(String name, String path)
{
ObsidianIngots.manager.register(this);
fullName = name;
guiTexturePath = path;
isActive = false;
}
@ -67,6 +78,30 @@ public abstract class TileEntityBasicMachine extends TileEntity implements IElec
}
}
public boolean isUseableByPlayer(EntityPlayer entityplayer)
{
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : entityplayer.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64.0D;
}
public void openChest() {}
public void closeChest() {}
public String getInvName()
{
return fullName;
}
public int getInventoryStackLimit()
{
return 64;
}
public void invalidate()
{
ObsidianIngots.manager.remove(this);
}
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
{
return true;

View file

@ -13,7 +13,7 @@ public class TileEntityCombiner extends TileEntityAdvancedElectricMachine
public TileEntityCombiner()
{
super("Combiner", 5, 1, 200, 1000, 200);
super("Combiner", "/gui/GuiCombiner.png", 5, 1, 200, 1000, 200);
}
public List getRecipes()

View file

@ -13,7 +13,7 @@ public class TileEntityCrusher extends TileEntityElectricMachine
public TileEntityCrusher()
{
super("Crusher", 5, 200, 1000);
super("Crusher", "/gui/GuiCrusher.png", 5, 200, 1000);
}
public List getRecipes()

View file

@ -24,9 +24,6 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
/** The inventory slot itemstacks used by this machine. */
public ItemStack[] inventory = new ItemStack[3];
/** The full name of this machine. */
public String fullName;
/** How much energy this machine uses per tick. */
public int ENERGY_PER_TICK;
@ -46,14 +43,15 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
* A simple electrical machine. This has 3 slots - the input slot (0), the energy slot (1),
* and the output slot (2). It will not run if it does not have enough energy.
*
* @param name - full name of the machine.
* @param name - full name of this machine
* @param path - GUI texture path of this machine
* @param perTick - energy used per tick.
* @param ticksRequired - ticks required to operate -- or smelt an item.
* @param maxEnergy - maximum energy this machine can hold.
*/
public TileEntityElectricMachine(String name, int perTick, int ticksRequired, int maxEnergy)
public TileEntityElectricMachine(String name, String path, int perTick, int ticksRequired, int maxEnergy)
{
fullName = name;
super(name, path);
ENERGY_PER_TICK = perTick;
TICKS_REQUIRED = ticksRequired;
MAX_ENERGY = maxEnergy;
@ -234,8 +232,6 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
}
}
public abstract List getRecipes();
public void sendPacket()
{
PacketHandler.sendElectricMachinePacket(this);
@ -261,50 +257,50 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
}
}
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
super.readFromNBT(nbtTags);
NBTTagList tagList = nbtTags.getTagList("Items");
inventory = new ItemStack[getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
for (int slots = 0; slots < tagList.tagCount(); ++slots)
{
NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(slots);
byte slotID = tagCompound.getByte("Slot");
if (var5 >= 0 && var5 < inventory.length)
if (slotID >= 0 && slotID < inventory.length)
{
inventory[var5] = ItemStack.loadItemStackFromNBT(var4);
inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound);
}
}
operatingTicks = par1NBTTagCompound.getInteger("operatingTicks");
energyStored = par1NBTTagCompound.getInteger("energyStored");
isActive = par1NBTTagCompound.getBoolean("isActive");
facing = par1NBTTagCompound.getInteger("facing");
operatingTicks = nbtTags.getInteger("operatingTicks");
energyStored = nbtTags.getInteger("energyStored");
isActive = nbtTags.getBoolean("isActive");
facing = nbtTags.getInteger("facing");
}
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("operatingTicks", operatingTicks);
par1NBTTagCompound.setInteger("energyStored", energyStored);
par1NBTTagCompound.setBoolean("isActive", isActive);
par1NBTTagCompound.setInteger("facing", facing);
NBTTagList var2 = new NBTTagList();
super.writeToNBT(nbtTags);
nbtTags.setInteger("operatingTicks", operatingTicks);
nbtTags.setInteger("energyStored", energyStored);
nbtTags.setBoolean("isActive", isActive);
nbtTags.setInteger("facing", facing);
NBTTagList tagList = new NBTTagList();
for (int var3 = 0; var3 < inventory.length; ++var3)
for (int slots = 0; slots < inventory.length; ++slots)
{
if (inventory[var3] != null)
if (inventory[slots] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
inventory[var3].writeToNBT(var4);
var2.appendTag(var4);
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setByte("Slot", (byte)slots);
inventory[slots].writeToNBT(tagCompound);
tagList.appendTag(tagCompound);
}
}
par1NBTTagCompound.setTag("Items", var2);
nbtTags.setTag("Items", tagList);
}
public int getStartInventorySide(ForgeDirection side)
@ -383,25 +379,6 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
}
}
public String getInvName()
{
return fullName;
}
public int getInventoryStackLimit()
{
return 64;
}
public boolean isUseableByPlayer(EntityPlayer var1)
{
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : var1.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64.0D;
}
public void openChest() {}
public void closeChest() {}
/**
* Sets the energy to a new amount.
* @param energy - amount to store

View file

@ -15,7 +15,7 @@ public class TileEntityEnrichmentChamber extends TileEntityElectricMachine
public TileEntityEnrichmentChamber()
{
super("Enrichment Chamber", 5, 200, 1000);
super("Enrichment Chamber", "/gui/GuiChamber.png", 5, 200, 1000);
}
public List getRecipes()

View file

@ -17,7 +17,7 @@ public class TileEntityPlatinumCompressor extends TileEntityAdvancedElectricMach
public TileEntityPlatinumCompressor()
{
super("Platinum Compressor", 5, 1, 200, 1000, 200);
super("Platinum Compressor", "/gui/GuiCompressor.png", 5, 1, 200, 1000, 200);
}
public List getRecipes()

View file

@ -5,7 +5,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import obsidian.api.IEnergizedItem;
import obsidian.api.INetworkedMachine;
import obsidian.api.ITileNetwork;
import universalelectricity.UniversalElectricity;
import universalelectricity.electricity.ElectricInfo;
@ -44,7 +44,7 @@ import net.minecraft.src.*;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
public class TileEntityPowerUnit extends TileEntityDisableable implements IInventory, ISidedInventory, INetworkedMachine, IWrenchable, IEnergySink, IEnergySource, IEnergyStorage, IPowerReceptor, IElectricityStorage, IElectricityReceiver, IPeripheral
public class TileEntityPowerUnit extends TileEntityDisableable implements IInventory, ISidedInventory, ITileNetwork, IWrenchable, IEnergySink, IEnergySource, IEnergyStorage, IPowerReceptor, IElectricityStorage, IElectricityReceiver, IPeripheral
{
public ItemStack[] inventory = new ItemStack[2];
@ -90,7 +90,7 @@ public class TileEntityPowerUnit extends TileEntityDisableable implements IInven
if(PowerFramework.currentFramework != null)
{
powerProvider = PowerFramework.currentFramework.createPowerProvider();
powerProvider.configure(20, 25, 25, 25, maxEnergy/10);
powerProvider.configure(5, 25, 25, 25, maxEnergy/10);
}
}
@ -309,54 +309,56 @@ public class TileEntityPowerUnit extends TileEntityDisableable implements IInven
public void closeChest() {}
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(par1NBTTagCompound);
super.readFromNBT(nbtTags);
if(PowerFramework.currentFramework != null)
{
PowerFramework.currentFramework.loadPowerProvider(this, par1NBTTagCompound);
PowerFramework.currentFramework.loadPowerProvider(this, nbtTags);
}
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
NBTTagList tagList = nbtTags.getTagList("Items");
inventory = new ItemStack[getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
for (int slots = 0; slots < tagList.tagCount(); ++slots)
{
NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(slots);
byte slotID = tagCompound.getByte("Slot");
if (var5 >= 0 && var5 < inventory.length)
if (slotID >= 0 && slotID < inventory.length)
{
inventory[var5] = ItemStack.loadItemStackFromNBT(var4);
inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound);
}
}
energyStored = par1NBTTagCompound.getInteger("energyStored");
facing = par1NBTTagCompound.getInteger("facing");
energyStored = nbtTags.getInteger("energyStored");
facing = nbtTags.getInteger("facing");
}
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(par1NBTTagCompound);
super.writeToNBT(nbtTags);
if(PowerFramework.currentFramework != null)
{
PowerFramework.currentFramework.savePowerProvider(this, par1NBTTagCompound);
PowerFramework.currentFramework.savePowerProvider(this, nbtTags);
}
par1NBTTagCompound.setInteger("energyStored", energyStored);
par1NBTTagCompound.setInteger("facing", facing);
NBTTagList var2 = new NBTTagList();
nbtTags.setInteger("energyStored", energyStored);
nbtTags.setInteger("facing", facing);
NBTTagList tagList = new NBTTagList();
for (int var3 = 0; var3 < inventory.length; ++var3)
for (int slots = 0; slots < inventory.length; ++slots)
{
if (inventory[var3] != null)
if (inventory[slots] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
inventory[var3].writeToNBT(var4);
var2.appendTag(var4);
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setByte("Slot", (byte)slots);
inventory[slots].writeToNBT(tagCompound);
tagList.appendTag(tagCompound);
}
}
par1NBTTagCompound.setTag("Items", var2);
nbtTags.setTag("Items", tagList);
}
public void handlePacketData(NetworkManager network, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
@ -507,6 +509,11 @@ public class TileEntityPowerUnit extends TileEntityDisableable implements IInven
return 120;
}
/**
* Whether or not the declared Tile Entity is an instance of a BuildCraft power receptor.
* @param tileEntity
* @return
*/
public boolean isPowerReceptor(TileEntity tileEntity)
{
if(tileEntity instanceof IPowerReceptor)

View file

@ -17,7 +17,7 @@ public class TileEntityTheoreticalElementizer extends TileEntityAdvancedElectric
public TileEntityTheoreticalElementizer()
{
super("Theoretical Elementizer", 50, 1, 1000, 10000, 1000);
super("Theoretical Elementizer", "/gui/GuiElementizer.png", 50, 1, 1000, 10000, 1000);
}
public List getRecipes()

View file

@ -13,7 +13,7 @@ import net.minecraftforge.common.ISidedInventory;
* @author AidanBrady
*
*/
public interface IElectricMachine extends IInventory, ISidedInventory, IWrenchable, INetworkedMachine, IPeripheral
public interface IElectricMachine extends IInventory, ISidedInventory, IWrenchable, ITileNetwork, IPeripheral
{
/**
* Update call for machines. Use instead of updateEntity() - it's called every tick.

View file

@ -11,7 +11,7 @@ import com.google.common.io.ByteArrayDataInput;
* @author AidanBrady
*
*/
public interface INetworkedMachine
public interface ITileNetwork
{
/**
* Called when a networked machine receives a packet.

View file

@ -102,16 +102,16 @@ public class ClientProxy extends CommonProxy
return new GuiWeatherOrb(player);
case 3:
TileEntityEnrichmentChamber tileentity = (TileEntityEnrichmentChamber)world.getBlockTileEntity(x, y, z);
return new GuiEnrichmentChamber(player.inventory, tileentity);
return new GuiElectricMachine(player.inventory, tileentity);
case 4:
TileEntityPlatinumCompressor tileentity1 = (TileEntityPlatinumCompressor)world.getBlockTileEntity(x, y, z);
return new GuiPlatinumCompressor(player.inventory, tileentity1);
return new GuiAdvancedElectricMachine(player.inventory, tileentity1);
case 5:
TileEntityCombiner tileentity2 = (TileEntityCombiner)world.getBlockTileEntity(x, y, z);
return new GuiCombiner(player.inventory, tileentity2);
return new GuiAdvancedElectricMachine(player.inventory, tileentity2);
case 6:
TileEntityCrusher tileentity3 = (TileEntityCrusher)world.getBlockTileEntity(x, y, z);
return new GuiCrusher(player.inventory, tileentity3);
return new GuiElectricMachine(player.inventory, tileentity3);
case 7:
TileEntityTheoreticalElementizer tileentity4 = (TileEntityTheoreticalElementizer)world.getBlockTileEntity(x, y, z);
return new GuiTheoreticalElementizer(player.inventory, tileentity4);

View file

@ -3,13 +3,13 @@ package net.uberkat.obsidian.client;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.*;
import net.uberkat.obsidian.common.ContainerAdvancedElectricMachine;
import net.uberkat.obsidian.common.TileEntityPlatinumCompressor;
import net.uberkat.obsidian.common.TileEntityAdvancedElectricMachine;
public class GuiPlatinumCompressor extends GuiContainer
public class GuiAdvancedElectricMachine extends GuiContainer
{
private TileEntityPlatinumCompressor tileEntity;
public TileEntityAdvancedElectricMachine tileEntity;
public GuiPlatinumCompressor(InventoryPlayer inventory, TileEntityPlatinumCompressor tentity)
public GuiAdvancedElectricMachine(InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity)
{
super(new ContainerAdvancedElectricMachine(inventory, tentity));
tileEntity = tentity;
@ -20,7 +20,7 @@ public class GuiPlatinumCompressor extends GuiContainer
*/
protected void drawGuiContainerForegroundLayer()
{
fontRenderer.drawString("Platinum Compressor", 45, 6, 0x404040);
fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
}
@ -29,7 +29,7 @@ public class GuiPlatinumCompressor extends GuiContainer
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int texture = mc.renderEngine.getTexture("/gui/GuiCompressor.png");
int texture = mc.renderEngine.getTexture(tileEntity.guiTexturePath);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(texture);
int guiWidth = (width - xSize) / 2;

View file

@ -1,46 +0,0 @@
package net.uberkat.obsidian.client;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.*;
import net.uberkat.obsidian.common.ContainerAdvancedElectricMachine;
import net.uberkat.obsidian.common.TileEntityCombiner;
public class GuiCombiner extends GuiContainer
{
private TileEntityCombiner tileEntity;
public GuiCombiner(InventoryPlayer inventory, TileEntityCombiner tentity)
{
super(new ContainerAdvancedElectricMachine(inventory, tentity));
tileEntity = tentity;
}
/**
* Draw the foreground layer for the GuiContainer (everythin in front of the items)
*/
protected void drawGuiContainerForegroundLayer()
{
fontRenderer.drawString("Combiner", 49, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int texture = mc.renderEngine.getTexture("/gui/GuiCombiner.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(texture);
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int displayInt;
displayInt = tileEntity.getScaledChargeLevel(12);
drawTexturedModalRect(guiWidth + 56, guiHeight + 36 + 12 - displayInt, 176, 12 - displayInt, 14, displayInt + 2);
displayInt = tileEntity.getScaledProgress(24);
drawTexturedModalRect(guiWidth + 79, guiHeight + 34, 176, 14, displayInt + 1, 16);
}
}

View file

@ -3,13 +3,13 @@ package net.uberkat.obsidian.client;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.*;
import net.uberkat.obsidian.common.ContainerElectricMachine;
import net.uberkat.obsidian.common.TileEntityCrusher;
import net.uberkat.obsidian.common.TileEntityElectricMachine;
public class GuiCrusher extends GuiContainer
public class GuiElectricMachine extends GuiContainer
{
private TileEntityCrusher tileEntity;
public TileEntityElectricMachine tileEntity;
public GuiCrusher(InventoryPlayer inventory, TileEntityCrusher tentity)
public GuiElectricMachine(InventoryPlayer inventory, TileEntityElectricMachine tentity)
{
super(new ContainerElectricMachine(inventory, tentity));
tileEntity = tentity;
@ -20,7 +20,7 @@ public class GuiCrusher extends GuiContainer
*/
protected void drawGuiContainerForegroundLayer()
{
fontRenderer.drawString("Crusher", 50, 6, 0x404040);
fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
}
@ -29,7 +29,7 @@ public class GuiCrusher extends GuiContainer
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int texture = mc.renderEngine.getTexture("/gui/GuiCrusher.png");
int texture = mc.renderEngine.getTexture(tileEntity.guiTexturePath);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(texture);
int guiWidth = (width - xSize) / 2;

View file

@ -1,46 +0,0 @@
package net.uberkat.obsidian.client;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.*;
import net.uberkat.obsidian.common.ContainerElectricMachine;
import net.uberkat.obsidian.common.TileEntityEnrichmentChamber;
public class GuiEnrichmentChamber extends GuiContainer
{
private TileEntityEnrichmentChamber tileEntity;
public GuiEnrichmentChamber(InventoryPlayer inventory, TileEntityEnrichmentChamber tentity)
{
super(new ContainerElectricMachine(inventory, tentity));
tileEntity = tentity;
}
/**
* Draw the foreground layer for the GuiContainer (everythin in front of the items)
*/
protected void drawGuiContainerForegroundLayer()
{
fontRenderer.drawString("Enrichment Chamber", 45, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int texture = mc.renderEngine.getTexture("/gui/GuiChamber.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(texture);
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int displayInt;
displayInt = tileEntity.getScaledChargeLevel(12);
drawTexturedModalRect(guiWidth + 56, guiHeight + 36 + 12 - displayInt, 176, 12 - displayInt, 14, displayInt + 2);
displayInt = tileEntity.getScaledProgress(24);
drawTexturedModalRect(guiWidth + 79, guiHeight + 34, 176, 14, displayInt + 1, 16);
}
}

View file

@ -61,28 +61,28 @@ public class GuiStopwatch extends GuiScreen {
if(guibutton.id == 0)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
ObsidianUtils.doFakeEntityExplosion(player);
PacketHandler.sendPacketDataInt(EnumPacketType.TIME, 0);
mc.displayGuiScreen(null);
}
if(guibutton.id == 1)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
ObsidianUtils.doFakeEntityExplosion(player);
PacketHandler.sendPacketDataInt(EnumPacketType.TIME, 6);
mc.displayGuiScreen(null);
}
if(guibutton.id == 2)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
ObsidianUtils.doFakeEntityExplosion(player);
PacketHandler.sendPacketDataInt(EnumPacketType.TIME, 12);
mc.displayGuiScreen(null);
}
if(guibutton.id == 3)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
ObsidianUtils.doFakeEntityExplosion(player);
PacketHandler.sendPacketDataInt(EnumPacketType.TIME, 18);
mc.displayGuiScreen(null);
}

View file

@ -7,24 +7,17 @@ import net.uberkat.obsidian.common.EnumColor;
import net.uberkat.obsidian.common.ObsidianUtils;
import net.uberkat.obsidian.common.TileEntityTheoreticalElementizer;
public class GuiTheoreticalElementizer extends GuiContainer
public class GuiTheoreticalElementizer extends GuiAdvancedElectricMachine
{
private TileEntityTheoreticalElementizer tileEntity;
public GuiTheoreticalElementizer(InventoryPlayer inventory, TileEntityTheoreticalElementizer tentity)
{
super(new ContainerAdvancedElectricMachine(inventory, tentity));
tileEntity = tentity;
super(inventory, tentity);
}
/**
* Draw the foreground layer for the GuiContainer (everythin in front of the items)
*/
protected void drawGuiContainerForegroundLayer()
{
super.drawGuiContainerForegroundLayer();
String displayText = "";
fontRenderer.drawString("Theoretical Elementizer", 32, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
if(tileEntity.isActive)
{
displayText = "Status: " + Integer.toString(tileEntity.operatingTicks/10) + "%";
@ -34,24 +27,4 @@ public class GuiTheoreticalElementizer extends GuiContainer
}
fontRenderer.drawString(displayText, 80, 60, 0x404040);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int texture = mc.renderEngine.getTexture("/gui/GuiElementizer.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(texture);
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int displayInt;
displayInt = tileEntity.getScaledChargeLevel(12);
drawTexturedModalRect(guiWidth + 56, guiHeight + 36 + 12 - displayInt, 176, 12 - displayInt, 14, displayInt + 2);
displayInt = tileEntity.getScaledProgress(24);
drawTexturedModalRect(guiWidth + 79, guiHeight + 34, 176, 14, displayInt + 1, 16);
}
}

View file

@ -62,28 +62,28 @@ public class GuiWeatherOrb extends GuiScreen {
if(guibutton.id == 0)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
ObsidianUtils.doFakeEntityExplosion(player);
PacketHandler.sendPacketDataInt(EnumPacketType.WEATHER, EnumWeatherType.CLEAR.id);
mc.displayGuiScreen(null);
}
if(guibutton.id == 1)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
ObsidianUtils.doFakeEntityExplosion(player);
PacketHandler.sendPacketDataInt(EnumPacketType.WEATHER, EnumWeatherType.STORM.id);
mc.displayGuiScreen(null);
}
if(guibutton.id == 2)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
ObsidianUtils.doFakeEntityExplosion(player);
PacketHandler.sendPacketDataInt(EnumPacketType.WEATHER, EnumWeatherType.HAZE.id);
mc.displayGuiScreen(null);
}
if(guibutton.id == 3)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
ObsidianUtils.doFakeEntityExplosion(player);
PacketHandler.sendPacketDataInt(EnumPacketType.WEATHER, EnumWeatherType.RAIN.id);
mc.displayGuiScreen(null);
}