use of com.minecraftabnormals.endergetic.common.entities.PoiseClusterEntity in project endergetic by team-abnormals.
the class PoiseClusterBlock method onProjectileHit.
@Override
public void onProjectileHit(World world, BlockState state, BlockRayTraceResult hit, ProjectileEntity projectile) {
BlockPos pos = hit.getBlockPos();
if (world.isEmptyBlock(pos.above()) && world.getEntitiesOfClass(PoiseClusterEntity.class, new AxisAlignedBB(pos.above())).isEmpty()) {
if (!world.isClientSide) {
PoiseClusterEntity cluster = new PoiseClusterEntity(world, pos, pos.getX(), pos.getY(), pos.getZ());
cluster.setBlocksToMoveUp(10);
world.addFreshEntity(cluster);
if (projectile instanceof ArrowEntity) {
projectile.remove();
}
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 2);
world.playSound(null, pos, EESounds.CLUSTER_BREAK.get(), SoundCategory.BLOCKS, 0.90F, 0.75F);
Random rand = new Random();
for (int i = 0; i < 8; i++) {
double offsetX = MathUtil.makeNegativeRandomly(rand.nextFloat() * 0.25F, rand);
double offsetZ = MathUtil.makeNegativeRandomly(rand.nextFloat() * 0.25F, rand);
double x = pos.getX() + 0.5D + offsetX;
double y = pos.getY() + 0.5D + (rand.nextFloat() * 0.05F);
double z = pos.getZ() + 0.5D + offsetZ;
NetworkUtil.spawnParticle("endergetic:short_poise_bubble", x, y, z, MathUtil.makeNegativeRandomly((rand.nextFloat() * 0.1F), rand) + 0.025F, (rand.nextFloat() * 0.15F) + 0.1F, MathUtil.makeNegativeRandomly((rand.nextFloat() * 0.1F), rand) + 0.025F);
}
}
}
}
use of com.minecraftabnormals.endergetic.common.entities.PoiseClusterEntity in project endergetic by team-abnormals.
the class PoiseClusterBlock method attack.
@Override
public void attack(BlockState state, World world, BlockPos pos, PlayerEntity player) {
ItemStack stack = player.getMainHandItem();
Item item = stack.getItem();
if (!item.is(Tags.Items.SHEARS)) {
if (world.isEmptyBlock(pos.above()) && world.getEntitiesOfClass(PoiseClusterEntity.class, new AxisAlignedBB(pos).move(0, 1, 0)).isEmpty()) {
if (!world.isClientSide) {
PoiseClusterEntity cluster = new PoiseClusterEntity(world, pos, pos.getX(), pos.getY(), pos.getZ());
cluster.setBlocksToMoveUp(10);
world.addFreshEntity(cluster);
Random rand = player.getRandom();
for (int i = 0; i < 8; i++) {
double offsetX = MathUtil.makeNegativeRandomly(rand.nextFloat() * 0.25F, rand);
double offsetZ = MathUtil.makeNegativeRandomly(rand.nextFloat() * 0.25F, rand);
double x = pos.getX() + 0.5D + offsetX;
double y = pos.getY() + 0.5D + (rand.nextFloat() * 0.05F);
double z = pos.getZ() + 0.5D + offsetZ;
NetworkUtil.spawnParticle("endergetic:short_poise_bubble", x, y, z, MathUtil.makeNegativeRandomly((rand.nextFloat() * 0.1F), rand) + 0.025F, (rand.nextFloat() * 0.15F) + 0.1F, MathUtil.makeNegativeRandomly((rand.nextFloat() * 0.1F), rand) + 0.025F);
}
}
world.removeBlock(pos, false);
}
} else {
world.destroyBlock(pos, false);
stack.hurtAndBreak(1, player, (broken) -> broken.broadcastBreakEvent(player.getUsedItemHand()));
popResource(world, pos, new ItemStack(this.asItem()));
}
}
Aggregations