Fixed leaves cascade update, basic structure classes separation
This commit is contained in:
parent
d87b98fcd7
commit
d0135e83e9
16 changed files with 136 additions and 53 deletions
|
@ -11,7 +11,6 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.Property;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
|
@ -287,31 +286,4 @@ public class BlocksHelper {
|
|||
public static Direction randomHorizontal(Random random) {
|
||||
return HORIZONTAL[random.nextInt(4)];
|
||||
}
|
||||
|
||||
public static BlockState getLeavesState(BlockState state, WorldAccess world, BlockPos pos) {
|
||||
int i = 7;
|
||||
BlockPos.Mutable mutable = new BlockPos.Mutable();
|
||||
Direction[] var5 = Direction.values();
|
||||
int var6 = var5.length;
|
||||
|
||||
for (int var7 = 0; var7 < var6; ++var7) {
|
||||
Direction direction = var5[var7];
|
||||
mutable.set(pos, direction);
|
||||
i = Math.min(i, getDistanceFromLog(world.getBlockState(mutable)) + 1);
|
||||
if (i == 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (BlockState) state.with(LeavesBlock.DISTANCE, i);
|
||||
}
|
||||
|
||||
private static int getDistanceFromLog(BlockState state) {
|
||||
if (BlockTags.LOGS.contains(state.getBlock())) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return state.getBlock() instanceof LeavesBlock ? (Integer) state.get(LeavesBlock.DISTANCE) : 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,10 +29,26 @@ public class PosInfo implements Comparable<PosInfo> {
|
|||
return state;
|
||||
}
|
||||
|
||||
public BlockState getState(BlockPos pos) {
|
||||
PosInfo info = blocks.get(pos);
|
||||
if (info == null) {
|
||||
info = add.get(pos);
|
||||
return info == null ? AIR : info.getState();
|
||||
}
|
||||
return info.getState();
|
||||
}
|
||||
|
||||
public void setState(BlockState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public void setState(BlockPos pos, BlockState state) {
|
||||
PosInfo info = blocks.get(pos);
|
||||
if (info != null) {
|
||||
info.setState(state);
|
||||
}
|
||||
}
|
||||
|
||||
public BlockState getState(Direction dir) {
|
||||
PosInfo info = blocks.get(pos.offset(dir));
|
||||
if (info == null) {
|
||||
|
|
|
@ -236,8 +236,10 @@ public abstract class SDF {
|
|||
if (infos.size() > 0) {
|
||||
Collections.sort(infos);
|
||||
infos.forEach((info) -> {
|
||||
BlockState state = postProcess.apply(info);
|
||||
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||
info.setState(postProcess.apply(info));
|
||||
});
|
||||
infos.forEach((info) -> {
|
||||
BlocksHelper.setWithoutUpdate(world, info.getPos(), info.getState());
|
||||
});
|
||||
|
||||
infos.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue