mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-18 11:19:28 +00:00
1 parent
6b4d7ebcc4
commit
fb7cd3ee09
30 files changed
+820
-297
No files matched your search
@@ -81,7 +81,7 @@ public interface IBeeRoot extends ISpeciesRoot {
|
||||
* Valid {@link IBeeGenome}
|
||||
* @return {@link IBee} from the passed genome
|
||||
*/
|
||||
IBee getBee(World world, IBeeGenome genome);
|
||||
IBee getBee(IBeeGenome genome);
|
||||
|
||||
/**
|
||||
* Creates an IBee suitable for a queen containing the necessary second genome for the mate.
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IWoodAccess {
|
||||
// ITEMS
|
||||
|
||||
ItemStack getLog(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getPlanks(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getSlab(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getFence(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getFenceGate(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getStairs(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
/**
|
||||
* All doors in Minecraft are fireproof.
|
||||
*/
|
||||
ItemStack getDoor(EnumWoodType woodType);
|
||||
|
||||
// BLOCKS
|
||||
|
||||
/**
|
||||
* Forestry logs have their own properties for woodType and use {@link BlockLog.EnumAxis} for orientation.
|
||||
*/
|
||||
IBlockState getLogBlock(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
/**
|
||||
* Forestry slabs have no properties except their wood type.
|
||||
*/
|
||||
IBlockState getPlanksBlock(EnumWoodType woodType, boolean fireProof);
|
||||
|
||||
/**
|
||||
* Forestry slabs have the same properties as {@link BlockSlab}
|
||||
*/
|
||||
IBlockState getSlabBlock(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
/**
|
||||
* Forestry fences have the same properties as {@link BlockFence}
|
||||
*/
|
||||
IBlockState getFenceBlock(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
/**
|
||||
* Forestry fence gates have the same properties as {@link BlockFenceGate}
|
||||
*/
|
||||
IBlockState getFenceGateBlock(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
/**
|
||||
* Forestry stairs have the same properties as {@link BlockStairs}
|
||||
*/
|
||||
IBlockState getStairsBlock(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
/**
|
||||
* Forestry doors have the same properties as {@link BlockDoor}
|
||||
*/
|
||||
IBlockState getDoorBlock(EnumWoodType woodType);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IWoodItemAccess {
|
||||
ItemStack getLog(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getPlanks(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getSlab(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getFence(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getFenceGate(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getStairs(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getDoor(EnumWoodType woodType);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public class TreeManager {
|
||||
/**
|
||||
* Convenient access to wood items.
|
||||
*/
|
||||
public static IWoodItemAccess woodItemAccess;
|
||||
public static IWoodAccess woodAccess;
|
||||
|
||||
/**
|
||||
* Used to create new trees.
|
||||
|
||||
@@ -14,12 +14,12 @@ public interface IForestryConstants {
|
||||
/**
|
||||
* @return The villager ID for the Apiarist Villager.
|
||||
*/
|
||||
int getApicultureVillagerID();
|
||||
String getApicultureVillagerID();
|
||||
|
||||
/**
|
||||
* @return The villager ID for the Arborist Villager.
|
||||
*/
|
||||
int getArboricultureVillagerID();
|
||||
String getArboricultureVillagerID();
|
||||
|
||||
/**
|
||||
* @return The {@link LootTableLoadEvent} key for adding items to the Forestry Villager chest.
|
||||
|
||||
@@ -123,6 +123,12 @@ public interface IAlleleRegistry {
|
||||
*/
|
||||
Collection<IAllele> getRegisteredAlleles(IChromosomeType type);
|
||||
|
||||
/**
|
||||
* @return unmodifiable collection of all the known chromosome types.
|
||||
* @since Forestry 5.0
|
||||
*/
|
||||
Collection<IChromosomeType> getChromosomeTypes(IAllele allele);
|
||||
|
||||
/* CLASSIFICATIONS */
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,4 +23,12 @@ public interface IAlleleSpeciesBuilder {
|
||||
|
||||
/** Uncounted species do not count toward total species discovered. */
|
||||
IAlleleSpeciesBuilder setIsNotCounted();
|
||||
|
||||
/**
|
||||
* Manually the genetic complexity.
|
||||
* If this is not set, the complexity is based on the number of breeding steps to reach this species.
|
||||
*
|
||||
* @see forestry.api.genetics.IAlleleSpecies#getComplexity()
|
||||
*/
|
||||
void setComplexity(int complexity);
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -43,12 +44,14 @@ import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.Forestry;
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.apiculture.hives.HiveManager;
|
||||
@@ -117,6 +120,7 @@ import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.Stack;
|
||||
import forestry.core.utils.Translator;
|
||||
import forestry.core.utils.VillagerTradeLists;
|
||||
import forestry.food.PluginFood;
|
||||
import forestry.food.items.ItemRegistryFood;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
@@ -142,6 +146,8 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
private final Map<String, String[]> defaultAcceptedFlowers = new HashMap<>();
|
||||
private final Map<String, String[]> defaultPlantableFlowers = new HashMap<>();
|
||||
|
||||
public static VillagerRegistry.VillagerProfession villagerApiarist;
|
||||
|
||||
@Override
|
||||
public void setupAPI() {
|
||||
super.setupAPI();
|
||||
@@ -188,10 +194,10 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
blocks.apiculture.addDefinitions(BlockTypeApiculture.VALUES);
|
||||
blocks.apicultureChest.addDefinitions(BlockTypeApicultureTesr.APIARIST_CHEST);
|
||||
|
||||
/*if (Config.enableVillagers) {
|
||||
if (Config.enableVillagers) {
|
||||
// Register village components with the Structure registry.
|
||||
VillageHandlerApiculture.registerVillageComponents();
|
||||
}*/
|
||||
VillageCreationApiculture.registerVillageComponents();
|
||||
}
|
||||
|
||||
// Commands
|
||||
PluginCore.rootCommand.addChildCommand(new CommandBee());
|
||||
@@ -298,14 +304,38 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
BeeManager.uncommonVillageBees.add(BeeDefinition.COMMON.getGenome());
|
||||
BeeManager.uncommonVillageBees.add(BeeDefinition.VALIANT.getGenome());
|
||||
|
||||
/*if (Config.enableVillagers) {
|
||||
if (Config.enableVillagers) {
|
||||
// Register villager stuff
|
||||
VillageHandlerApiculture villageHandler = new VillageHandlerApiculture();
|
||||
VillagerRegistry.instance().registerVillageCreationHandler(villageHandler);
|
||||
VillagerRegistry.instance().registerVillagerId(Constants.ID_VILLAGER_BEEKEEPER);
|
||||
Proxies.render.registerVillagerSkin(Constants.ID_VILLAGER_BEEKEEPER, Constants.TEXTURE_SKIN_BEEKPEEPER);
|
||||
VillagerRegistry.instance().registerVillageTradeHandler(Constants.ID_VILLAGER_BEEKEEPER, villageHandler);
|
||||
}*/
|
||||
VillageCreationApiculture villageHandler = new VillageCreationApiculture();
|
||||
VillagerRegistry villagerRegistry = VillagerRegistry.instance();
|
||||
villagerRegistry.registerVillageCreationHandler(villageHandler);
|
||||
|
||||
villagerApiarist = new VillagerRegistry.VillagerProfession(Constants.ID_VILLAGER_APIARIST, Constants.TEXTURE_SKIN_BEEKPEEPER);
|
||||
villagerRegistry.register(villagerApiarist);
|
||||
|
||||
ItemStack wildcardPrincess = new ItemStack(PluginApiculture.items.beePrincessGE, 1);
|
||||
ItemStack apiary = PluginApiculture.blocks.apiculture.get(BlockTypeApiculture.APIARY);
|
||||
ItemStack provenFrames = PluginApiculture.items.frameProven.getItemStack();
|
||||
ItemStack monasticDrone = BeeDefinition.MONASTIC.getMemberStack(EnumBeeType.DRONE);
|
||||
|
||||
VillagerRegistry.VillagerCareer apiaristCareer = new VillagerRegistry.VillagerCareer(villagerApiarist, "apiarist");
|
||||
apiaristCareer.addTrade(1,
|
||||
new VillagerApiaristTrades.GiveRandomCombsForItems(new ItemStack(Items.WHEAT), new EntityVillager.PriceInfo(8, 12), new EntityVillager.PriceInfo(2, 4)),
|
||||
new VillagerApiaristTrades.GiveRandomCombsForItems(new ItemStack(Items.CARROT), new EntityVillager.PriceInfo(8, 12), new EntityVillager.PriceInfo(2, 4)),
|
||||
new VillagerApiaristTrades.GiveRandomCombsForItems(new ItemStack(Items.POTATO), new EntityVillager.PriceInfo(8, 12), new EntityVillager.PriceInfo(2, 4))
|
||||
);
|
||||
apiaristCareer.addTrade(2,
|
||||
new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 4), new ItemStack(items.smoker), null),
|
||||
new VillagerTradeLists.GiveItemForLogsAndEmeralds(apiary, new EntityVillager.PriceInfo(1, 1), new EntityVillager.PriceInfo(16, 32), new EntityVillager.PriceInfo(1, 2))
|
||||
);
|
||||
apiaristCareer.addTrade(3,
|
||||
new VillagerTradeLists.GiveEmeraldForItems(wildcardPrincess, null),
|
||||
new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 2), provenFrames, new EntityVillager.PriceInfo(1, 6))
|
||||
);
|
||||
apiaristCareer.addTrade(4,
|
||||
new VillagerTradeLists.GiveItemForItemAndEmerald(wildcardPrincess, null, new EntityVillager.PriceInfo(10, 64), monasticDrone, null)
|
||||
);
|
||||
}
|
||||
|
||||
proxy.initializeRendering();
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.gen.structure.MapGenStructureIO;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
|
||||
import forestry.apiculture.worldgen.VillageApiaristHouse;
|
||||
|
||||
public class VillageCreationApiculture implements VillagerRegistry.IVillageCreationHandler {
|
||||
|
||||
public static void registerVillageComponents() {
|
||||
MapGenStructureIO.registerStructureComponent(VillageApiaristHouse.class, "Forestry:BeeHouse");
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int size) {
|
||||
return new StructureVillagePieces.PieceWeight(VillageApiaristHouse.class, 15, MathHelper.getRandomIntegerInRange(random, size, 1 + size));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getComponentClass() {
|
||||
return VillageApiaristHouse.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) {
|
||||
return VillageApiaristHouse.buildComponent(startPiece, pieces, random, p1, p2, p3, facing, p5);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
|
||||
|
||||
/**
|
||||
* TODO: Make it to a {@link VillagerProfession} when Forge has Fixed the {@link VillagerRegistry}
|
||||
*/
|
||||
public class VillageHandlerApiculture /*implements IVillageCreationHandler, IVillageTradeHandler*/ {
|
||||
|
||||
/*public static void registerVillageComponents() {
|
||||
MapGenStructureIO.registerStructureComponent(ComponentVillageBeeHouse.class, "Forestry:BeeHouse");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) {
|
||||
ItemStack wildcardPrincess = new ItemStack(PluginApiculture.items.beePrincessGE, 1, OreDictionary.WILDCARD_VALUE);
|
||||
recipeList.add(new MerchantRecipe(wildcardPrincess, new ItemStack(Items.EMERALD, 1)));
|
||||
|
||||
ItemStack randomComb = PluginApiculture.items.beeComb.getRandomComb(1, random, false);
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.WHEAT, 2), randomComb));
|
||||
|
||||
ItemStack apiary = PluginApiculture.blocks.apiculture.get(BlockTypeApiculture.APIARY);
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Blocks.LOG, 24, OreDictionary.WILDCARD_VALUE), apiary));
|
||||
|
||||
ItemStack provenFrames = PluginApiculture.items.frameProven.getItemStack(6);
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.EMERALD, 1), provenFrames));
|
||||
|
||||
ItemStack monasticDrone = BeeDefinition.MONASTIC.getMemberStack(EnumBeeType.DRONE);
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.EMERALD, 12), wildcardPrincess, monasticDrone));
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int size) {
|
||||
return new StructureVillagePieces.PieceWeight(ComponentVillageBeeHouse.class, 15, MathHelper.getRandomIntegerInRange(random, size, 1 + size));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getComponentClass() {
|
||||
return ComponentVillageBeeHouse.class;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@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 ComponentVillageBeeHouse.buildComponent(startPiece, pieces, random, p1, p2, p3, p4, p5);
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package forestry.apiculture;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.village.MerchantRecipe;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
|
||||
public class VillagerApiaristTrades {
|
||||
|
||||
public static class GiveRandomCombsForItems implements EntityVillager.ITradeList {
|
||||
public ItemStack itemToBuy;
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo buyInfo;
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo priceInfo;
|
||||
|
||||
public GiveRandomCombsForItems(ItemStack stack, @Nullable EntityVillager.PriceInfo buyInfo, @Nullable EntityVillager.PriceInfo priceInfo) {
|
||||
this.itemToBuy = stack;
|
||||
this.buyInfo = buyInfo;
|
||||
this.priceInfo = priceInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) {
|
||||
int sellAmount = 1;
|
||||
if (this.priceInfo != null) {
|
||||
sellAmount = this.priceInfo.getPrice(random);
|
||||
}
|
||||
|
||||
int buyAmount = 1;
|
||||
if (this.buyInfo != null) {
|
||||
buyAmount = this.buyInfo.getPrice(random);
|
||||
}
|
||||
|
||||
ItemStack itemToBuy = this.itemToBuy.copy();
|
||||
itemToBuy.stackSize = buyAmount;
|
||||
ItemStack randomComb = PluginApiculture.items.beeComb.getRandomComb(sellAmount, random, false);
|
||||
recipeList.add(new MerchantRecipe(itemToBuy, randomComb));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class CommandBeeGive extends SubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
IBee bee = BeeManager.beeRoot.getBee(player.worldObj, beeGenome);
|
||||
IBee bee = BeeManager.beeRoot.getBee(beeGenome);
|
||||
|
||||
if (beeType == EnumBeeType.QUEEN) {
|
||||
bee.mate(bee);
|
||||
|
||||
@@ -201,7 +201,7 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBee getBee(World world, IBeeGenome genome) {
|
||||
public IBee getBee(IBeeGenome genome) {
|
||||
return new Bee(genome);
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
|
||||
if (beeGenome == null) {
|
||||
beeGenome = BeeDefinition.FOREST.getGenome();
|
||||
}
|
||||
this.containedBee = BeeManager.beeRoot.getBee(worldObj, beeGenome);
|
||||
this.containedBee = BeeManager.beeRoot.getBee(beeGenome);
|
||||
}
|
||||
return this.containedBee;
|
||||
}
|
||||
|
||||
Executable → Regular
+94
-86
@@ -11,11 +11,19 @@
|
||||
package forestry.apiculture.worldgen;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockNewLog;
|
||||
import net.minecraft.block.BlockOldLog;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.BlockTorch;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -27,6 +35,9 @@ import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
@@ -34,6 +45,7 @@ import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IWoodAccess;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
@@ -45,36 +57,33 @@ import forestry.apiculture.flowers.Flower;
|
||||
import forestry.apiculture.flowers.FlowerRegistry;
|
||||
import forestry.apiculture.inventory.InventoryApiary;
|
||||
import forestry.apiculture.tiles.TileApiary;
|
||||
import forestry.arboriculture.worldgen.BlockTypeLog;
|
||||
import forestry.arboriculture.worldgen.BlockTypeVanillaStairs;
|
||||
import forestry.arboriculture.worldgen.BlockTypeWood;
|
||||
import forestry.arboriculture.worldgen.BlockTypeWoodStairs;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.blocks.BlockTypeCoreTesr;
|
||||
import forestry.core.blocks.BlockCore;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.worldgen.BlockType;
|
||||
import forestry.core.worldgen.BlockTypeTileForestry;
|
||||
import forestry.core.worldgen.IBlockType;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
|
||||
public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
private int averageGroundLevel = -1;
|
||||
private boolean isInDesert = false;
|
||||
private IBlockType planks;
|
||||
private IBlockType logs;
|
||||
private IBlockType stairs;
|
||||
private IBlockType fence;
|
||||
private IBlockState planks;
|
||||
private IBlockState logs;
|
||||
private IBlockState stairs;
|
||||
private IBlockState fence;
|
||||
private IBlockState door;
|
||||
private IBlockState fenceGate;
|
||||
|
||||
public ComponentVillageBeeHouse() {
|
||||
@SuppressWarnings("unused")
|
||||
public VillageApiaristHouse() {
|
||||
createBuildingBlocks(random);
|
||||
}
|
||||
|
||||
public ComponentVillageBeeHouse(StructureVillagePieces.Start startPiece, int componentType, Random random, StructureBoundingBox boundingBox, EnumFacing coordBaseMode) {
|
||||
super(startPiece, componentType, random, boundingBox, coordBaseMode);
|
||||
public VillageApiaristHouse(StructureVillagePieces.Start startPiece, int componentType, Random random, StructureBoundingBox boundingBox, EnumFacing facing) {
|
||||
super(startPiece, componentType, random, boundingBox, facing);
|
||||
|
||||
isInDesert = startPiece.inDesert;
|
||||
|
||||
@@ -86,31 +95,52 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
|
||||
|
||||
boolean fireproof = random.nextInt(4) == 0;
|
||||
|
||||
EnumWoodType roofWood = EnumWoodType.getRandom(random);
|
||||
EnumWoodType logWood = EnumWoodType.getRandom(random);
|
||||
EnumWoodType fenceWood = EnumWoodType.getRandom(random);
|
||||
EnumWoodType woodType = EnumWoodType.getRandom(random);
|
||||
|
||||
logs = new BlockTypeLog(TreeManager.woodItemAccess.getLog(logWood, fireproof));
|
||||
planks = new BlockTypeWood(TreeManager.woodItemAccess.getPlanks(roofWood, fireproof));
|
||||
stairs = new BlockTypeWoodStairs(TreeManager.woodItemAccess.getStairs(roofWood, fireproof));
|
||||
fence = new BlockTypeWood(TreeManager.woodItemAccess.getFence(fenceWood, fireproof));
|
||||
IWoodAccess woodAccess = TreeManager.woodAccess;
|
||||
this.logs = woodAccess.getLogBlock(woodType, fireproof);
|
||||
this.planks = woodAccess.getPlanksBlock(woodType, fireproof);
|
||||
this.stairs = woodAccess.getStairsBlock(woodType, fireproof);
|
||||
this.fence = woodAccess.getFenceBlock(woodType, fireproof);
|
||||
this.door = woodAccess.getDoorBlock(woodType);
|
||||
this.fenceGate = woodAccess.getFenceGateBlock(woodType, fireproof);
|
||||
} else {
|
||||
int roofMeta = random.nextInt(16);
|
||||
if (random.nextInt(6) < 4) {
|
||||
this.logs = getRandomVariant(random, Blocks.LOG.getDefaultState(), BlockOldLog.VARIANT);
|
||||
} else {
|
||||
this.logs = getRandomVariant(random, Blocks.LOG2.getDefaultState(), BlockNewLog.VARIANT);
|
||||
}
|
||||
this.planks = getRandomVariant(random, Blocks.PLANKS.getDefaultState(), BlockPlanks.VARIANT);
|
||||
|
||||
logs = new BlockType(Blocks.LOG, random.nextInt(4));
|
||||
planks = new BlockType(Blocks.PLANKS, roofMeta);
|
||||
stairs = new BlockTypeVanillaStairs(roofMeta);
|
||||
fence = new BlockType(Blocks.OAK_FENCE, 0);
|
||||
List<Block> stairs = Arrays.asList(
|
||||
Blocks.ACACIA_STAIRS, Blocks.BIRCH_STAIRS, Blocks.DARK_OAK_STAIRS, Blocks.JUNGLE_STAIRS, Blocks.SPRUCE_STAIRS
|
||||
);
|
||||
this.stairs = stairs.get(random.nextInt(stairs.size())).getDefaultState();
|
||||
|
||||
List<Block> fences = Arrays.asList(
|
||||
Blocks.ACACIA_FENCE, Blocks.BIRCH_FENCE, Blocks.DARK_OAK_FENCE, Blocks.JUNGLE_FENCE, Blocks.SPRUCE_FENCE
|
||||
);
|
||||
this.fence = fences.get(random.nextInt(fences.size())).getDefaultState();
|
||||
|
||||
this.door = Blocks.OAK_DOOR.getDefaultState();
|
||||
this.fenceGate = Blocks.OAK_FENCE_GATE.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
public static ComponentVillageBeeHouse buildComponent(StructureVillagePieces.Start startPiece, List<StructureComponent> par1List, Random random, int par3, int par4, int par5, EnumFacing par6, int par7) {
|
||||
StructureBoundingBox bbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 10, 9, 11, par6);
|
||||
private static <T extends Comparable<T>> IBlockState getRandomVariant(Random random, IBlockState defaultState, IProperty<T> variantProperty) {
|
||||
Collection<T> allowedValues = variantProperty.getAllowedValues();
|
||||
List<T> allowedValuesList = new ArrayList<>(allowedValues);
|
||||
T randomValue = allowedValuesList.get(random.nextInt(allowedValuesList.size()));
|
||||
return defaultState.withProperty(variantProperty, randomValue);
|
||||
}
|
||||
|
||||
public static VillageApiaristHouse buildComponent(StructureVillagePieces.Start startPiece, List<StructureComponent> par1List, Random random, int structureMinX, int structureMinY, int structureMinZ, EnumFacing facing, int componentType) {
|
||||
StructureBoundingBox bbox = StructureBoundingBox.getComponentToAddBoundingBox(structureMinX, structureMinY, structureMinZ, 0, 0, 0, 10, 9, 11, facing);
|
||||
if (!canVillageGoDeeper(bbox) || StructureComponent.findIntersecting(par1List, bbox) != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ComponentVillageBeeHouse(startPiece, par7, random, bbox, par6);
|
||||
return new VillageApiaristHouse(startPiece, componentType, random, bbox, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,9 +162,11 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
|
||||
buildGarden(world, structBoundingBox);
|
||||
|
||||
// Garden fence
|
||||
fillBoxWith(world, structBoundingBox, 1, 1, 6, 1, 1, 10, fence, false);
|
||||
fillBoxWith(world, structBoundingBox, 8, 1, 6, 8, 1, 10, fence, false);
|
||||
fillBoxWith(world, structBoundingBox, 2, 1, 10, 7, 1, 10, fence, false);
|
||||
fillWithBlocks(world, structBoundingBox, 1, 1, 6, 1, 1, 10, fence, fence, false);
|
||||
fillWithBlocks(world, structBoundingBox, 8, 1, 6, 8, 1, 10, fence, fence, false);
|
||||
fillWithBlocks(world, structBoundingBox, 2, 1, 10, 7, 1, 10, fence, fence, false);
|
||||
|
||||
placeBlockAtCurrentPosition(world, fenceGate, 8, 1, 8, structBoundingBox);
|
||||
|
||||
// Flowers
|
||||
plantFlowerGarden(world, structBoundingBox, 2, 1, 5, 7, 1, 9);
|
||||
@@ -151,11 +183,11 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
|
||||
fillWithBlocks(world, structBoundingBox, 1, 0, 0, 7, 1, 0, cobblestoneState, cobblestoneState, false);
|
||||
fillWithBlocks(world, structBoundingBox, 1, 0, 5, 7, 1, 5, cobblestoneState, cobblestoneState, false);
|
||||
|
||||
fillBoxWith(world, structBoundingBox, 1, 2, 0, 7, 3, 0, planks, false);
|
||||
fillBoxWith(world, structBoundingBox, 1, 2, 5, 7, 3, 5, planks, false);
|
||||
fillBoxWith(world, structBoundingBox, 0, 4, 1, 8, 4, 1, planks, false);
|
||||
fillBoxWith(world, structBoundingBox, 0, 4, 4, 8, 4, 4, planks, false);
|
||||
fillBoxWith(world, structBoundingBox, 0, 5, 2, 8, 5, 3, planks, false);
|
||||
fillWithBlocks(world, structBoundingBox, 1, 2, 0, 7, 3, 0, planks, planks, false);
|
||||
fillWithBlocks(world, structBoundingBox, 1, 2, 5, 7, 3, 5, planks, planks, false);
|
||||
fillWithBlocks(world, structBoundingBox, 0, 4, 1, 8, 4, 1, planks, planks, false);
|
||||
fillWithBlocks(world, structBoundingBox, 0, 4, 4, 8, 4, 4, planks, planks, false);
|
||||
fillWithBlocks(world, structBoundingBox, 0, 5, 2, 8, 5, 3, planks, planks, false);
|
||||
|
||||
placeBlockAtCurrentPosition(world, planks, 0, 4, 2, structBoundingBox);
|
||||
placeBlockAtCurrentPosition(world, planks, 0, 4, 3, structBoundingBox);
|
||||
@@ -186,15 +218,14 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
|
||||
|
||||
// Escritoire
|
||||
if (random.nextInt(2) == 0) {
|
||||
IBlockType escritoireBlock = new BlockTypeTileForestry(PluginCore.blocks.core, BlockTypeCoreTesr.ESCRITOIRE.ordinal());
|
||||
escritoireBlock.setDirection(EnumFacing.EAST);
|
||||
IBlockState escritoireBlock = PluginCore.blocks.escritoire.getDefaultState().withProperty(BlockCore.FACING, EnumFacing.WEST);
|
||||
placeBlockAtCurrentPosition(world, escritoireBlock, 1, 1, 3, structBoundingBox);
|
||||
}
|
||||
|
||||
IBlockState airState = Blocks.AIR.getDefaultState();
|
||||
setBlockState(world, airState, 2, 1, 0, structBoundingBox);
|
||||
setBlockState(world, airState, 2, 2, 0, structBoundingBox);
|
||||
placeDoorCurrentPosition(world, structBoundingBox, random, 2, 1, 0, getCoordBaseMode());
|
||||
|
||||
this.setBlockState(world, this.door.withProperty(BlockDoor.FACING, EnumFacing.NORTH), 2, 1, 0, structBoundingBox);
|
||||
this.setBlockState(world, this.door.withProperty(BlockDoor.FACING, EnumFacing.NORTH).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2, 2, 0, structBoundingBox);
|
||||
|
||||
if (isAirBlockAtCurrentPosition(world, new BlockPos(2, 0, -1), structBoundingBox) && !isAirBlockAtCurrentPosition(world, new BlockPos(2, -1, -1), structBoundingBox)) {
|
||||
setBlockState(world, Blocks.STONE_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.NORTH), 2, 0, -1, structBoundingBox);
|
||||
@@ -204,14 +235,10 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
|
||||
setBlockState(world, airState, 6, 2, 5, structBoundingBox);
|
||||
|
||||
// Candles / Lighting
|
||||
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.NORTH), 2, 3, 1, structBoundingBox);
|
||||
|
||||
IBlockState torchState = Blocks.TORCH.getDefaultState();
|
||||
setBlockState(world, torchState, 2, 3, 4, structBoundingBox);
|
||||
setBlockState(world, torchState, 6, 3, 4, structBoundingBox);
|
||||
setBlockState(world, torchState, 2, 3, 1, structBoundingBox);
|
||||
setBlockState(world, torchState, 6, 3, 1, structBoundingBox);
|
||||
|
||||
placeDoorCurrentPosition(world, structBoundingBox, random, 6, 1, 5, getCoordBaseMode());
|
||||
this.setBlockState(world, this.door.withProperty(BlockDoor.FACING, EnumFacing.SOUTH), 6, 1, 5, structBoundingBox);
|
||||
this.setBlockState(world, this.door.withProperty(BlockDoor.FACING, EnumFacing.SOUTH).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 6, 2, 5, structBoundingBox);
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
@@ -220,12 +247,9 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Chest loot
|
||||
// generateChestContents(world, structBoundingBox, random, 7, 1, 4,
|
||||
// ChestGenHooks.getItems(Constants.VILLAGE_NATURALIST_LOOT_KEY, random),
|
||||
// random.nextInt(4) + random.nextInt(4) + 5);
|
||||
generateChest(world, structBoundingBox, random, 7, 1, 4, Constants.VILLAGE_NATURALIST_LOOT_KEY);
|
||||
|
||||
spawnVillagers(world, boundingBox, 7, 1, 1, 2);
|
||||
spawnVillagers(world, boundingBox, 2, 1, 2, 2);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -233,11 +257,11 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
|
||||
private void buildRoof(World world, StructureBoundingBox structBoundingBox) {
|
||||
for (int i = -1; i <= 2; ++i) {
|
||||
for (int j = 0; j <= 8; ++j) {
|
||||
stairs.setDirection(EnumFacing.NORTH);
|
||||
placeBlockAtCurrentPosition(world, stairs, j, 4 + i, i, structBoundingBox);
|
||||
IBlockState northStairs = stairs.withProperty(BlockStairs.FACING, EnumFacing.NORTH);
|
||||
placeBlockAtCurrentPosition(world, northStairs, j, 4 + i, i, structBoundingBox);
|
||||
|
||||
stairs.setDirection(EnumFacing.SOUTH);
|
||||
placeBlockAtCurrentPosition(world, stairs, j, 4 + i, 5 - i, structBoundingBox);
|
||||
IBlockState southStairs = stairs.withProperty(BlockStairs.FACING, EnumFacing.SOUTH);
|
||||
placeBlockAtCurrentPosition(world, southStairs, j, 4 + i, 5 - i, structBoundingBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -371,10 +395,10 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
|
||||
if (valid.isEmpty()) {
|
||||
int index = world.rand.nextInt(BeeManager.commonVillageBees.size());
|
||||
IBeeGenome genome = BeeManager.commonVillageBees.get(index);
|
||||
return BeeManager.beeRoot.getBee(world, genome);
|
||||
return BeeManager.beeRoot.getBee(genome);
|
||||
}
|
||||
|
||||
return BeeManager.beeRoot.getBee(world, valid.get(world.rand.nextInt(valid.size())));
|
||||
return BeeManager.beeRoot.getBee(valid.get(world.rand.nextInt(valid.size())));
|
||||
}
|
||||
|
||||
private static boolean checkBiomeHazard(IBeeGenome genome, EnumTemperature biomeTemperature, EnumHumidity biomeHumidity) {
|
||||
@@ -384,36 +408,20 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
|
||||
species.getHumidity(), genome.getToleranceHumid());
|
||||
}
|
||||
|
||||
private void fillBoxWith(World world, StructureBoundingBox box, int par3, int par4, int par5, int par6, int par7, int par8, IBlockType block, boolean replace) {
|
||||
|
||||
for (int var14 = par4; var14 <= par7; ++var14) {
|
||||
for (int var15 = par3; var15 <= par6; ++var15) {
|
||||
for (int var16 = par5; var16 <= par8; ++var16) {
|
||||
if (!replace || !isAirBlockAtCurrentPosition(world, new BlockPos(var15, var14, var16), box)) {
|
||||
placeBlockAtCurrentPosition(world, block, var15, var14, var16, box);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void placeBlockAtCurrentPosition(World world, IBlockType block, int x, int y, int z, StructureBoundingBox par7StructureBoundingBox) {
|
||||
int xC = getXWithOffset(x, z);
|
||||
int yC = getYWithOffset(y);
|
||||
int zC = getZWithOffset(x, z);
|
||||
BlockPos pos = new BlockPos(xC, yC, zC);
|
||||
|
||||
if (par7StructureBoundingBox.isVecInside(pos)) {
|
||||
block.setBlock(world, pos);
|
||||
}
|
||||
private void placeBlockAtCurrentPosition(World world, IBlockState block, int x, int y, int z, StructureBoundingBox boundingboxIn) {
|
||||
setBlockState(world, block, x, y, z, boundingboxIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int chooseProfession(int villagerCount, int currentVillagerProfession) {
|
||||
FMLControlledNamespacedRegistry<VillagerRegistry.VillagerProfession> registry = (FMLControlledNamespacedRegistry<VillagerRegistry.VillagerProfession>) VillagerRegistry.instance().getRegistry();
|
||||
|
||||
if (villagerCount <= 0) {
|
||||
return Constants.ID_VILLAGER_BEEKEEPER;
|
||||
return registry.getId(PluginApiculture.villagerApiarist);
|
||||
} else if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ARBORICULTURE)) {
|
||||
return registry.getId(PluginArboriculture.villagerArborist);
|
||||
} else {
|
||||
return Constants.ID_VILLAGER_LUMBERJACK;
|
||||
return currentVillagerProfession;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -28,10 +29,12 @@ import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IAlleleFruit;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
@@ -62,6 +65,7 @@ import forestry.arboriculture.tiles.TileFruitPod;
|
||||
import forestry.arboriculture.tiles.TileLeaves;
|
||||
import forestry.arboriculture.tiles.TileSapling;
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.genetics.alleles.AllelePlantType;
|
||||
@@ -70,6 +74,7 @@ import forestry.core.network.IPacketRegistry;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.utils.IMCUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.VillagerTradeLists;
|
||||
import forestry.factory.recipes.FabricatorRecipe;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
@@ -87,12 +92,14 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
public static ItemRegistryArboriculture items;
|
||||
public static BlockRegistryArboriculture blocks;
|
||||
|
||||
public static VillagerRegistry.VillagerProfession villagerArborist;
|
||||
|
||||
@Override
|
||||
public void setupAPI() {
|
||||
TreeManager.treeFactory = new TreeFactory();
|
||||
TreeManager.treeMutationFactory = new TreeMutationFactory();
|
||||
|
||||
TreeManager.woodItemAccess = new WoodItemAccess();
|
||||
TreeManager.woodAccess = new WoodAccess();
|
||||
|
||||
// Init tree interface
|
||||
TreeManager.treeRoot = new TreeRoot();
|
||||
@@ -118,20 +125,20 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
WoodItemAccess.registerLogs(blocks.logs);
|
||||
WoodItemAccess.registerPlanks(blocks.planks);
|
||||
WoodItemAccess.registerSlabs(blocks.slabs);
|
||||
WoodItemAccess.registerFences(blocks.fences);
|
||||
WoodItemAccess.registerFenceGates(blocks.fenceGates);
|
||||
WoodItemAccess.registerStairs(blocks.stairs);
|
||||
WoodItemAccess.registerDoors(blocks.doors);
|
||||
WoodAccess.registerLogs(blocks.logs);
|
||||
WoodAccess.registerPlanks(blocks.planks);
|
||||
WoodAccess.registerSlabs(blocks.slabs);
|
||||
WoodAccess.registerFences(blocks.fences);
|
||||
WoodAccess.registerFenceGates(blocks.fenceGates);
|
||||
WoodAccess.registerStairs(blocks.stairs);
|
||||
WoodAccess.registerDoors(blocks.doors);
|
||||
|
||||
WoodItemAccess.registerLogs(blocks.logsFireproof);
|
||||
WoodItemAccess.registerPlanks(blocks.planksFireproof);
|
||||
WoodItemAccess.registerSlabs(blocks.slabsFireproof);
|
||||
WoodItemAccess.registerFences(blocks.fencesFireproof);
|
||||
WoodItemAccess.registerFenceGates(blocks.fenceGatesFireproof);
|
||||
WoodItemAccess.registerStairs(blocks.stairsFireproof);
|
||||
WoodAccess.registerLogs(blocks.logsFireproof);
|
||||
WoodAccess.registerPlanks(blocks.planksFireproof);
|
||||
WoodAccess.registerSlabs(blocks.slabsFireproof);
|
||||
WoodAccess.registerFences(blocks.fencesFireproof);
|
||||
WoodAccess.registerFenceGates(blocks.fenceGatesFireproof);
|
||||
WoodAccess.registerStairs(blocks.stairsFireproof);
|
||||
|
||||
blocks.arboriculture.addDefinitions(BlockTypeArboricultureTesr.ARB_CHEST);
|
||||
|
||||
@@ -163,12 +170,29 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
|
||||
blocks.arboriculture.init();
|
||||
|
||||
// TODO bring back villagers
|
||||
/*if (Config.enableVillagers) {
|
||||
VillagerRegistry.instance().registerVillagerId(Constants.ID_VILLAGER_LUMBERJACK);
|
||||
Proxies.render.registerVillagerSkin(Constants.ID_VILLAGER_LUMBERJACK, Constants.TEXTURE_SKIN_LUMBERJACK);
|
||||
VillagerRegistry.instance().registerVillageTradeHandler(Constants.ID_VILLAGER_LUMBERJACK, new VillageHandlerArboriculture());
|
||||
}*/
|
||||
if (Config.enableVillagers) {
|
||||
villagerArborist = new VillagerRegistry.VillagerProfession(Constants.ID_VILLAGER_ARBORIST, Constants.TEXTURE_SKIN_LUMBERJACK);
|
||||
VillagerRegistry.instance().register(villagerArborist);
|
||||
|
||||
VillagerRegistry.VillagerCareer arboristCareer = new VillagerRegistry.VillagerCareer(villagerArborist, "arborist");
|
||||
arboristCareer.addTrade(1,
|
||||
new VillagerArboristTrades.GivePlanksForEmeralds(new EntityVillager.PriceInfo(1, 1), new EntityVillager.PriceInfo(10, 32)),
|
||||
new VillagerArboristTrades.GivePollenForEmeralds(new EntityVillager.PriceInfo(1, 1), new EntityVillager.PriceInfo(1, 3), EnumGermlingType.SAPLING, 4)
|
||||
);
|
||||
arboristCareer.addTrade(2,
|
||||
new VillagerArboristTrades.GivePlanksForEmeralds(new EntityVillager.PriceInfo(1, 1), new EntityVillager.PriceInfo(10, 32)),
|
||||
new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 4), items.grafterProven.getItemStack(), new EntityVillager.PriceInfo(1, 1)),
|
||||
new VillagerArboristTrades.GivePollenForEmeralds(new EntityVillager.PriceInfo(2, 3), new EntityVillager.PriceInfo(1, 1), EnumGermlingType.POLLEN, 6)
|
||||
);
|
||||
arboristCareer.addTrade(3,
|
||||
new VillagerArboristTrades.GiveLogsForEmeralds(new EntityVillager.PriceInfo(2, 5), new EntityVillager.PriceInfo(6, 18)),
|
||||
new VillagerArboristTrades.GiveLogsForEmeralds(new EntityVillager.PriceInfo(2, 5), new EntityVillager.PriceInfo(6, 18))
|
||||
);
|
||||
arboristCareer.addTrade(4,
|
||||
new VillagerArboristTrades.GivePollenForEmeralds(new EntityVillager.PriceInfo(5, 20), new EntityVillager.PriceInfo(1, 1), EnumGermlingType.POLLEN, 10),
|
||||
new VillagerArboristTrades.GivePollenForEmeralds(new EntityVillager.PriceInfo(5, 20), new EntityVillager.PriceInfo(1, 1), EnumGermlingType.SAPLING, 10)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,20 +217,20 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
}
|
||||
|
||||
for (EnumWoodType woodType : EnumWoodType.VALUES) {
|
||||
ItemStack planks = TreeManager.woodItemAccess.getPlanks(woodType, false);
|
||||
ItemStack logs = TreeManager.woodItemAccess.getLog(woodType, false);
|
||||
ItemStack slabs = TreeManager.woodItemAccess.getSlab(woodType, false);
|
||||
ItemStack fences = TreeManager.woodItemAccess.getFence(woodType, false);
|
||||
ItemStack fenceGates = TreeManager.woodItemAccess.getFenceGate(woodType, false);
|
||||
ItemStack stairs = TreeManager.woodItemAccess.getStairs(woodType, false);
|
||||
ItemStack doors = TreeManager.woodItemAccess.getDoor(woodType);
|
||||
ItemStack planks = TreeManager.woodAccess.getPlanks(woodType, false);
|
||||
ItemStack logs = TreeManager.woodAccess.getLog(woodType, false);
|
||||
ItemStack slabs = TreeManager.woodAccess.getSlab(woodType, false);
|
||||
ItemStack fences = TreeManager.woodAccess.getFence(woodType, false);
|
||||
ItemStack fenceGates = TreeManager.woodAccess.getFenceGate(woodType, false);
|
||||
ItemStack stairs = TreeManager.woodAccess.getStairs(woodType, false);
|
||||
ItemStack doors = TreeManager.woodAccess.getDoor(woodType);
|
||||
|
||||
ItemStack fireproofPlanks = TreeManager.woodItemAccess.getPlanks(woodType, true);
|
||||
ItemStack fireproofLogs = TreeManager.woodItemAccess.getLog(woodType, true);
|
||||
ItemStack fireproofSlabs = TreeManager.woodItemAccess.getSlab(woodType, true);
|
||||
ItemStack fireproofFences = TreeManager.woodItemAccess.getFence(woodType, true);
|
||||
ItemStack fireproofFenceGates = TreeManager.woodItemAccess.getFenceGate(woodType, true);
|
||||
ItemStack fireproofStairs = TreeManager.woodItemAccess.getStairs(woodType, true);
|
||||
ItemStack fireproofPlanks = TreeManager.woodAccess.getPlanks(woodType, true);
|
||||
ItemStack fireproofLogs = TreeManager.woodAccess.getLog(woodType, true);
|
||||
ItemStack fireproofSlabs = TreeManager.woodAccess.getSlab(woodType, true);
|
||||
ItemStack fireproofFences = TreeManager.woodAccess.getFence(woodType, true);
|
||||
ItemStack fireproofFenceGates = TreeManager.woodAccess.getFenceGate(woodType, true);
|
||||
ItemStack fireproofStairs = TreeManager.woodAccess.getStairs(woodType, true);
|
||||
|
||||
planks.stackSize = 4;
|
||||
logs.stackSize = 1;
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
|
||||
|
||||
/**
|
||||
* TODO: Make it to a {@link VillagerProfession} when Forge has Fixed the {@link VillagerRegistry}
|
||||
*/
|
||||
public class VillageHandlerArboriculture /*implements IVillageTradeHandler*/ {
|
||||
|
||||
/*@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) {
|
||||
IAllele[] randomTemplate = TreeManager.treeRoot.getRandomTemplate(random);
|
||||
ITreeGenome randomGenome = TreeManager.treeRoot.templateAsGenome(randomTemplate);
|
||||
ITree randomTree = TreeManager.treeRoot.getTree(villager.worldObj, randomGenome);
|
||||
ItemStack randomTreeStack = TreeManager.treeRoot.getMemberStack(randomTree, EnumGermlingType.SAPLING.ordinal());
|
||||
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.EMERALD, 8), randomTreeStack));
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.EMERALD, 2), PluginArboriculture.items.grafterProven.getItemStack()));
|
||||
|
||||
EnumWoodType randomWoodType = EnumWoodType.getRandom(random);
|
||||
ItemStack planks = TreeManager.woodItemAccess.getPlanks(randomWoodType, false);
|
||||
planks.stackSize = 32;
|
||||
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.EMERALD, 1), planks));
|
||||
}*/
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package forestry.arboriculture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.village.MerchantRecipe;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class VillagerArboristTrades {
|
||||
|
||||
public static class GiveLogsForEmeralds implements EntityVillager.ITradeList {
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo emeraldPriceInfo;
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo sellInfo;
|
||||
|
||||
public GiveLogsForEmeralds(@Nullable EntityVillager.PriceInfo emeraldPriceInfo, @Nullable EntityVillager.PriceInfo sellInfo) {
|
||||
this.emeraldPriceInfo = emeraldPriceInfo;
|
||||
this.sellInfo = sellInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) {
|
||||
int i = 1;
|
||||
if (this.sellInfo != null) {
|
||||
i = this.sellInfo.getPrice(random);
|
||||
}
|
||||
|
||||
int j = 1;
|
||||
if (this.emeraldPriceInfo != null) {
|
||||
j = this.emeraldPriceInfo.getPrice(random);
|
||||
}
|
||||
|
||||
EnumWoodType woodType = EnumWoodType.getRandom(random);
|
||||
ItemStack sellStack = TreeManager.woodAccess.getLog(woodType, false);
|
||||
sellStack.stackSize = i;
|
||||
|
||||
ItemStack emeralds = new ItemStack(Items.EMERALD, j);
|
||||
|
||||
recipeList.add(new MerchantRecipe(emeralds, sellStack));
|
||||
}
|
||||
}
|
||||
|
||||
public static class GivePlanksForEmeralds implements EntityVillager.ITradeList {
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo emeraldPriceInfo;
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo sellInfo;
|
||||
|
||||
public GivePlanksForEmeralds(@Nullable EntityVillager.PriceInfo emeraldPriceInfo, @Nullable EntityVillager.PriceInfo sellInfo) {
|
||||
this.emeraldPriceInfo = emeraldPriceInfo;
|
||||
this.sellInfo = sellInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) {
|
||||
int i = 1;
|
||||
if (this.sellInfo != null) {
|
||||
i = this.sellInfo.getPrice(random);
|
||||
}
|
||||
|
||||
int j = 1;
|
||||
if (this.emeraldPriceInfo != null) {
|
||||
j = this.emeraldPriceInfo.getPrice(random);
|
||||
}
|
||||
|
||||
EnumWoodType woodType = EnumWoodType.getRandom(random);
|
||||
ItemStack sellStack = TreeManager.woodAccess.getPlanks(woodType, false);
|
||||
sellStack.stackSize = i;
|
||||
|
||||
ItemStack emeralds = new ItemStack(Items.EMERALD, j);
|
||||
|
||||
recipeList.add(new MerchantRecipe(emeralds, sellStack));
|
||||
}
|
||||
}
|
||||
|
||||
public static class GivePollenForEmeralds implements EntityVillager.ITradeList {
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo emeraldPriceInfo;
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo sellInfo;
|
||||
@Nonnull
|
||||
private final EnumGermlingType type;
|
||||
|
||||
private final int maxComplexity;
|
||||
|
||||
public GivePollenForEmeralds(@Nullable EntityVillager.PriceInfo emeraldPriceInfo, @Nullable EntityVillager.PriceInfo sellInfo, @Nonnull EnumGermlingType type, int maxComplexity) {
|
||||
this.emeraldPriceInfo = emeraldPriceInfo;
|
||||
this.sellInfo = sellInfo;
|
||||
this.type = type;
|
||||
this.maxComplexity = maxComplexity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) {
|
||||
int i = 1;
|
||||
if (this.sellInfo != null) {
|
||||
i = this.sellInfo.getPrice(random);
|
||||
}
|
||||
|
||||
int j = 1;
|
||||
if (this.emeraldPriceInfo != null) {
|
||||
j = this.emeraldPriceInfo.getPrice(random);
|
||||
}
|
||||
|
||||
IChromosomeType treeSpeciesType = TreeManager.treeRoot.getKaryotypeKey();
|
||||
Collection<IAllele> registeredSpecies = AlleleManager.alleleRegistry.getRegisteredAlleles(treeSpeciesType);
|
||||
List<IAlleleSpecies> potentialSpecies = new ArrayList<>();
|
||||
for (IAllele allele : registeredSpecies) {
|
||||
if (allele instanceof IAlleleSpecies) {
|
||||
IAlleleSpecies species = (IAlleleSpecies) allele;
|
||||
if (species.getComplexity() <= maxComplexity) {
|
||||
potentialSpecies.add(species);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (potentialSpecies.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IAlleleSpecies chosenSpecies = potentialSpecies.get(random.nextInt(potentialSpecies.size()));
|
||||
IAllele[] template = TreeManager.treeRoot.getTemplate(chosenSpecies.getUID());
|
||||
IIndividual individual = TreeManager.treeRoot.templateAsIndividual(template);
|
||||
|
||||
ItemStack sellStack = TreeManager.treeRoot.getMemberStack(individual, type);
|
||||
sellStack.stackSize = i;
|
||||
|
||||
ItemStack emeralds = new ItemStack(Items.EMERALD, j);
|
||||
|
||||
recipeList.add(new MerchantRecipe(emeralds, sellStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
+87
-19
@@ -15,11 +15,17 @@ import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IWoodItemAccess;
|
||||
import forestry.api.arboriculture.IWoodAccess;
|
||||
import forestry.arboriculture.blocks.BlockArbDoor;
|
||||
import forestry.arboriculture.blocks.BlockArbFence;
|
||||
import forestry.arboriculture.blocks.BlockArbFenceGate;
|
||||
@@ -29,7 +35,7 @@ import forestry.arboriculture.blocks.BlockArbSlab;
|
||||
import forestry.arboriculture.blocks.BlockArbStairs;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
public class WoodItemAccess implements IWoodItemAccess {
|
||||
public class WoodAccess implements IWoodAccess {
|
||||
private static final WoodMap logs = new WoodMap("logs");
|
||||
private static final WoodMap planks = new WoodMap("planks");
|
||||
private static final WoodMap slabs = new WoodMap("slabs");
|
||||
@@ -39,16 +45,26 @@ public class WoodItemAccess implements IWoodItemAccess {
|
||||
private static final WoodMap doors = new WoodMap("doors") {
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumMap<EnumWoodType, ItemStack> get(boolean fireproof) {
|
||||
return super.get(false);
|
||||
public EnumMap<EnumWoodType, ItemStack> getItem(boolean fireproof) {
|
||||
return super.getItem(false);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumMap<EnumWoodType, IBlockState> getBlock(boolean fireproof) {
|
||||
return super.getBlock(false);
|
||||
}
|
||||
};
|
||||
|
||||
private static class WoodMap {
|
||||
@Nonnull
|
||||
private final EnumMap<EnumWoodType, ItemStack> normal = new EnumMap<>(EnumWoodType.class);
|
||||
private final EnumMap<EnumWoodType, ItemStack> normalItems = new EnumMap<>(EnumWoodType.class);
|
||||
@Nonnull
|
||||
private final EnumMap<EnumWoodType, ItemStack> fireproof = new EnumMap<>(EnumWoodType.class);
|
||||
private final EnumMap<EnumWoodType, ItemStack> fireproofItems = new EnumMap<>(EnumWoodType.class);
|
||||
@Nonnull
|
||||
private final EnumMap<EnumWoodType, IBlockState> normalBlocks = new EnumMap<>(EnumWoodType.class);
|
||||
@Nonnull
|
||||
private final EnumMap<EnumWoodType, IBlockState> fireproofBlocks = new EnumMap<>(EnumWoodType.class);
|
||||
@Nonnull
|
||||
private final String name;
|
||||
|
||||
@@ -62,8 +78,13 @@ public class WoodItemAccess implements IWoodItemAccess {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public EnumMap<EnumWoodType, ItemStack> get(boolean fireproof) {
|
||||
return fireproof ? this.fireproof : this.normal;
|
||||
public EnumMap<EnumWoodType, ItemStack> getItem(boolean fireproof) {
|
||||
return fireproof ? this.fireproofItems : this.normalItems;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public EnumMap<EnumWoodType, IBlockState> getBlock(boolean fireproof) {
|
||||
return fireproof ? this.fireproofBlocks : this.normalBlocks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,56 +132,103 @@ public class WoodItemAccess implements IWoodItemAccess {
|
||||
|
||||
private static <T extends Block & IWoodTyped> void register(T woodTyped, WoodMap woodMap) {
|
||||
boolean fireproof = woodTyped.isFireproof();
|
||||
EnumMap<EnumWoodType, ItemStack> registryMap = woodMap.get(fireproof);
|
||||
EnumMap<EnumWoodType, ItemStack> itemRegistryMap = woodMap.getItem(fireproof);
|
||||
EnumMap<EnumWoodType, IBlockState> blockRegistryMap = woodMap.getBlock(fireproof);
|
||||
for (IBlockState blockState : woodTyped.getBlockState().getValidStates()) {
|
||||
int meta = woodTyped.getMetaFromState(blockState);
|
||||
EnumWoodType woodType = woodTyped.getWoodType(meta);
|
||||
ItemStack itemStack = new ItemStack(woodTyped, 1, meta);
|
||||
registryMap.put(woodType, itemStack);
|
||||
|
||||
itemRegistryMap.put(woodType, itemStack);
|
||||
blockRegistryMap.put(woodType, blockState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPlanks(EnumWoodType woodType, boolean fireproof) {
|
||||
return get(woodType, fireproof, planks);
|
||||
return getItem(woodType, fireproof, planks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getLog(EnumWoodType woodType, boolean fireproof) {
|
||||
return get(woodType, fireproof, logs);
|
||||
return getItem(woodType, fireproof, logs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSlab(EnumWoodType woodType, boolean fireproof) {
|
||||
return get(woodType, fireproof, slabs);
|
||||
return getItem(woodType, fireproof, slabs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getFence(EnumWoodType woodType, boolean fireproof) {
|
||||
return get(woodType, fireproof, fences);
|
||||
return getItem(woodType, fireproof, fences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getFenceGate(EnumWoodType woodType, boolean fireproof) {
|
||||
return get(woodType, fireproof, fenceGates);
|
||||
return getItem(woodType, fireproof, fenceGates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStairs(EnumWoodType woodType, boolean fireproof) {
|
||||
return get(woodType, fireproof, stairs);
|
||||
return getItem(woodType, fireproof, stairs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDoor(EnumWoodType woodType) {
|
||||
return get(woodType, false, doors);
|
||||
return getItem(woodType, false, doors);
|
||||
}
|
||||
|
||||
private static ItemStack get(EnumWoodType woodType, boolean fireproof, WoodMap woodMap) {
|
||||
ItemStack itemStack = woodMap.get(fireproof).get(woodType);
|
||||
@Override
|
||||
public IBlockState getLogBlock(EnumWoodType woodType, boolean fireproof) {
|
||||
return getBlock(woodType, fireproof, logs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getPlanksBlock(EnumWoodType woodType, boolean fireproof) {
|
||||
return getBlock(woodType, fireproof, planks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getSlabBlock(EnumWoodType woodType, boolean fireproof) {
|
||||
return getBlock(woodType, fireproof, slabs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getFenceBlock(EnumWoodType woodType, boolean fireproof) {
|
||||
return getBlock(woodType, fireproof, fences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getFenceGateBlock(EnumWoodType woodType, boolean fireproof) {
|
||||
return getBlock(woodType, fireproof, fenceGates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStairsBlock(EnumWoodType woodType, boolean fireproof) {
|
||||
return getBlock(woodType, fireproof, stairs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getDoorBlock(EnumWoodType woodType) {
|
||||
return getBlock(woodType, false, doors);
|
||||
}
|
||||
|
||||
private static ItemStack getItem(EnumWoodType woodType, boolean fireproof, WoodMap woodMap) {
|
||||
ItemStack itemStack = woodMap.getItem(fireproof).get(woodType);
|
||||
if (itemStack == null) {
|
||||
Log.error("No stack found for {} {} {}", woodType, woodMap.getName(), fireproof ? "fireproof" : "non-fireproof");
|
||||
return null;
|
||||
}
|
||||
return itemStack.copy();
|
||||
}
|
||||
|
||||
private static IBlockState getBlock(EnumWoodType woodType, boolean fireproof, WoodMap woodMap) {
|
||||
IBlockState blockState = woodMap.getBlock(fireproof).get(woodType);
|
||||
if (blockState == null) {
|
||||
Log.error("No block found for {} {} {}", woodType, woodMap.getName(), fireproof ? "fireproof" : "non-fireproof");
|
||||
return null;
|
||||
}
|
||||
return blockState;
|
||||
}
|
||||
}
|
||||
@@ -105,6 +105,6 @@ public class BlockArbDoor extends BlockDoor implements IWoodTyped, IItemModelReg
|
||||
}
|
||||
|
||||
private Item getItem() {
|
||||
return TreeManager.woodItemAccess.getDoor(woodType).getItem();
|
||||
return TreeManager.woodAccess.getDoor(woodType).getItem();
|
||||
}
|
||||
}
|
||||
@@ -206,7 +206,7 @@ public abstract class BlockArbFence extends BlockFence implements IWoodTyped, II
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
for (EnumWoodType woodType : getVariant().getAllowedValues()) {
|
||||
list.add(TreeManager.woodItemAccess.getFence(woodType, fireproof));
|
||||
list.add(TreeManager.woodAccess.getFence(woodType, fireproof));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class BlockArbFenceGate extends BlockFenceGate implements IWoodTyped, IIt
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
list.add(TreeManager.woodItemAccess.getFenceGate(woodType, fireproof));
|
||||
list.add(TreeManager.woodAccess.getFenceGate(woodType, fireproof));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -173,7 +173,7 @@ public abstract class BlockArbLog extends BlockLog implements IWoodTyped, IState
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
for (EnumWoodType woodType : getVariant().getAllowedValues()) {
|
||||
list.add(TreeManager.woodItemAccess.getLog(woodType, fireproof));
|
||||
list.add(TreeManager.woodAccess.getLog(woodType, fireproof));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ public abstract class BlockArbPlanks extends Block implements IWoodTyped, IState
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
for (EnumWoodType woodType : getVariant().getAllowedValues()) {
|
||||
list.add(TreeManager.woodItemAccess.getPlanks(woodType, fireproof));
|
||||
list.add(TreeManager.woodAccess.getPlanks(woodType, fireproof));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
|
||||
EnumWoodType woodType = state.getValue(getVariant());
|
||||
ItemStack slab = TreeManager.woodItemAccess.getSlab(woodType, isFireproof());
|
||||
ItemStack slab = TreeManager.woodAccess.getSlab(woodType, isFireproof());
|
||||
return slab.getItem();
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
@Override
|
||||
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) {
|
||||
EnumWoodType woodType = state.getValue(getVariant());
|
||||
ItemStack slab = TreeManager.woodItemAccess.getSlab(woodType, isFireproof());
|
||||
ItemStack slab = TreeManager.woodAccess.getSlab(woodType, isFireproof());
|
||||
return new ItemStack(slab.getItem(), 1, getMetaFromState(state));
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List<ItemStack> list) {
|
||||
if (!isDouble()) {
|
||||
for (EnumWoodType woodType : getVariant().getAllowedValues()) {
|
||||
list.add(TreeManager.woodItemAccess.getSlab(woodType, fireproof));
|
||||
list.add(TreeManager.woodAccess.getSlab(woodType, fireproof));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleTreeSpeciesBuilder treeSpecies) {
|
||||
|
||||
treeSpecies.setComplexity(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1026,7 +1026,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
} else {
|
||||
AlleleBoolean fireproofAllele = (AlleleBoolean) genome.getActiveAllele(EnumTreeChromosome.FIREPROOF);
|
||||
boolean fireproof = fireproofAllele.getValue();
|
||||
ItemStack log = TreeManager.woodItemAccess.getLog(woodType, fireproof);
|
||||
ItemStack log = TreeManager.woodAccess.getLog(woodType, fireproof);
|
||||
|
||||
BlockTypeLog logBlock = new BlockTypeLog(log);
|
||||
logBlock.setDirection(facing);
|
||||
|
||||
@@ -42,12 +42,12 @@ public class Constants implements IForestryConstants {
|
||||
public static final String TEXTURE_APIARIST_ARMOR_PRIMARY = TEXTURE_PATH_ITEMS + "/apiarist_armor_1.png";
|
||||
public static final String TEXTURE_APIARIST_ARMOR_SECONDARY = TEXTURE_PATH_ITEMS + "/apiarist_armor_2.png";
|
||||
public static final String TEXTURE_NATURALIST_ARMOR_PRIMARY = TEXTURE_PATH_ITEMS + "/naturalist_armor_1.png";
|
||||
public static final String TEXTURE_SKIN_BEEKPEEPER = TEXTURE_PATH_ENTITIES + "/beekeeper.png";
|
||||
public static final String TEXTURE_SKIN_LUMBERJACK = TEXTURE_PATH_ENTITIES + "/lumberjack.png";
|
||||
public static final String TEXTURE_SKIN_BEEKPEEPER = RESOURCE_ID + ":" + TEXTURE_PATH_ENTITIES + "/beekeeper.png";
|
||||
public static final String TEXTURE_SKIN_LUMBERJACK = RESOURCE_ID + ":" + TEXTURE_PATH_ENTITIES + "/lumberjack.png";
|
||||
|
||||
// Villagers
|
||||
public static final int ID_VILLAGER_BEEKEEPER = 80;
|
||||
public static final int ID_VILLAGER_LUMBERJACK = 81;
|
||||
public static final String ID_VILLAGER_APIARIST = RESOURCE_ID + ":apiarist";
|
||||
public static final String ID_VILLAGER_ARBORIST = RESOURCE_ID + ":arborist";
|
||||
|
||||
// Village Loot Key
|
||||
public static final ResourceLocation VILLAGE_NATURALIST_LOOT_KEY = new ResourceLocation(RESOURCE_ID, "chests/village_naturalist");
|
||||
@@ -127,13 +127,13 @@ public class Constants implements IForestryConstants {
|
||||
public static final int CARPENTER_CRATING_LIQUID_QUANTITY = 100;
|
||||
|
||||
@Override
|
||||
public int getApicultureVillagerID() {
|
||||
return ID_VILLAGER_BEEKEEPER;
|
||||
public String getApicultureVillagerID() {
|
||||
return ID_VILLAGER_APIARIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArboricultureVillagerID() {
|
||||
return ID_VILLAGER_LUMBERJACK;
|
||||
public String getArboricultureVillagerID() {
|
||||
return ID_VILLAGER_ARBORIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -192,7 +192,7 @@ public class AlleleRegistry implements IAlleleRegistry {
|
||||
return Collections.unmodifiableSet(allelesByType.get(type));
|
||||
}
|
||||
|
||||
// This method is not useful until all mod addon alleles are registered with their valid IChromosomeTypes
|
||||
@Override
|
||||
public Collection<IChromosomeType> getChromosomeTypes(IAllele allele) {
|
||||
return Collections.unmodifiableSet(typesByAllele.get(allele));
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpeciesBuil
|
||||
private boolean isCounted = true;
|
||||
private EnumTemperature climate = EnumTemperature.NORMAL;
|
||||
private EnumHumidity humidity = EnumHumidity.NORMAL;
|
||||
private Integer complexityOverride = null;
|
||||
|
||||
protected AlleleSpecies(@Nonnull String uid,
|
||||
@Nonnull String unlocalizedName,
|
||||
@@ -99,9 +100,17 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpeciesBuil
|
||||
|
||||
@Override
|
||||
public int getComplexity() {
|
||||
if (complexityOverride != null) {
|
||||
return complexityOverride;
|
||||
}
|
||||
return GeneticsUtil.getResearchComplexity(this, getRoot().getKaryotypeKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComplexity(int complexity) {
|
||||
this.complexityOverride = complexity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) {
|
||||
ItemStack research = null;
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
package forestry.core.utils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.village.MerchantRecipe;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
|
||||
import forestry.apiculture.PluginApiculture;
|
||||
|
||||
public class VillagerTradeLists {
|
||||
/**
|
||||
* Copy of {@link net.minecraft.entity.passive.EntityVillager.ItemAndEmeraldToItem}
|
||||
* that takes ItemStacks as parameters and has emerald price info
|
||||
*/
|
||||
public static class GiveItemForItemAndEmerald implements EntityVillager.ITradeList {
|
||||
@Nonnull
|
||||
public ItemStack buyingItemStack;
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo buyingPriceInfo;
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo emeraldPriceInfo;
|
||||
@Nonnull
|
||||
public ItemStack sellingItemstack;
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo sellingPriceInfo;
|
||||
|
||||
public GiveItemForItemAndEmerald(
|
||||
@Nonnull ItemStack buyingItemStack,
|
||||
@Nullable EntityVillager.PriceInfo buyingPriceInfo,
|
||||
@Nullable EntityVillager.PriceInfo emeraldPriceInfo,
|
||||
@Nonnull ItemStack sellingItemstack,
|
||||
@Nullable EntityVillager.PriceInfo sellingPriceInfo) {
|
||||
this.buyingItemStack = buyingItemStack;
|
||||
this.buyingPriceInfo = buyingPriceInfo;
|
||||
this.emeraldPriceInfo = emeraldPriceInfo;
|
||||
this.sellingItemstack = sellingItemstack;
|
||||
this.sellingPriceInfo = sellingPriceInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) {
|
||||
int buyAmount = 1;
|
||||
if (this.buyingPriceInfo != null) {
|
||||
buyAmount = this.buyingPriceInfo.getPrice(random);
|
||||
}
|
||||
|
||||
int emeraldAmount = 1;
|
||||
if (this.emeraldPriceInfo != null) {
|
||||
emeraldAmount = this.emeraldPriceInfo.getPrice(random);
|
||||
}
|
||||
|
||||
int sellAmount = 1;
|
||||
if (this.sellingPriceInfo != null) {
|
||||
sellAmount = this.sellingPriceInfo.getPrice(random);
|
||||
}
|
||||
|
||||
ItemStack buyItemStack = this.buyingItemStack.copy();
|
||||
buyItemStack.stackSize = buyAmount;
|
||||
ItemStack sellItemStack = this.sellingItemstack.copy();
|
||||
sellItemStack.stackSize = sellAmount;
|
||||
recipeList.add(new MerchantRecipe(buyItemStack, new ItemStack(Items.EMERALD, emeraldAmount, 0), sellItemStack));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy of {@link EntityVillager.EmeraldForItems}
|
||||
* that takes itemStack as a parameter
|
||||
*/
|
||||
public static class GiveEmeraldForItems implements EntityVillager.ITradeList {
|
||||
public ItemStack buyingItem;
|
||||
public EntityVillager.PriceInfo price;
|
||||
|
||||
public GiveEmeraldForItems(ItemStack itemIn, EntityVillager.PriceInfo priceIn) {
|
||||
this.buyingItem = itemIn;
|
||||
this.price = priceIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Affects the given MerchantRecipeList to possibly add or remove MerchantRecipes.
|
||||
*/
|
||||
@Override
|
||||
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) {
|
||||
int buyAmount = 1;
|
||||
if (this.price != null) {
|
||||
buyAmount = this.price.getPrice(random);
|
||||
}
|
||||
|
||||
ItemStack itemToBuy = this.buyingItem.copy();
|
||||
itemToBuy.stackSize = buyAmount;
|
||||
recipeList.add(new MerchantRecipe(itemToBuy, Items.EMERALD));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy of {@link EntityVillager.ListItemForEmeralds}
|
||||
* that copies itemStacks properly
|
||||
*/
|
||||
public static class GiveItemForEmeralds implements EntityVillager.ITradeList {
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo emeraldPriceInfo;
|
||||
@Nonnull
|
||||
public ItemStack itemToSell;
|
||||
@Nullable
|
||||
public EntityVillager.PriceInfo sellInfo;
|
||||
|
||||
public GiveItemForEmeralds(@Nullable EntityVillager.PriceInfo emeraldPriceInfo, @Nonnull ItemStack itemToSell, @Nullable EntityVillager.PriceInfo sellInfo) {
|
||||
this.emeraldPriceInfo = emeraldPriceInfo;
|
||||
this.itemToSell = itemToSell;
|
||||
this.sellInfo = sellInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) {
|
||||
int i = 1;
|
||||
if (this.sellInfo != null) {
|
||||
i = this.sellInfo.getPrice(random);
|
||||
}
|
||||
|
||||
int j = 1;
|
||||
if (this.emeraldPriceInfo != null) {
|
||||
j = this.emeraldPriceInfo.getPrice(random);
|
||||
}
|
||||
|
||||
ItemStack sellStack = this.itemToSell.copy();
|
||||
sellStack.stackSize = i;
|
||||
|
||||
ItemStack emeralds = new ItemStack(Items.EMERALD, j);
|
||||
|
||||
recipeList.add(new MerchantRecipe(emeralds, sellStack));
|
||||
}
|
||||
}
|
||||
|
||||
public static class GiveItemForLogsAndEmeralds implements EntityVillager.ITradeList {
|
||||
@Nonnull
|
||||
public ItemStack itemToSell;
|
||||
@Nonnull
|
||||
public EntityVillager.PriceInfo itemInfo;
|
||||
@Nonnull
|
||||
public EntityVillager.PriceInfo logsInfo;
|
||||
@Nonnull
|
||||
public EntityVillager.PriceInfo emeraldsInfo;
|
||||
|
||||
public GiveItemForLogsAndEmeralds(@Nonnull ItemStack itemToSell, @Nonnull EntityVillager.PriceInfo itemInfo, @Nonnull EntityVillager.PriceInfo logsInfo, @Nonnull EntityVillager.PriceInfo emeraldsInfo) {
|
||||
this.itemToSell = itemToSell;
|
||||
this.itemInfo = itemInfo;
|
||||
this.logsInfo = logsInfo;
|
||||
this.emeraldsInfo = emeraldsInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) {
|
||||
int itemAmount = this.itemInfo.getPrice(random);
|
||||
int emeraldsAmount = this.emeraldsInfo.getPrice(random);
|
||||
int logsAmount = this.logsInfo.getPrice(random);
|
||||
|
||||
ItemStack itemToSell = this.itemToSell.copy();
|
||||
itemToSell.stackSize = itemAmount;
|
||||
|
||||
int logMeta = random.nextInt(6);
|
||||
Block log;
|
||||
if (logMeta < 4) {
|
||||
log = Blocks.LOG;
|
||||
} else {
|
||||
log = Blocks.LOG2;
|
||||
logMeta -= 4;
|
||||
}
|
||||
ItemStack randomLog = new ItemStack(log, logsAmount, logMeta);
|
||||
|
||||
recipeList.add(new MerchantRecipe(randomLog, new ItemStack(Items.EMERALD, emeraldsAmount), itemToSell));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user