use of com.github.jikoo.planarwrappers.world.Direction in project Easterlyn by Easterlyn.
the class CompilationAmalgamator method ejectItem.
private void ejectItem(Location key, @Nullable ItemStack item, ConfigurationSection storage) {
if (item == null) {
return;
}
Direction facing = this.getDirection(storage).getRelativeDirection(Direction.SOUTH);
BlockState blockState = key.clone().add(facing.getRelativeVector(new Vector(0, 0, 1))).getBlock().getState();
if (blockState instanceof InventoryHolder) {
// MACHINES InventoryMoveItemEvent
if (((InventoryHolder) blockState).getInventory().addItem(item).size() == 0) {
return;
}
}
// Center block location
key.add(facing.getRelativeVector(new Vector(0.5D, 0.5D, 1.5D)));
BlockFace face = facing.toBlockFace();
// See net.minecraft.server.DispenseBehaviorItem
Random random = ThreadLocalRandom.current();
double motionRandom = random.nextDouble() * 0.1D + 0.2D;
// 0.007499999832361937D * 6
double motX = face.getModX() * motionRandom + random.nextGaussian() * 0.044999998994171622D;
double motY = 0.2000000029802322D + random.nextGaussian() * 0.044999998994171622D;
double motZ = face.getModZ() * motionRandom + random.nextGaussian() * 0.044999998994171622D;
// MACHINES BlockDispenseEvent
if (key.getWorld() != null) {
key.getWorld().dropItem(key, item).setVelocity(new Vector(motX, motY, motZ));
key.getWorld().playSound(key, Sound.BLOCK_DISPENSER_DISPENSE, SoundCategory.BLOCKS, 1F, 1F);
key.getWorld().playEffect(key, Effect.SMOKE, face);
}
}
use of com.github.jikoo.planarwrappers.world.Direction in project Easterlyn by Easterlyn.
the class Densificator method ejectItem.
private void ejectItem(Location key, ItemStack item, ConfigurationSection storage) {
Direction facing = this.getDirection(storage).getRelativeDirection(Direction.SOUTH);
BlockState blockState = key.clone().add(facing.getRelativeVector(new Vector(0, 0, 1))).getBlock().getState();
if (blockState instanceof InventoryHolder) {
// TODO InventoryMoveItemEvent? Currently prevents instant chaining.
if (((InventoryHolder) blockState).getInventory().addItem(item).size() == 0) {
return;
}
}
// Center block location
key.add(facing.getRelativeVector(new Vector(0.5D, 0.5D, 1.5D)));
BlockFace face = facing.toBlockFace();
// See net.minecraft.server.DispenseBehaviorItem
Random random = ThreadLocalRandom.current();
double motionRandom = random.nextDouble() * 0.1D + 0.2D;
// 0.007499999832361937D * 6
double motX = face.getModX() * motionRandom + random.nextGaussian() * 0.044999998994171622D;
double motY = 0.2000000029802322D + random.nextGaussian() * 0.044999998994171622D;
double motZ = face.getModZ() * motionRandom + random.nextGaussian() * 0.044999998994171622D;
// TODO BlockDispenseEvent
if (key.getWorld() != null) {
key.getWorld().dropItem(key, item).setVelocity(new Vector(motX, motY, motZ));
key.getWorld().playSound(key, Sound.BLOCK_DISPENSER_DISPENSE, SoundCategory.BLOCKS, 1F, 1F);
key.getWorld().playEffect(key, Effect.SMOKE, face);
key.getWorld().playEffect(key, Effect.SMOKE, face);
}
}
use of com.github.jikoo.planarwrappers.world.Direction in project Easterlyn by Easterlyn.
the class Machine method failedAssembly.
/**
* Sets up the Machine Block configuration using a BlockPlaceEvent.
*
* @param storage the ConfigurationSection of data specific to the given Machine
* @return false if assembly failed due to space requirements
*/
public boolean failedAssembly(@NotNull ConfigurationSection storage) {
Location key = getKey(storage);
Direction direction = getDirection(storage);
for (Block block : shape.getBuildLocations(key.getBlock(), direction).keySet()) {
if (!block.getLocation().equals(key) && (!block.isEmpty() || getMachines().isExplodedMachine(block)) || block.getY() > 255) {
this.assemblyFailed(storage);
return true;
}
}
this.assemble(key.getBlock(), direction, storage);
return false;
}
Aggregations