use of net.minecraft.entity.item.EntityItem in project LogisticsPipes by RS485.
the class SimpleStackInventory method dropItems.
private void dropItems(World world, ItemStack stack, int i, int j, int k) {
if (stack.stackSize <= 0) {
return;
}
float f1 = 0.7F;
double d = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D;
double d1 = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D;
double d2 = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D;
EntityItem entityitem = new EntityItem(world, i + d, j + d1, k + d2, stack);
entityitem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityitem);
}
use of net.minecraft.entity.item.EntityItem in project Witchworks by Um-Mitternacht.
the class TileKettle method processingLogic.
//------------------------------------Crafting Logic------------------------------------//
@SuppressWarnings("ConstantConditions")
public boolean processingLogic(ItemStack stack) {
if (!isBoiling() || hasIngredients() || stack.getCount() > 64)
return false;
Map<Item, ItemValidator<ItemStack>> processing = KettleRegistry.getKettleProcessing(inv.getInnerFluid());
if (processing != null && processing.containsKey(stack.getItem())) {
ItemValidator<ItemStack> validator = processing.get(stack.getItem());
Optional<ItemStack> optional = validator.getMatchFor(stack);
if (optional.isPresent()) {
ItemStack out = optional.get().copy();
if (stack.isItemDamaged() && out.isItemStackDamageable())
out.setItemDamage(stack.getItemDamage());
int fluidAmount = inv.getFluidAmount();
int fluidTaken = 250;
out.setCount(0);
if (stack.getCount() <= 16) {
out.setCount(stack.getCount());
stack.setCount(0);
} else {
while (stack.getCount() > 0 && fluidTaken <= fluidAmount) {
stack.shrink(1);
out.grow(1);
if (out.getCount() % 16 == 0) {
if (fluidTaken >= fluidAmount) {
fluidTaken = fluidAmount;
break;
}
fluidTaken += 250;
}
}
}
if (out.getCount() > 0) {
final double x = getPos().getX();
final double y = getPos().getY() + 1D;
final double z = getPos().getZ();
final EntityItem item = new EntityItem(world, x + 0.5D, y, z + 0.5D, out);
item.motionX = world.rand.nextDouble() * 2 - 1;
item.motionZ = world.rand.nextDouble() * 2 - 1;
item.motionY = 0.1D;
item.setPickupDelay(0);
world.spawnEntity(item);
play(SoundEvents.BLOCK_FIRE_EXTINGUISH, 1F, 1F);
for (int i = 0; i < 4; i++) {
PacketHandler.spawnParticle(ParticleF.STEAM, world, x + world.rand.nextFloat(), getParticleLevel(), z + world.rand.nextFloat(), 5, 0, 0, 0);
}
inv.drain(fluidTaken, true);
return true;
}
}
}
return false;
}
use of net.minecraft.entity.item.EntityItem in project Witchworks by Um-Mitternacht.
the class TileKettle method update.
@Override
public void update() {
if (!world.isRemote && ticks % 2 == 0) {
double x = getPos().getX();
double y = getPos().getY();
double z = getPos().getZ();
AxisAlignedBB box = new AxisAlignedBB(x, y, z, x + 1, y + 0.65D, z + 1);
final List<EntityItem> entityItemList = world.getEntitiesWithinAABB(EntityItem.class, box);
entityItemList.forEach(this::collideItem);
}
if (inv.hasFluid()) {
if (!inv.hasFluid(FluidRegistry.LAVA)) {
if (isBoiling()) {
handleParticles();
if (ticks % 5 == 0 && world.rand.nextInt(15) == 0) {
play(SoundEvents.BLOCK_LAVA_AMBIENT, 0.1F, 1F);
}
}
} else if (ticks % 5 == 0 && world.rand.nextInt(20) == 0) {
play(SoundEvents.BLOCK_LAVA_AMBIENT, 1F, 1F);
}
}
if (ticks % 20 == 0) {
handleHeat();
tryTurnLiquid();
}
if (!world.isRemote && mode == Mode.RITUAL && ritual != null) {
handleRitual();
}
++ticks;
}
use of net.minecraft.entity.item.EntityItem in project Witchworks by Um-Mitternacht.
the class TileApiary method dropItems.
public void dropItems() {
for (int i = 0; i < 16; ++i) {
final ItemStack stack = itemStacks.get(i);
if (!world.isRemote && !stack.isEmpty()) {
final EntityItem item = new EntityItem(world, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, stack);
world.spawnEntity(item);
}
itemStacks.set(i, ItemStack.EMPTY);
}
}
use of net.minecraft.entity.item.EntityItem in project Witchworks by Um-Mitternacht.
the class ItemRitual method spawnItem.
@SuppressWarnings("ConstantConditions")
private void spawnItem(World world, double x, double y, double z) {
final EntityItem item = new EntityItem(world, x + 0.5D, y, z + 0.5D, stack);
item.motionX = world.rand.nextDouble() * 2 - 1;
item.motionZ = world.rand.nextDouble() * 2 - 1;
item.motionY = 0.1D;
world.spawnEntity(item);
}
Aggregations