mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Keep leaves from cutting logs
Ported from v3e (3ba277aa4). Overlapping objects wrote over each other block by block, so one tree's leaves could cut another tree's trunk and leave the top floating. Leaves now keep a log already placed there, as in vanilla trees.
This commit is contained in:
1 parent
d65da98624
commit
501862b9ea
1 file changed
+16
-6
@@ -52,7 +52,7 @@ import java.util.Set;
|
|||||||
* Module {@code iris:blocks}: writes the object's blocks where the placement puts them, then its markers.
|
* Module {@code iris:blocks}: writes the object's blocks where the placement puts them, then its markers.
|
||||||
* Each block is turned with the object, edited, warped, painted onto its column when the mode paints,
|
* Each block is turned with the object, edited, warped, painted onto its column when the mode paints,
|
||||||
* waterlogged in water and attached to the faces vines can hang from. Air is not written, except by
|
* waterlogged in water and attached to the faces vines can hang from. Air is not written, except by
|
||||||
* structure pieces, and neither is a vine into a solid block or a melded block into open space.
|
* structure pieces, and neither is a vine into a solid block, leaves onto a log or a melded block into open space.
|
||||||
*/
|
*/
|
||||||
public final class BlocksModule implements IrisModule {
|
public final class BlocksModule implements IrisModule {
|
||||||
private static final Set<String> AIR_MATERIALS = Set.of("minecraft:air", "minecraft:cave_air");
|
private static final Set<String> AIR_MATERIALS = Set.of("minecraft:air", "minecraft:cave_air");
|
||||||
@@ -156,13 +156,23 @@ public final class BlocksModule implements IrisModule {
|
|||||||
if (world.has(data, BlockTrait.CUSTOM)) {
|
if (world.has(data, BlockTrait.CUSTOM)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean vineIntoSolid = world.has(data, BlockTrait.VINE) && world.isSolid(x, y, z);
|
return shouldPlaceObjectBlock(structurePiece, AIR_MATERIALS.contains(data.material().toString()), keepsExisting(world, data, x, y, z));
|
||||||
return shouldPlaceObjectBlock(structurePiece, AIR_MATERIALS.contains(data.material().toString()), vineIntoSolid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Air is written only by structure pieces, and a vine never replaces a solid block. */
|
/**
|
||||||
static boolean shouldPlaceObjectBlock(boolean structurePiece, boolean air, boolean vineIntoSolid) {
|
* A vine never replaces a solid block, and leaves never cut a log another object already placed, as in vanilla
|
||||||
return !vineIntoSolid && (structurePiece || !air);
|
* trees: the log above the cut would float.
|
||||||
|
*/
|
||||||
|
private static boolean keepsExisting(PlacementWorld world, BlockState data, int x, int y, int z) {
|
||||||
|
if (world.has(data, BlockTrait.VINE)) {
|
||||||
|
return world.isSolid(x, y, z);
|
||||||
|
}
|
||||||
|
return world.has(data, BlockTrait.LEAVES) && world.has(world.get(x, y, z), BlockTrait.LOG);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Air is written only by structure pieces, and nothing is written where the existing block is kept. */
|
||||||
|
static boolean shouldPlaceObjectBlock(boolean structurePiece, boolean air, boolean keepsExisting) {
|
||||||
|
return !keepsExisting && (structurePiece || !air);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Whether a waterloggable block lands in water a waterloggable or underwater placement keeps. */
|
/** Whether a waterloggable block lands in water a waterloggable or underwater placement keeps. */
|
||||||
|
|||||||
Reference in new issue
Block a user