Archiviert
12
0

Add TickFreeze Patch

Dieser Commit ist enthalten in:
yoyosource 2021-12-13 20:51:18 +01:00
Ursprung c9f8b471d0
Commit 0a9b35f004

Datei anzeigen

@ -5,7 +5,7 @@ Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
===================================================================
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
--- a/src/main/java/net/minecraft/server/WorldServer.java (revision 571772e5fd38f66c11220ce29cd15d70e8da46f6)
+++ b/src/main/java/net/minecraft/server/WorldServer.java (date 1639394168874)
+++ b/src/main/java/net/minecraft/server/WorldServer.java (date 1639424761201)
@@ -14,38 +14,28 @@
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
@ -58,29 +58,40 @@ diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java
// CraftBukkit end
public class WorldServer extends World {
@@ -303,12 +293,14 @@
}
@@ -161,6 +151,7 @@
this.N();
- this.a();
+ if (!freezed) {
+ this.a();
+ }
gameprofilerfiller.exitEnter("chunkSource");
public void doTick(BooleanSupplier booleansupplier) {
GameProfilerFiller gameprofilerfiller = this.getMethodProfiler();
+ currentlyFrozen = freezed; // Do not Change freezed mid tick!
this.ticking = true;
gameprofilerfiller.enter("world border");
@@ -308,7 +299,7 @@
this.getChunkProvider().tick(booleansupplier);
gameprofilerfiller.exitEnter("tickPending");
timings.doTickPending.startTiming(); // Spigot
- if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
+ if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES && !freezed) {
+ if (!currentlyFrozen && this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
this.nextTickListBlock.b();
this.nextTickListFluid.b();
}
@@ -332,19 +324,29 @@
@@ -322,7 +313,9 @@
gameprofilerfiller.exitEnter("blockEvents");
timings.doSounds.startTiming(); // Spigot
- this.ad();
+ if (!currentlyFrozen) {
+ this.ad();
+ }
timings.doSounds.stopTiming(); // Spigot
this.ticking = false;
gameprofilerfiller.exitEnter("entities");
@@ -332,18 +325,28 @@
this.resetEmptyTime();
}
+ lastFreezed = false;
+ if (!freezed && !physicsTick.isEmpty()) {
+ if (!currentlyFrozen && !physicsTick.isEmpty()) {
+ Map<BlockPosition, Runnable> physicsTickList = new LinkedHashMap<>(physicsTick);
+ physicsTick.clear();
+ physicsTickList.forEach((blockPosition, runnable) -> runnable.run());
@ -99,55 +110,64 @@ diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java
// CraftBukkit start - Fixed an NPE
if (entity == null) {
continue;
}
+ if (freezed && !(entity instanceof EntityPlayer)) {
+ continue;
+ }
+ if (currentlyFrozen && !(entity instanceof EntityPlayer)) {
+ continue;
}
// CraftBukkit end
this.a((entity1) -> {
++entity1.ticksLived;
@@ -428,6 +430,7 @@
@@ -415,7 +418,9 @@
gameprofilerfiller.exit();
timings.tickEntities.stopTiming(); // Spigot
- this.tickBlockEntities();
+ if (!currentlyFrozen) {
+ this.tickBlockEntities();
+ }
}
gameprofilerfiller.exit();
@@ -428,6 +433,7 @@
}
public void a(Chunk chunk, int i) {
+ if (freezed) return;
+ if (currentlyFrozen) return;
ChunkCoordIntPair chunkcoordintpair = chunk.getPos();
boolean flag = this.isRaining();
int j = chunkcoordintpair.d();
@@ -584,6 +587,7 @@
@@ -584,6 +590,7 @@
}
private void a(NextTickListEntry<FluidType> nextticklistentry) {
+ if (freezed) return;
+ if (currentlyFrozen) return;
Fluid fluid = this.getFluid(nextticklistentry.a);
if (fluid.getType() == nextticklistentry.b()) {
@@ -593,6 +597,7 @@
@@ -593,6 +600,7 @@
}
private void b(NextTickListEntry<Block> nextticklistentry) {
+ if (freezed) return;
+ if (currentlyFrozen) return;
IBlockData iblockdata = this.getType(nextticklistentry.a);
if (iblockdata.getBlock() == nextticklistentry.b()) {
@@ -602,6 +607,37 @@
@@ -602,6 +610,36 @@
}
public void entityJoinedWorld(Entity entity) {
+ if (freezed && !(entity instanceof EntityPlayer) && !(entity instanceof EntityItem)) {
+ if (currentlyFrozen && !(entity instanceof EntityPlayer) && !(entity instanceof EntityItem)) {
+ PacketPlayOutEntityVelocity packetPlayOutEntityVelocity = new PacketPlayOutEntityVelocity(entity.getId(), new Vec3D(0, 0, 0));
+ PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(entity);
+ entity.setNoGravity(true);
+ PacketPlayOutEntityMetadata packetPlayOutEntityMetadata;
+ if (entity instanceof EntityTNTPrimed) {
+ EntityTNTPrimed entitytntprimed = (EntityTNTPrimed) entity;
+ entitytntprimed.setInvisible(true);
+ EntityTNTPrimed entityTNTPrimed = new EntityTNTPrimed(EntityTypes.TNT, this);
+ entityTNTPrimed.setNoGravity(true);
+ entityTNTPrimed.setPosition(entity.locX(), entity.locY(), entity.locZ());
+ entityTNTPrimed.setFuseTicks(((EntityTNTPrimed) entity).getFuseTicks());
+ packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(entity.getId(), entityTNTPrimed.getDataWatcher(), true);
+ } else {
+ packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), true);
+ }
+ PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), true);
+ if (entity instanceof EntityTNTPrimed) {
+ EntityTNTPrimed entitytntprimed = (EntityTNTPrimed) entity;
+ entitytntprimed.setInvisible(false);
+ }
+ entity.setNoGravity(false);
+ players.forEach(entityPlayer -> {
+ entityPlayer.playerConnection.sendPacket(packetPlayOutEntityVelocity);
+ entityPlayer.playerConnection.sendPacket(packetPlayOutEntityTeleport);
@ -168,6 +188,19 @@ diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java
if (entity instanceof EntityHuman || this.getChunkProvider().a(entity)) {
// Spigot start
if (!org.spigotmc.ActivationRange.checkIfActive(entity)) {
@@ -1315,6 +1353,12 @@
@Override
public void playBlockAction(BlockPosition blockposition, Block block, int i, int j) {
+ if (!currentlyFrozen) {
+ physicsTick.put(blockposition, () -> {
+ this.I.add(new BlockActionData(blockposition, block, i, j));
+ });
+ return;
+ }
this.I.add(new BlockActionData(blockposition, block, i, j));
}
Index: src/main/java/net/minecraft/server/World.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
@ -175,7 +208,7 @@ Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
===================================================================
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
--- a/src/main/java/net/minecraft/server/World.java (revision 571772e5fd38f66c11220ce29cd15d70e8da46f6)
+++ b/src/main/java/net/minecraft/server/World.java (date 1639348240863)
+++ b/src/main/java/net/minecraft/server/World.java (date 1639417061068)
@@ -1,29 +1,23 @@
package net.minecraft.server;
@ -214,24 +247,25 @@ diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/m
// CraftBukkit end
public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -76,6 +70,10 @@
@@ -76,6 +70,11 @@
private org.spigotmc.TickLimiter tileLimiter;
private int tileTickPosition;
+ public boolean freezed = false;
+ protected boolean currentlyFrozen = false;
+ protected boolean lastFreezed = false;
+ protected Map<BlockPosition, Runnable> physicsTick = new LinkedHashMap();
+
public CraftWorld getWorld() {
return this.world;
}
@@ -322,8 +320,15 @@
@@ -322,8 +321,15 @@
}
}
// CraftBukkit end
- iblockdata.a(this, blockposition, j);
- iblockdata.b(this, blockposition, j);
+ if (!freezed) {
+ if (!currentlyFrozen) {
+ iblockdata.a(this, blockposition, j);
+ iblockdata.b(this, blockposition, j);
+ } else {
@ -243,11 +277,11 @@ diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/m
}
this.a(blockposition, iblockdata1, iblockdata2);
@@ -418,6 +423,14 @@
@@ -418,6 +424,14 @@
}
public void a(BlockPosition blockposition, Block block, BlockPosition blockposition1) {
+ if (freezed) {
+ if (currentlyFrozen) {
+ if (!isClientSide) {
+ physicsTick.put(blockposition, () -> {
+ this.a(blockposition, block, blockposition1);
@ -258,3 +292,32 @@ diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/m
if (!this.isClientSide) {
IBlockData iblockdata = this.getType(blockposition);
@@ -1193,7 +1207,9 @@
}
protected void a() {
- this.a(this.worldData.getTime() + 1L);
+ if (!currentlyFrozen) {
+ this.a(this.worldData.getTime() + 1L);
+ }
if (this.worldData.v().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)) {
this.setDayTime(this.worldData.getDayTime() + 1L);
}
@@ -1226,7 +1242,16 @@
}
public void playBlockAction(BlockPosition blockposition, Block block, int i, int j) {
- this.getType(blockposition).a(this, blockposition, i, j);
+ /*
+ if (!currentlyFrozen) {
+ physicsTick.put(blockposition, () -> {
+ this.getType(blockposition).a(this, blockposition, i, j);
+ });
+ return;
+ }
+ */
+ IBlockData iblockdata = this.getType(blockposition); // Block of Position
+ iblockdata.a(this, blockposition, i, j);
}
@Override