Merge remote-tracking branch 'origin/master-MC1.12' into master-MC1.12

This commit is contained in:
Nedelosk committed 2017-10-29 14:53:12 +01:00
commit b60554e90a
2 files changed
+35 -9

No files matched your search

@@ -3,8 +3,12 @@ package binnie.extrabees.genetics;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
import forestry.api.genetics.IFlowerAcceptableRule;
import forestry.api.genetics.IFlowerRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -74,8 +78,13 @@ public enum ExtraBeesFlowers implements IFlowerProvider, IAlleleFlowers {
public void register() {
//AlleleManager.alleleRegistry.registerAllele(this);
IFlowerRegistry flowerRegistry = FlowerManager.flowerRegistry;
for (Block block : getAcceptableBlocks()) {
FlowerManager.flowerRegistry.registerAcceptableFlower(block, getUID());
flowerRegistry.registerAcceptableFlower(block, getUID());
}
if (this == ROCK) {
flowerRegistry.registerAcceptableFlowerRule((blockState, world, pos, flowerType) -> blockState.getMaterial() == Material.ROCK, getUID());
}
AlleleManager.alleleRegistry.registerAllele(this, EnumBeeChromosome.FLOWER_PROVIDER);
@@ -90,7 +99,7 @@ public enum ExtraBeesFlowers implements IFlowerProvider, IAlleleFlowers {
return Collections.singletonList(Blocks.REEDS);
}
case ROCK: {
return Collections.singletonList(Blocks.COBBLESTONE);
return ImmutableList.of(Blocks.COBBLESTONE, Blocks.STONE);
}
case BOOK: {
return Collections.singletonList(Blocks.BOOKSHELF);
@@ -2,9 +2,11 @@ package binnie.extrabees.worldgen;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockStateMatcher;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -19,14 +21,29 @@ public class WorldGenHiveRock extends WorldGenHive {
}
@Override
public boolean generate(final World world, final Random random, final BlockPos pos) {
final IBlockState block = world.getBlockState(pos);
if (block.getBlock().isAir(block, world, pos)) {
return false;
public boolean generate(final World world, final Random random, BlockPos pos) {
IBlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
while (block.isReplaceableOreGen(blockState, world, pos, BlockStateMatcher.forBlock(Blocks.STONE)))
{
if (hasAirOnOneSide(world, pos)) {
IBlockState hiveState = ExtraBees.hive.getDefaultState().withProperty(BlockExtraBeeHives.HIVE_TYPE, EnumHiveType.ROCK);
world.setBlockState(pos, hiveState);
return true;
}
pos = pos.down();
blockState = world.getBlockState(pos);
block = blockState.getBlock();
}
if (block.getBlock().isReplaceableOreGen(block, world, pos, BlockStateMatcher.forBlock(Blocks.STONE))) {
world.setBlockState(pos, ExtraBees.hive.getDefaultState().withProperty(BlockExtraBeeHives.HIVE_TYPE, EnumHiveType.ROCK));
return true;
return false;
}
public boolean hasAirOnOneSide(final World world, final BlockPos pos) {
for (EnumFacing facing : EnumFacing.HORIZONTALS) {
BlockPos sidePos = pos.offset(facing);
if (world.isBlockLoaded(sidePos) && world.isAirBlock(sidePos)) {
return true;
}
}
return false;
}