Fixes
This commit is contained in:
parent
b47607cb6a
commit
d2148baf66
5 changed files with 52 additions and 26 deletions
|
@ -1,7 +1,6 @@
|
|||
package ru.betterend.util.sdf;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
@ -11,15 +10,15 @@ 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 Map<BlockPos, PosInfo> add;
|
||||
private final BlockPos pos;
|
||||
private BlockState state;
|
||||
|
||||
public static PosInfo create(Map<BlockPos, PosInfo> blocks, Set<PosInfo> add, BlockPos pos) {
|
||||
public static PosInfo create(Map<BlockPos, PosInfo> blocks, Map<BlockPos, PosInfo> add, BlockPos pos) {
|
||||
return new PosInfo(blocks, add, pos);
|
||||
}
|
||||
|
||||
private PosInfo(Map<BlockPos, PosInfo> blocks, Set<PosInfo> add, BlockPos pos) {
|
||||
private PosInfo(Map<BlockPos, PosInfo> blocks, Map<BlockPos, PosInfo> add, BlockPos pos) {
|
||||
this.blocks = blocks;
|
||||
this.add = add;
|
||||
this.pos = pos;
|
||||
|
@ -37,7 +36,8 @@ public class PosInfo implements Comparable<PosInfo> {
|
|||
public BlockState getState(Direction dir) {
|
||||
PosInfo info = blocks.get(pos.offset(dir));
|
||||
if (info == null) {
|
||||
return AIR;
|
||||
info = add.get(pos.offset(dir));
|
||||
return info == null ? AIR : info.getState();
|
||||
}
|
||||
return info.getState();
|
||||
}
|
||||
|
@ -83,6 +83,6 @@ public class PosInfo implements Comparable<PosInfo> {
|
|||
public void setBlockPos(BlockPos pos, BlockState state) {
|
||||
PosInfo info = new PosInfo(blocks, add, pos);
|
||||
info.state = state;
|
||||
add.add(info);
|
||||
add.put(pos, info);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +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();
|
||||
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
|
||||
Set<BlockPos> blocks = Sets.newHashSet();
|
||||
Set<BlockPos> ends = Sets.newHashSet();
|
||||
Set<BlockPos> add = Sets.newHashSet();
|
||||
|
@ -85,19 +85,22 @@ public abstract class SDF {
|
|||
BlockState state = postProcess.apply(info);
|
||||
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);
|
||||
}
|
||||
});
|
||||
infos.clear();
|
||||
infos.addAll(addInfo.values());
|
||||
Collections.sort(infos);
|
||||
infos.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();
|
||||
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
|
||||
Set<BlockPos> blocks = Sets.newHashSet();
|
||||
Set<BlockPos> ends = Sets.newHashSet();
|
||||
Set<BlockPos> add = Sets.newHashSet();
|
||||
|
@ -135,19 +138,22 @@ public abstract class SDF {
|
|||
BlockState state = postProcess.apply(info);
|
||||
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||
});
|
||||
|
||||
infos.clear();
|
||||
infos.addAll(addInfo.values());
|
||||
Collections.sort(infos);
|
||||
infos.forEach((info) -> {
|
||||
if (canReplace.apply(world.getBlockState(info.getPos()))) {
|
||||
BlockState state = postProcess.apply(info);
|
||||
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();
|
||||
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
|
||||
Set<BlockPos> blocks = Sets.newHashSet();
|
||||
Set<BlockPos> ends = Sets.newHashSet();
|
||||
Set<BlockPos> add = Sets.newHashSet();
|
||||
|
@ -179,14 +185,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) -> {
|
||||
infos.clear();
|
||||
infos.addAll(addInfo.values());
|
||||
Collections.sort(infos);
|
||||
infos.forEach((info) -> {
|
||||
BlockState state = postProcess.apply(info);
|
||||
world.setBlock(info.getPos(), state);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue