use of com.toadstoolstudios.sprout.entities.BounceBugVariant in project Sprout by ThatGravyBoat.
the class SpreadShroomOrGrowWartGoal method tick.
@Override
public void tick() {
World world = bug.getWorld();
BounceBugVariant variant = bug.getBounceBugVariant();
if (!world.isClient)
((ServerWorld) world).spawnParticles(variant.particleEffect, bug.getX(), bug.getY(), bug.getZ(), 1, 0.1, 0.1, 0.1, 0);
// noinspection ConstantConditions
bug.lookAt(bug.getCommandSource().getEntityAnchor(), Vec3d.ofCenter(bug.getTargetPlant()));
if (isShroom && growTimer % 15 == 1) {
Box blocks = Box.from(Vec3d.ofCenter(shroomPos)).expand(2, 1, 2);
BlockPos.stream(blocks).filter(blockPos -> world.getBlockState(blockPos).isAir()).filter(blockPos -> mushroomPredicate(world.getBlockState(shroomPos), world.getBlockState(blockPos.down()), world, blockPos)).forEach(blockPos -> {
if (world.random.nextInt(30) == 1) {
if (!world.isClient)
((ServerWorld) world).spawnParticles(variant.particleEffect, blockPos.getX(), blockPos.getY(), blockPos.getZ(), 2, 0.1, 0.1, 0.1, 0.2);
world.setBlockState(blockPos, world.getBlockState(shroomPos).getBlock().getDefaultState());
}
});
} else if (!isShroom) {
Box blocks = Box.from(Vec3d.ofCenter(shroomPos)).expand(1, 1, 1);
BlockPos.stream(blocks).filter(blockPos -> world.getBlockState(blockPos).isOf(Blocks.NETHER_WART)).forEach(blockPos -> {
BlockState state = world.getBlockState(blockPos);
if (world.getRandom().nextInt(150) == 1) {
int age = state.get(NetherWartBlock.AGE);
if (age < NetherWartBlock.field_31199)
world.setBlockState(blockPos, state.with(NetherWartBlock.AGE, age + 1));
}
});
}
growTimer++;
}
Aggregations