-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb4ab02
commit 46e145a
Showing
2 changed files
with
326 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> | ||
Date: Sat, 22 Jul 2023 16:15:37 +0800 | ||
Subject: [PATCH] Optimize Vine Spread | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/world/level/block/VineBlock.java b/src/main/java/net/minecraft/world/level/block/VineBlock.java | ||
index 10b63e9a4253f5f572cbc717edc6322a98e9e0eb..629b9404683eeff298287568fa1538ddd12aa1bc 100644 | ||
--- a/src/main/java/net/minecraft/world/level/block/VineBlock.java | ||
+++ b/src/main/java/net/minecraft/world/level/block/VineBlock.java | ||
@@ -295,11 +295,8 @@ public class VineBlock extends Block { | ||
boolean flag = true; | ||
Iterable<BlockPos> iterable = BlockPos.betweenClosed(pos.getX() - 4, pos.getY() - 1, pos.getZ() - 4, pos.getX() + 4, pos.getY() + 1, pos.getZ() + 4); | ||
int i = 5; | ||
- Iterator iterator = iterable.iterator(); | ||
- | ||
- while (iterator.hasNext()) { | ||
- BlockPos blockposition1 = (BlockPos) iterator.next(); | ||
|
||
+ for (BlockPos blockposition1 : iterable) { // Leaf - Optimize Vine Spread | ||
if (world.getBlockState(blockposition1).is((Block) this)) { | ||
--i; | ||
if (i <= 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,303 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> | ||
Date: Sat, 22 Jul 2023 16:52:31 +0800 | ||
Subject: [PATCH] Optimize PoweredRail | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/world/level/block/PoweredRailBlock.java b/src/main/java/net/minecraft/world/level/block/PoweredRailBlock.java | ||
index 40893e71fe8447b695350273bef9623bd5accdcd..0ec427fe0e1f85c07585e1a05269c4c38fc3e9f5 100644 | ||
--- a/src/main/java/net/minecraft/world/level/block/PoweredRailBlock.java | ||
+++ b/src/main/java/net/minecraft/world/level/block/PoweredRailBlock.java | ||
@@ -32,22 +32,23 @@ public class PoweredRailBlock extends BaseRailBlock { | ||
boolean flag1 = true; | ||
RailShape blockpropertytrackposition = (RailShape) state.getValue(PoweredRailBlock.SHAPE); | ||
|
||
+ // Leaf start - Optimize PoweredRail swtich | ||
switch (blockpropertytrackposition) { | ||
- case NORTH_SOUTH: | ||
+ case NORTH_SOUTH -> { | ||
if (flag) { | ||
++l; | ||
} else { | ||
--l; | ||
} | ||
- break; | ||
- case EAST_WEST: | ||
+ } | ||
+ case EAST_WEST -> { | ||
if (flag) { | ||
--j; | ||
} else { | ||
++j; | ||
} | ||
- break; | ||
- case ASCENDING_EAST: | ||
+ } | ||
+ case ASCENDING_EAST -> { | ||
if (flag) { | ||
--j; | ||
} else { | ||
@@ -55,10 +56,9 @@ public class PoweredRailBlock extends BaseRailBlock { | ||
++k; | ||
flag1 = false; | ||
} | ||
- | ||
blockpropertytrackposition = RailShape.EAST_WEST; | ||
- break; | ||
- case ASCENDING_WEST: | ||
+ } | ||
+ case ASCENDING_WEST -> { | ||
if (flag) { | ||
--j; | ||
++k; | ||
@@ -66,10 +66,9 @@ public class PoweredRailBlock extends BaseRailBlock { | ||
} else { | ||
++j; | ||
} | ||
- | ||
blockpropertytrackposition = RailShape.EAST_WEST; | ||
- break; | ||
- case ASCENDING_NORTH: | ||
+ } | ||
+ case ASCENDING_NORTH -> { | ||
if (flag) { | ||
++l; | ||
} else { | ||
@@ -77,10 +76,9 @@ public class PoweredRailBlock extends BaseRailBlock { | ||
++k; | ||
flag1 = false; | ||
} | ||
- | ||
blockpropertytrackposition = RailShape.NORTH_SOUTH; | ||
- break; | ||
- case ASCENDING_SOUTH: | ||
+ } | ||
+ case ASCENDING_SOUTH -> { | ||
if (flag) { | ||
++l; | ||
++k; | ||
@@ -88,11 +86,12 @@ public class PoweredRailBlock extends BaseRailBlock { | ||
} else { | ||
--l; | ||
} | ||
- | ||
blockpropertytrackposition = RailShape.NORTH_SOUTH; | ||
+ } | ||
} | ||
+ // Leaf end | ||
|
||
- return this.isSameRailWithPower(world, new BlockPos(j, k, l), flag, distance, blockpropertytrackposition) ? true : flag1 && this.isSameRailWithPower(world, new BlockPos(j, k - 1, l), flag, distance, blockpropertytrackposition); | ||
+ return this.isSameRailWithPower(world, new BlockPos(j, k, l), flag, distance, blockpropertytrackposition) || flag1 && this.isSameRailWithPower(world, new BlockPos(j, k - 1, l), flag, distance, blockpropertytrackposition); // Leaf - Optimize PoweredRail | ||
} | ||
} | ||
|
||
@@ -104,7 +103,7 @@ public class PoweredRailBlock extends BaseRailBlock { | ||
} else { | ||
RailShape blockpropertytrackposition1 = (RailShape) iblockdata.getValue(PoweredRailBlock.SHAPE); | ||
|
||
- return shape == RailShape.EAST_WEST && (blockpropertytrackposition1 == RailShape.NORTH_SOUTH || blockpropertytrackposition1 == RailShape.ASCENDING_NORTH || blockpropertytrackposition1 == RailShape.ASCENDING_SOUTH) ? false : (shape == RailShape.NORTH_SOUTH && (blockpropertytrackposition1 == RailShape.EAST_WEST || blockpropertytrackposition1 == RailShape.ASCENDING_EAST || blockpropertytrackposition1 == RailShape.ASCENDING_WEST) ? false : ((Boolean) iblockdata.getValue(PoweredRailBlock.POWERED) ? (world.hasNeighborSignal(pos) ? true : this.findPoweredRailSignal(world, pos, iblockdata, flag, distance + 1)) : false)); | ||
+ return (shape != RailShape.EAST_WEST || (blockpropertytrackposition1 != RailShape.NORTH_SOUTH && blockpropertytrackposition1 != RailShape.ASCENDING_NORTH && blockpropertytrackposition1 != RailShape.ASCENDING_SOUTH)) && ((shape != RailShape.NORTH_SOUTH || (blockpropertytrackposition1 != RailShape.EAST_WEST && blockpropertytrackposition1 != RailShape.ASCENDING_EAST && blockpropertytrackposition1 != RailShape.ASCENDING_WEST)) && ((Boolean) iblockdata.getValue(PoweredRailBlock.POWERED) && (world.hasNeighborSignal(pos) || this.findPoweredRailSignal(world, pos, iblockdata, flag, distance + 1)))); // Leaf - Optimize PoweredRail | ||
} | ||
} | ||
|
||
@@ -137,119 +136,120 @@ public class PoweredRailBlock extends BaseRailBlock { | ||
|
||
@Override | ||
public BlockState rotate(BlockState state, Rotation rotation) { | ||
+ // Leaf start - Optimize PoweredRail swtich | ||
switch (rotation) { | ||
case CLOCKWISE_180: | ||
switch ((RailShape) state.getValue(PoweredRailBlock.SHAPE)) { | ||
- case ASCENDING_EAST: | ||
+ case ASCENDING_EAST -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_WEST); | ||
- case ASCENDING_WEST: | ||
+ } | ||
+ case ASCENDING_WEST -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_EAST); | ||
- case ASCENDING_NORTH: | ||
+ } | ||
+ case ASCENDING_NORTH -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_SOUTH); | ||
- case ASCENDING_SOUTH: | ||
+ } | ||
+ case ASCENDING_SOUTH -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_NORTH); | ||
- case SOUTH_EAST: | ||
+ } | ||
+ case SOUTH_EAST -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST); | ||
- case SOUTH_WEST: | ||
+ } | ||
+ case SOUTH_WEST -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST); | ||
- case NORTH_WEST: | ||
+ } | ||
+ case NORTH_WEST -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST); | ||
- case NORTH_EAST: | ||
+ } | ||
+ case NORTH_EAST -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST); | ||
+ } | ||
} | ||
case COUNTERCLOCKWISE_90: | ||
- switch ((RailShape) state.getValue(PoweredRailBlock.SHAPE)) { | ||
- case NORTH_SOUTH: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.EAST_WEST); | ||
- case EAST_WEST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_SOUTH); | ||
- case ASCENDING_EAST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_NORTH); | ||
- case ASCENDING_WEST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_SOUTH); | ||
- case ASCENDING_NORTH: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_WEST); | ||
- case ASCENDING_SOUTH: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_EAST); | ||
- case SOUTH_EAST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST); | ||
- case SOUTH_WEST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST); | ||
- case NORTH_WEST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST); | ||
- case NORTH_EAST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST); | ||
- } | ||
+ return switch ((RailShape) state.getValue(PoweredRailBlock.SHAPE)) { | ||
+ case NORTH_SOUTH -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.EAST_WEST); | ||
+ case EAST_WEST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_SOUTH); | ||
+ case ASCENDING_EAST -> | ||
+ (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_NORTH); | ||
+ case ASCENDING_WEST -> | ||
+ (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_SOUTH); | ||
+ case ASCENDING_NORTH -> | ||
+ (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_WEST); | ||
+ case ASCENDING_SOUTH -> | ||
+ (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_EAST); | ||
+ case SOUTH_EAST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST); | ||
+ case SOUTH_WEST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST); | ||
+ case NORTH_WEST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST); | ||
+ case NORTH_EAST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST); | ||
+ }; | ||
case CLOCKWISE_90: | ||
- switch ((RailShape) state.getValue(PoweredRailBlock.SHAPE)) { | ||
- case NORTH_SOUTH: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.EAST_WEST); | ||
- case EAST_WEST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_SOUTH); | ||
- case ASCENDING_EAST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_SOUTH); | ||
- case ASCENDING_WEST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_NORTH); | ||
- case ASCENDING_NORTH: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_EAST); | ||
- case ASCENDING_SOUTH: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_WEST); | ||
- case SOUTH_EAST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST); | ||
- case SOUTH_WEST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST); | ||
- case NORTH_WEST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST); | ||
- case NORTH_EAST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST); | ||
- } | ||
+ return switch ((RailShape) state.getValue(PoweredRailBlock.SHAPE)) { | ||
+ case NORTH_SOUTH -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.EAST_WEST); | ||
+ case EAST_WEST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_SOUTH); | ||
+ case ASCENDING_EAST -> | ||
+ (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_SOUTH); | ||
+ case ASCENDING_WEST -> | ||
+ (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_NORTH); | ||
+ case ASCENDING_NORTH -> | ||
+ (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_EAST); | ||
+ case ASCENDING_SOUTH -> | ||
+ (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_WEST); | ||
+ case SOUTH_EAST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST); | ||
+ case SOUTH_WEST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST); | ||
+ case NORTH_WEST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST); | ||
+ case NORTH_EAST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST); | ||
+ }; | ||
default: | ||
return state; | ||
} | ||
+ // Leaf end | ||
} | ||
|
||
@Override | ||
public BlockState mirror(BlockState state, Mirror mirror) { | ||
RailShape blockpropertytrackposition = (RailShape) state.getValue(PoweredRailBlock.SHAPE); | ||
|
||
+ // Leaf start - Optimize PoweredRail swtich | ||
switch (mirror) { | ||
- case LEFT_RIGHT: | ||
- switch (blockpropertytrackposition) { | ||
- case ASCENDING_NORTH: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_SOUTH); | ||
- case ASCENDING_SOUTH: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_NORTH); | ||
- case SOUTH_EAST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST); | ||
- case SOUTH_WEST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST); | ||
- case NORTH_WEST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST); | ||
- case NORTH_EAST: | ||
- return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST); | ||
- default: | ||
- return super.mirror(state, mirror); | ||
- } | ||
- case FRONT_BACK: | ||
+ case LEFT_RIGHT -> { | ||
+ return switch (blockpropertytrackposition) { | ||
+ case ASCENDING_NORTH -> | ||
+ (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_SOUTH); | ||
+ case ASCENDING_SOUTH -> | ||
+ (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_NORTH); | ||
+ case SOUTH_EAST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST); | ||
+ case SOUTH_WEST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST); | ||
+ case NORTH_WEST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST); | ||
+ case NORTH_EAST -> (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST); | ||
+ default -> super.mirror(state, mirror); | ||
+ }; | ||
+ } | ||
+ case FRONT_BACK -> { | ||
switch (blockpropertytrackposition) { | ||
- case ASCENDING_EAST: | ||
+ case ASCENDING_EAST -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_WEST); | ||
- case ASCENDING_WEST: | ||
+ } | ||
+ case ASCENDING_WEST -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_EAST); | ||
- case ASCENDING_NORTH: | ||
- case ASCENDING_SOUTH: | ||
- default: | ||
- break; | ||
- case SOUTH_EAST: | ||
+ } | ||
+ default -> { | ||
+ } | ||
+ case SOUTH_EAST -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST); | ||
- case SOUTH_WEST: | ||
+ } | ||
+ case SOUTH_WEST -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST); | ||
- case NORTH_WEST: | ||
+ } | ||
+ case NORTH_WEST -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST); | ||
- case NORTH_EAST: | ||
+ } | ||
+ case NORTH_EAST -> { | ||
return (BlockState) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST); | ||
+ } | ||
} | ||
+ } | ||
} | ||
+ // Leaf end | ||
|
||
return super.mirror(state, mirror); | ||
} |