use of net.minecraft.entity.mob.PatrolEntity in project Biome-Makeover by Lemonszz.
the class PillagerSpawnerMixin method spawnMixin.
@Inject(at = @At("HEAD"), method = "spawnPillager", cancellable = true)
private void spawnMixin(ServerWorld world, BlockPos pos, Random random, boolean captain, CallbackInfoReturnable<Boolean> cbi) {
Biome biome = world.getBiome(pos);
Biome.Category category = biome.getCategory();
if (category == Biome.Category.MESA) {
BlockState blockState = world.getBlockState(pos);
if (!SpawnHelper.isClearForSpawn(world, pos, blockState, blockState.getFluidState(), BMEntities.COWBOY)) {
cbi.setReturnValue(false);
return;
} else if (!PatrolEntity.canSpawn(BMEntities.COWBOY, world, SpawnReason.PATROL, pos, random)) {
cbi.setReturnValue(false);
return;
} else {
PatrolEntity patrolEntity = BMEntities.COWBOY.create(world);
if (patrolEntity != null) {
HorseEntity horseEntity = EntityType.HORSE.create(world);
horseEntity.updatePosition(pos.getX(), pos.getY(), pos.getZ());
horseEntity.initialize(world, world.getLocalDifficulty(pos), SpawnReason.PATROL, null, null);
patrolEntity.startRiding(horseEntity);
if (captain) {
patrolEntity.setPatrolLeader(true);
patrolEntity.setRandomPatrolTarget();
((HorseHat) horseEntity).setHat();
}
((HorseHat) horseEntity).setCowboySpawned();
patrolEntity.updatePosition(pos.getX(), pos.getY(), pos.getZ());
patrolEntity.initialize(world, world.getLocalDifficulty(pos), SpawnReason.PATROL, null, null);
world.spawnEntityAndPassengers(horseEntity);
cbi.setReturnValue(true);
return;
} else {
cbi.setReturnValue(false);
return;
}
}
}
}
Aggregations