Merge pull request #2025 from temp1011/flowerpot-flowers

Add potted plants as flowers for bees
This commit is contained in:
Nedelosk authored and GitHub committed 2018-03-14 17:03:47 +01:00
commit b74e142ce1
2 files changed
+42 -14

No files matched your search

@@ -22,6 +22,8 @@ import java.util.Random;
import java.util.Set;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.BlockFlowerPot;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.passive.EntityVillager;
@@ -153,9 +155,9 @@ public class ModuleApiculture extends BlankForestryModule {
public static String beekeepingMode = "NORMAL";
public static int ticksPerBeeWorkCycle = 550;
public static boolean hivesDamageOnPeaceful = false;
public static int maxFlowersSpawnedPerHive = 20;
@Nullable
public static VillagerRegistry.VillagerProfession villagerApiarist;
@@ -233,17 +235,17 @@ public class ModuleApiculture extends BlankForestryModule {
// Commands
ModuleCore.rootCommand.addChildCommand(new CommandBee());
if(ModuleManager.getInstance().isModuleEnabled(Constants.MOD_ID, ForestryModuleUids.SORTING)){
if (ModuleManager.getInstance().isModuleEnabled(Constants.MOD_ID, ForestryModuleUids.SORTING)) {
ApicultureFilterRuleType.init();
ApicultureFilterRule.init();
}
}
// TODO: Buildcraft for 1.9
// @Override
// public void registerTriggers() {
// ApicultureTriggers.initialize();
// }
// @Override
// public void registerTriggers() {
// ApicultureTriggers.initialize();
// }
@Override
public void doInit() {
@@ -274,9 +276,9 @@ public class ModuleApiculture extends BlankForestryModule {
String[] blacklist = config.getStringListLocalized("species", "blacklist", Constants.EMPTY_STRINGS);
parseBeeBlacklist(blacklist);
ticksPerBeeWorkCycle = config.getIntLocalized("beekeeping", "ticks.work", 550, 250, 850);
hivesDamageOnPeaceful = config.getBooleanLocalized("beekeeping", "hivedamage.peaceful", false);
config.save();
@@ -406,6 +408,28 @@ public class ModuleApiculture extends BlankForestryModule {
flowerRegistry.registerPlantableFlower(Blocks.BROWN_MUSHROOM.getDefaultState(), 1.0, FlowerManager.FlowerTypeMushrooms);
flowerRegistry.registerPlantableFlower(Blocks.RED_MUSHROOM.getDefaultState(), 1.0, FlowerManager.FlowerTypeMushrooms);
flowerRegistry.registerPlantableFlower(Blocks.CACTUS.getDefaultState(), 1.0, FlowerManager.FlowerTypeCacti);
//Flower Pots
IBlockState flowerPot = Blocks.FLOWER_POT.getBlockState().getBaseState();
PropertyEnum<BlockFlowerPot.EnumFlowerType> CONTENTS = BlockFlowerPot.CONTENTS;
String[] standardTypes = new String[]{FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow};
for (BlockFlowerPot.EnumFlowerType flowerType : BlockFlowerPot.EnumFlowerType.values()) {
if (flowerType == BlockFlowerPot.EnumFlowerType.EMPTY ||
flowerType.getName().contains("sapling") ||
flowerType == BlockFlowerPot.EnumFlowerType.DEAD_BUSH ||
flowerType == BlockFlowerPot.EnumFlowerType.FERN) {
continue;
} else if (flowerType == BlockFlowerPot.EnumFlowerType.MUSHROOM_RED ||
flowerType == BlockFlowerPot.EnumFlowerType.MUSHROOM_BROWN) {
flowerRegistry.registerAcceptableFlower(flowerPot.withProperty(CONTENTS, flowerType), FlowerManager.FlowerTypeMushrooms);
} else if (flowerType == BlockFlowerPot.EnumFlowerType.CACTUS) {
flowerRegistry.registerAcceptableFlower(flowerPot.withProperty(CONTENTS, flowerType), FlowerManager.FlowerTypeCacti);
} else {
flowerRegistry.registerAcceptableFlower(flowerPot.withProperty(CONTENTS, flowerType), standardTypes);
}
}
}
@Override
@@ -510,9 +534,9 @@ public class ModuleApiculture extends BlankForestryModule {
"C",
'B', new ItemStack(blocks.apiary),
'C', Items.MINECART);
for(int blockCount = 0;blockCount < blocks.beeCombs.length;blockCount++){
for (int blockCount = 0; blockCount < blocks.beeCombs.length; blockCount++) {
BlockHoneyComb block = blocks.beeCombs[blockCount];
for(int blockMeta = 0;blockMeta < EnumHoneyComb.VALUES.length - blockCount * 16;blockMeta++){
for (int blockMeta = 0; blockMeta < EnumHoneyComb.VALUES.length - blockCount * 16; blockMeta++) {
int itemMeta = blockMeta + blockCount * 16;
RecipeUtil.addRecipe("comb." + itemMeta, new ItemStack(block, 1, blockMeta),
"###",
@@ -914,8 +938,11 @@ public class ModuleApiculture extends BlankForestryModule {
}
@Override
public void populateChunk(IChunkGenerator chunkGenerator, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) {
if(!world.provider.getDimensionType().equals(DimensionType.THE_END)) return;
public void populateChunk(IChunkGenerator chunkGenerator, World world, Random rand, int chunkX, int chunkZ,
boolean hasVillageGenerated) {
if (!world.provider.getDimensionType().equals(DimensionType.THE_END)) {
return;
}
if (Config.getBeehivesAmount() > 0.0) {
HiveDecorator.decorateHives(world, rand, chunkX, chunkZ);
}
@@ -953,7 +980,7 @@ public class ModuleApiculture extends BlankForestryModule {
return true;
} else if (message.key.equals("blacklist-hives-dimension")) {
int[] dims = message.getNBTValue().getIntArray("dimensions");
for(int dim : dims) {
for (int dim : dims) {
HiveConfig.addBlacklistedDim(dim);
}
return true;
@@ -311,6 +311,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
public boolean test(World world, BlockPos blockPos) {
if (world.isBlockLoaded(blockPos)) {
IBlockState blockState = world.getBlockState(blockPos);
blockState = blockState.getBlock().getActualState(blockState, world, blockPos);
if (!blockState.getBlock().isAir(blockState, world, blockPos)) {
for (IFlowerAcceptableRule acceptableRule : acceptableRules) {
if (acceptableRule.isAcceptableFlower(blockState, world, blockPos, flowerType)) {