mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-16 18:31:53 +01:00
Move redstone config changes to Eigencraft patch
This commit is contained in:
parent
14d355612e
commit
6084c2a6bd
3 changed files with 64 additions and 127 deletions
|
@ -1835,46 +1835,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
||||
piglinsGuardChests = getBoolean("piglins-guard-chests", piglinsGuardChests);
|
||||
}
|
||||
|
||||
- public boolean useEigencraftRedstone = false;
|
||||
- private void useEigencraftRedstone() {
|
||||
- useEigencraftRedstone = this.getBoolean("use-faster-eigencraft-redstone", false);
|
||||
- if (useEigencraftRedstone) {
|
||||
- log("Using Eigencraft redstone algorithm by theosib.");
|
||||
+ public enum RedstoneImplementation {
|
||||
public enum RedstoneImplementation {
|
||||
- VANILLA, EIGENCRAFT
|
||||
+ VANILLA, EIGENCRAFT, ALTERNATE_CURRENT
|
||||
+ }
|
||||
+ public RedstoneImplementation redstoneImplementation = RedstoneImplementation.VANILLA;
|
||||
+ private void redstoneImplementation() {
|
||||
+ String implementation;
|
||||
+ if (PaperConfig.version < 27) {
|
||||
+ implementation = "vanilla";
|
||||
+ if (config.contains("world-settings.default.use-faster-eigencraft-redstone")) {
|
||||
+ implementation = config.getBoolean("world-settings.default.use-faster-eigencraft-redstone") ? "eigencraft" : "vanilla";
|
||||
+ config.set("world-settings.default.redstone-implementation", implementation);
|
||||
+ }
|
||||
+ if (config.contains("world-settings." + worldName + ".use-faster-eigencraft-redstone")) {
|
||||
+ implementation = config.getBoolean("world-settings." + worldName + ".use-faster-eigencraft-redstone") ? "eigencraft" : "vanilla";
|
||||
+ config.set("world-settings." + worldName + ".redstone-implementation", implementation);
|
||||
+ }
|
||||
+ remove("use-faster-eigencraft-redstone");
|
||||
} else {
|
||||
- log("Using vanilla redstone algorithm.");
|
||||
+ implementation = this.getString("redstone-implementation", "vanilla").toLowerCase().trim();
|
||||
+ }
|
||||
+ switch (implementation) {
|
||||
+ default:
|
||||
}
|
||||
public RedstoneImplementation redstoneImplementation = RedstoneImplementation.VANILLA;
|
||||
private void redstoneImplementation() {
|
||||
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
||||
}
|
||||
switch (implementation) {
|
||||
default:
|
||||
- logError("Invalid redstone-implementation config " + implementation + " - must be one of: vanilla, eigencraft");
|
||||
+ logError("Invalid redstone-implementation config " + implementation + " - must be one of: vanilla, eigencraft, alternate-current");
|
||||
+ case "vanilla":
|
||||
+ redstoneImplementation = RedstoneImplementation.VANILLA;
|
||||
+ log("Using the Vanilla redstone implementation.");
|
||||
+ break;
|
||||
+ case "eigencraft":
|
||||
+ redstoneImplementation = RedstoneImplementation.EIGENCRAFT;
|
||||
+ log("Using Eigencraft's redstone implementation by theosib.");
|
||||
+ break;
|
||||
case "vanilla":
|
||||
redstoneImplementation = RedstoneImplementation.VANILLA;
|
||||
log("Using the Vanilla redstone implementation.");
|
||||
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
||||
redstoneImplementation = RedstoneImplementation.EIGENCRAFT;
|
||||
log("Using Eigencraft's redstone implementation by theosib.");
|
||||
break;
|
||||
+ case "alternate-current":
|
||||
+ redstoneImplementation = RedstoneImplementation.ALTERNATE_CURRENT;
|
||||
+ log("Using Alternate Current's redstone implementation by Space Walker.");
|
||||
|
@ -2109,21 +2090,13 @@ diff --git a/src/main/java/net/minecraft/world/level/block/PoweredBlock.java b/s
|
|||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/PoweredBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/PoweredBlock.java
|
||||
@@ -0,0 +0,0 @@ package net.minecraft.world.level.block;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
+import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
@@ -0,0 +0,0 @@ public class PoweredBlock extends Block {
|
||||
return true;
|
||||
}
|
||||
|
||||
+ // Paper start - optimize redstone (Alternate Current)
|
||||
+ @Override
|
||||
+ public boolean isSignalSourceTo(Level level, BlockPos pos, BlockState state, Direction dir) {
|
||||
+ public boolean isSignalSourceTo(net.minecraft.world.level.Level level, BlockPos pos, BlockState state, Direction dir) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
@ -2135,14 +2108,6 @@ diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.jav
|
|||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||
@@ -0,0 +0,0 @@
|
||||
package net.minecraft.world.level.block;
|
||||
|
||||
import com.destroystokyo.paper.PaperConfig;
|
||||
+import com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation;
|
||||
import com.destroystokyo.paper.util.RedstoneWireTurbo;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
||||
return floor.isFaceSturdy(world, pos, Direction.UP) || floor.is(Blocks.HOPPER);
|
||||
}
|
||||
|
@ -2150,51 +2115,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
- // Paper start - Optimize redstone
|
||||
+ // Paper start - Optimize redstone (Eigencraft)
|
||||
// The bulk of the new functionality is found in RedstoneWireTurbo.java
|
||||
RedstoneWireTurbo turbo = new RedstoneWireTurbo(this);
|
||||
com.destroystokyo.paper.util.RedstoneWireTurbo turbo = new com.destroystokyo.paper.util.RedstoneWireTurbo(this);
|
||||
|
||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
||||
* Note: Added 'source' argument so as to help determine direction of information flow
|
||||
*/
|
||||
private void updateSurroundingRedstone(Level worldIn, BlockPos pos, BlockState state, BlockPos source) {
|
||||
- if (worldIn.paperConfig.useEigencraftRedstone) {
|
||||
+ if (worldIn.paperConfig.redstoneImplementation == RedstoneImplementation.EIGENCRAFT) {
|
||||
turbo.updateSurroundingRedstone(worldIn, pos, state, source);
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
||||
int k = worldIn.getBestNeighborSignal(pos1);
|
||||
this.shouldSignal = true;
|
||||
|
||||
- if (!worldIn.paperConfig.useEigencraftRedstone) {
|
||||
+ if (worldIn.paperConfig.redstoneImplementation == RedstoneImplementation.VANILLA) {
|
||||
// This code is totally redundant to if statements just below the loop.
|
||||
if (k > 0 && k > j - 1) {
|
||||
j = k;
|
||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
||||
// redstone wire will be set to 'k'. If 'k' is already 15, then nothing inside the
|
||||
// following loop can affect the power level of the wire. Therefore, the loop is
|
||||
// skipped if k is already 15.
|
||||
- if (!worldIn.paperConfig.useEigencraftRedstone || k < 15) {
|
||||
+ if (worldIn.paperConfig.redstoneImplementation == RedstoneImplementation.VANILLA || k < 15) {
|
||||
for (Direction enumfacing : Direction.Plane.HORIZONTAL) {
|
||||
BlockPos blockpos = pos1.relative(enumfacing);
|
||||
boolean flag = blockpos.getX() != pos2.getX() || blockpos.getZ() != pos2.getZ();
|
||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
||||
}
|
||||
}
|
||||
|
||||
- if (!worldIn.paperConfig.useEigencraftRedstone) {
|
||||
+ if (worldIn.paperConfig.redstoneImplementation == RedstoneImplementation.VANILLA) {
|
||||
// The old code would decrement the wire value only by 1 at a time.
|
||||
if (l > j) {
|
||||
j = l - 1;
|
||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
||||
@Override
|
||||
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
||||
if (!oldState.is(state.getBlock()) && !world.isClientSide) {
|
||||
- this.updateSurroundingRedstone(world, pos, state, null); // Paper - Optimize redstone
|
||||
+ // Paper start - optimize redstone - replace call to updatePowerStrength
|
||||
+ if (world.paperConfig.redstoneImplementation == RedstoneImplementation.ALTERNATE_CURRENT) {
|
||||
+ if (world.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.ALTERNATE_CURRENT) {
|
||||
+ world.getWireHandler().onWireAdded(pos); // Alternate Current
|
||||
+ } else {
|
||||
+ this.updateSurroundingRedstone(world, pos, state, null); // vanilla/Eigencraft
|
||||
|
@ -2209,7 +2138,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
- this.updateSurroundingRedstone(world, pos, state, null); // Paper - Optimize redstone
|
||||
+ // Paper start - optimize redstone - replace call to updatePowerStrength
|
||||
+ if (world.paperConfig.redstoneImplementation == RedstoneImplementation.ALTERNATE_CURRENT) {
|
||||
+ if (world.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.ALTERNATE_CURRENT) {
|
||||
+ world.getWireHandler().onWireRemoved(pos, state); // Alternate Current
|
||||
+ } else {
|
||||
+ this.updateSurroundingRedstone(world, pos, state, null); // vanilla/Eigencraft
|
||||
|
@ -2224,7 +2153,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
if (!world.isClientSide) {
|
||||
+ // Paper start - optimize redstone (Alternate Current)
|
||||
+ // Alternate Current handles breaking of redstone wires in the WireHandler.
|
||||
+ if (world.paperConfig.redstoneImplementation == RedstoneImplementation.ALTERNATE_CURRENT) {
|
||||
+ if (world.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.ALTERNATE_CURRENT) {
|
||||
+ world.getWireHandler().onWireUpdated(pos);
|
||||
+ } else
|
||||
+ // Paper end
|
||||
|
@ -2315,26 +2244,18 @@ diff --git a/src/main/java/net/minecraft/world/level/block/TrappedChestBlock.jav
|
|||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/TrappedChestBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/TrappedChestBlock.java
|
||||
@@ -0,0 +0,0 @@ import net.minecraft.stats.Stat;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
+import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||
@@ -0,0 +0,0 @@ public class TrappedChestBlock extends ChestBlock {
|
||||
return true;
|
||||
}
|
||||
|
||||
+ // Paper start - optimize redstone (Alternate Current)
|
||||
+ @Override
|
||||
+ public boolean isSignalSourceTo(Level level, BlockPos pos, BlockState state, Direction dir) {
|
||||
+ public boolean isSignalSourceTo(net.minecraft.world.level.Level level, BlockPos pos, BlockState state, Direction dir) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isDirectSignalSourceTo(Level level, BlockPos pos, BlockState state, Direction dir) {
|
||||
+ public boolean isDirectSignalSourceTo(net.minecraft.world.level.Level level, BlockPos pos, BlockState state, Direction dir) {
|
||||
+ return dir == Direction.UP;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
@ -2374,7 +2295,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
public abstract class BlockBehaviour {
|
||||
|
||||
- protected static final Direction[] UPDATE_SHAPE_ORDER = new Direction[]{Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP};
|
||||
+ public static final Direction[] UPDATE_SHAPE_ORDER = new Direction[]{Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP};
|
||||
+ public static final Direction[] UPDATE_SHAPE_ORDER = new Direction[]{Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP}; // Paper - public
|
||||
protected final Material material;
|
||||
public final boolean hasCollision;
|
||||
protected final float explosionResistance;
|
||||
|
|
|
@ -17,9 +17,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ piglinsGuardChests = getBoolean("piglins-guard-chests", piglinsGuardChests);
|
||||
+ }
|
||||
+
|
||||
public boolean useEigencraftRedstone = false;
|
||||
private void useEigencraftRedstone() {
|
||||
useEigencraftRedstone = this.getBoolean("use-faster-eigencraft-redstone", false);
|
||||
public enum RedstoneImplementation {
|
||||
VANILLA, EIGENCRAFT
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: theosib <millerti@172.16.221.1>
|
||||
Date: Thu, 27 Sep 2018 01:43:35 -0600
|
||||
Subject: [PATCH] Optimize redstone algorithm
|
||||
Subject: [PATCH] Eigencraft redstone implementation
|
||||
|
||||
Author: theosib <millerti@172.16.221.1>
|
||||
Co-authored-by: egg82 <eggys82@gmail.com>
|
||||
|
@ -26,13 +26,37 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
zombiesTargetTurtleEggs = getBoolean("zombies-target-turtle-eggs", zombiesTargetTurtleEggs);
|
||||
}
|
||||
|
||||
+ public boolean useEigencraftRedstone = false;
|
||||
+ private void useEigencraftRedstone() {
|
||||
+ useEigencraftRedstone = this.getBoolean("use-faster-eigencraft-redstone", false);
|
||||
+ if (useEigencraftRedstone) {
|
||||
+ log("Using Eigencraft redstone algorithm by theosib.");
|
||||
+ public enum RedstoneImplementation {
|
||||
+ VANILLA, EIGENCRAFT
|
||||
+ }
|
||||
+ public RedstoneImplementation redstoneImplementation = RedstoneImplementation.VANILLA;
|
||||
+ private void redstoneImplementation() {
|
||||
+ String implementation;
|
||||
+ if (PaperConfig.version < 27) {
|
||||
+ implementation = "vanilla";
|
||||
+ if (config.contains("world-settings.default.use-faster-eigencraft-redstone")) {
|
||||
+ implementation = config.getBoolean("world-settings.default.use-faster-eigencraft-redstone") ? "eigencraft" : "vanilla";
|
||||
+ config.set("world-settings.default.redstone-implementation", implementation);
|
||||
+ }
|
||||
+ if (config.contains("world-settings." + worldName + ".use-faster-eigencraft-redstone")) {
|
||||
+ implementation = config.getBoolean("world-settings." + worldName + ".use-faster-eigencraft-redstone") ? "eigencraft" : "vanilla";
|
||||
+ config.set("world-settings." + worldName + ".redstone-implementation", implementation);
|
||||
+ }
|
||||
+ remove("use-faster-eigencraft-redstone");
|
||||
+ } else {
|
||||
+ log("Using vanilla redstone algorithm.");
|
||||
+ implementation = this.getString("redstone-implementation", "vanilla").toLowerCase().trim();
|
||||
+ }
|
||||
+ switch (implementation) {
|
||||
+ default:
|
||||
+ logError("Invalid redstone-implementation config " + implementation + " - must be one of: vanilla, eigencraft");
|
||||
+ case "vanilla":
|
||||
+ redstoneImplementation = RedstoneImplementation.VANILLA;
|
||||
+ log("Using the Vanilla redstone implementation.");
|
||||
+ break;
|
||||
+ case "eigencraft":
|
||||
+ redstoneImplementation = RedstoneImplementation.EIGENCRAFT;
|
||||
+ log("Using Eigencraft's redstone implementation by theosib.");
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
|
@ -962,21 +986,13 @@ diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.jav
|
|||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||
@@ -0,0 +0,0 @@
|
||||
package net.minecraft.world.level.block;
|
||||
|
||||
+import com.destroystokyo.paper.PaperConfig;
|
||||
+import com.destroystokyo.paper.util.RedstoneWireTurbo;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
||||
return floor.isFaceSturdy(world, pos, Direction.UP) || floor.is(Blocks.HOPPER);
|
||||
}
|
||||
|
||||
+ // Paper start - Optimize redstone
|
||||
+ // The bulk of the new functionality is found in RedstoneWireTurbo.java
|
||||
+ RedstoneWireTurbo turbo = new RedstoneWireTurbo(this);
|
||||
+ com.destroystokyo.paper.util.RedstoneWireTurbo turbo = new com.destroystokyo.paper.util.RedstoneWireTurbo(this);
|
||||
+
|
||||
+ /*
|
||||
+ * Modified version of pre-existing updateSurroundingRedstone, which is called from
|
||||
|
@ -984,7 +1000,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * Note: Added 'source' argument so as to help determine direction of information flow
|
||||
+ */
|
||||
+ private void updateSurroundingRedstone(Level worldIn, BlockPos pos, BlockState state, BlockPos source) {
|
||||
+ if (worldIn.paperConfig.useEigencraftRedstone) {
|
||||
+ if (worldIn.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.EIGENCRAFT) {
|
||||
+ turbo.updateSurroundingRedstone(worldIn, pos, state, source);
|
||||
+ return;
|
||||
+ }
|
||||
|
@ -1008,7 +1024,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ int k = worldIn.getBestNeighborSignal(pos1);
|
||||
+ this.shouldSignal = true;
|
||||
+
|
||||
+ if (!worldIn.paperConfig.useEigencraftRedstone) {
|
||||
+ if (worldIn.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.VANILLA) {
|
||||
+ // This code is totally redundant to if statements just below the loop.
|
||||
+ if (k > 0 && k > j - 1) {
|
||||
+ j = k;
|
||||
|
@ -1022,7 +1038,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ // redstone wire will be set to 'k'. If 'k' is already 15, then nothing inside the
|
||||
+ // following loop can affect the power level of the wire. Therefore, the loop is
|
||||
+ // skipped if k is already 15.
|
||||
+ if (!worldIn.paperConfig.useEigencraftRedstone || k < 15) {
|
||||
+ if (worldIn.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.VANILLA || k < 15) {
|
||||
+ for (Direction enumfacing : Direction.Plane.HORIZONTAL) {
|
||||
+ BlockPos blockpos = pos1.relative(enumfacing);
|
||||
+ boolean flag = blockpos.getX() != pos2.getX() || blockpos.getZ() != pos2.getZ();
|
||||
|
@ -1041,7 +1057,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!worldIn.paperConfig.useEigencraftRedstone) {
|
||||
+ if (worldIn.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.VANILLA) {
|
||||
+ // The old code would decrement the wire value only by 1 at a time.
|
||||
+ if (l > j) {
|
||||
+ j = l - 1;
|
Loading…
Add table
Reference in a new issue