Search in sources :

Example 1 with BasicStructureConfiguration

use of com.wuest.prefab.structures.config.BasicStructureConfiguration in project MC-Prefab by Brian-Wuest.

the class StructureBasic method hasGlassColor.

@Override
protected boolean hasGlassColor(StructureConfiguration configuration) {
    BasicStructureConfiguration config = (BasicStructureConfiguration) configuration;
    BaseOption chosenOption = config.chosenOption;
    return chosenOption.getHasGlassColor();
}
Also used : BasicStructureConfiguration(com.wuest.prefab.structures.config.BasicStructureConfiguration) BaseOption(com.wuest.prefab.structures.config.enums.BaseOption)

Example 2 with BasicStructureConfiguration

use of com.wuest.prefab.structures.config.BasicStructureConfiguration in project MC-Prefab by Brian-Wuest.

the class ClientEventHandler method checkIfStackIsCorrectGui.

public static boolean checkIfStackIsCorrectGui(StructureTagMessage.EnumStructureConfiguration currentConfiguration, ItemStack stack) {
    GuiStructure mainHandGui = ClientProxy.ModGuis.get(stack.getItem());
    mainHandGui.init();
    if (currentConfiguration == mainHandGui.configurationEnum) {
        if (currentConfiguration == StructureTagMessage.EnumStructureConfiguration.Basic) {
            ItemBasicStructure item = (ItemBasicStructure) stack.getItem();
            BasicStructureConfiguration.EnumBasicStructureName basicStructureName = ((BasicStructureConfiguration) StructureRenderHandler.currentConfiguration).basicStructureName;
            return item.structureType == basicStructureName;
        } else {
            return true;
        }
    }
    return false;
}
Also used : GuiStructure(com.wuest.prefab.structures.gui.GuiStructure) BasicStructureConfiguration(com.wuest.prefab.structures.config.BasicStructureConfiguration) ItemBasicStructure(com.wuest.prefab.structures.items.ItemBasicStructure)

Example 3 with BasicStructureConfiguration

use of com.wuest.prefab.structures.config.BasicStructureConfiguration 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);
    }
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) SpawnerBlockEntity(net.minecraft.world.level.block.entity.SpawnerBlockEntity) SignBlockEntity(net.minecraft.world.level.block.entity.SignBlockEntity) BasicStructureConfiguration(com.wuest.prefab.structures.config.BasicStructureConfiguration) Chicken(net.minecraft.world.entity.animal.Chicken) BlockPos(net.minecraft.core.BlockPos) BaseOption(com.wuest.prefab.structures.config.enums.BaseOption) SignBlockEntity(net.minecraft.world.level.block.entity.SignBlockEntity) SpawnerBlockEntity(net.minecraft.world.level.block.entity.SpawnerBlockEntity) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 4 with BasicStructureConfiguration

use of com.wuest.prefab.structures.config.BasicStructureConfiguration in project MC-Prefab by Brian-Wuest.

the class StructureBasic method CustomBlockProcessingHandled.

@Override
protected Boolean CustomBlockProcessingHandled(StructureConfiguration configuration, BuildBlock block, Level world, BlockPos originalPos, Block foundBlock, BlockState blockState, Player player) {
    BasicStructureConfiguration config = (BasicStructureConfiguration) configuration;
    String structureName = config.basicStructureName.getName();
    BaseOption chosenOption = config.chosenOption;
    if (foundBlock instanceof HopperBlock && structureName.equals(EnumBasicStructureName.ModerateFarm.getName()) && chosenOption == ModerateFarmOptions.AutomatedChickenCoop) {
        this.customBlockPos = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    } else if (foundBlock instanceof TrapDoorBlock && structureName.equals(EnumBasicStructureName.MineshaftEntrance.getName())) {
        this.customBlockPos = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    } else if (foundBlock == Blocks.SPONGE && structureName.equals(BasicStructureConfiguration.EnumBasicStructureName.WorkShop.getName())) {
        // Sponges are sometimes used in-place of trapdoors when trapdoors are used for decoration.
        this.customBlockPos = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing).above();
    } else if (foundBlock instanceof BedBlock && chosenOption.getHasBedColor()) {
        // Even if a structure has a bed; we may want to keep a specific color to match what the design of the structure is.
        BlockPos bedHeadPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
        BlockPos bedFootPosition = block.getSubBlock().getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
        Tuple<BlockState, BlockState> blockStateTuple = BuildingMethods.getBedState(bedHeadPosition, bedFootPosition, config.bedColor);
        block.setBlockState(blockStateTuple.getFirst());
        block.getSubBlock().setBlockState(blockStateTuple.getSecond());
        this.priorityOneBlocks.add(block);
        return true;
    } else if (foundBlock instanceof SpawnerBlock && structureName.equals(EnumBasicStructureName.AdvancedFarm.getName()) && chosenOption == AdvancedFarmOptions.MonsterMasher && CommonProxy.proxyConfiguration.serverConfiguration.includeSpawnersInMasher) {
        this.mobSpawnerPos.add(block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing));
    } else if (foundBlock instanceof SignBlock && structureName.equals(EnumBasicStructureName.AdvancedFarm.getName()) && chosenOption == AdvancedFarmOptions.MonsterMasher) {
        this.signPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    }
    return false;
}
Also used : BasicStructureConfiguration(com.wuest.prefab.structures.config.BasicStructureConfiguration) BlockPos(net.minecraft.core.BlockPos) Tuple(com.wuest.prefab.Tuple) BaseOption(com.wuest.prefab.structures.config.enums.BaseOption)

Aggregations

BasicStructureConfiguration (com.wuest.prefab.structures.config.BasicStructureConfiguration)4 BaseOption (com.wuest.prefab.structures.config.enums.BaseOption)3 BlockPos (net.minecraft.core.BlockPos)2 Tuple (com.wuest.prefab.Tuple)1 GuiStructure (com.wuest.prefab.structures.gui.GuiStructure)1 ItemBasicStructure (com.wuest.prefab.structures.items.ItemBasicStructure)1 TextComponent (net.minecraft.network.chat.TextComponent)1 Chicken (net.minecraft.world.entity.animal.Chicken)1 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)1 SignBlockEntity (net.minecraft.world.level.block.entity.SignBlockEntity)1 SpawnerBlockEntity (net.minecraft.world.level.block.entity.SpawnerBlockEntity)1