From d7382976e547dfbe071b9360113f0d8250af9677 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 29 Jun 2015 20:55:56 +0200 Subject: [PATCH] -Added new Villager Field -Fixed Jam House -Added Dispenser Handlers for Buckets and Fertilizer --- .../actuallyadditions/ActuallyAdditions.java | 15 ++- .../config/values/ConfigBoolValues.java | 1 + .../crafting/GrinderCrafting.java | 2 +- .../event/BucketFillEvent.java | 16 ++-- .../actuallyadditions/gen/InitVillager.java | 10 +- .../gen/JamVillagerTradeHandler.java | 33 +++---- .../ellpeck/actuallyadditions/gen/OreGen.java | 10 +- .../gen/VillageComponentCustomCropField.java | 96 +++++++++++++++++++ .../gen/VillageComponentJamHouse.java | 9 +- .../gen/VillageCustomCropFieldHandler.java | 25 +++++ .../actuallyadditions/items/InitItems.java | 8 +- .../items/ItemCoffeeBean.java | 2 +- .../actuallyadditions/items/ItemSeed.java | 6 +- .../items/metalists/TheFoods.java | 2 +- .../items/metalists/TheMiscItems.java | 2 +- .../misc/DispenserHandlerEmptyBucket.java | 27 ++++++ .../misc/DispenserHandlerFertilize.java | 25 +++++ 17 files changed, 238 insertions(+), 51 deletions(-) create mode 100644 src/main/java/ellpeck/actuallyadditions/gen/VillageComponentCustomCropField.java create mode 100644 src/main/java/ellpeck/actuallyadditions/gen/VillageCustomCropFieldHandler.java create mode 100644 src/main/java/ellpeck/actuallyadditions/misc/DispenserHandlerEmptyBucket.java create mode 100644 src/main/java/ellpeck/actuallyadditions/misc/DispenserHandlerFertilize.java diff --git a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java index 5e5da37a6..7f2e1e7c5 100644 --- a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java +++ b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java @@ -4,10 +4,7 @@ import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.*; import ellpeck.actuallyadditions.achievement.InitAchievements; import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.communication.InterModCommunications; @@ -22,6 +19,8 @@ import ellpeck.actuallyadditions.inventory.GuiHandler; import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.ItemCoffee; import ellpeck.actuallyadditions.material.InitItemMaterials; +import ellpeck.actuallyadditions.misc.DispenserHandlerEmptyBucket; +import ellpeck.actuallyadditions.misc.DispenserHandlerFertilize; import ellpeck.actuallyadditions.network.PacketHandler; import ellpeck.actuallyadditions.proxy.IProxy; import ellpeck.actuallyadditions.recipe.FuelHandler; @@ -29,6 +28,7 @@ import ellpeck.actuallyadditions.recipe.HairyBallHandler; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.Util; +import net.minecraft.block.BlockDispenser; @Mod(modid = ModUtil.MOD_ID, name = ModUtil.NAME, version = ModUtil.VERSION) public class ActuallyAdditions{ @@ -88,4 +88,11 @@ public class ActuallyAdditions{ public void onIMCReceived(FMLInterModComms.IMCEvent event){ InterModCommunications.processIMC(event.getMessages()); } + + @EventHandler + public void serverStarting(FMLServerStartingEvent event){ + BlockDispenser.dispenseBehaviorRegistry.putObject(InitItems.itemBucketCanolaOil, new DispenserHandlerEmptyBucket()); + BlockDispenser.dispenseBehaviorRegistry.putObject(InitItems.itemBucketOil, new DispenserHandlerEmptyBucket()); + BlockDispenser.dispenseBehaviorRegistry.putObject(InitItems.itemFertilizer, new DispenserHandlerFertilize()); + } } diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java index b33a7f454..719b30b5f 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java @@ -11,6 +11,7 @@ public enum ConfigBoolValues{ LEAF_BLOWER_SOUND("Leaf Blower: Sound", ConfigCategories.TOOL_VALUES, true, "If the Leaf Blower makes Sounds"), JAM_VILLAGER_EXISTS("Jam Villager: Existence", ConfigCategories.WORLD_GEN, true, "If the Jam Villager and his House exist"), + CROP_FIELD_EXISTS("Crop Field: Existence", ConfigCategories.WORLD_GEN, true, "If the Custom Crop Fields exist"), GENERATE_QUARTZ("Black Quartz", ConfigCategories.WORLD_GEN, true, "If the Black Quartz generates in the world"), diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/GrinderCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/GrinderCrafting.java index 092df6a4f..938af8d54 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/GrinderCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/GrinderCrafting.java @@ -26,7 +26,7 @@ public class GrinderCrafting{ GrinderRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.stone), new ItemStack(Blocks.cobblestone)); GrinderRecipeManualRegistry.registerRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(Items.sugar, 2)); - GrinderRecipeManualRegistry.registerRecipe("oreNickel", "dustNickel", "dustPlatinum", 30, 2); + GrinderRecipeManualRegistry.registerRecipe("oreNickel", "dustNickel", "dustPlatinum", 15, 2); GrinderRecipeManualRegistry.registerRecipe("oreIron", "dustIron", "dustGold", 20, 2); GrinderRecipeAutoRegistry.searchCases.add(new SearchCase("oreNether", 6)); diff --git a/src/main/java/ellpeck/actuallyadditions/event/BucketFillEvent.java b/src/main/java/ellpeck/actuallyadditions/event/BucketFillEvent.java index 791ff6795..eb94ffc57 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/BucketFillEvent.java +++ b/src/main/java/ellpeck/actuallyadditions/event/BucketFillEvent.java @@ -5,6 +5,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.items.InitItems; import net.minecraft.block.Block; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.player.FillBucketEvent; @@ -12,17 +13,16 @@ public class BucketFillEvent{ @SubscribeEvent public void onBucketFilled(FillBucketEvent event){ + this.fillBucket(event, InitItems.itemBucketOil, InitBlocks.blockOil); + this.fillBucket(event, InitItems.itemBucketCanolaOil, InitBlocks.blockCanolaOil); + } + + private void fillBucket(FillBucketEvent event, Item item, Block fluid){ Block block = event.world.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ); - if(block == InitBlocks.blockCanolaOil){ + if(block == fluid){ event.world.setBlockToAir(event.target.blockX, event.target.blockY, event.target.blockZ); - event.result = new ItemStack(InitItems.itemBucketCanolaOil); - event.setResult(Event.Result.ALLOW); - } - if(block == InitBlocks.blockOil){ - event.world.setBlockToAir(event.target.blockX, event.target.blockY, event.target.blockZ); - event.result = new ItemStack(InitItems.itemBucketOil); + event.result = new ItemStack(item); event.setResult(Event.Result.ALLOW); } } - } diff --git a/src/main/java/ellpeck/actuallyadditions/gen/InitVillager.java b/src/main/java/ellpeck/actuallyadditions/gen/InitVillager.java index a35437f9e..47b5351ff 100644 --- a/src/main/java/ellpeck/actuallyadditions/gen/InitVillager.java +++ b/src/main/java/ellpeck/actuallyadditions/gen/InitVillager.java @@ -23,6 +23,9 @@ public class InitVillager{ if(ConfigBoolValues.JAM_VILLAGER_EXISTS.isEnabled()){ initJamVillagePart(); } + if(ConfigBoolValues.CROP_FIELD_EXISTS.isEnabled()){ + initCustomCropFieldPart(); + } } private static void initJamVillagePart(){ @@ -32,7 +35,7 @@ public class InitVillager{ ChestGenHooks jamHouseChest = ChestGenHooks.getInfo(JAM_HOUSE_CHEST_NAME); jamHouseChest.setMin(5); - jamHouseChest.setMax(20); + jamHouseChest.setMax(10); for(int i = 0; i < TheJams.values().length; i++){ ChestGenHooks.addItem(JAM_HOUSE_CHEST_NAME, new WeightedRandomChestContent(new ItemStack(InitItems.itemJams, 1, i), 1, 1, 10)); } @@ -43,4 +46,9 @@ public class InitVillager{ MapGenStructureIO.func_143031_a(VillageComponentJamHouse.class, ModUtil.MOD_ID_LOWER+":jamHouseStructure"); } + private static void initCustomCropFieldPart(){ + VillagerRegistry.instance().registerVillageCreationHandler(new VillageCustomCropFieldHandler()); + MapGenStructureIO.func_143031_a(VillageComponentCustomCropField.class, ModUtil.MOD_ID_LOWER+":customCropFieldStructure"); + } + } diff --git a/src/main/java/ellpeck/actuallyadditions/gen/JamVillagerTradeHandler.java b/src/main/java/ellpeck/actuallyadditions/gen/JamVillagerTradeHandler.java index e3b287914..00c100363 100644 --- a/src/main/java/ellpeck/actuallyadditions/gen/JamVillagerTradeHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/gen/JamVillagerTradeHandler.java @@ -6,6 +6,7 @@ import ellpeck.actuallyadditions.items.metalists.TheJams; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; import net.minecraftforge.oredict.OreDictionary; @@ -18,15 +19,15 @@ public class JamVillagerTradeHandler implements VillagerRegistry.IVillageTradeHa private ArrayList trades = new ArrayList(); public JamVillagerTradeHandler(){ - this.addWants("ingotGold", 5, 2); - this.addWants("cropWheat", 15, 10); - this.addWants("dustRedstone", 25, 15); - this.addWants(new ItemStack(Items.bucket), 5, 4); - this.addWants(new ItemStack(Items.glass_bottle), 12, 5); - this.addWants(new ItemStack(Items.potionitem), 1, 0); - this.addWants("ingotIron", 10, 5); + this.addWants("ingotGold", 5, 7); + this.addWants("cropWheat", 15, 25); + this.addWants("dustRedstone", 25, 40); + this.addWants(new ItemStack(Items.bucket), 5, 9); + this.addWants(new ItemStack(Items.glass_bottle), 12, 17); + this.addWants(new ItemStack(Items.potionitem), 1, 1); + this.addWants("ingotIron", 10, 15); this.addWants("gemDiamond", 1, 2); - this.addWants("dustGlowstone", 12, 10); + this.addWants("dustGlowstone", 12, 22); } @Override @@ -37,12 +38,12 @@ public class JamVillagerTradeHandler implements VillagerRegistry.IVillageTradeHa ItemStack wantsTwo = null; ItemStack wantsOne = trades.get(i).wants.get(j); - wantsOne.stackSize = rand.nextInt(trades.get(i).extraStackSize) + trades.get(i).baseStackSize; + wantsOne.stackSize = MathHelper.getRandomIntegerInRange(rand, trades.get(i).minStackSize, trades.get(i).maxStackSize); if(rand.nextInt(3) == 0){ int toGet = rand.nextInt(trades.size()); for(int k = 0; k < trades.get(toGet).wants.size(); k++){ wantsTwo = trades.get(toGet).wants.get(k); - wantsTwo.stackSize = rand.nextInt(trades.get(k).extraStackSize) + trades.get(k).baseStackSize; + wantsTwo.stackSize = MathHelper.getRandomIntegerInRange(rand, trades.get(k).minStackSize, trades.get(k).maxStackSize); } } if(wantsOne == wantsTwo) wantsTwo = null; @@ -66,19 +67,19 @@ public class JamVillagerTradeHandler implements VillagerRegistry.IVillageTradeHa public static class Trade{ public final ArrayList wants = new ArrayList(); - public final int baseStackSize; - public final int extraStackSize; + public final int minStackSize; + public final int maxStackSize; public Trade(ArrayList wants, int minStackSize, int maxStackSize){ this.wants.addAll(wants); - this.baseStackSize = minStackSize <= 0 ? 1 : minStackSize; - this.extraStackSize = maxStackSize <= 0 ? 1 : maxStackSize; + this.minStackSize = minStackSize <= 0 ? 1 : minStackSize; + this.maxStackSize = maxStackSize <= 0 ? 1 : maxStackSize; } public Trade(ItemStack want, int minStackSize, int maxStackSize){ this.wants.add(want); - this.baseStackSize = minStackSize <= 0 ? 1 : minStackSize; - this.extraStackSize = maxStackSize <= 0 ? 1 : maxStackSize; + this.minStackSize = minStackSize <= 0 ? 1 : minStackSize; + this.maxStackSize = maxStackSize <= 0 ? 1 : maxStackSize; } } diff --git a/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java b/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java index 513548c1c..0040e9275 100644 --- a/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java +++ b/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java @@ -10,8 +10,8 @@ import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.Util; import net.minecraft.block.Block; import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import net.minecraft.world.WorldType; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import org.apache.logging.log4j.Level; @@ -22,8 +22,6 @@ public class OreGen implements IWorldGenerator{ @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){ - if(world.provider.terrainType == WorldType.FLAT) return; - switch(world.provider.dimensionId){ case -1: generateNether(world, random, chunkX*16, chunkZ*16); @@ -43,7 +41,7 @@ public class OreGen implements IWorldGenerator{ private void generateSurface(World world, Random random, int x, int z){ if(ConfigBoolValues.GENERATE_QUARTZ.isEnabled()){ - this.addOreSpawn(InitBlocks.blockMisc, TheMiscBlocks.ORE_QUARTZ.ordinal(), Blocks.stone, world, random, x, z, this.getRandom(ConfigIntValues.BLACK_QUARTZ_BASE_AMOUNT.getValue(), ConfigIntValues.BLACK_QUARTZ_ADD_CHANCE.getValue(), random), ConfigIntValues.BLACK_QUARTZ_CHANCE.getValue(), ConfigIntValues.BLACK_QUARTZ_MIN_HEIGHT.getValue(), ConfigIntValues.BLACK_QUARTZ_MAX_HEIGHT.getValue()); + this.addOreSpawn(InitBlocks.blockMisc, TheMiscBlocks.ORE_QUARTZ.ordinal(), Blocks.stone, world, random, x, z, MathHelper.getRandomIntegerInRange(random, ConfigIntValues.BLACK_QUARTZ_BASE_AMOUNT.getValue(), ConfigIntValues.BLACK_QUARTZ_ADD_CHANCE.getValue()), ConfigIntValues.BLACK_QUARTZ_CHANCE.getValue(), ConfigIntValues.BLACK_QUARTZ_MIN_HEIGHT.getValue(), ConfigIntValues.BLACK_QUARTZ_MAX_HEIGHT.getValue()); } } @@ -65,10 +63,6 @@ public class OreGen implements IWorldGenerator{ else ModUtil.LOGGER.log(Level.FATAL, "Couldn't generate '" + block.getUnlocalizedName() + "' into the world because the Min Y coordinate is bigger than the Max! This is definitely a Config Error! Check the Files!"); } - public int getRandom(int base, int extra, Random rand){ - return extra > 0 ? base+rand.nextInt(extra+1) : base; - } - public static void init(){ Util.logInfo("Registering World Generator..."); GameRegistry.registerWorldGenerator(new OreGen(), 10); diff --git a/src/main/java/ellpeck/actuallyadditions/gen/VillageComponentCustomCropField.java b/src/main/java/ellpeck/actuallyadditions/gen/VillageComponentCustomCropField.java new file mode 100644 index 000000000..c3a957ff9 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/gen/VillageComponentCustomCropField.java @@ -0,0 +1,96 @@ +package ellpeck.actuallyadditions.gen; + +import ellpeck.actuallyadditions.blocks.InitBlocks; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +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 java.util.List; +import java.util.Random; + +public class VillageComponentCustomCropField extends StructureVillagePieces.House1{ + + private static final int xSize = 13; + private static final int ySize = 4; + private static final int zSize = 9; + + private int averageGroundLevel = -1; + + @SuppressWarnings("unused") + public VillageComponentCustomCropField(){ + + } + + public VillageComponentCustomCropField(StructureBoundingBox boundingBox, int par5){ + this.coordBaseMode = par5; + this.boundingBox = boundingBox; + } + + public static VillageComponentCustomCropField buildComponent(List pieces, int p1, int p2, int p3, int p4){ + StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, xSize, ySize, zSize, p4); + return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null ? new VillageComponentCustomCropField(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+ySize-1, 0); + } + + this.fillWithBlocks(world, sbb, 0, 0, 0, xSize-1, ySize-1, zSize-1, Blocks.air); + this.spawnActualHouse(world, rand, sbb); + + for (int i = 0; i < xSize; i++){ + for(int j = 0; j < zSize; j++){ + this.clearCurrentPositionBlocksUpwards(world, i, ySize, j, sbb); + this.func_151554_b(world, Blocks.dirt, 0, i, -1, j, sbb); + } + } + + return true; + } + + private Block getRandomCropType(Random rand){ + switch(rand.nextInt(4)){ + case 0: return InitBlocks.blockFlax; + case 1: return InitBlocks.blockCoffee; + case 2: return InitBlocks.blockRice; + default: return InitBlocks.blockCanola; + } + } + + public void spawnActualHouse(World world, Random rand, StructureBoundingBox sbb){ + this.fillWithBlocks(world, sbb, 1, 0, 1, 2, 0, 7, Blocks.farmland); + this.fillWithBlocks(world, sbb, 4, 0, 1, 5, 0, 7, Blocks.farmland); + this.fillWithBlocks(world, sbb, 7, 0, 1, 8, 0, 7, Blocks.farmland); + this.fillWithBlocks(world, sbb, 10, 0, 1, 11, 0, 7, Blocks.farmland); + this.fillWithBlocks(world, sbb, 0, 0, 0, 0, 0, 8, Blocks.log); + this.fillWithBlocks(world, sbb, 6, 0, 0, 6, 0, 8, Blocks.log); + this.fillWithBlocks(world, sbb, 12, 0, 0, 12, 0, 8, Blocks.log); + this.fillWithBlocks(world, sbb, 1, 0, 0, 11, 0, 0, Blocks.log); + this.fillWithBlocks(world, sbb, 1, 0, 8, 11, 0, 8, Blocks.log); + this.fillWithBlocks(world, sbb, 3, 0, 1, 3, 0, 7, Blocks.water); + this.fillWithBlocks(world, sbb, 9, 0, 1, 9, 0, 7, Blocks.water); + + for(int i = 1; i <= 7; ++i){ + this.placeBlockAtCurrentPosition(world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 1, 1, i, sbb); + this.placeBlockAtCurrentPosition(world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 2, 1, i, sbb); + this.placeBlockAtCurrentPosition(world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 4, 1, i, sbb); + this.placeBlockAtCurrentPosition(world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 5, 1, i, sbb); + this.placeBlockAtCurrentPosition(world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 7, 1, i, sbb); + this.placeBlockAtCurrentPosition(world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 8, 1, i, sbb); + this.placeBlockAtCurrentPosition(world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 10, 1, i, sbb); + this.placeBlockAtCurrentPosition(world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 11, 1, i, sbb); + } + } + + 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, block, false); + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/gen/VillageComponentJamHouse.java b/src/main/java/ellpeck/actuallyadditions/gen/VillageComponentJamHouse.java index dfc349da1..16a4b36f5 100644 --- a/src/main/java/ellpeck/actuallyadditions/gen/VillageComponentJamHouse.java +++ b/src/main/java/ellpeck/actuallyadditions/gen/VillageComponentJamHouse.java @@ -17,9 +17,9 @@ import java.util.Random; public class VillageComponentJamHouse extends StructureVillagePieces.House1{ - private static final int xSize = 10; + private static final int xSize = 11; private static final int ySize = 8; - private static final int zSize = 11; + private static final int zSize = 12; private int averageGroundLevel = -1; @@ -34,7 +34,7 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{ } public static VillageComponentJamHouse buildComponent(List pieces, int p1, int p2, int p3, int p4){ - StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, xSize+1, ySize+1, zSize+1, p4); + StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, xSize, ySize, zSize, p4); return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null ? new VillageComponentJamHouse(boundingBox, p4) : null; } @@ -43,9 +43,10 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{ 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+ySize, 0); + this.boundingBox.offset(0, this.averageGroundLevel-this.boundingBox.maxY+ySize-1, 0); } + this.fillWithBlocks(world, sbb, 0, 0, 0, xSize-1, ySize-1, zSize-1, Blocks.air); this.spawnActualHouse(world, rand, sbb); for (int i = 0; i < xSize; i++){ diff --git a/src/main/java/ellpeck/actuallyadditions/gen/VillageCustomCropFieldHandler.java b/src/main/java/ellpeck/actuallyadditions/gen/VillageCustomCropFieldHandler.java new file mode 100644 index 000000000..7b319a2d3 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/gen/VillageCustomCropFieldHandler.java @@ -0,0 +1,25 @@ +package ellpeck.actuallyadditions.gen; + +import cpw.mods.fml.common.registry.VillagerRegistry; +import net.minecraft.world.gen.structure.StructureVillagePieces; + +import java.util.List; +import java.util.Random; + +public class VillageCustomCropFieldHandler implements VillagerRegistry.IVillageCreationHandler{ + + @Override + public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i){ + return new StructureVillagePieces.PieceWeight(VillageComponentCustomCropField.class, 5, 2); + } + + @Override + public Class getComponentClass(){ + return VillageComponentCustomCropField.class; + } + + @Override + public Object buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, int p4, int p5){ + return VillageComponentCustomCropField.buildComponent(pieces, p1, p2, p3, p4); + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/InitItems.java b/src/main/java/ellpeck/actuallyadditions/items/InitItems.java index 388eca358..4c9f80fe1 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/InitItems.java +++ b/src/main/java/ellpeck/actuallyadditions/items/InitItems.java @@ -159,19 +159,19 @@ public class InitItems{ itemCoffeeBean = new ItemCoffeeBean(); ItemUtil.register(itemCoffeeBean); - itemRiceSeed = new ItemSeed("itemRiceSeed", InitBlocks.blockRice, itemFoods, TheFoods.RICE.ordinal()); + itemRiceSeed = new ItemSeed("itemRiceSeed", "seedRice", InitBlocks.blockRice, itemFoods, TheFoods.RICE.ordinal()); ItemUtil.register(itemRiceSeed); CompatUtil.registerMFRSeed(itemRiceSeed); - itemCanolaSeed = new ItemSeed("itemCanolaSeed", InitBlocks.blockCanola, itemMisc, TheMiscItems.CANOLA.ordinal()); + itemCanolaSeed = new ItemSeed("itemCanolaSeed", "seedCanola", InitBlocks.blockCanola, itemMisc, TheMiscItems.CANOLA.ordinal()); ItemUtil.register(itemCanolaSeed); CompatUtil.registerMFRSeed(itemCanolaSeed); - itemFlaxSeed = new ItemSeed("itemFlaxSeed", InitBlocks.blockFlax, Items.string, 0); + itemFlaxSeed = new ItemSeed("itemFlaxSeed", "seedFlax", InitBlocks.blockFlax, Items.string, 0); ItemUtil.register(itemFlaxSeed); CompatUtil.registerMFRSeed(itemFlaxSeed); - itemCoffeeSeed = new ItemSeed("itemCoffeeSeed", InitBlocks.blockCoffee, itemCoffeeBean, 0); + itemCoffeeSeed = new ItemSeed("itemCoffeeSeed", "seedCoffeeBeans", InitBlocks.blockCoffee, itemCoffeeBean, 0); ItemUtil.register(itemCoffeeSeed); CompatUtil.registerMFRSeed(itemCoffeeSeed); diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemCoffeeBean.java b/src/main/java/ellpeck/actuallyadditions/items/ItemCoffeeBean.java index 08a55cd57..859989db3 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemCoffeeBean.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemCoffeeBean.java @@ -23,7 +23,7 @@ public class ItemCoffeeBean extends ItemFood implements INameableItem{ @Override public String getOredictName(){ - return this.getName(); + return "cropCoffeeBeans"; } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemSeed.java b/src/main/java/ellpeck/actuallyadditions/items/ItemSeed.java index d052b3690..26aa8751e 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemSeed.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemSeed.java @@ -23,10 +23,12 @@ public class ItemSeed extends ItemSeeds implements INameableItem{ public Block plant; public String name; + public String oredictName; - public ItemSeed(String name, Block plant, Item returnItem, int returnMeta){ + public ItemSeed(String name, String oredictName, Block plant, Item returnItem, int returnMeta){ super(plant, Blocks.farmland); this.name = name; + this.oredictName = oredictName; this.plant = plant; ((BlockPlant)this.plant).seedItem = this; ((BlockPlant)this.plant).returnItem = returnItem; @@ -72,6 +74,6 @@ public class ItemSeed extends ItemSeeds implements INameableItem{ @Override public String getOredictName(){ - return this.getName(); + return this.oredictName; } } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/items/metalists/TheFoods.java b/src/main/java/ellpeck/actuallyadditions/items/metalists/TheFoods.java index 4dc38122c..2bb0903e5 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/metalists/TheFoods.java +++ b/src/main/java/ellpeck/actuallyadditions/items/metalists/TheFoods.java @@ -24,7 +24,7 @@ public enum TheFoods implements INameableItem{ HAMBURGER("Hamburger", 14, 6F, false, 40, EnumRarity.common, "foodHamburger"), PIZZA("Pizza", 20, 10F, false, 45, EnumRarity.uncommon, "foodPizza"), BAGUETTE("Baguette", 7, 2F, false, 25, EnumRarity.common, "foodBaguette"), - RICE("Rice", 2, 1F, false, 10, EnumRarity.uncommon, "foodRice"), + RICE("Rice", 2, 1F, false, 10, EnumRarity.uncommon, "cropRice"), RICE_BREAD("RiceBread", 8, 3F, false, 25, EnumRarity.uncommon, "foodRiceBread"); public static void setReturnItems(){ diff --git a/src/main/java/ellpeck/actuallyadditions/items/metalists/TheMiscItems.java b/src/main/java/ellpeck/actuallyadditions/items/metalists/TheMiscItems.java index d1a819731..b45e746ff 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/metalists/TheMiscItems.java +++ b/src/main/java/ellpeck/actuallyadditions/items/metalists/TheMiscItems.java @@ -18,7 +18,7 @@ public enum TheMiscItems implements INameableItem{ TINY_COAL("TinyCoal", EnumRarity.common, "itemTinyCoal"), TINY_CHAR("TinyCharcoal", EnumRarity.common, "itemTinyChar"), RICE_SLIME("RiceSlime", EnumRarity.uncommon, "slimeball"), - CANOLA("Canola", EnumRarity.uncommon, "itemCanola"), + CANOLA("Canola", EnumRarity.uncommon, "cropCanola"), CUP("Cup", EnumRarity.uncommon, "itemCup"); public final String name; diff --git a/src/main/java/ellpeck/actuallyadditions/misc/DispenserHandlerEmptyBucket.java b/src/main/java/ellpeck/actuallyadditions/misc/DispenserHandlerEmptyBucket.java new file mode 100644 index 000000000..733437b42 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/misc/DispenserHandlerEmptyBucket.java @@ -0,0 +1,27 @@ +package ellpeck.actuallyadditions.misc; + +import net.minecraft.block.BlockDispenser; +import net.minecraft.dispenser.BehaviorDefaultDispenseItem; +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.init.Items; +import net.minecraft.item.ItemBucket; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; + +public class DispenserHandlerEmptyBucket extends BehaviorDefaultDispenseItem{ + + @Override + public ItemStack dispenseStack(IBlockSource source, ItemStack bucket){ + EnumFacing facing = BlockDispenser.func_149937_b(source.getBlockMetadata()); + int x = source.getXInt()+facing.getFrontOffsetX(); + int y = source.getYInt()+facing.getFrontOffsetY(); + int z = source.getZInt()+facing.getFrontOffsetZ(); + + if(source.getWorld().isAirBlock(x, y, z) && !source.getWorld().getBlock(x, y, z).getMaterial().isSolid() && ((ItemBucket)bucket.getItem()).tryPlaceContainedLiquid(source.getWorld(), x, y, z)){ + return new ItemStack(Items.bucket); + } + + return new BehaviorDefaultDispenseItem().dispense(source, bucket); + } + +} diff --git a/src/main/java/ellpeck/actuallyadditions/misc/DispenserHandlerFertilize.java b/src/main/java/ellpeck/actuallyadditions/misc/DispenserHandlerFertilize.java new file mode 100644 index 000000000..6ed128c38 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/misc/DispenserHandlerFertilize.java @@ -0,0 +1,25 @@ +package ellpeck.actuallyadditions.misc; + +import net.minecraft.block.BlockDispenser; +import net.minecraft.dispenser.BehaviorDefaultDispenseItem; +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.item.ItemDye; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; + +public class DispenserHandlerFertilize extends BehaviorDefaultDispenseItem{ + + @Override + public ItemStack dispenseStack(IBlockSource source, ItemStack stack){ + EnumFacing facing = BlockDispenser.func_149937_b(source.getBlockMetadata()); + int x = source.getXInt()+facing.getFrontOffsetX(); + int y = source.getYInt()+facing.getFrontOffsetY(); + int z = source.getZInt()+facing.getFrontOffsetZ(); + + if(ItemDye.applyBonemeal(stack, source.getWorld(), x, y, z, null)){ + source.getWorld().playAuxSFX(2005, x, y, z, 0); + } + return stack; + } + +}