cleanup
This commit is contained in:
parent
c7947817e7
commit
c3158aeb74
5 changed files with 21 additions and 81 deletions
|
@ -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";
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -333,6 +333,10 @@ public abstract class TileEntityMachine extends TileEntityUniversalElectrical im
|
|||
nbt.setBoolean("shouldPower", this.unpowered);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------
|
||||
* IInventory stuff
|
||||
* ------------------------------------------------------------- */
|
||||
|
||||
@Override
|
||||
public IInvBox getInventory()
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue