use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.
the class BlockEssenceRefiner method breakBlock.
@Override
public void breakBlock(World world, int i, int j, int k, Block par5, int metadata) {
if (!keepRefinerInventory) {
TileEntityEssenceRefiner refiner = (TileEntityEssenceRefiner) world.getTileEntity(i, j, k);
if (refiner == null)
return;
for (int l = 0; l < refiner.getSizeInventory() - 3; l++) {
ItemStack itemstack = refiner.getStackInSlot(l);
if (itemstack == null) {
continue;
}
float f = world.rand.nextFloat() * 0.8F + 0.1F;
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
do {
if (itemstack.stackSize <= 0) {
break;
}
int i1 = world.rand.nextInt(21) + 10;
if (i1 > itemstack.stackSize) {
i1 = itemstack.stackSize;
}
itemstack.stackSize -= i1;
ItemStack newItem = new ItemStack(itemstack.getItem(), i1, itemstack.getItemDamage());
newItem.setTagCompound(itemstack.getTagCompound());
EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem);
float f3 = 0.05F;
entityitem.motionX = (float) world.rand.nextGaussian() * f3;
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
} while (true);
}
}
super.breakBlock(world, i, j, k, par5, metadata);
}
use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.
the class BlockArcaneDeconstructor method breakBlock.
@Override
public void breakBlock(World world, int i, int j, int k, Block par5, int metadata) {
TileEntityArcaneDeconstructor deconstructor = (TileEntityArcaneDeconstructor) world.getTileEntity(i, j, k);
if (deconstructor == null)
return;
for (int l = 0; l < deconstructor.getSizeInventory() - 3; l++) {
ItemStack itemstack = deconstructor.getStackInSlot(l);
if (itemstack == null) {
continue;
}
float f = world.rand.nextFloat() * 0.8F + 0.1F;
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
do {
if (itemstack.stackSize <= 0) {
break;
}
int i1 = world.rand.nextInt(21) + 10;
if (i1 > itemstack.stackSize) {
i1 = itemstack.stackSize;
}
itemstack.stackSize -= i1;
ItemStack newItem = new ItemStack(itemstack.getItem(), i1, itemstack.getItemDamage());
newItem.setTagCompound(itemstack.getTagCompound());
EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem);
float f3 = 0.05F;
entityitem.motionX = (float) world.rand.nextGaussian() * f3;
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
} while (true);
}
super.breakBlock(world, i, j, k, par5, metadata);
}
use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.
the class BlockArcaneReconstructor method breakBlock.
@Override
public void breakBlock(World world, int i, int j, int k, Block par5, int metadata) {
if (!world.isRemote) {
TileEntityArcaneReconstructor reconstructor = (TileEntityArcaneReconstructor) world.getTileEntity(i, j, k);
if (reconstructor == null)
return;
for (int l = 0; l < reconstructor.getSizeInventory() - 3; l++) {
ItemStack itemstack = reconstructor.getStackInSlot(l);
if (itemstack == null) {
continue;
}
float f = world.rand.nextFloat() * 0.8F + 0.1F;
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
do {
if (itemstack.stackSize <= 0) {
break;
}
int i1 = world.rand.nextInt(21) + 10;
if (i1 > itemstack.stackSize) {
i1 = itemstack.stackSize;
}
itemstack.stackSize -= i1;
ItemStack newItem = new ItemStack(itemstack.getItem(), i1, itemstack.getItemDamage());
newItem.setTagCompound(itemstack.getTagCompound());
EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem);
float f3 = 0.05F;
entityitem.motionX = (float) world.rand.nextGaussian() * f3;
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
} while (true);
}
}
super.breakBlock(world, i, j, k, par5, metadata);
}
use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.
the class BlockInertSpawner method breakBlock.
@Override
public void breakBlock(World world, int x, int y, int z, Block oldBlockID, int oldMetadata) {
TileEntityInertSpawner spawner = (TileEntityInertSpawner) world.getTileEntity(x, y, z);
//if there is no habitat at the location break out
if (spawner == null)
return;
//if the habitat has a flicker throw it on the ground
if (spawner.getStackInSlot(0) != null) {
ItemStack stack = spawner.getStackInSlot(0);
float offsetX = world.rand.nextFloat() * 0.8F + 0.1F;
float offsetY = world.rand.nextFloat() * 0.8F + 0.1F;
float offsetZ = world.rand.nextFloat() * 0.8F + 0.1F;
float force = 0.05F;
EntityItem entityItem = new EntityItem(world, x + offsetX, y + offsetY, z + offsetZ, stack);
entityItem.motionX = (float) world.rand.nextGaussian() * force;
entityItem.motionY = (float) world.rand.nextGaussian() * force + 0.2F;
entityItem.motionZ = (float) world.rand.nextGaussian() * force;
world.spawnEntityInWorld(entityItem);
}
super.breakBlock(world, x, y, z, oldBlockID, oldMetadata);
}
use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.
the class BlockKeystoneChest method breakBlock.
@Override
public void breakBlock(World world, int i, int j, int k, Block par5, int metadata) {
if (world.isRemote) {
super.breakBlock(world, i, j, k, par5, metadata);
return;
}
TileEntityKeystoneChest receptacle = (TileEntityKeystoneChest) world.getTileEntity(i, j, k);
if (receptacle == null)
return;
if (KeystoneUtilities.instance.getKeyFromRunes(receptacle.getRunesInKey()) == 0) {
for (int l = 0; l < receptacle.getSizeInventory() - 3; l++) {
ItemStack itemstack = receptacle.getStackInSlot(l);
if (itemstack == null) {
continue;
}
float f = world.rand.nextFloat() * 0.8F + 0.1F;
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
do {
if (itemstack.stackSize <= 0) {
break;
}
int i1 = world.rand.nextInt(21) + 10;
if (i1 > itemstack.stackSize) {
i1 = itemstack.stackSize;
}
itemstack.stackSize -= i1;
ItemStack newItem = new ItemStack(itemstack.getItem(), i1, itemstack.getItemDamage());
newItem.setTagCompound(itemstack.getTagCompound());
EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem);
float f3 = 0.05F;
entityitem.motionX = (float) world.rand.nextGaussian() * f3;
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
} while (true);
}
super.breakBlock(world, i, j, k, par5, metadata);
}
}
Aggregations