From 824b444b5194c5554c517e638cd5268ceda769b3 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 20 Nov 2016 23:52:40 +0100 Subject: [PATCH] Added engineer's house. Still needs items and stuff like that. --- .../mod/config/values/ConfigBoolValues.java | 1 + .../mod/gen/InitVillager.java | 8 ++ .../gen/VillageComponentEngineerHouse.java | 125 ++++++++++++++++++ .../mod/gen/VillageEngineerHouseHandler.java | 37 ++++++ .../mod/gen/VillageJamHouseHandler.java | 2 +- .../structures/andrew_house.nbt | Bin 0 -> 5530 bytes 6 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageComponentEngineerHouse.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageEngineerHouseHandler.java create mode 100644 src/main/resources/assets/actuallyadditions/structures/andrew_house.nbt diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigBoolValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigBoolValues.java index b4c8243d6..11b936599 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigBoolValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigBoolValues.java @@ -16,6 +16,7 @@ public enum ConfigBoolValues{ JAM_VILLAGER_EXISTS("Jam Villager: Existence", ConfigCategories.WORLD_GEN, true, "Should the Jam Villager and his House generate in the world?"), CROP_FIELD_EXISTS("Crop Field: Existence", ConfigCategories.WORLD_GEN, true, "Should Custom Crop Fields exist?"), + ENGINEER_VILLAGER_EXISTS("Engineer Villager: Existence", ConfigCategories.WORLD_GEN, true, "Should the Engineer Villager and his House generate in the worl?"), GENERATE_QUARTZ("Black Quartz", ConfigCategories.WORLD_GEN, true, "Shold Black Quartz generate in the world?"), diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/InitVillager.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/InitVillager.java index 49587d04c..853c7a1f1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/InitVillager.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/InitVillager.java @@ -30,6 +30,14 @@ public final class InitVillager{ if(ConfigBoolValues.CROP_FIELD_EXISTS.isEnabled()){ initCustomCropFieldPart(); } + if(ConfigBoolValues.ENGINEER_VILLAGER_EXISTS.isEnabled()){ + initEngineerVillagePart(); + } + } + + private static void initEngineerVillagePart(){ + VillagerRegistry.instance().registerVillageCreationHandler(new VillageEngineerHouseHandler()); + MapGenStructureIO.registerStructureComponent(VillageComponentEngineerHouse.class, ModUtil.MOD_ID+":engineerHouseStructure"); } private static void initJamVillagePart(){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageComponentEngineerHouse.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageComponentEngineerHouse.java new file mode 100644 index 000000000..545b43b5f --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageComponentEngineerHouse.java @@ -0,0 +1,125 @@ +/* + * This file ("VillageComponentEngineerHouse.java") is part of the Actually Additions mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://ellpeck.de/actaddlicense + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015-2016 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.gen; + +import de.ellpeck.actuallyadditions.mod.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Rotation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.gen.structure.StructureBoundingBox; +import net.minecraft.world.gen.structure.StructureComponent; +import net.minecraft.world.gen.structure.StructureVillagePieces; +import net.minecraft.world.gen.structure.template.PlacementSettings; +import net.minecraft.world.gen.structure.template.Template; +import net.minecraft.world.gen.structure.template.TemplateManager; + +import java.util.List; +import java.util.Random; + +public class VillageComponentEngineerHouse extends StructureVillagePieces.House1{ + + private static final ResourceLocation STRUCTURE_RES_LOC = new ResourceLocation(ModUtil.MOD_ID, "andrew_house"); + + private static final int X_SIZE = 13; + private static final int Y_SIZE = 11; + private static final int Z_SIZE = 10; + + private int averageGroundLevel = -1; + + public VillageComponentEngineerHouse(){ + + } + + public VillageComponentEngineerHouse(StructureBoundingBox boundingBox, EnumFacing par5){ + this.setCoordBaseMode(par5); + this.boundingBox = boundingBox; + } + + public static VillageComponentEngineerHouse buildComponent(List pieces, int p1, int p2, int p3, EnumFacing p4){ + StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4); + return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null ? new VillageComponentEngineerHouse(boundingBox, p4) : null; + } + + @Override + public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb){ + if(this.averageGroundLevel < 0){ + this.averageGroundLevel = this.getAverageGroundLevel(world, sbb); + if(this.averageGroundLevel < 0){ + return true; + } + this.boundingBox.offset(0, this.averageGroundLevel-this.boundingBox.maxY+Y_SIZE-2, 0); + } + + this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE-1, Y_SIZE-1, Z_SIZE-1, Blocks.AIR); + this.spawnActualHouse(world, rand, sbb); + + for(int i = 0; i < X_SIZE; i++){ + for(int j = 0; j < Z_SIZE; j++){ + this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb); + this.replaceAirAndLiquidDownwards(world, Blocks.DIRT.getDefaultState(), i, -1, j, sbb); + } + } + + this.spawnVillagers(world, sbb, 3, 1, 3, 1); + + return true; + } + + public void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block){ + this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false); + } + + public void spawnActualHouse(World world, Random rand, StructureBoundingBox sbb){ + TemplateManager manager = world.getSaveHandler().getStructureTemplateManager(); + MinecraftServer server = world.getMinecraftServer(); + + if(manager != null && server != null){ + EnumFacing facing = this.getCoordBaseMode(); + + Mirror mirror; + Rotation rotation; + if(facing == EnumFacing.SOUTH){ + mirror = Mirror.NONE; + rotation = Rotation.NONE; + } + else if(facing == EnumFacing.WEST){ + mirror = Mirror.NONE; + rotation = Rotation.CLOCKWISE_90; + } + else if(facing == EnumFacing.EAST){ + mirror = Mirror.LEFT_RIGHT; + rotation = Rotation.CLOCKWISE_90; + } + else{ + mirror = Mirror.LEFT_RIGHT; + rotation = Rotation.NONE; + } + + PlacementSettings placement = new PlacementSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(sbb); + Template template = manager.getTemplate(server, STRUCTURE_RES_LOC); + + if(template != null){ + template.addBlocksToWorld(world, new BlockPos(this.getXWithOffset(0, 0), this.getYWithOffset(0), this.getZWithOffset(0, 0)), placement); + } + } + } + + /*@Override + protected VillagerProfession chooseForgeProfession(int count, VillagerProfession prof){ + return InitVillager.jamProfession; + }*/ +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageEngineerHouseHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageEngineerHouseHandler.java new file mode 100644 index 000000000..da9f20d28 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageEngineerHouseHandler.java @@ -0,0 +1,37 @@ +/* + * This file ("VillageEngineerHouseHandler.java") is part of the Actually Additions mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://ellpeck.de/actaddlicense + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015-2016 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.gen; + +import net.minecraft.util.EnumFacing; +import net.minecraft.world.gen.structure.StructureComponent; +import net.minecraft.world.gen.structure.StructureVillagePieces; +import net.minecraftforge.fml.common.registry.VillagerRegistry; + +import java.util.List; +import java.util.Random; + +public class VillageEngineerHouseHandler implements VillagerRegistry.IVillageCreationHandler{ + + @Override + public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i){ + return new StructureVillagePieces.PieceWeight(VillageComponentEngineerHouse.class, 5, 1); + } + + @Override + public Class getComponentClass(){ + return VillageComponentEngineerHouse.class; + } + + @Override + public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5){ + return VillageComponentEngineerHouse.buildComponent(pieces, p1, p2, p3, facing); + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageJamHouseHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageJamHouseHandler.java index ac2809b31..8a03dedfe 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageJamHouseHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageJamHouseHandler.java @@ -22,7 +22,7 @@ public class VillageJamHouseHandler implements VillagerRegistry.IVillageCreation @Override public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i){ - return new StructureVillagePieces.PieceWeight(VillageComponentJamHouse.class, 5, 1); + return new StructureVillagePieces.PieceWeight(VillageComponentJamHouse.class, 3, 1); } @Override diff --git a/src/main/resources/assets/actuallyadditions/structures/andrew_house.nbt b/src/main/resources/assets/actuallyadditions/structures/andrew_house.nbt new file mode 100644 index 0000000000000000000000000000000000000000..ef04208266e9a6b9d0aa3e0a502f94cbaa4200da GIT binary patch literal 5530 zcmbtYdpy(o|Ch^2`bLfpayn6+ToR@kDbeL5G=x(Q!ccQIB3npoL#HIVI7{Z1bcWn> zOw3)PFiqPKHY=A&nD$#NX7l~brBj_>zkh!I*u!H!@Av2Re!ZTzH_ZfjspX#*mIwOh zwv&y#Uq_3BX6GN9ng$rv!va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