From c3158aeb74bd0df6b2557974806ba7ec25f9b066 Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Mon, 2 Sep 2013 16:26:02 -0400 Subject: [PATCH] cleanup --- src/dark/common/DarkMain.java | 2 +- src/dark/prefab/BlockMachine.java | 85 +++----------------------- src/dark/prefab/TileEntityInv.java | 3 + src/dark/prefab/TileEntityMachine.java | 4 ++ src/dark/prefab/damage/IHpTile.java | 8 ++- 5 files changed, 21 insertions(+), 81 deletions(-) diff --git a/src/dark/common/DarkMain.java b/src/dark/common/DarkMain.java index f3221e1a..d45f0079 100644 --- a/src/dark/common/DarkMain.java +++ b/src/dark/common/DarkMain.java @@ -59,7 +59,7 @@ public class DarkMain extends ModPrefab public static final String MOD_NAME = "Darks CoreMachine"; public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVIS_VERSION + "." + BUILD_VERSION; - @SidedProxy(clientSide = "dark.core.ClientProxy", serverSide = "dark.core.CommonProxy") + @SidedProxy(clientSide = "dark.client.ClientProxy", serverSide = "dark.common.CommonProxy") public static CommonProxy proxy; public static final String CHANNEL = "DarkPackets"; diff --git a/src/dark/prefab/BlockMachine.java b/src/dark/prefab/BlockMachine.java index 45508b6d..1ebcee84 100644 --- a/src/dark/prefab/BlockMachine.java +++ b/src/dark/prefab/BlockMachine.java @@ -3,16 +3,11 @@ package dark.prefab; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; -import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.Configuration; -import universalelectricity.prefab.block.BlockAdvanced; +import universalelectricity.prefab.block.BlockTile; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import dark.common.DarkMain; @@ -23,7 +18,7 @@ import dark.interfaces.INetworkPart; * file each time * * @author Darkguardsman */ -public abstract class BlockMachine extends BlockAdvanced implements ITileEntityProvider +public abstract class BlockMachine extends BlockTile implements ITileEntityProvider { /** @param name - The name the block will use for both the config and translation file * @param config - configuration reference used to pull blockID from @@ -34,15 +29,16 @@ public abstract class BlockMachine extends BlockAdvanced implements ITileEntityP super(config.getBlock(name, blockID).getInt(), material); this.isBlockContainer = true; this.setUnlocalizedName(name); - } - @SideOnly(Side.CLIENT) @Override + @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconReg) { if (this.blockIcon == null) + { this.blockIcon = iconReg.registerIcon(DarkMain.getInstance().PREFIX + "machine"); + } } @Override @@ -56,25 +52,18 @@ public abstract class BlockMachine extends BlockAdvanced implements ITileEntityP @Override public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if (tileEntity instanceof INetworkPart) { ((INetworkPart) tileEntity).refresh(); } - super.onBlockAdded(world, x, y, z); - } - - @Override - public void breakBlock(World world, int x, int y, int z, int par5, int par6) - { - super.breakBlock(world, x, y, z, par5, par6); - this.dropEntireInventory(world, x, y, z, par5, par6); - world.removeBlockTileEntity(x, y, z); } @Override public void onNeighborBlockChange(World world, int x, int y, int z, int blockID) { + super.onNeighborBlockChange(world, x, y, z, blockID); TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if (tileEntity instanceof INetworkPart) @@ -83,64 +72,4 @@ public abstract class BlockMachine extends BlockAdvanced implements ITileEntityP } } - /** Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it - * on to the tile entity at this location. Args: world, x, y, z, blockID, EventID, event - * parameter */ - @Override - public boolean onBlockEventReceived(World world, int x, int y, int z, int blockID, int eventID) - { - super.onBlockEventReceived(world, x, y, z, blockID, eventID); - TileEntity tileentity = world.getBlockTileEntity(x, y, z); - return tileentity != null ? tileentity.receiveClientEvent(blockID, eventID) : false; - } - - public void dropEntireInventory(World world, int x, int y, int z, int par5, int par6) - { - TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - - if (tileEntity != null) - { - if (tileEntity instanceof IInventory) - { - IInventory inventory = (IInventory) tileEntity; - - for (int slot = 0; slot < inventory.getSizeInventory(); ++slot) - { - ItemStack itemStack = inventory.getStackInSlot(slot); - - if (itemStack != null) - { - float deltaX = world.rand.nextFloat() * 0.8F + 0.1F; - float deltaY = world.rand.nextFloat() * 0.8F + 0.1F; - float deltaZ = world.rand.nextFloat() * 0.8F + 0.1F; - - while (itemStack.stackSize > 0) - { - int stackSplit = world.rand.nextInt(21) + 10; - - if (stackSplit > itemStack.stackSize) - { - stackSplit = itemStack.stackSize; - } - - itemStack.stackSize -= stackSplit; - EntityItem entityItem = new EntityItem(world, (x + deltaX), (y + deltaY), (z + deltaZ), new ItemStack(itemStack.itemID, stackSplit, itemStack.getItemDamage())); - - if (itemStack.hasTagCompound()) - { - entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); - } - - float var13 = 0.05F; - entityItem.motionX = ((float) world.rand.nextGaussian() * var13); - entityItem.motionY = ((float) world.rand.nextGaussian() * var13 + 0.2F); - entityItem.motionZ = ((float) world.rand.nextGaussian() * var13); - world.spawnEntityInWorld(entityItem); - } - } - } - } - } - } - } diff --git a/src/dark/prefab/TileEntityInv.java b/src/dark/prefab/TileEntityInv.java index 925737e3..3ccdb9a4 100644 --- a/src/dark/prefab/TileEntityInv.java +++ b/src/dark/prefab/TileEntityInv.java @@ -10,6 +10,9 @@ import dark.interfaces.IExternalInv; import dark.interfaces.IInvBox; import dark.prefab.invgui.InvChest; +/** Prefab for simple object who only need basic inv support and nothing more + * + * @author Darkguardsman */ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, ISidedInventory { protected IInvBox inventory; diff --git a/src/dark/prefab/TileEntityMachine.java b/src/dark/prefab/TileEntityMachine.java index b2e6d2d4..b8e5e0ac 100644 --- a/src/dark/prefab/TileEntityMachine.java +++ b/src/dark/prefab/TileEntityMachine.java @@ -333,6 +333,10 @@ public abstract class TileEntityMachine extends TileEntityUniversalElectrical im nbt.setBoolean("shouldPower", this.unpowered); } + /*-------------------------------------------------------------- + * IInventory stuff + * ------------------------------------------------------------- */ + @Override public IInvBox getInventory() { diff --git a/src/dark/prefab/damage/IHpTile.java b/src/dark/prefab/damage/IHpTile.java index 2b54b35f..acf5c0ea 100644 --- a/src/dark/prefab/damage/IHpTile.java +++ b/src/dark/prefab/damage/IHpTile.java @@ -3,10 +3,14 @@ package dark.prefab.damage; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; +/** Used by tiles that want to pretend to be living objects. Will require the use of this interface + * as well spawning a EntityTileDamage entity as its location + * + * @author DarkGuardsman */ public interface IHpTile { /** Same as attackEntityFrom in Entity.class - * + * * @param source - DamageSource/DamageType * @param ammount - amount of damage * @return */ @@ -20,7 +24,7 @@ public interface IHpTile public int hp(); /** Sets the tiles hp - * + * * @param i - amount * @param increase - increase instead of replace */ public void setHp(int i, boolean increase);