diff --git a/src/main/java/ru/betterend/blocks/BlockEndLotusSeed.java b/src/main/java/ru/betterend/blocks/BlockEndLotusSeed.java index 3f0b0a9b..b495a988 100644 --- a/src/main/java/ru/betterend/blocks/BlockEndLotusSeed.java +++ b/src/main/java/ru/betterend/blocks/BlockEndLotusSeed.java @@ -34,8 +34,7 @@ public class BlockEndLotusSeed extends BlockUnderwaterPlantWithAge { TripleShape shape = (height == 0) ? TripleShape.TOP : TripleShape.MIDDLE; Direction dir = BlocksHelper.randomHorizontal(random); BlockPos leafCenter = bpos.toImmutable().offset(dir); - boolean hasLeaf = hasLeaf(world, leafCenter); - if (hasLeaf) { + if (hasLeaf(world, leafCenter)) { generateLeaf(world, leafCenter); BlocksHelper.setWithoutUpdate(world, bpos, startLeaf.with(BlockEndLotusStem.SHAPE, shape).with(BlockEndLotusStem.FACING, dir)); } @@ -70,7 +69,8 @@ public class BlockEndLotusSeed extends BlockUnderwaterPlantWithAge { stem = stem.with(BlockEndLotusStem.WATERLOGGED, true); } } - if (hasLeaf) { + + if (world.getBlockState(bpos.offset(dir)).isOf(BlockRegistry.END_LOTUS_LEAF)) { stem = stem.with(BlockEndLotusStem.LEAF, true).with(BlockEndLotusStem.FACING, dir); } diff --git a/src/main/java/ru/betterend/entity/EntityEndFish.java b/src/main/java/ru/betterend/entity/EntityEndFish.java index 045cad9d..557d81af 100644 --- a/src/main/java/ru/betterend/entity/EntityEndFish.java +++ b/src/main/java/ru/betterend/entity/EntityEndFish.java @@ -1,5 +1,6 @@ package ru.betterend.entity; +import java.util.List; import java.util.Random; import net.minecraft.block.Blocks; @@ -19,6 +20,7 @@ import net.minecraft.particle.ParticleTypes; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Box; import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; @@ -108,6 +110,8 @@ public class EntityEndFish extends SchoolingFishEntity { } public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { - return true; + Box box = new Box(pos).expand(16); + List list = world.getEntitiesByClass(EntityEndFish.class, box, (entity) -> { return true; }); + return list.size() < 9; } } diff --git a/src/main/java/ru/betterend/util/BlocksHelper.java b/src/main/java/ru/betterend/util/BlocksHelper.java index b4256b6d..9a4b34dd 100644 --- a/src/main/java/ru/betterend/util/BlocksHelper.java +++ b/src/main/java/ru/betterend/util/BlocksHelper.java @@ -3,6 +3,9 @@ package ru.betterend.util; import java.util.HashSet; import java.util.Iterator; import java.util.Random; +import java.util.Set; + +import com.google.common.collect.Sets; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -131,6 +134,7 @@ public class BlocksHelper { public static void fixBlocks(WorldAccess world, BlockPos start, BlockPos end) { BlockState state; + Set doubleCheck = Sets.newHashSet(); for (int x = start.getX(); x <= end.getX(); x++) { POS.setX(x); for (int z = start.getZ(); z <= end.getZ(); z++) { @@ -139,6 +143,10 @@ public class BlocksHelper { POS.setY(y); state = world.getBlockState(POS); + if (state.getBlock() instanceof BlockGlowingFur) { + doubleCheck.add(POS.toImmutable()); + } + // Liquids if (!state.getFluidState().isEmpty()) { POS.setY(y - 1); @@ -222,6 +230,12 @@ public class BlocksHelper { } } } + + doubleCheck.forEach((pos) -> { + if (!world.getBlockState(pos).canPlaceAt(world, pos)) { + BlocksHelper.setWithoutUpdate(world, pos, AIR); + } + }); } public static boolean isEndNylium(Block block) {