mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 10:35:38 +01:00
Port Eigencraft to 1.16
This commit is contained in:
parent
0bad695802
commit
3efe45f56d
@ -19,12 +19,12 @@ Aside from making the obvious class/function renames and obfhelpers I didn't nee
|
||||
Just added Bukkit's event system and took a few liberties with dead code and comment misspellings.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index 0862a1d629435dea92178fb5473068f23a15adf2..4ba72275b965693f3650f9b4fb138d3320d1b88b 100644
|
||||
index d5a1ade21749bba420257f3ece7878f32148d6ff..9b96b1b326169e7963d828eb9d0612c3c8cb428a 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -432,4 +432,14 @@ public class PaperWorldConfig {
|
||||
private void preventMovingIntoUnloadedChunks() {
|
||||
preventMovingIntoUnloadedChunks = getBoolean("prevent-moving-into-unloaded-chunks", false);
|
||||
@@ -654,4 +654,14 @@ public class PaperWorldConfig {
|
||||
maxLightningFlashDistance = 512; // Vanilla value
|
||||
}
|
||||
}
|
||||
+
|
||||
+ public boolean useEigencraftRedstone = false;
|
||||
@ -959,7 +959,7 @@ index 0000000000000000000000000000000000000000..b69803cbf2db2781aa050b145bf88468
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
|
||||
index 5bf2fc0b3f0a5209682b6056a6512ba9dbdca6d0..52a4982ecd7e4346e55c6fbab80032ed49490c15 100644
|
||||
index 7b3ccded0451f7b6634aeca0bdc1b5cc94f52b96..6abc3d4cfbe8f5cc1dbe83031d90ee8df3b2f914 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockRedstoneWire.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
|
||||
@@ -1,5 +1,7 @@
|
||||
@ -968,21 +968,19 @@ index 5bf2fc0b3f0a5209682b6056a6512ba9dbdca6d0..52a4982ecd7e4346e55c6fbab80032ed
|
||||
+import com.destroystokyo.paper.PaperConfig;
|
||||
+import com.destroystokyo.paper.util.RedstoneWireTurbo;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -22,8 +24,8 @@ public class BlockRedstoneWire extends Block {
|
||||
public static final BlockStateInteger POWER = BlockProperties.at;
|
||||
public static final Map<EnumDirection, BlockStateEnum<BlockPropertyRedstoneSide>> f = Maps.newEnumMap(ImmutableMap.of(EnumDirection.NORTH, BlockRedstoneWire.NORTH, EnumDirection.EAST, BlockRedstoneWire.EAST, EnumDirection.SOUTH, BlockRedstoneWire.SOUTH, EnumDirection.WEST, BlockRedstoneWire.WEST));
|
||||
protected static final VoxelShape[] g = new VoxelShape[]{Block.a(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.a(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.a(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.a(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.a(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.a(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.a(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.a(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.a(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.a(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.a(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.a(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.a(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.a(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D), Block.a(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.a(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D)};
|
||||
- private boolean h = true;
|
||||
- private final Set<BlockPosition> i = Sets.newHashSet();
|
||||
+ private boolean h = true; public final boolean canProvidePower() { return this.h; } public final void setCanProvidePower(boolean value) { this.h = value; } // Paper - OBFHELPER
|
||||
+ private final Set<BlockPosition> i = Sets.newHashSet(); private Set<BlockPosition> getBlocksNeedingUpdate() { return this.i; } // Paper - OBFHELPER
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -25,7 +27,7 @@ public class BlockRedstoneWire extends Block {
|
||||
private final Map<IBlockData, VoxelShape> j = Maps.newHashMap();
|
||||
private static final Vector3fa[] k = new Vector3fa[16];
|
||||
private final IBlockData o;
|
||||
- private boolean p = true;
|
||||
+ private boolean p = true; public final boolean canProvidePower() { return this.p; } public final void setCanProvidePower(boolean value) { this.p = value; } // Paper - OBFHELPER
|
||||
|
||||
public BlockRedstoneWire(Block.Info block_info) {
|
||||
super(block_info);
|
||||
@@ -157,6 +159,117 @@ public class BlockRedstoneWire extends Block {
|
||||
return iblockdata1.d(iworldreader, blockposition1, EnumDirection.UP) || iblockdata1.getBlock() == Blocks.HOPPER;
|
||||
public BlockRedstoneWire(BlockBase.Info blockbase_info) {
|
||||
super(blockbase_info);
|
||||
@@ -212,6 +214,120 @@ public class BlockRedstoneWire extends Block {
|
||||
return iblockdata.d(iblockaccess, blockposition, EnumDirection.UP) || iblockdata.a(Blocks.HOPPER);
|
||||
}
|
||||
|
||||
+ // Paper start - Optimize redstone
|
||||
@ -994,11 +992,11 @@ index 5bf2fc0b3f0a5209682b6056a6512ba9dbdca6d0..52a4982ecd7e4346e55c6fbab80032ed
|
||||
+ * this.neighborChanged and a few other methods in this class.
|
||||
+ * Note: Added 'source' argument so as to help determine direction of information flow
|
||||
+ */
|
||||
+ private IBlockData updateSurroundingRedstone(World worldIn, BlockPosition pos, IBlockData state, BlockPosition source) {
|
||||
+ private void updateSurroundingRedstone(World worldIn, BlockPosition pos, IBlockData state, BlockPosition source) {
|
||||
+ if (worldIn.paperConfig.useEigencraftRedstone) {
|
||||
+ return turbo.updateSurroundingRedstone(worldIn, pos, state, source);
|
||||
+ turbo.updateSurroundingRedstone(worldIn, pos, state, source);
|
||||
+ }
|
||||
+ return a(worldIn, pos, state);
|
||||
+ a(worldIn, pos, state);
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
@ -1011,7 +1009,7 @@ index 5bf2fc0b3f0a5209682b6056a6512ba9dbdca6d0..52a4982ecd7e4346e55c6fbab80032ed
|
||||
+ */
|
||||
+ public IBlockData calculateCurrentChanges(World worldIn, BlockPosition pos1, BlockPosition pos2, IBlockData state) {
|
||||
+ IBlockData iblockstate = state;
|
||||
+ int i = state.get(POWER).intValue();
|
||||
+ int i = state.get(POWER);
|
||||
+ int j = 0;
|
||||
+ j = this.getPower(j, worldIn.getType(pos2));
|
||||
+ this.setCanProvidePower(false);
|
||||
@ -1076,48 +1074,60 @@ index 5bf2fc0b3f0a5209682b6056a6512ba9dbdca6d0..52a4982ecd7e4346e55c6fbab80032ed
|
||||
+ }
|
||||
+
|
||||
+ if (i != j) {
|
||||
+ state = state.set(POWER, Integer.valueOf(j));
|
||||
+ state = state.set(POWER, j);
|
||||
+
|
||||
+ if (worldIn.getType(pos1) == iblockstate) {
|
||||
+ worldIn.setTypeAndData(pos1, state, 2);
|
||||
+ }
|
||||
+
|
||||
+ if (!worldIn.paperConfig.useEigencraftRedstone) {
|
||||
+ // The new search algorithm keeps track of blocks needing updates in its own data structures,
|
||||
+ // so only add anything to blocksNeedingUpdate if we're using the vanilla update algorithm.
|
||||
+ this.getBlocksNeedingUpdate().add(pos1);
|
||||
+
|
||||
+ for (EnumDirection enumfacing1 : EnumDirection.values()) {
|
||||
+ this.getBlocksNeedingUpdate().add(pos1.shift(enumfacing1));
|
||||
+ }
|
||||
+ }
|
||||
+ // 1.16(.1?) dropped the need for blocks needing updates.
|
||||
+ // Whether this is necessary after all is to be seen.
|
||||
+// if (!worldIn.paperConfig.useEigencraftRedstone) {
|
||||
+// // The new search algorithm keeps track of blocks needing updates in its own data structures,
|
||||
+// // so only add anything to blocksNeedingUpdate if we're using the vanilla update algorithm.
|
||||
+// this.getBlocksNeedingUpdate().add(pos1);
|
||||
+//
|
||||
+// for (EnumDirection enumfacing1 : EnumDirection.values()) {
|
||||
+// this.getBlocksNeedingUpdate().add(pos1.shift(enumfacing1));
|
||||
+// }
|
||||
+// }
|
||||
+ }
|
||||
+
|
||||
+ return state;
|
||||
+ }
|
||||
+ // Paper end
|
||||
private IBlockData a(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
iblockdata = this.b(world, blockposition, iblockdata);
|
||||
List<BlockPosition> list = Lists.newArrayList(this.i);
|
||||
@@ -255,7 +368,7 @@ public class BlockRedstoneWire extends Block {
|
||||
+
|
||||
private void a(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
int i = this.a(world, blockposition);
|
||||
|
||||
@@ -281,6 +397,8 @@ public class BlockRedstoneWire extends Block {
|
||||
return Math.max(i, j - 1);
|
||||
}
|
||||
|
||||
+ private int getPower(int min, IBlockData iblockdata) { return Math.max(min, getPower(iblockdata)); } // Paper - Optimize redstone
|
||||
+ private int getPower(IBlockData iblockdata) { return this.o(iblockdata); } // Paper - OBFHELPER
|
||||
private int o(IBlockData iblockdata) {
|
||||
return iblockdata.a((Block) this) ? (Integer) iblockdata.get(BlockRedstoneWire.POWER) : 0;
|
||||
}
|
||||
@@ -303,7 +421,7 @@ public class BlockRedstoneWire extends Block {
|
||||
@Override
|
||||
public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) {
|
||||
if (iblockdata1.getBlock() != iblockdata.getBlock() && !world.isClientSide) {
|
||||
if (!iblockdata1.a(iblockdata.getBlock()) && !world.isClientSide) {
|
||||
- this.a(world, blockposition, iblockdata);
|
||||
+ this.updateSurroundingRedstone(world, blockposition, iblockdata, null); // Paper - Optimize redstone
|
||||
Iterator iterator = EnumDirection.EnumDirectionLimit.VERTICAL.iterator();
|
||||
|
||||
EnumDirection enumdirection;
|
||||
@@ -302,7 +415,7 @@ public class BlockRedstoneWire extends Block {
|
||||
while (iterator.hasNext()) {
|
||||
@@ -330,7 +448,7 @@ public class BlockRedstoneWire extends Block {
|
||||
world.applyPhysics(blockposition.shift(enumdirection), this);
|
||||
}
|
||||
|
||||
- this.a(world, blockposition, iblockdata);
|
||||
+ this.updateSurroundingRedstone(world, blockposition, iblockdata, null); // Paper - Optimize redstone
|
||||
Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
|
||||
|
||||
EnumDirection enumdirection1;
|
||||
@@ -343,7 +456,7 @@ public class BlockRedstoneWire extends Block {
|
||||
this.d(world, blockposition);
|
||||
}
|
||||
}
|
||||
@@ -365,7 +483,7 @@ public class BlockRedstoneWire extends Block {
|
||||
public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) {
|
||||
if (!world.isClientSide) {
|
||||
if (iblockdata.canPlace(world, blockposition)) {
|
||||
@ -1127,10 +1137,10 @@ index 5bf2fc0b3f0a5209682b6056a6512ba9dbdca6d0..52a4982ecd7e4346e55c6fbab80032ed
|
||||
c(iblockdata, world, blockposition);
|
||||
world.a(blockposition, false);
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 2db91e85bd5e95d15b607a96114f33b6e7687b19..29594e5fcddfd47d543813a2bf12234d9cbd29fd 100644
|
||||
index 287db5203f3a4995c2b09bfd9fe17734538e7466..d20fe9232ec09289969cc16cfbaec57fe4bb381d 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -523,6 +523,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
||||
@@ -607,6 +607,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
||||
|
||||
}
|
||||
|
||||
@ -1138,11 +1148,11 @@ index 2db91e85bd5e95d15b607a96114f33b6e7687b19..29594e5fcddfd47d543813a2bf12234d
|
||||
public void a(BlockPosition blockposition, Block block, BlockPosition blockposition1) {
|
||||
if (!this.isClientSide) {
|
||||
IBlockData iblockdata = this.getType(blockposition);
|
||||
@@ -1278,6 +1279,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
||||
@@ -1232,6 +1233,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
||||
return this.getBlockFacePower(blockposition.down(), EnumDirection.DOWN) > 0 ? true : (this.getBlockFacePower(blockposition.up(), EnumDirection.UP) > 0 ? true : (this.getBlockFacePower(blockposition.north(), EnumDirection.NORTH) > 0 ? true : (this.getBlockFacePower(blockposition.south(), EnumDirection.SOUTH) > 0 ? true : (this.getBlockFacePower(blockposition.west(), EnumDirection.WEST) > 0 ? true : this.getBlockFacePower(blockposition.east(), EnumDirection.EAST) > 0))));
|
||||
}
|
||||
|
||||
+ public int isBlockIndirectlyGettingPowered(BlockPosition pos) { return this.q(pos); } // Paper - OBFHELPER
|
||||
public int q(BlockPosition blockposition) {
|
||||
+ public int isBlockIndirectlyGettingPowered(BlockPosition pos) { return this.s(pos); } // Paper - OBFHELPER
|
||||
public int s(BlockPosition blockposition) {
|
||||
int i = 0;
|
||||
EnumDirection[] aenumdirection = World.a;
|
Loading…
Reference in New Issue
Block a user