fix structures not generating/ delete faulty mixin overwrite
This commit is contained in:
parent
b1d86815bb
commit
643f1925e7
6 changed files with 22 additions and 52 deletions
|
@ -15,4 +15,15 @@ public class BlockBoxUtil {
|
|||
ChunkPos pos = chunk.getPos();
|
||||
return BlockBox.create(new Vec3i(pos.getStartX(), chunk.getBottomY(), pos.getStartZ()), new Vec3i(pos.getEndX(), chunk.getTopY() - 1, pos.getEndZ()));
|
||||
}
|
||||
|
||||
public static BlockBox intersect(BlockBox box1, BlockBox box2) {
|
||||
int minX = Math.max(box1.getMinX(), box2.getMinX());
|
||||
int minY = Math.max(box1.getMinY(), box2.getMinY());
|
||||
int minZ = Math.max(box1.getMinZ(), box2.getMinZ());
|
||||
int maxX = Math.min(box1.getMaxX(), box2.getMaxX());
|
||||
int maxY = Math.min(box1.getMaxY(), box2.getMaxY());
|
||||
int maxZ = Math.min(box1.getMaxZ(), box2.getMaxZ());
|
||||
|
||||
return new BlockBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
package org.dimdev.dimdoors.mixin;
|
||||
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
// TODO: DELETE WHEN MOJANK BUG FIXED
|
||||
@Mixin(BlockBox.class)
|
||||
public class BlockBoxMixin {
|
||||
@Shadow
|
||||
private int minX;
|
||||
@Shadow
|
||||
private int minY;
|
||||
@Shadow
|
||||
private int minZ;
|
||||
@Shadow
|
||||
private int maxX;
|
||||
@Shadow
|
||||
private int maxY;
|
||||
@Shadow
|
||||
private int maxZ;
|
||||
|
||||
|
||||
/**
|
||||
* @author CreepyCre
|
||||
* @reason method is bugged, currently does the same as {@link net.minecraft.util.math.BlockBox#encompass(net.minecraft.util.math.BlockPos pos)}
|
||||
*/
|
||||
@Overwrite
|
||||
public BlockBox encompass(BlockBox box) {
|
||||
this.minX = Math.max(this.minX, box.getMinX());
|
||||
this.minY = Math.max(this.minY, box.getMinY());
|
||||
this.minZ = Math.max(this.minZ, box.getMinZ());
|
||||
this.maxX = Math.min(this.maxX, box.getMaxX());
|
||||
this.maxY = Math.min(this.maxY, box.getMaxY());
|
||||
this.maxZ = Math.min(this.maxZ, box.getMaxZ());
|
||||
return (BlockBox) (Object) this;
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ public abstract class WorldMixin {
|
|||
since then a large part of the method would need to be canceled. This is rather hacky, but it should fulfill the purpose best
|
||||
~CreepyCre
|
||||
*/
|
||||
@ModifyVariable(method = "Lnet/minecraft/world/World;breakBlock(Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/entity/Entity;I)Z",
|
||||
@ModifyVariable(method = "breakBlock(Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/entity/Entity;I)Z",
|
||||
at = @At(value = "INVOKE_ASSIGN",
|
||||
target = "Lnet/minecraft/world/World;getFluidState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/fluid/FluidState;",
|
||||
ordinal = 0))
|
||||
|
@ -48,7 +48,7 @@ public abstract class WorldMixin {
|
|||
return new CustomBreakBlock.HackyFluidState(pair.getLeft(), pair.getRight());
|
||||
}
|
||||
|
||||
@Inject(method = "Lnet/minecraft/world/World;breakBlock(Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/entity/Entity;I)Z",
|
||||
@Inject(method = "breakBlock(Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/entity/Entity;I)Z",
|
||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;II)Z",
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ShellModifier implements LazyModifier {
|
|||
// x-planes
|
||||
temp = BlockBox.create(new Vec3i(boxToDrawAround.getMaxX() + 1 + boxExpansion, boxToDrawAround.getMinY() - thickness - boxExpansion, boxToDrawAround.getMinZ() - thickness - boxExpansion), new Vec3i(boxToDrawAround.getMaxX() + thickness + boxExpansion, boxToDrawAround.getMaxY() + thickness + boxExpansion, boxToDrawAround.getMaxZ() + thickness + boxExpansion));
|
||||
if (temp.intersects(chunkBox)) {
|
||||
temp = temp.encompass(chunkBox);
|
||||
temp = BlockBoxUtil.intersect(temp, chunkBox);
|
||||
BlockPos.stream(temp)
|
||||
.forEach(blockPos -> {
|
||||
if (chunk.getBlockState(blockPos).isAir()) chunk.setBlockState(blockPos, blockState, false);
|
||||
|
@ -75,7 +75,7 @@ public class ShellModifier implements LazyModifier {
|
|||
}
|
||||
temp = BlockBox.create(new Vec3i(boxToDrawAround.getMinX() - 1 - boxExpansion, boxToDrawAround.getMinY() - thickness - boxExpansion, boxToDrawAround.getMinZ() - thickness - boxExpansion), new Vec3i(boxToDrawAround.getMinX() - thickness - boxExpansion, boxToDrawAround.getMaxY() + thickness + boxExpansion, boxToDrawAround.getMaxZ() + thickness + boxExpansion));
|
||||
if (temp.intersects(chunkBox)) {
|
||||
temp = temp.encompass(chunkBox);
|
||||
temp = BlockBoxUtil.intersect(temp, chunkBox);
|
||||
BlockPos.stream(temp)
|
||||
.forEach(blockPos -> {
|
||||
if (chunk.getBlockState(blockPos).isAir()) chunk.setBlockState(blockPos, blockState, false);
|
||||
|
@ -85,7 +85,7 @@ public class ShellModifier implements LazyModifier {
|
|||
// y-planes
|
||||
temp = BlockBox.create(new Vec3i(boxToDrawAround.getMinX() - boxExpansion, boxToDrawAround.getMaxY() + 1 + boxExpansion, boxToDrawAround.getMinZ() - thickness - boxExpansion), new Vec3i(boxToDrawAround.getMaxX() + boxExpansion, boxToDrawAround.getMaxY() + thickness + boxExpansion, boxToDrawAround.getMaxZ() + thickness + boxExpansion));
|
||||
if (temp.intersects(chunkBox)) {
|
||||
temp = temp.encompass(chunkBox);
|
||||
temp = BlockBoxUtil.intersect(temp, chunkBox);
|
||||
BlockPos.stream(temp)
|
||||
.forEach(blockPos -> {
|
||||
if (chunk.getBlockState(blockPos).getBlock() instanceof AirBlock)
|
||||
|
@ -94,7 +94,7 @@ public class ShellModifier implements LazyModifier {
|
|||
}
|
||||
temp = BlockBox.create(new Vec3i(boxToDrawAround.getMinX() - boxExpansion, boxToDrawAround.getMinY() - 1 - boxExpansion, boxToDrawAround.getMinZ() - thickness - boxExpansion), new Vec3i(boxToDrawAround.getMaxX() + boxExpansion, boxToDrawAround.getMinY() - thickness - boxExpansion, boxToDrawAround.getMaxZ() + thickness + boxExpansion));
|
||||
if (temp.intersects(chunkBox)) {
|
||||
temp = temp.encompass(chunkBox);
|
||||
temp = BlockBoxUtil.intersect(temp, chunkBox);
|
||||
BlockPos.stream(temp)
|
||||
.forEach(blockPos -> {
|
||||
if (chunk.getBlockState(blockPos).isAir()) chunk.setBlockState(blockPos, blockState, false);
|
||||
|
@ -104,7 +104,7 @@ public class ShellModifier implements LazyModifier {
|
|||
// z-planes
|
||||
temp = BlockBox.create(new Vec3i(boxToDrawAround.getMinX() - boxExpansion, boxToDrawAround.getMinY() - boxExpansion, boxToDrawAround.getMinZ() - 1 - boxExpansion), new Vec3i(boxToDrawAround.getMaxX() + boxExpansion, boxToDrawAround.getMaxY() + boxExpansion, boxToDrawAround.getMinZ() - thickness - boxExpansion));
|
||||
if (temp.intersects(chunkBox)) {
|
||||
temp = temp.encompass(chunkBox);
|
||||
temp = BlockBoxUtil.intersect(temp, chunkBox);
|
||||
BlockPos.stream(temp)
|
||||
.forEach(blockPos -> {
|
||||
if (chunk.getBlockState(blockPos).isAir()) chunk.setBlockState(blockPos, blockState, false);
|
||||
|
@ -112,7 +112,7 @@ public class ShellModifier implements LazyModifier {
|
|||
}
|
||||
temp = BlockBox.create(new Vec3i(boxToDrawAround.getMinX() - boxExpansion, boxToDrawAround.getMinY() - boxExpansion, boxToDrawAround.getMaxZ() + 1 + boxExpansion), new Vec3i(boxToDrawAround.getMaxX() + boxExpansion, boxToDrawAround.getMaxY() + boxExpansion, boxToDrawAround.getMaxZ() + thickness + boxExpansion));
|
||||
if (temp.intersects(chunkBox)) {
|
||||
temp = temp.encompass(chunkBox);
|
||||
temp = BlockBoxUtil.intersect(temp, chunkBox);
|
||||
BlockPos.stream(temp)
|
||||
.forEach(blockPos -> {
|
||||
if (chunk.getBlockState(blockPos).isAir()) chunk.setBlockState(blockPos, blockState, false);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
"package": "org.dimdev.dimdoors.mixin",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"mixins": [
|
||||
"BlockBoxMixin",
|
||||
"BlockMixin",
|
||||
"DefaultBiomeFeaturesMixin",
|
||||
"ExplosionMixin",
|
||||
|
|
|
@ -143,10 +143,9 @@ public class RelativeBlockSample implements BlockView, ModifiableWorld {
|
|||
ChunkPos pos = chunk.getPos();
|
||||
BlockBox chunkBox = BlockBoxUtil.getBox(chunk);
|
||||
Vec3i schemDimensions = new Vec3i(schematic.getWidth(), schematic.getHeight(), schematic.getLength());
|
||||
BlockBox intersection = BlockBox.create(origin, origin.add(schemDimensions).add(-1, -1, -1));
|
||||
if (!intersection.intersects(chunkBox)) return;
|
||||
intersection.encompass(chunkBox);
|
||||
|
||||
BlockBox schemBox = BlockBox.create(origin, origin.add(schemDimensions).add(-1, -1, -1));
|
||||
if (!schemBox.intersects(chunkBox)) return;
|
||||
BlockBox intersection = BlockBoxUtil.intersect(schemBox, chunkBox);
|
||||
|
||||
ServerChunkManager serverChunkManager = world.getChunkManager();
|
||||
|
||||
|
|
Loading…
Reference in a new issue