use of net.geforcemods.securitycraft.tileentity.TileEntityKeypadFurnace in project SecurityCraft by Geforce132.
the class BlockKeypadFurnace method breakBlock.
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5Block, int par6) {
TileEntityKeypadFurnace tileentityfurnace = (TileEntityKeypadFurnace) par1World.getTileEntity(par2, par3, par4);
if (tileentityfurnace != null) {
for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) {
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
if (itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
float f2 = random.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0) {
int j1 = random.nextInt(21) + 10;
if (j1 > itemstack.stackSize)
j1 = itemstack.stackSize;
itemstack.stackSize -= j1;
EntityItem entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getMetadata()));
if (itemstack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
float f3 = 0.05F;
entityitem.motionX = (float) random.nextGaussian() * f3;
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) random.nextGaussian() * f3;
par1World.spawnEntityInWorld(entityitem);
}
}
}
par1World.updateNeighborsAboutBlockChange(par2, par3, par4, par5Block);
}
super.breakBlock(par1World, par2, par3, par4, par5Block, par6);
}
use of net.geforcemods.securitycraft.tileentity.TileEntityKeypadFurnace in project SecurityCraft by Geforce132.
the class BlockUtils method setBlockProperty.
public static void setBlockProperty(World par1World, BlockPos pos, PropertyBool property, boolean value, boolean retainOldTileEntity) {
if (retainOldTileEntity) {
ItemStack[] modules = null;
ItemStack[] inventory = null;
int[] times = new int[4];
String password = "";
Owner owner = null;
int cooldown = -1;
if (par1World.getTileEntity(pos) instanceof CustomizableSCTE)
modules = ((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks;
if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
inventory = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks;
times[0] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime;
times[1] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime;
times[2] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime;
times[3] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime;
}
if (par1World.getTileEntity(pos) instanceof TileEntityOwnable && ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner() != null)
owner = ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner();
if (par1World.getTileEntity(pos) instanceof TileEntityKeypad && ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword() != null)
password = ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword();
if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace && ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword() != null)
password = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword();
if (par1World.getTileEntity(pos) instanceof TileEntityKeypadChest && ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword() != null)
password = ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword();
if (par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown() != 0)
cooldown = ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown();
TileEntity tileEntity = par1World.getTileEntity(pos);
par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
par1World.setTileEntity(pos, tileEntity);
if (modules != null)
((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks = modules;
if (inventory != null && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks = inventory;
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime = times[0];
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime = times[1];
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime = times[2];
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime = times[3];
}
if (owner != null)
((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner().set(owner);
if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypad)
((TileEntityKeypad) par1World.getTileEntity(pos)).setPassword(password);
if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace)
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).setPassword(password);
if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadChest)
((TileEntityKeypadChest) par1World.getTileEntity(pos)).setPassword(password);
if (cooldown != -1 && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar)
((TileEntityPortableRadar) par1World.getTileEntity(pos)).setAttackCooldown(cooldown);
} else
par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
}
use of net.geforcemods.securitycraft.tileentity.TileEntityKeypadFurnace in project SecurityCraft by Geforce132.
the class BlockKeypadFurnace method convert.
@Override
public boolean convert(EntityPlayer player, World world, BlockPos pos) {
EnumFacing enumfacing = (EnumFacing) world.getBlockState(pos).getValue(FACING);
TileEntityFurnace furnace = (TileEntityFurnace) world.getTileEntity(pos);
NBTTagCompound tag = new NBTTagCompound();
furnace.writeToNBT(tag);
furnace.clear();
world.setBlockState(pos, SCContent.keypadFurnace.getDefaultState().withProperty(FACING, enumfacing).withProperty(OPEN, false));
((IOwnable) world.getTileEntity(pos)).getOwner().set(player.getCommandSenderName(), player.getUniqueID().toString());
((TileEntityKeypadFurnace) world.getTileEntity(pos)).readFromNBT(tag);
return true;
}
Aggregations