Floating fur fix

This commit is contained in:
paulevsGitch 2020-10-24 01:21:02 +03:00
parent 1afa06c39e
commit ac0c207f36
3 changed files with 22 additions and 4 deletions

View file

@ -34,8 +34,7 @@ public class BlockEndLotusSeed extends BlockUnderwaterPlantWithAge {
TripleShape shape = (height == 0) ? TripleShape.TOP : TripleShape.MIDDLE; TripleShape shape = (height == 0) ? TripleShape.TOP : TripleShape.MIDDLE;
Direction dir = BlocksHelper.randomHorizontal(random); Direction dir = BlocksHelper.randomHorizontal(random);
BlockPos leafCenter = bpos.toImmutable().offset(dir); BlockPos leafCenter = bpos.toImmutable().offset(dir);
boolean hasLeaf = hasLeaf(world, leafCenter); if (hasLeaf(world, leafCenter)) {
if (hasLeaf) {
generateLeaf(world, leafCenter); generateLeaf(world, leafCenter);
BlocksHelper.setWithoutUpdate(world, bpos, startLeaf.with(BlockEndLotusStem.SHAPE, shape).with(BlockEndLotusStem.FACING, dir)); 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); 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); stem = stem.with(BlockEndLotusStem.LEAF, true).with(BlockEndLotusStem.FACING, dir);
} }

View file

@ -1,5 +1,6 @@
package ru.betterend.entity; package ru.betterend.entity;
import java.util.List;
import java.util.Random; import java.util.Random;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -19,6 +20,7 @@ import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -108,6 +110,8 @@ public class EntityEndFish extends SchoolingFishEntity {
} }
public static boolean canSpawn(EntityType<EntityEndFish> type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { public static boolean canSpawn(EntityType<EntityEndFish> type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) {
return true; Box box = new Box(pos).expand(16);
List<EntityEndFish> list = world.getEntitiesByClass(EntityEndFish.class, box, (entity) -> { return true; });
return list.size() < 9;
} }
} }

View file

@ -3,6 +3,9 @@ package ru.betterend.util;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Random; import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -131,6 +134,7 @@ public class BlocksHelper {
public static void fixBlocks(WorldAccess world, BlockPos start, BlockPos end) { public static void fixBlocks(WorldAccess world, BlockPos start, BlockPos end) {
BlockState state; BlockState state;
Set<BlockPos> doubleCheck = Sets.newHashSet();
for (int x = start.getX(); x <= end.getX(); x++) { for (int x = start.getX(); x <= end.getX(); x++) {
POS.setX(x); POS.setX(x);
for (int z = start.getZ(); z <= end.getZ(); z++) { for (int z = start.getZ(); z <= end.getZ(); z++) {
@ -139,6 +143,10 @@ public class BlocksHelper {
POS.setY(y); POS.setY(y);
state = world.getBlockState(POS); state = world.getBlockState(POS);
if (state.getBlock() instanceof BlockGlowingFur) {
doubleCheck.add(POS.toImmutable());
}
// Liquids // Liquids
if (!state.getFluidState().isEmpty()) { if (!state.getFluidState().isEmpty()) {
POS.setY(y - 1); 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) { public static boolean isEndNylium(Block block) {