use of net.minecraft.world.entity.animal.Chicken in project MC-Prefab by Brian-Wuest.
the class StructureBasic method AfterBuilding.
/**
* This method is used after the main building is build for any additional structures or modifications.
*
* @param configuration The structure configuration.
* @param world The current world.
* @param originalPos The original position clicked on.
* @param player The player which initiated the construction.
*/
@Override
public void AfterBuilding(StructureConfiguration configuration, ServerLevel world, BlockPos originalPos, Player player) {
BasicStructureConfiguration config = (BasicStructureConfiguration) configuration;
String structureName = config.basicStructureName.getName();
BaseOption chosenOption = config.chosenOption;
if (this.customBlockPos != null) {
if (structureName.equals(EnumBasicStructureName.ModerateFarm.getName()) && chosenOption == ModerateFarmOptions.AutomatedChickenCoop) {
// For the advanced chicken coop, spawn 4 chickens above the hopper.
for (int i = 0; i < 4; i++) {
Chicken entity = new Chicken(EntityType.CHICKEN, world);
entity.setPos(this.customBlockPos.getX(), this.customBlockPos.above().getY(), this.customBlockPos.getZ());
world.addFreshEntity(entity);
}
} else if (structureName.equals(EnumBasicStructureName.MineshaftEntrance.getName()) || structureName.equals(BasicStructureConfiguration.EnumBasicStructureName.WorkShop.getName())) {
// Build the mineshaft where the trap door exists.
BuildingMethods.PlaceMineShaft(world, this.customBlockPos.below(), configuration.houseFacing, true);
}
this.customBlockPos = null;
}
if (structureName.equals(EnumBasicStructureName.AdvancedFarm.getName()) && chosenOption == AdvancedFarmOptions.MonsterMasher) {
int monstersPlaced = 0;
// Set the spawner.
for (BlockPos pos : this.mobSpawnerPos) {
BlockEntity tileEntity = world.getBlockEntity(pos);
if (tileEntity instanceof SpawnerBlockEntity) {
SpawnerBlockEntity spawner = (SpawnerBlockEntity) tileEntity;
switch(monstersPlaced) {
case 0:
{
// Zombie.
spawner.getSpawner().setEntityId(EntityType.ZOMBIE);
break;
}
case 1:
{
// Skeleton.
spawner.getSpawner().setEntityId(EntityType.SKELETON);
break;
}
case 2:
{
// Spider.
spawner.getSpawner().setEntityId(EntityType.SPIDER);
break;
}
default:
{
// Creeper.
spawner.getSpawner().setEntityId(EntityType.CREEPER);
break;
}
}
monstersPlaced++;
}
}
if (this.signPosition != null) {
BlockEntity tileEntity = world.getBlockEntity(this.signPosition);
if (tileEntity instanceof SignBlockEntity) {
SignBlockEntity signTile = (SignBlockEntity) tileEntity;
signTile.setMessage(0, new TextComponent("Lamp On=Mobs"));
signTile.setMessage(2, new TextComponent("Lamp Off=No Mobs"));
}
}
}
if (structureName.equals(EnumBasicStructureName.AquaBase.getName()) || structureName.equals(EnumBasicStructureName.AdvancedAquaBase.getName())) {
// Replace the entrance area with air blocks.
BlockPos airPos = originalPos.above(4).relative(configuration.houseFacing.getOpposite(), 1);
// This is the first wall.
world.removeBlock(airPos.relative(configuration.houseFacing.getClockWise()), false);
world.removeBlock(airPos, false);
world.removeBlock(airPos.relative(configuration.houseFacing.getCounterClockWise()), false);
airPos = airPos.below();
world.removeBlock(airPos.relative(configuration.houseFacing.getClockWise()), false);
world.removeBlock(airPos, false);
world.removeBlock(airPos.relative(configuration.houseFacing.getCounterClockWise()), false);
airPos = airPos.below();
world.removeBlock(airPos.relative(configuration.houseFacing.getClockWise()), false);
world.removeBlock(airPos, false);
world.removeBlock(airPos.relative(configuration.houseFacing.getCounterClockWise()), false);
airPos = airPos.below();
world.removeBlock(airPos.relative(configuration.houseFacing.getClockWise()), false);
world.removeBlock(airPos, false);
world.removeBlock(airPos.relative(configuration.houseFacing.getCounterClockWise()), false);
// Second part of the wall.
airPos = airPos.relative(configuration.houseFacing.getOpposite()).above();
world.removeBlock(airPos.relative(configuration.houseFacing.getClockWise()), false);
world.removeBlock(airPos, false);
world.removeBlock(airPos.relative(configuration.houseFacing.getCounterClockWise()), false);
airPos = airPos.above();
world.removeBlock(airPos.relative(configuration.houseFacing.getClockWise()), false);
world.removeBlock(airPos, false);
world.removeBlock(airPos.relative(configuration.houseFacing.getCounterClockWise()), false);
airPos = airPos.above();
world.removeBlock(airPos, false);
}
}
Aggregations