Fixes
This commit is contained in:
parent
42ef270e2e
commit
b47607cb6a
3 changed files with 53 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
|||
package ru.betterend.util.sdf;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
@ -10,15 +11,17 @@ import net.minecraft.util.math.Direction;
|
|||
public class PosInfo implements Comparable<PosInfo> {
|
||||
private static final BlockState AIR = Blocks.AIR.getDefaultState();
|
||||
private final Map<BlockPos, PosInfo> blocks;
|
||||
private final Set<PosInfo> add;
|
||||
private final BlockPos pos;
|
||||
private BlockState state;
|
||||
|
||||
public static PosInfo create(Map<BlockPos, PosInfo> blocks, BlockPos pos) {
|
||||
return new PosInfo(blocks, pos);
|
||||
public static PosInfo create(Map<BlockPos, PosInfo> blocks, Set<PosInfo> add, BlockPos pos) {
|
||||
return new PosInfo(blocks, add, pos);
|
||||
}
|
||||
|
||||
private PosInfo(Map<BlockPos, PosInfo> blocks, BlockPos pos) {
|
||||
private PosInfo(Map<BlockPos, PosInfo> blocks, Set<PosInfo> add, BlockPos pos) {
|
||||
this.blocks = blocks;
|
||||
this.add = add;
|
||||
this.pos = pos;
|
||||
blocks.put(pos, this);
|
||||
}
|
||||
|
@ -55,10 +58,12 @@ public class PosInfo implements Comparable<PosInfo> {
|
|||
return getState(Direction.DOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return pos.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof PosInfo)) {
|
||||
return false;
|
||||
|
@ -74,4 +79,10 @@ public class PosInfo implements Comparable<PosInfo> {
|
|||
public BlockPos getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public void setBlockPos(BlockPos pos, BlockState state) {
|
||||
PosInfo info = new PosInfo(blocks, add, pos);
|
||||
info.state = state;
|
||||
add.add(info);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ public abstract class SDF {
|
|||
|
||||
public void fillRecursive(ServerWorldAccess world, BlockPos start, int dx, int dy, int dz) {
|
||||
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
|
||||
Set<PosInfo> addInfo = Sets.newHashSet();
|
||||
Set<BlockPos> blocks = Sets.newHashSet();
|
||||
Set<BlockPos> ends = Sets.newHashSet();
|
||||
Set<BlockPos> add = Sets.newHashSet();
|
||||
|
@ -60,7 +61,7 @@ public abstract class SDF {
|
|||
if (!blocks.contains(pos) && canReplace.apply(world.getBlockState(wpos))) {
|
||||
if (this.getDistance(pos.getX(), pos.getY(), pos.getZ()) < 0) {
|
||||
BlockState state = getBlockState(wpos);
|
||||
PosInfo.create(mapWorld, wpos).setState(state);
|
||||
PosInfo.create(mapWorld, addInfo, wpos).setState(state);
|
||||
if (Math.abs(pos.getX()) < dx && Math.abs(pos.getY()) < dy && Math.abs(pos.getZ()) < dz) {
|
||||
add.add(pos);
|
||||
}
|
||||
|
@ -85,10 +86,18 @@ public abstract class SDF {
|
|||
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||
});
|
||||
}
|
||||
|
||||
addInfo.forEach((info) -> {
|
||||
if (canReplace.apply(world.getBlockState(info.getPos()))) {
|
||||
BlockState state = postProcess.apply(info);
|
||||
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void fillRecursive(ServerWorldAccess world, BlockPos start) {
|
||||
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
|
||||
Set<PosInfo> addInfo = Sets.newHashSet();
|
||||
Set<BlockPos> blocks = Sets.newHashSet();
|
||||
Set<BlockPos> ends = Sets.newHashSet();
|
||||
Set<BlockPos> add = Sets.newHashSet();
|
||||
|
@ -104,7 +113,7 @@ public abstract class SDF {
|
|||
if (!blocks.contains(pos) && canReplace.apply(world.getBlockState(wpos))) {
|
||||
if (this.getDistance(pos.getX(), pos.getY(), pos.getZ()) < 0) {
|
||||
BlockState state = getBlockState(wpos);
|
||||
PosInfo.create(mapWorld, wpos).setState(state);
|
||||
PosInfo.create(mapWorld, addInfo, wpos).setState(state);
|
||||
add.add(pos);
|
||||
}
|
||||
}
|
||||
|
@ -119,11 +128,6 @@ public abstract class SDF {
|
|||
run &= !ends.isEmpty();
|
||||
}
|
||||
|
||||
mapWorld.forEach((pos, info) -> {
|
||||
BlockState state = postProcess.apply(info);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, state);
|
||||
});
|
||||
|
||||
List<PosInfo> infos = new ArrayList<PosInfo>(mapWorld.values());
|
||||
if (infos.size() > 0) {
|
||||
Collections.sort(infos);
|
||||
|
@ -132,10 +136,18 @@ public abstract class SDF {
|
|||
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||
});
|
||||
}
|
||||
|
||||
addInfo.forEach((info) -> {
|
||||
if (canReplace.apply(world.getBlockState(info.getPos()))) {
|
||||
BlockState state = postProcess.apply(info);
|
||||
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void fillRecursive(StructureWorld world, BlockPos start) {
|
||||
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
|
||||
Set<PosInfo> addInfo = Sets.newHashSet();
|
||||
Set<BlockPos> blocks = Sets.newHashSet();
|
||||
Set<BlockPos> ends = Sets.newHashSet();
|
||||
Set<BlockPos> add = Sets.newHashSet();
|
||||
|
@ -151,7 +163,7 @@ public abstract class SDF {
|
|||
if (!blocks.contains(pos)) {
|
||||
if (this.getDistance(pos.getX(), pos.getY(), pos.getZ()) < 0) {
|
||||
BlockState state = getBlockState(wpos);
|
||||
PosInfo.create(mapWorld, wpos).setState(state);
|
||||
PosInfo.create(mapWorld, addInfo, wpos).setState(state);
|
||||
add.add(pos);
|
||||
}
|
||||
}
|
||||
|
@ -167,10 +179,16 @@ public abstract class SDF {
|
|||
}
|
||||
|
||||
List<PosInfo> infos = new ArrayList<PosInfo>(mapWorld.values());
|
||||
infos.addAll(addInfo);
|
||||
Collections.sort(infos);
|
||||
infos.forEach((info) -> {
|
||||
BlockState state = postProcess.apply(info);
|
||||
world.setBlock(info.getPos(), state);
|
||||
});
|
||||
|
||||
addInfo.forEach((info) -> {
|
||||
BlockState state = postProcess.apply(info);
|
||||
world.setBlock(info.getPos(), state);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,11 +9,13 @@ import net.minecraft.block.Material;
|
|||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.blocks.BlockMossyGlowshroomCap;
|
||||
import ru.betterend.blocks.basis.BlockGlowingFur;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.registry.BlockTagRegistry;
|
||||
|
@ -130,6 +132,17 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
|||
info.setState(BlockRegistry.MOSSY_GLOWSHROOM_CAP.getDefaultState());
|
||||
return info.getState();
|
||||
}
|
||||
else if (info.getState().getBlock() == BlockRegistry.MOSSY_GLOWSHROOM_HYMENOPHORE) {
|
||||
for (Direction dir: BlocksHelper.HORIZONTAL) {
|
||||
if (info.getState(dir) == AIR) {
|
||||
info.setBlockPos(info.getPos().offset(dir), BlockRegistry.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(BlockGlowingFur.FACING, dir));
|
||||
}
|
||||
}
|
||||
|
||||
if (info.getStateDown() == AIR) {
|
||||
info.setBlockPos(info.getPos().down(), BlockRegistry.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(BlockGlowingFur.FACING, Direction.DOWN));
|
||||
}
|
||||
}
|
||||
return info.getState();
|
||||
})
|
||||
.fillRecursive(world, blockPos);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue