mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
Update redstone optimization and lag compensation patches
This commit is contained in:
parent
ac69f75d23
commit
d37b5601d2
4 changed files with 237 additions and 250 deletions
|
@ -28,30 +28,30 @@ which is most likely in an unloaded chunk - which means that the
|
||||||
client will not tick the entity and thus not lerp the entity
|
client will not tick the entity and thus not lerp the entity
|
||||||
from its old position to its new position.
|
from its old position to its new position.
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
|
diff --git a/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java b/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index db31989ebe3d7021cfd2311439e9a00f819b0841..1373977b339405ef59bb3ea03d195285c96dd3fe 100644
|
||||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
|
--- a/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
|
||||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
|
+++ b/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
|
||||||
@@ -0,0 +0,0 @@ public class ClientboundAddEntityPacket implements Packet<ClientGamePacketListen
|
@@ -42,9 +42,11 @@ public class ClientboundAddEntityPacket implements Packet<ClientGamePacketListen
|
||||||
this(
|
this(
|
||||||
entity.getId(),
|
entity.getId(),
|
||||||
entity.getUUID(),
|
entity.getUUID(),
|
||||||
- entityTrackerEntry.getPositionBase().x(),
|
- serverEntity.getPositionBase().x(),
|
||||||
- entityTrackerEntry.getPositionBase().y(),
|
- serverEntity.getPositionBase().y(),
|
||||||
- entityTrackerEntry.getPositionBase().z(),
|
- serverEntity.getPositionBase().z(),
|
||||||
+ // Paper start - fix entity tracker desync
|
+ // Paper start - fix entity tracker desync
|
||||||
+ entity.trackingPosition().x(),
|
+ entity.trackingPosition().x(),
|
||||||
+ entity.trackingPosition().y(),
|
+ entity.trackingPosition().y(),
|
||||||
+ entity.trackingPosition().z(),
|
+ entity.trackingPosition().z(),
|
||||||
+ // Paper end - fix entity tracker desync
|
+ // Paper end - fix entity tracker desync
|
||||||
entityTrackerEntry.getLastSentXRot(),
|
serverEntity.getLastSentXRot(),
|
||||||
entityTrackerEntry.getLastSentYRot(),
|
serverEntity.getLastSentYRot(),
|
||||||
entity.getType(),
|
entity.getType(),
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index f8f145cd9614f7e38d6aa72501fe31837340a8bb..fa48e63fea42f387dcd154c08af54cfb0d3b08af 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
--- a/net/minecraft/server/level/ChunkMap.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
+++ b/net/minecraft/server/level/ChunkMap.java
|
||||||
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -1419,6 +1419,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
this.serverEntity.addPairing(player);
|
this.serverEntity.addPairing(player);
|
||||||
}
|
}
|
||||||
// Paper end - entity tracking events
|
// Paper end - entity tracking events
|
||||||
|
@ -59,11 +59,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
}
|
}
|
||||||
} else if (this.seenBy.remove(player.connection)) {
|
} else if (this.seenBy.remove(player.connection)) {
|
||||||
this.serverEntity.removePairing(player);
|
this.serverEntity.removePairing(player);
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 4c891706c2a3efc8e8c44fc1c031e8a1d21efb60..66f7926a2639ade41cb89419e38e12053314c982 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
--- a/net/minecraft/server/level/ServerEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
+++ b/net/minecraft/server/level/ServerEntity.java
|
||||||
@@ -0,0 +0,0 @@ public class ServerEntity {
|
@@ -90,6 +90,13 @@ public class ServerEntity {
|
||||||
this.trackedDataValues = entity.getEntityData().getNonDefaultValues();
|
this.trackedDataValues = entity.getEntityData().getNonDefaultValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,31 +75,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper end - fix desync when a player is added to the tracker
|
+ // Paper end - fix desync when a player is added to the tracker
|
||||||
+
|
+
|
||||||
public void sendChanges() {
|
public void sendChanges() {
|
||||||
// Paper start - optimise collisions
|
List<Entity> passengers = this.entity.getPassengers();
|
||||||
if (((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)this.entity).moonrise$isHardColliding()) {
|
if (!passengers.equals(this.lastPassengers)) {
|
||||||
@@ -0,0 +0,0 @@ public class ServerEntity {
|
@@ -125,7 +132,7 @@ public class ServerEntity {
|
||||||
}
|
this.sendDirtyEntityData();
|
||||||
}
|
}
|
||||||
|
|
||||||
- if (this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) {
|
- if (this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) {
|
||||||
+ if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { // Paper - fix desync when a player is added to the tracker
|
+ if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { // Paper - fix desync when a player is added to the tracker
|
||||||
byte b0 = Mth.packDegrees(this.entity.getYRot());
|
byte b = Mth.packDegrees(this.entity.getYRot());
|
||||||
byte b1 = Mth.packDegrees(this.entity.getXRot());
|
byte b1 = Mth.packDegrees(this.entity.getXRot());
|
||||||
boolean flag = Math.abs(b0 - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1;
|
boolean flag = Math.abs(b - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1;
|
||||||
@@ -0,0 +0,0 @@ public class ServerEntity {
|
@@ -160,7 +167,7 @@ public class ServerEntity {
|
||||||
long k = this.positionCodec.encodeZ(vec3d);
|
long l1 = this.positionCodec.encodeY(vec3);
|
||||||
boolean flag5 = i < -32768L || i > 32767L || j < -32768L || j > 32767L || k < -32768L || k > 32767L;
|
long l2 = this.positionCodec.encodeZ(vec3);
|
||||||
|
boolean flag5 = l < -32768L || l > 32767L || l1 < -32768L || l1 > 32767L || l2 < -32768L || l2 > 32767L;
|
||||||
- if (!flag5 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()) {
|
- if (flag5 || this.teleportDelay > 400 || this.wasRiding || this.wasOnGround != this.entity.onGround()) {
|
||||||
+ if (!this.forceStateResync && !flag5 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()) { // Paper - fix desync when a player is added to the tracker
|
+ if (this.forceStateResync || flag5 || this.teleportDelay > 400 || this.wasRiding || this.wasOnGround != this.entity.onGround()) { // Paper - fix desync when a player is added to the tracker
|
||||||
if ((!flag2 || !flag) && !(this.entity instanceof AbstractArrow)) {
|
this.wasOnGround = this.entity.onGround();
|
||||||
if (flag2) {
|
this.teleportDelay = 0;
|
||||||
packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) i), (short) ((int) j), (short) ((int) k), this.entity.onGround());
|
packet = ClientboundEntityPositionSyncPacket.of(this.entity);
|
||||||
@@ -0,0 +0,0 @@ public class ServerEntity {
|
@@ -225,6 +232,7 @@ public class ServerEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entity.hasImpulse = false;
|
this.entity.hasImpulse = false;
|
||||||
+ this.forceStateResync = false; // Paper - fix desync when a player is added to the tracker
|
+ this.forceStateResync = false; // Paper - fix desync when a player is added to the tracker
|
||||||
}
|
}
|
||||||
|
|
||||||
++this.tickCount;
|
this.tickCount++;
|
||||||
|
|
|
@ -7,66 +7,65 @@ Areas affected by lag comepnsation:
|
||||||
- Block breaking and destroying
|
- Block breaking and destroying
|
||||||
- Eating food items
|
- Eating food items
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..8aa9ae2925ad44d57a27be3e520fcf20e30237d6 100644
|
||||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
--- a/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
+++ b/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -299,6 +299,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
|
||||||
public volatile Thread shutdownThread; // Paper
|
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
||||||
public volatile boolean abnormalExit = false; // Paper
|
private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
|
||||||
+ public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
|
+ public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
|
||||||
|
|
||||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> serverFactory) {
|
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
|
||||||
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
|
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
|
||||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -1564,6 +1565,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
|
for (ServerLevel serverLevel : this.getAllLevels()) {
|
||||||
worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
|
serverLevel.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
|
||||||
net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers
|
serverLevel.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
|
||||||
+ worldserver.updateLagCompensationTick(); // Paper - lag compensation
|
+ serverLevel.updateLagCompensationTick(); // Paper - lag compensation
|
||||||
|
profilerFiller.push(() -> serverLevel + " " + serverLevel.dimension().location());
|
||||||
gameprofilerfiller.push(() -> {
|
/* Drop global time updates
|
||||||
String s = String.valueOf(worldserver);
|
if (this.tickCount % 20 == 0) {
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index ca9427a7eae9a66f4f1ccedda7b1def7ac2a88da..efc18884358907661d1226409f11d19a394073b3 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
--- a/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
@@ -2362,4 +2362,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
);
|
return this.server.getPlayerList().getPlayer(uuid);
|
||||||
}
|
}
|
||||||
// Paper end - chunk tick iteration
|
// Paper end - check global player list where appropriate
|
||||||
|
+
|
||||||
+ // Paper start - lag compensation
|
+ // Paper start - lag compensation
|
||||||
+ private long lagCompensationTick = net.minecraft.server.MinecraftServer.SERVER_INIT;
|
+ private long lagCompensationTick = MinecraftServer.SERVER_INIT;
|
||||||
+
|
+
|
||||||
+ public long getLagCompensationTick() {
|
+ public long getLagCompensationTick() {
|
||||||
+ return this.lagCompensationTick;
|
+ return this.lagCompensationTick;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public void updateLagCompensationTick() {
|
+ public void updateLagCompensationTick() {
|
||||||
+ this.lagCompensationTick = (System.nanoTime() - net.minecraft.server.MinecraftServer.SERVER_INIT) / (java.util.concurrent.TimeUnit.MILLISECONDS.toNanos(50L));
|
+ this.lagCompensationTick = (System.nanoTime() - MinecraftServer.SERVER_INIT) / (java.util.concurrent.TimeUnit.MILLISECONDS.toNanos(50L));
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - lag compensation
|
+ // Paper end - lag compensation
|
||||||
|
}
|
||||||
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer
|
diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||||
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
index 6176f0738aa1a18df5d7d4d49fd6961e3f2eb736..d6da40d7188a55a9b2eeedb540c8e275359342e4 100644
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
--- a/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
+++ b/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
@@ -111,7 +111,7 @@ public class ServerPlayerGameMode {
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
||||||
@@ -0,0 +0,0 @@ public class ServerPlayerGameMode {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tick() {
|
public void tick() {
|
||||||
- this.gameTicks = MinecraftServer.currentTick; // CraftBukkit;
|
- this.gameTicks = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit;
|
||||||
+ this.gameTicks = (int)this.level.getLagCompensationTick(); // CraftBukkit; // Paper - lag compensation
|
+ this.gameTicks = (int) this.level.getLagCompensationTick(); // Paper - lag compensation
|
||||||
BlockState iblockdata;
|
|
||||||
|
|
||||||
if (this.hasDelayedDestroy) {
|
if (this.hasDelayedDestroy) {
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
BlockState blockState = this.level.getBlockStateIfLoaded(this.delayedDestroyPos); // Paper - Don't allow digging into unloaded chunks
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
if (blockState == null || blockState.isAir()) { // Paper - Don't allow digging into unloaded chunks
|
||||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
index c83aeaf4e50dd7290c608dfe260a3bd2404b6004..8439e1593c9973243383dc7091c587f7e72eb9e0 100644
|
||||||
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
@@ -3831,6 +3831,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
this.resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer);
|
this.resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer);
|
||||||
}
|
}
|
||||||
// Paper end - Properly cancel usable items
|
// Paper end - Properly cancel usable items
|
||||||
|
@ -77,33 +76,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
private void updatingUsingItem() {
|
private void updatingUsingItem() {
|
||||||
if (this.isUsingItem()) {
|
if (this.isUsingItem()) {
|
||||||
if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) {
|
if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) {
|
||||||
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -3844,7 +3848,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
|
|
||||||
protected void updateUsingItem(ItemStack stack) {
|
protected void updateUsingItem(ItemStack usingItem) {
|
||||||
stack.onUseTick(this.level(), this, this.getUseItemRemainingTicks());
|
usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks());
|
||||||
- if (--this.useItemRemaining == 0 && !this.level().isClientSide && !stack.useOnRelease()) {
|
- if (--this.useItemRemaining == 0 && !this.level().isClientSide && !usingItem.useOnRelease()) {
|
||||||
+ // Paper start - lag compensate eating
|
+ // Paper start - lag compensate eating
|
||||||
+ // we add 1 to the expected time to avoid lag compensating when we should not
|
+ // we add 1 to the expected time to avoid lag compensating when we should not
|
||||||
+ final boolean shouldLagCompensate = this.useItem.has(DataComponents.FOOD) && this.eatStartTime != -1 && (System.nanoTime() - this.eatStartTime) > ((1L + this.totalEatTimeTicks) * 50L * (1000L * 1000L));
|
+ final boolean shouldLagCompensate = this.useItem.has(DataComponents.FOOD) && this.eatStartTime != -1 && (System.nanoTime() - this.eatStartTime) > ((1L + this.totalEatTimeTicks) * 50L * (1000L * 1000L));
|
||||||
+ if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !this.level().isClientSide && !stack.useOnRelease()) {
|
+ if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !this.level().isClientSide && !usingItem.useOnRelease()) {
|
||||||
+ this.useItemRemaining = 0;
|
+ this.useItemRemaining = 0;
|
||||||
+ // Paper end - lag compensate eating
|
+ // Paper end - lag compensate eating
|
||||||
this.completeUsingItem();
|
this.completeUsingItem();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -3878,7 +3887,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
|
ItemStack itemInHand = this.getItemInHand(hand);
|
||||||
if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
|
if (!itemInHand.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
|
||||||
this.useItem = itemstack;
|
this.useItem = itemInHand;
|
||||||
- this.useItemRemaining = itemstack.getUseDuration(this);
|
- this.useItemRemaining = itemInHand.getUseDuration(this);
|
||||||
+ // Paper start - lag compensate eating
|
+ // Paper start - lag compensate eating
|
||||||
+ this.useItemRemaining = this.totalEatTimeTicks = itemstack.getUseDuration(this);
|
+ this.useItemRemaining = this.totalEatTimeTicks = itemInHand.getUseDuration(this);
|
||||||
+ this.eatStartTime = System.nanoTime();
|
+ this.eatStartTime = System.nanoTime();
|
||||||
+ // Paper end - lag compensate eating
|
+ // Paper end - lag compensate eating
|
||||||
if (!this.level().isClientSide) {
|
if (!this.level().isClientSide) {
|
||||||
this.setLivingEntityFlag(1, true);
|
this.setLivingEntityFlag(1, true);
|
||||||
this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND);
|
this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND);
|
||||||
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -3902,7 +3914,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
}
|
}
|
||||||
} else if (!this.isUsingItem() && !this.useItem.isEmpty()) {
|
} else if (!this.isUsingItem() && !this.useItem.isEmpty()) {
|
||||||
this.useItem = ItemStack.EMPTY;
|
this.useItem = ItemStack.EMPTY;
|
||||||
|
@ -114,8 +113,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper end - lag compensate eating
|
+ // Paper end - lag compensate eating
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -4026,7 +4041,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.useItem = ItemStack.EMPTY;
|
this.useItem = ItemStack.EMPTY;
|
||||||
|
|
|
@ -3,8 +3,6 @@ From: theosib <millerti@172.16.221.1>
|
||||||
Date: Thu, 27 Sep 2018 01:43:35 -0600
|
Date: Thu, 27 Sep 2018 01:43:35 -0600
|
||||||
Subject: [PATCH] Eigencraft redstone implementation
|
Subject: [PATCH] Eigencraft redstone implementation
|
||||||
|
|
||||||
Author: theosib <millerti@172.16.221.1>
|
|
||||||
|
|
||||||
Original license: MIT
|
Original license: MIT
|
||||||
|
|
||||||
This patch implements theosib's redstone algorithms to completely overhaul the way redstone works.
|
This patch implements theosib's redstone algorithms to completely overhaul the way redstone works.
|
||||||
|
@ -17,19 +15,15 @@ A lot of this code is self-contained in a helper class.
|
||||||
Aside from making the obvious class/function renames and obfhelpers I didn't need to modify much.
|
Aside from making the obvious class/function renames and obfhelpers I didn't need to modify much.
|
||||||
Just added Bukkit's event system and took a few liberties with dead code and comment misspellings.
|
Just added Bukkit's event system and took a few liberties with dead code and comment misspellings.
|
||||||
|
|
||||||
== AT ==
|
|
||||||
public net.minecraft.world.level.block.RedStoneWireBlock shouldSignal
|
|
||||||
public net.minecraft.world.level.block.RedStoneWireBlock canSurvive(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/LevelReader;Lnet/minecraft/core/BlockPos;)Z
|
|
||||||
|
|
||||||
Co-authored-by: egg82 <eggys82@gmail.com>
|
Co-authored-by: egg82 <eggys82@gmail.com>
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/util/RedstoneWireTurbo.java b/src/main/java/com/destroystokyo/paper/util/RedstoneWireTurbo.java
|
diff --git a/io/papermc/paper/redstone/RedstoneWireTurbo.java b/io/papermc/paper/redstone/RedstoneWireTurbo.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
index 0000000000000000000000000000000000000000..ff747a1ecdf3c888bca0d69de4f85dcd810b6139
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/util/RedstoneWireTurbo.java
|
+++ b/io/papermc/paper/redstone/RedstoneWireTurbo.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +1,954 @@
|
||||||
+package com.destroystokyo.paper.util;
|
+package io.papermc.paper.redstone;
|
||||||
+
|
+
|
||||||
+import java.util.List;
|
+import java.util.List;
|
||||||
+import java.util.Map;
|
+import java.util.Map;
|
||||||
|
@ -48,14 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+import com.google.common.collect.Lists;
|
+import com.google.common.collect.Lists;
|
||||||
+import com.google.common.collect.Maps;
|
+import com.google.common.collect.Maps;
|
||||||
+
|
+
|
||||||
+/**
|
+public final class RedstoneWireTurbo {
|
||||||
+ * Used for the faster redstone algorithm.
|
|
||||||
+ * Original author: theosib
|
|
||||||
+ * Original license: MIT
|
|
||||||
+ *
|
|
||||||
+ * Ported to Paper and updated to 1.13 by egg82
|
|
||||||
+ */
|
|
||||||
+public class RedstoneWireTurbo {
|
|
||||||
+ /*
|
+ /*
|
||||||
+ * This is Helper class for BlockRedstoneWire. It implements a minimally-invasive
|
+ * This is Helper class for BlockRedstoneWire. It implements a minimally-invasive
|
||||||
+ * bolt-on accelerator that performs a breadth-first search through redstone wire blocks
|
+ * bolt-on accelerator that performs a breadth-first search through redstone wire blocks
|
||||||
|
@ -862,7 +849,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ */
|
+ */
|
||||||
+ private BlockState calculateCurrentChanges(final Level worldIn, final UpdateNode upd) {
|
+ private BlockState calculateCurrentChanges(final Level worldIn, final UpdateNode upd) {
|
||||||
+ BlockState state = upd.currentState;
|
+ BlockState state = upd.currentState;
|
||||||
+ final int i = state.getValue(RedStoneWireBlock.POWER).intValue();
|
+ final int i = state.getValue(RedStoneWireBlock.POWER);
|
||||||
+ int j = 0;
|
+ int j = 0;
|
||||||
+ j = getMaxCurrentStrength(upd, j);
|
+ j = getMaxCurrentStrength(upd, j);
|
||||||
+ int l = 0;
|
+ int l = 0;
|
||||||
|
@ -986,21 +973,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ */
|
+ */
|
||||||
+ private static int getMaxCurrentStrength(final UpdateNode upd, final int strength) {
|
+ private static int getMaxCurrentStrength(final UpdateNode upd, final int strength) {
|
||||||
+ if (upd.type != UpdateNode.Type.REDSTONE) return strength;
|
+ if (upd.type != UpdateNode.Type.REDSTONE) return strength;
|
||||||
+ final int i = upd.currentState.getValue(RedStoneWireBlock.POWER).intValue();
|
+ final int i = upd.currentState.getValue(RedStoneWireBlock.POWER);
|
||||||
+ return i > strength ? i : strength;
|
+ return i > strength ? i : strength;
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 84e6c986917128d4488afa23d29c689cadb4f55d..f02232ce97779db0d12a5d5da1d767326d78ea4c 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
--- a/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
+++ b/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
@@ -290,6 +290,60 @@ public class RedStoneWireBlock extends Block {
|
||||||
return floor.isFaceSturdy(world, pos, Direction.UP) || floor.is(Blocks.HOPPER);
|
return state.isFaceSturdy(level, pos, Direction.UP) || state.is(Blocks.HOPPER);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start - Optimize redstone
|
+ // Paper start - Optimize redstone
|
||||||
+ // The bulk of the new functionality is found in RedstoneWireTurbo.java
|
+ // The bulk of the new functionality is found in RedstoneWireTurbo.java
|
||||||
+ com.destroystokyo.paper.util.RedstoneWireTurbo turbo = new com.destroystokyo.paper.util.RedstoneWireTurbo(this);
|
+ io.papermc.paper.redstone.RedstoneWireTurbo turbo = new io.papermc.paper.redstone.RedstoneWireTurbo(this);
|
||||||
+
|
+
|
||||||
+ /*
|
+ /*
|
||||||
+ * Modified version of pre-existing updateSurroundingRedstone, which is called from
|
+ * Modified version of pre-existing updateSurroundingRedstone, which is called from
|
||||||
|
@ -1052,46 +1039,46 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
private void updatePowerStrength(Level world, BlockPos pos, BlockState state, @Nullable Orientation orientation, boolean blockAdded) {
|
private void updatePowerStrength(Level level, BlockPos pos, BlockState state, @Nullable Orientation orientation, boolean updateShape) {
|
||||||
if (useExperimentalEvaluator(world)) {
|
if (useExperimentalEvaluator(level)) {
|
||||||
new ExperimentalRedstoneWireEvaluator(this).updatePowerStrength(world, pos, state, orientation, blockAdded);
|
new ExperimentalRedstoneWireEvaluator(this).updatePowerStrength(level, pos, state, orientation, updateShape);
|
||||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
@@ -318,7 +372,7 @@ public class RedStoneWireBlock extends Block {
|
||||||
@Override
|
@Override
|
||||||
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||||
if (!oldState.is(state.getBlock()) && !world.isClientSide) {
|
if (!oldState.is(state.getBlock()) && !level.isClientSide) {
|
||||||
- this.updatePowerStrength(world, pos, state, null, true);
|
- this.updatePowerStrength(level, pos, state, null, true);
|
||||||
+ this.updateSurroundingRedstone(world, pos, state, null, true); // Paper - Optimize redstone
|
+ this.updateSurroundingRedstone(level, pos, state, null, true); // Paper - Optimize redstone
|
||||||
|
|
||||||
for (Direction direction : Direction.Plane.VERTICAL) {
|
for (Direction direction : Direction.Plane.VERTICAL) {
|
||||||
world.updateNeighborsAt(pos.relative(direction), this);
|
level.updateNeighborsAt(pos.relative(direction), this);
|
||||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
@@ -337,7 +391,7 @@ public class RedStoneWireBlock extends Block {
|
||||||
world.updateNeighborsAt(pos.relative(direction), this);
|
level.updateNeighborsAt(pos.relative(direction), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
- this.updatePowerStrength(world, pos, state, null, false);
|
- this.updatePowerStrength(level, pos, state, null, false);
|
||||||
+ this.updateSurroundingRedstone(world, pos, state, null, false); // Paper - Optimize redstone
|
+ this.updateSurroundingRedstone(level, pos, state, null, false); // Paper - Optimize redstone
|
||||||
this.updateNeighborsOfNeighboringWires(world, pos);
|
this.updateNeighborsOfNeighboringWires(level, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
@@ -363,7 +417,7 @@ public class RedStoneWireBlock extends Block {
|
||||||
if (!world.isClientSide) {
|
if (!level.isClientSide) {
|
||||||
if (sourceBlock != this || !useExperimentalEvaluator(world)) {
|
if (neighborBlock != this || !useExperimentalEvaluator(level)) {
|
||||||
if (state.canSurvive(world, pos)) {
|
if (state.canSurvive(level, pos)) {
|
||||||
- this.updatePowerStrength(world, pos, state, wireOrientation, false);
|
- this.updatePowerStrength(level, pos, state, orientation, false);
|
||||||
+ this.updateSurroundingRedstone(world, pos, state, wireOrientation, false); // Paper - Optimize redstone
|
+ this.updateSurroundingRedstone(level, pos, state, orientation, false); // Paper - Optimize redstone
|
||||||
} else {
|
} else {
|
||||||
dropResources(state, world, pos);
|
dropResources(state, level, pos);
|
||||||
world.removeBlock(pos, false);
|
level.removeBlock(pos, false);
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java b/src/main/java/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
|
diff --git a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 380fc51a252022195e178daccd8aa53dd1d71a2e..2d77780b6727f82ffc3cb216ca5f2d6483496cfd 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
|
--- a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
|
+++ b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
|
||||||
@@ -0,0 +0,0 @@ public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator {
|
@@ -44,7 +44,7 @@ public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- private int calculateTargetStrength(Level world, BlockPos pos) {
|
- private int calculateTargetStrength(Level level, BlockPos pos) {
|
||||||
+ public int calculateTargetStrength(Level world, BlockPos pos) { // Paper - Optimize redstone
|
+ public int calculateTargetStrength(Level level, BlockPos pos) { // Paper - Optimize redstone
|
||||||
int i = this.getBlockSignal(world, pos);
|
int blockSignal = this.getBlockSignal(level, pos);
|
||||||
|
return blockSignal == 15 ? blockSignal : Math.max(blockSignal, this.getIncomingWireSignal(level, pos));
|
||||||
return i == 15 ? i : Math.max(i, this.getIncomingWireSignal(world, pos));
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@ Alternate Current needs the following modifications:
|
||||||
* RedStoneWireBlock: Replace calls to vanilla's or Eigencraft's methods for handling power changes with calls to
|
* RedStoneWireBlock: Replace calls to vanilla's or Eigencraft's methods for handling power changes with calls to
|
||||||
Alternate Current's wire handler.
|
Alternate Current's wire handler.
|
||||||
|
|
||||||
diff --git a/src/main/java/alternate/current/wire/LevelHelper.java b/src/main/java/alternate/current/wire/LevelHelper.java
|
diff --git a/alternate/current/wire/LevelHelper.java b/alternate/current/wire/LevelHelper.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
index 0000000000000000000000000000000000000000..eda108e2df9bf7d1ddd89287b8d2c2d7f1637c96
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/alternate/current/wire/LevelHelper.java
|
+++ b/alternate/current/wire/LevelHelper.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +1,66 @@
|
||||||
+package alternate.current.wire;
|
+package alternate.current.wire;
|
||||||
+
|
+
|
||||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||||
|
@ -92,12 +92,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ return true;
|
+ return true;
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/alternate/current/wire/Node.java b/src/main/java/alternate/current/wire/Node.java
|
diff --git a/alternate/current/wire/Node.java b/alternate/current/wire/Node.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
index 0000000000000000000000000000000000000000..8af6c69098e64945361d116b5fd6ac21e97fcd8d
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/alternate/current/wire/Node.java
|
+++ b/alternate/current/wire/Node.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +1,113 @@
|
||||||
+package alternate.current.wire;
|
+package alternate.current.wire;
|
||||||
+
|
+
|
||||||
+import java.util.Arrays;
|
+import java.util.Arrays;
|
||||||
|
@ -211,12 +211,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ throw new UnsupportedOperationException("Not a WireNode!");
|
+ throw new UnsupportedOperationException("Not a WireNode!");
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/alternate/current/wire/PriorityQueue.java b/src/main/java/alternate/current/wire/PriorityQueue.java
|
diff --git a/alternate/current/wire/PriorityQueue.java b/alternate/current/wire/PriorityQueue.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
index 0000000000000000000000000000000000000000..d71b4d0e4c44a2620b41b89475412db53bea20ed
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/alternate/current/wire/PriorityQueue.java
|
+++ b/alternate/current/wire/PriorityQueue.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +1,211 @@
|
||||||
+package alternate.current.wire;
|
+package alternate.current.wire;
|
||||||
+
|
+
|
||||||
+import java.util.AbstractQueue;
|
+import java.util.AbstractQueue;
|
||||||
|
@ -428,12 +428,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ return prev;
|
+ return prev;
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/alternate/current/wire/SimpleQueue.java b/src/main/java/alternate/current/wire/SimpleQueue.java
|
diff --git a/alternate/current/wire/SimpleQueue.java b/alternate/current/wire/SimpleQueue.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
index 0000000000000000000000000000000000000000..2b30074252551e1dc55d5be17d26fb4a2d8eb2e4
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/alternate/current/wire/SimpleQueue.java
|
+++ b/alternate/current/wire/SimpleQueue.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +1,112 @@
|
||||||
+package alternate.current.wire;
|
+package alternate.current.wire;
|
||||||
+
|
+
|
||||||
+import java.util.AbstractQueue;
|
+import java.util.AbstractQueue;
|
||||||
|
@ -546,12 +546,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/alternate/current/wire/UpdateOrder.java b/src/main/java/alternate/current/wire/UpdateOrder.java
|
diff --git a/alternate/current/wire/UpdateOrder.java b/alternate/current/wire/UpdateOrder.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
index 0000000000000000000000000000000000000000..29338efd16cf62bb49e81cce09fbafd9b4319e7c
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/alternate/current/wire/UpdateOrder.java
|
+++ b/alternate/current/wire/UpdateOrder.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +1,390 @@
|
||||||
+package alternate.current.wire;
|
+package alternate.current.wire;
|
||||||
+
|
+
|
||||||
+import java.util.Locale;
|
+import java.util.Locale;
|
||||||
|
@ -942,12 +942,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ public abstract void forEachNeighbor(NodeProvider nodes, Node source, int forward, Consumer<Node> action);
|
+ public abstract void forEachNeighbor(NodeProvider nodes, Node source, int forward, Consumer<Node> action);
|
||||||
+
|
+
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/alternate/current/wire/WireConnection.java b/src/main/java/alternate/current/wire/WireConnection.java
|
diff --git a/alternate/current/wire/WireConnection.java b/alternate/current/wire/WireConnection.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
index 0000000000000000000000000000000000000000..4fd8cb29024330397cfe4cbc1f237d285bfb7b3e
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/alternate/current/wire/WireConnection.java
|
+++ b/alternate/current/wire/WireConnection.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +1,30 @@
|
||||||
+package alternate.current.wire;
|
+package alternate.current.wire;
|
||||||
+
|
+
|
||||||
+/**
|
+/**
|
||||||
|
@ -978,12 +978,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ this.accept = accept;
|
+ this.accept = accept;
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/alternate/current/wire/WireConnectionManager.java b/src/main/java/alternate/current/wire/WireConnectionManager.java
|
diff --git a/alternate/current/wire/WireConnectionManager.java b/alternate/current/wire/WireConnectionManager.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
index 0000000000000000000000000000000000000000..f03b313e58385d626490a9e64c9616fd08aa951e
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/alternate/current/wire/WireConnectionManager.java
|
+++ b/alternate/current/wire/WireConnectionManager.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +1,134 @@
|
||||||
+package alternate.current.wire;
|
+package alternate.current.wire;
|
||||||
+
|
+
|
||||||
+import java.util.Arrays;
|
+import java.util.Arrays;
|
||||||
|
@ -1118,12 +1118,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/alternate/current/wire/WireHandler.java b/src/main/java/alternate/current/wire/WireHandler.java
|
diff --git a/alternate/current/wire/WireHandler.java b/alternate/current/wire/WireHandler.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
index 0000000000000000000000000000000000000000..259b301b2c8b64cb7974a235afb260e0e991af54
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/alternate/current/wire/WireHandler.java
|
+++ b/alternate/current/wire/WireHandler.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +1,1073 @@
|
||||||
+package alternate.current.wire;
|
+package alternate.current.wire;
|
||||||
+
|
+
|
||||||
+import java.util.Iterator;
|
+import java.util.Iterator;
|
||||||
|
@ -2197,12 +2197,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/alternate/current/wire/WireNode.java b/src/main/java/alternate/current/wire/WireNode.java
|
diff --git a/alternate/current/wire/WireNode.java b/alternate/current/wire/WireNode.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9f5689bdb
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/alternate/current/wire/WireNode.java
|
+++ b/alternate/current/wire/WireNode.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +1,122 @@
|
||||||
+package alternate.current.wire;
|
+package alternate.current.wire;
|
||||||
+
|
+
|
||||||
+import net.minecraft.core.BlockPos;
|
+import net.minecraft.core.BlockPos;
|
||||||
|
@ -2325,11 +2325,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ return LevelHelper.setWireState(level, pos, state, added);
|
+ return LevelHelper.setWireState(level, pos, state, added);
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index efc18884358907661d1226409f11d19a394073b3..9cc47bda7197ca3f63b0ede9905c9a13931f84ed 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
--- a/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
@@ -214,6 +214,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
public final UUID uuid;
|
public final UUID uuid;
|
||||||
public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent
|
public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent
|
||||||
public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent
|
public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent
|
||||||
|
@ -2337,7 +2337,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
public LevelChunk getChunkIfLoaded(int x, int z) {
|
public LevelChunk getChunkIfLoaded(int x, int z) {
|
||||||
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately
|
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately
|
||||||
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
@@ -2213,6 +2214,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
return this.chunkSource.getGenerator().getSeaLevel();
|
return this.chunkSource.getGenerator().getSeaLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2348,14 +2348,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - optimize redstone (Alternate Current)
|
+ // Paper end - optimize redstone (Alternate Current)
|
||||||
+
|
+
|
||||||
private final class EntityCallbacks implements LevelCallback<Entity> {
|
final class EntityCallbacks implements LevelCallback<Entity> {
|
||||||
|
@Override
|
||||||
EntityCallbacks() {}
|
public void onCreated(Entity entity) {
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 872c3b8826f436b15f6ab0a3619692c5202eadc3..cb6ca60af3d3f90501e4693a78466b9f7462362d 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
--- a/net/minecraft/world/level/Level.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
+++ b/net/minecraft/world/level/Level.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -1401,6 +1401,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||||
|
|
||||||
public abstract FuelValues fuelValues();
|
public abstract FuelValues fuelValues();
|
||||||
|
|
||||||
|
@ -2371,74 +2371,75 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper end - optimize redstone (Alternate Current)
|
+ // Paper end - optimize redstone (Alternate Current)
|
||||||
+
|
+
|
||||||
public static enum ExplosionInteraction implements StringRepresentable {
|
public static enum ExplosionInteraction implements StringRepresentable {
|
||||||
|
NONE("none"),
|
||||||
NONE("none"), BLOCK("block"), MOB("mob"), TNT("tnt"), TRIGGER("trigger"), STANDARD("standard"); // CraftBukkit - Add STANDARD which will always use Explosion.Effect.DESTROY
|
BLOCK("block"),
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index f02232ce97779db0d12a5d5da1d767326d78ea4c..12c9d60314c99fb65e640d255a2d0c6b7790ad4d 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
--- a/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
+++ b/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
@@ -290,7 +290,7 @@ public class RedStoneWireBlock extends Block {
|
||||||
return floor.isFaceSturdy(world, pos, Direction.UP) || floor.is(Blocks.HOPPER);
|
return state.isFaceSturdy(level, pos, Direction.UP) || state.is(Blocks.HOPPER);
|
||||||
}
|
}
|
||||||
|
|
||||||
- // Paper start - Optimize redstone
|
- // Paper start - Optimize redstone
|
||||||
+ // Paper start - Optimize redstone (Eigencraft)
|
+ // Paper start - Optimize redstone (Eigencraft)
|
||||||
// The bulk of the new functionality is found in RedstoneWireTurbo.java
|
// The bulk of the new functionality is found in RedstoneWireTurbo.java
|
||||||
com.destroystokyo.paper.util.RedstoneWireTurbo turbo = new com.destroystokyo.paper.util.RedstoneWireTurbo(this);
|
io.papermc.paper.redstone.RedstoneWireTurbo turbo = new io.papermc.paper.redstone.RedstoneWireTurbo(this);
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
@@ -372,7 +372,13 @@ public class RedStoneWireBlock extends Block {
|
||||||
@Override
|
@Override
|
||||||
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||||
if (!oldState.is(state.getBlock()) && !world.isClientSide) {
|
if (!oldState.is(state.getBlock()) && !level.isClientSide) {
|
||||||
- this.updateSurroundingRedstone(world, pos, state, null, true); // Paper - Optimize redstone
|
- this.updateSurroundingRedstone(level, pos, state, null, true); // Paper - Optimize redstone
|
||||||
+ // Paper start - optimize redstone - replace call to updatePowerStrength
|
+ // Paper start - optimize redstone - replace call to updatePowerStrength
|
||||||
+ if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
|
+ if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
|
||||||
+ world.getWireHandler().onWireAdded(pos, state); // Alternate Current
|
+ level.getWireHandler().onWireAdded(pos, state); // Alternate Current
|
||||||
+ } else {
|
+ } else {
|
||||||
+ this.updateSurroundingRedstone(world, pos, state, null, true); // Vanilla/Eigencraft
|
+ this.updateSurroundingRedstone(level, pos, state, null, true); // Vanilla/Eigencraft
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end - optimize redstone
|
||||||
|
|
||||||
for (Direction direction : Direction.Plane.VERTICAL) {
|
for (Direction direction : Direction.Plane.VERTICAL) {
|
||||||
world.updateNeighborsAt(pos.relative(direction), this);
|
level.updateNeighborsAt(pos.relative(direction), this);
|
||||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
@@ -391,7 +397,13 @@ public class RedStoneWireBlock extends Block {
|
||||||
world.updateNeighborsAt(pos.relative(direction), this);
|
level.updateNeighborsAt(pos.relative(direction), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
- this.updateSurroundingRedstone(world, pos, state, null, false); // Paper - Optimize redstone
|
- this.updateSurroundingRedstone(level, pos, state, null, false); // Paper - Optimize redstone
|
||||||
+ // Paper start - optimize redstone - replace call to updatePowerStrength
|
+ // Paper start - optimize redstone - replace call to updatePowerStrength
|
||||||
+ if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
|
+ if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
|
||||||
+ world.getWireHandler().onWireRemoved(pos, state); // Alternate Current
|
+ level.getWireHandler().onWireRemoved(pos, state); // Alternate Current
|
||||||
+ } else {
|
+ } else {
|
||||||
+ this.updateSurroundingRedstone(world, pos, state, null, false); // Vanilla/Eigencraft
|
+ this.updateSurroundingRedstone(level, pos, state, null, false); // Vanilla/Eigencraft
|
||||||
+ }
|
+ }
|
||||||
this.updateNeighborsOfNeighboringWires(world, pos);
|
+ // Paper end - optimize redstone
|
||||||
|
this.updateNeighborsOfNeighboringWires(level, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
|
@@ -415,9 +427,15 @@ public class RedStoneWireBlock extends Block {
|
||||||
@Override
|
@Override
|
||||||
protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, @Nullable Orientation wireOrientation, boolean notify) {
|
protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) {
|
||||||
if (!world.isClientSide) {
|
if (!level.isClientSide) {
|
||||||
+ // Paper start - optimize redstone (Alternate Current)
|
+ // Paper start - optimize redstone (Alternate Current)
|
||||||
+ // Alternate Current handles breaking of redstone wires in the WireHandler.
|
+ // Alternate Current handles breaking of redstone wires in the WireHandler.
|
||||||
+ if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
|
+ if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
|
||||||
+ world.getWireHandler().onWireUpdated(pos, state, wireOrientation);
|
+ level.getWireHandler().onWireUpdated(pos, state, orientation);
|
||||||
+ } else
|
+ } else
|
||||||
+ // Paper end - optimize redstone (Alternate Current)
|
+ // Paper end - optimize redstone (Alternate Current)
|
||||||
if (sourceBlock != this || !useExperimentalEvaluator(world)) {
|
if (neighborBlock != this || !useExperimentalEvaluator(level)) {
|
||||||
if (state.canSurvive(world, pos)) {
|
if (state.canSurvive(level, pos)) {
|
||||||
- this.updateSurroundingRedstone(world, pos, state, wireOrientation, false); // Paper - Optimize redstone
|
- this.updateSurroundingRedstone(level, pos, state, orientation, false); // Paper - Optimize redstone
|
||||||
+ this.updateSurroundingRedstone(world, pos, state, wireOrientation, false); // Paper - Optimize redstone (Eigencraft)
|
+ this.updateSurroundingRedstone(level, pos, state, orientation, false); // Paper - Optimize redstone (Eigencraft)
|
||||||
} else {
|
} else {
|
||||||
dropResources(state, world, pos);
|
dropResources(state, level, pos);
|
||||||
world.removeBlock(pos, false);
|
level.removeBlock(pos, false);
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java b/src/main/java/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
|
diff --git a/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java b/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 83f5da3e24834882193b9d7e3a788517e4b12b55..db7a7b091d2eb0f5b7efbe0db2b91709dee688e8 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
|
--- a/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
|
+++ b/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
|
||||||
@@ -0,0 +0,0 @@ public class ExperimentalRedstoneUtils {
|
@@ -17,6 +17,11 @@ public class ExperimentalRedstoneUtils {
|
||||||
if (up != null) {
|
if (front != null) {
|
||||||
orientation = orientation.withFront(up);
|
orientation = orientation.withFront(front);
|
||||||
}
|
}
|
||||||
+ // Paper start - Optimize redstone (Alternate Current) - use default front instead of random
|
+ // Paper start - Optimize redstone (Alternate Current) - use default front instead of random
|
||||||
+ else if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
|
+ else if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
|
||||||
|
|
Loading…
Reference in a new issue