use of net.minecraft.core.BlockPos.MutableBlockPos in project additionaladditions by Dqu1J.
the class CopperPatinaBlock method updateIndirectNeighbourShapes.
public void updateIndirectNeighbourShapes(BlockState state, LevelAccessor world, BlockPos pos, int flags, int maxUpdateDepth) {
MutableBlockPos mutable = new MutableBlockPos();
Iterator var7 = Plane.HORIZONTAL.iterator();
while (var7.hasNext()) {
Direction direction = (Direction) var7.next();
RedstoneSide wireConnection = (RedstoneSide) state.getValue((Property) DIRECTION_TO_WIRE_CONNECTION_PROPERTY.get(direction));
if (wireConnection != RedstoneSide.NONE && !world.getBlockState(mutable.setWithOffset(pos, direction)).is(this)) {
mutable.move(Direction.DOWN);
BlockState blockState = world.getBlockState(mutable);
if (!blockState.is(Blocks.OBSERVER)) {
BlockPos blockPos = mutable.relative(direction.getOpposite());
BlockState blockState2 = blockState.updateShape(direction.getOpposite(), world.getBlockState(blockPos), world, mutable, blockPos);
updateOrDestroy(blockState, blockState2, world, mutable, flags, maxUpdateDepth);
}
mutable.setWithOffset(pos, direction).move(Direction.UP);
BlockState blockState3 = world.getBlockState(mutable);
if (!blockState3.is(Blocks.OBSERVER)) {
BlockPos blockPos2 = mutable.relative(direction.getOpposite());
BlockState blockState4 = blockState3.updateShape(direction.getOpposite(), world.getBlockState(blockPos2), world, mutable, blockPos2);
updateOrDestroy(blockState3, blockState4, world, mutable, flags, maxUpdateDepth);
}
}
}
}
use of net.minecraft.core.BlockPos.MutableBlockPos in project BCLib by paulevsGitch.
the class SDF method fillRecursive.
public void fillRecursive(StructureWorld world, BlockPos start) {
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
Set<BlockPos> blocks = Sets.newHashSet();
Set<BlockPos> ends = Sets.newHashSet();
Set<BlockPos> add = Sets.newHashSet();
ends.add(new BlockPos(0, 0, 0));
boolean run = true;
MutableBlockPos bPos = new MutableBlockPos();
while (run) {
for (BlockPos center : ends) {
for (Direction dir : Direction.values()) {
bPos.set(center).move(dir);
BlockPos wpos = bPos.offset(start);
if (!blocks.contains(bPos)) {
if (this.getDistance(bPos.getX(), bPos.getY(), bPos.getZ()) < 0) {
BlockState state = getBlockState(wpos);
PosInfo.create(mapWorld, addInfo, wpos).setState(state);
add.add(bPos.immutable());
}
}
}
}
blocks.addAll(ends);
ends.clear();
ends.addAll(add);
add.clear();
run &= !ends.isEmpty();
}
List<PosInfo> infos = new ArrayList<PosInfo>(mapWorld.values());
Collections.sort(infos);
postProcesses.forEach((postProcess) -> {
infos.forEach((info) -> {
info.setState(postProcess.apply(info));
});
});
infos.forEach((info) -> {
world.setBlock(info.getPos(), info.getState());
});
infos.clear();
infos.addAll(addInfo.values());
Collections.sort(infos);
postProcesses.forEach((postProcess) -> {
infos.forEach((info) -> {
info.setState(postProcess.apply(info));
});
});
infos.forEach((info) -> {
world.setBlock(info.getPos(), info.getState());
});
}
use of net.minecraft.core.BlockPos.MutableBlockPos in project BCLib by paulevsGitch.
the class SDF method fillRecursive.
public void fillRecursive(ServerLevelAccessor world, BlockPos start) {
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
Set<BlockPos> blocks = Sets.newHashSet();
Set<BlockPos> ends = Sets.newHashSet();
Set<BlockPos> add = Sets.newHashSet();
ends.add(new BlockPos(0, 0, 0));
boolean run = true;
MutableBlockPos bPos = new MutableBlockPos();
while (run) {
for (BlockPos center : ends) {
for (Direction dir : Direction.values()) {
bPos.set(center).move(dir);
BlockPos wpos = bPos.offset(start);
if (!blocks.contains(bPos) && canReplace.apply(world.getBlockState(wpos))) {
if (this.getDistance(bPos.getX(), bPos.getY(), bPos.getZ()) < 0) {
BlockState state = getBlockState(wpos);
PosInfo.create(mapWorld, addInfo, wpos).setState(state);
add.add(bPos.immutable());
}
}
}
}
blocks.addAll(ends);
ends.clear();
ends.addAll(add);
add.clear();
run &= !ends.isEmpty();
}
List<PosInfo> infos = new ArrayList<PosInfo>(mapWorld.values());
if (infos.size() > 0) {
Collections.sort(infos);
postProcesses.forEach((postProcess) -> {
infos.forEach((info) -> {
info.setState(postProcess.apply(info));
});
});
infos.forEach((info) -> {
BlocksHelper.setWithoutUpdate(world, info.getPos(), info.getState());
});
infos.clear();
infos.addAll(addInfo.values());
Collections.sort(infos);
postProcesses.forEach((postProcess) -> {
infos.forEach((info) -> {
info.setState(postProcess.apply(info));
});
});
infos.forEach((info) -> {
if (canReplace.apply(world.getBlockState(info.getPos()))) {
BlocksHelper.setWithoutUpdate(world, info.getPos(), info.getState());
}
});
}
}
use of net.minecraft.core.BlockPos.MutableBlockPos in project BCLib by paulevsGitch.
the class SDF method fillArea.
public void fillArea(ServerLevelAccessor world, BlockPos center, AABB box) {
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
MutableBlockPos mut = new MutableBlockPos();
for (int y = (int) box.minY; y <= box.maxY; y++) {
mut.setY(y);
for (int x = (int) box.minX; x <= box.maxX; x++) {
mut.setX(x);
for (int z = (int) box.minZ; z <= box.maxZ; z++) {
mut.setZ(z);
if (canReplace.apply(world.getBlockState(mut))) {
BlockPos fpos = mut.subtract(center);
if (this.getDistance(fpos.getX(), fpos.getY(), fpos.getZ()) < 0) {
PosInfo.create(mapWorld, addInfo, mut.immutable()).setState(getBlockState(mut));
}
}
}
}
}
List<PosInfo> infos = new ArrayList<PosInfo>(mapWorld.values());
if (infos.size() > 0) {
Collections.sort(infos);
postProcesses.forEach((postProcess) -> {
infos.forEach((info) -> {
info.setState(postProcess.apply(info));
});
});
infos.forEach((info) -> {
BlocksHelper.setWithoutUpdate(world, info.getPos(), info.getState());
});
infos.clear();
infos.addAll(addInfo.values());
Collections.sort(infos);
postProcesses.forEach((postProcess) -> {
infos.forEach((info) -> {
info.setState(postProcess.apply(info));
});
});
infos.forEach((info) -> {
if (canReplace.apply(world.getBlockState(info.getPos()))) {
BlocksHelper.setWithoutUpdate(world, info.getPos(), info.getState());
}
});
}
}
use of net.minecraft.core.BlockPos.MutableBlockPos in project BCLib by paulevsGitch.
the class SDF method fillRecursiveIgnore.
public void fillRecursiveIgnore(ServerLevelAccessor world, BlockPos start, Function<BlockState, Boolean> ignore) {
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
Set<BlockPos> blocks = Sets.newHashSet();
Set<BlockPos> ends = Sets.newHashSet();
Set<BlockPos> add = Sets.newHashSet();
ends.add(new BlockPos(0, 0, 0));
boolean run = true;
MutableBlockPos bPos = new MutableBlockPos();
while (run) {
for (BlockPos center : ends) {
for (Direction dir : Direction.values()) {
bPos.set(center).move(dir);
BlockPos wpos = bPos.offset(start);
BlockState state = world.getBlockState(wpos);
boolean ign = ignore.apply(state);
if (!blocks.contains(bPos) && (ign || canReplace.apply(state))) {
if (this.getDistance(bPos.getX(), bPos.getY(), bPos.getZ()) < 0) {
PosInfo.create(mapWorld, addInfo, wpos).setState(ign ? state : getBlockState(bPos));
add.add(bPos.immutable());
}
}
}
}
blocks.addAll(ends);
ends.clear();
ends.addAll(add);
add.clear();
run &= !ends.isEmpty();
}
List<PosInfo> infos = new ArrayList<PosInfo>(mapWorld.values());
if (infos.size() > 0) {
Collections.sort(infos);
postProcesses.forEach((postProcess) -> {
infos.forEach((info) -> {
info.setState(postProcess.apply(info));
});
});
infos.forEach((info) -> {
BlocksHelper.setWithoutUpdate(world, info.getPos(), info.getState());
});
infos.clear();
infos.addAll(addInfo.values());
Collections.sort(infos);
postProcesses.forEach((postProcess) -> {
infos.forEach((info) -> {
info.setState(postProcess.apply(info));
});
});
infos.forEach((info) -> {
if (canReplace.apply(world.getBlockState(info.getPos()))) {
BlocksHelper.setWithoutUpdate(world, info.getPos(), info.getState());
}
});
}
}
Aggregations