3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 11:00:06 +01:00

Even more patches for 1.14

Dieser Commit ist enthalten in:
Shane Freeder 2019-05-05 03:23:25 +01:00
Ursprung acd2bd3c2c
Commit eb25d664df
28 geänderte Dateien mit 591 neuen und 1150 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,132 @@
From 2296ebebccd5c2aa4de40146dc5df177da04acad Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 28 Jul 2018 12:18:27 -0400
Subject: [PATCH] Ignore Dead Entities in entityList iteration
A spigot change delays removal of entities from the entity list.
This causes a change in behavior from Vanilla where getEntities type
methods will return dead entities that they shouldn't otherwise be doing.
This will ensure that dead entities are skipped from iteration since
they shouldn't of been in the list in the first place.
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index f38179e98..8e1bda4de 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -176,6 +176,7 @@ public class PaperCommand extends Command {
List<Entity> entities = world.entityList;
entities.forEach(e -> {
MinecraftKey key = e.getMinecraftKey();
+ if (e.shouldBeRemoved) return; // Paper
MutablePair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ());
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 0c8a2ac90..21fae98c1 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -665,6 +665,7 @@ public class Chunk implements IChunkAccess {
while (iterator.hasNext()) {
Entity entity1 = (Entity) iterator.next();
+ if (entity1.shouldBeRemoved) continue; // Paper
if (entity1.getBoundingBox().c(axisalignedbb) && entity1 != entity) {
if (predicate == null || predicate.test(entity1)) {
@@ -702,6 +703,7 @@ public class Chunk implements IChunkAccess {
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
+ if (entity.shouldBeRemoved) continue; // Paper
if ((entitytypes == null || entity.getEntityType() == entitytypes) && entity.getBoundingBox().c(axisalignedbb) && predicate.test(entity)) {
list.add(entity);
@@ -723,6 +725,7 @@ public class Chunk implements IChunkAccess {
while (iterator.hasNext()) {
T t0 = (T) iterator.next(); // CraftBukkit - decompile error
+ if (t0.shouldBeRemoved) continue; // Paper
if (oclass.isInstance(t0) && t0.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(t0))) { // Spigot - instance check
list.add(t0);
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 4648a93b0..99abf7f9c 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -122,7 +122,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
public boolean dead;
public float D;
public float E;
- public float F;
+ public boolean shouldBeRemoved; // Paper
public float fallDistance;
private float av;
private float aw;
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 3e41c080d..3bfe40bb6 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -843,6 +843,7 @@ public class WorldServer extends World {
while (objectiterator.hasNext()) {
Entity entity = (Entity) objectiterator.next();
+ if (entity.shouldBeRemoved) continue; // Paper
// CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs
if (entity instanceof EntityInsentient) {
EntityInsentient entityinsentient = (EntityInsentient) entity;
@@ -1131,6 +1132,7 @@ public class WorldServer extends World {
this.I.add(((EntityInsentient) entity).getNavigation());
}
entity.valid = true; // CraftBukkit
+ entity.shouldBeRemoved = false; // Paper - shouldn't be removed after being re-added
new com.destroystokyo.paper.event.entity.EntityAddToWorldEvent(entity.getBukkitEntity()).callEvent(); // Paper - fire while valid
}
@@ -1145,6 +1147,7 @@ public class WorldServer extends World {
this.removeEntityFromChunk(entity);
this.entitiesById.remove(entity.getId());
this.unregisterEntity(entity);
+ entity.shouldBeRemoved = true; // Paper
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index f8870f37b..03148879f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -805,6 +805,7 @@ public class CraftWorld implements World {
for (Object o : world.entitiesById.values()) {
if (o instanceof net.minecraft.server.Entity) {
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
+ if (mcEnt.shouldBeRemoved) continue; // Paper
Entity bukkitEntity = mcEnt.getBukkitEntity();
// Assuming that bukkitEntity isn't null
@@ -823,6 +824,7 @@ public class CraftWorld implements World {
for (Object o : world.entitiesById.values()) {
if (o instanceof net.minecraft.server.Entity) {
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
+ if (mcEnt.shouldBeRemoved) continue; // Paper
Entity bukkitEntity = mcEnt.getBukkitEntity();
// Assuming that bukkitEntity isn't null
@@ -847,6 +849,7 @@ public class CraftWorld implements World {
for (Object entity: world.entitiesById.values()) {
if (entity instanceof net.minecraft.server.Entity) {
+ if (((net.minecraft.server.Entity) entity).shouldBeRemoved) continue; // Paper
Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity();
if (bukkitEntity == null) {
@@ -869,6 +872,7 @@ public class CraftWorld implements World {
for (Object entity: world.entitiesById.values()) {
if (entity instanceof net.minecraft.server.Entity) {
+ if (((net.minecraft.server.Entity) entity).shouldBeRemoved) continue; // Paper
Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity();
if (bukkitEntity == null) {
--
2.21.0

Datei anzeigen

@ -1,4 +1,4 @@
From 2fab85ef228b9e7e1aafe1b04abd84ff634bbbda Mon Sep 17 00:00:00 2001
From d1a4bbe9d075d932918bfbf3c054ae1871cad606 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 29 Jul 2018 15:48:50 -0400
Subject: [PATCH] Provide option to use a versioned world folder for testing
@ -19,7 +19,7 @@ may be some delay there, but region files are only copied on demand.
This is highly experiemental so backup your world before relying on this to not modify it
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index d42853d14c..63fdd94818 100644
index c8f9c45e5..52adc671e 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -13,6 +13,7 @@ import java.util.List;
@ -30,7 +30,7 @@ index d42853d14c..63fdd94818 100644
import java.util.regex.Pattern;
import com.google.common.collect.Lists;
@@ -308,4 +309,27 @@ public class PaperConfig {
@@ -284,4 +285,27 @@ public class PaperConfig {
Bukkit.getLogger().log(Level.INFO, "Using Aikar's Alternative Luck Formula to apply Luck attribute to all loot pool calculations. See https://luckformula.emc.gs");
}
}
@ -58,45 +58,31 @@ index d42853d14c..63fdd94818 100644
+ }
+ }
}
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 485bce9872..60143ff63f 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -58,8 +58,55 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
// private boolean f; // CraftBukkit
public final LongSet blacklist = new LongOpenHashSet();
private static final double SAVE_QUEUE_TARGET_SIZE = 625; // Spigot
+ // Paper start - support saving to an alternate directory
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
index c8573a8ee..1b12a1611 100644
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
@@ -10,13 +10,41 @@ import java.io.IOException;
import javax.annotation.Nullable;
import com.destroystokyo.paper.PaperConfig; // Paper
+import org.apache.logging.log4j.LogManager;
+
public abstract class RegionFileCache implements AutoCloseable {
public final Long2ObjectLinkedOpenHashMap<RegionFile> cache = new Long2ObjectLinkedOpenHashMap();
private final File a;
+ // Paper start
+ private final File templateWorld;
+ private final File actualWorld;
+ private final boolean useAltWorld;
+
+ private void copyIfNeeded(int x, int z) {
+ if (!useAltWorld) {
+ return;
+ }
+ synchronized (RegionFileCache.class) {
+ if (RegionFileCache.hasRegionFile(this.actualWorld, x, z)) {
+ return;
+ }
+ File actual = RegionFileCache.getRegionFileName(this.actualWorld, x, z);
+ File template = RegionFileCache.getRegionFileName(this.templateWorld, x, z);
+ if (!actual.exists() && template.exists()) {
+ try {
+ //a.info("Copying" + template + " to " + actual);
+ java.nio.file.Files.copy(template.toPath(), actual.toPath(), java.nio.file.StandardCopyOption.COPY_ATTRIBUTES);
+ } catch (IOException e1) {
+ LogManager.getLogger().error("Error copying " + template + " to " + actual, e1);
+ MinecraftServer.getServer().safeShutdown();
+ com.destroystokyo.paper.util.SneakyThrow.sneaky(e1);
+ }
+ }
+ }
+ }
+ private boolean useAltWorld;
+ // Paper end
+
public ChunkRegionLoader(File file, DataFixer datafixer) {
+ // Paper start
protected RegionFileCache(File file) {
this.a = file;
+ // Paper end
+
+ this.actualWorld = file;
+ if (com.destroystokyo.paper.PaperConfig.useVersionedWorld) {
+ this.useAltWorld = true;
@ -114,57 +100,73 @@ index 485bce9872..60143ff63f 100644
+ this.useAltWorld = false;
+ this.templateWorld = file;
+ }
+ // Paper end
this.c = file;
this.d = datafixer;
}
@@ -97,7 +144,13 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
}
public boolean chunkExists(int x, int z) {
- return RegionFileCache.chunkExists(this.c, x, z);
+ // Paper start
+ if (this.saveMap.containsKey(ChunkCoordIntPair.asLong(x, z))) {
+ return true;
+ }
+ copyIfNeeded(x, z);
+ return RegionFileCache.chunkExists(this.actualWorld, x, z);
+ // Paper end
}
@Nullable
@@ -107,6 +160,8 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
return null;
}
// CraftBukkit end
+ copyIfNeeded(i, j); // Paper
+
NBTTagCompound nbttagcompound = SupplierUtils.getIfExists(this.saveMap.get(ChunkCoordIntPair.asLong(i, j))); // Spigot // Paper
private RegionFile a(ChunkCoordIntPair chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit
@@ -34,6 +62,7 @@ public abstract class RegionFileCache implements AutoCloseable {
this.a.mkdirs();
}
if (nbttagcompound != null) {
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
index d072222390..8c8b7cbab5 100644
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
@@ -76,6 +76,13 @@ public class RegionFileCache {
itr.remove();
+ copyIfNeeded(chunkcoordintpair.x, chunkcoordintpair.z); // Paper
File file = new File(this.a, "r." + chunkcoordintpair.getRegionX() + "." + chunkcoordintpair.getRegionZ() + ".mca");
if (existingOnly && !file.exists()) return null; // CraftBukkit
RegionFile regionfile1 = new RegionFile(file);
@@ -43,6 +72,15 @@ public abstract class RegionFileCache implements AutoCloseable {
}
}
+ public static synchronized File getRegionFileName(File file, int i, int j) {
+ File file1 = new File(file, "region");
+ return new File(file1, "r." + (i >> 5) + "." + (j >> 5) + ".mca");
+ }
+ public static synchronized boolean hasRegionFile(File file, int i, int j) {
+ return RegionFileCache.cache.containsKey(getRegionFileName(file, i, j));
+ public synchronized boolean hasRegionFile(File file, int i, int j) {
+ return cache.containsKey(getRegionFileName(file, i, j));
+ }
// Paper End
+ // Paper End
+
@Nullable
public NBTTagCompound read(ChunkCoordIntPair chunkcoordintpair) throws IOException {
RegionFile regionfile = this.a(chunkcoordintpair, false); // CraftBukkit
@@ -129,9 +167,33 @@ public abstract class RegionFileCache implements AutoCloseable {
public static synchronized void a() {
// CraftBukkit start
public boolean chunkExists(ChunkCoordIntPair pos) throws IOException {
+ copyIfNeeded(pos.x, pos.z); // Paper
RegionFile regionfile = a(pos, true);
return regionfile != null ? regionfile.d(pos) : false;
}
// CraftBukkit end
+
+ private void copyIfNeeded(int x, int z) {
+ if (!useAltWorld) {
+ return;
+ }
+ synchronized (RegionFileCache.class) {
+ if (hasRegionFile(this.actualWorld, x, z)) {
+ return;
+ }
+ File actual = RegionFileCache.getRegionFileName(this.actualWorld, x, z);
+ File template = RegionFileCache.getRegionFileName(this.templateWorld, x, z);
+ if (!actual.exists() && template.exists()) {
+ try {
+ net.minecraft.server.MinecraftServer.LOGGER.info("Copying" + template + " to " + actual);
+ java.nio.file.Files.copy(template.toPath(), actual.toPath(), java.nio.file.StandardCopyOption.COPY_ATTRIBUTES);
+ } catch (IOException e1) {
+ LogManager.getLogger().error("Error copying " + template + " to " + actual, e1);
+ MinecraftServer.getServer().safeShutdown(false);
+ com.destroystokyo.paper.util.SneakyThrow.sneaky(e1);
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/net/minecraft/server/WorldNBTStorage.java b/src/main/java/net/minecraft/server/WorldNBTStorage.java
index 577ba1b5f9..9be0e994ef 100644
index 350ac42d6..eaae44686 100644
--- a/src/main/java/net/minecraft/server/WorldNBTStorage.java
+++ b/src/main/java/net/minecraft/server/WorldNBTStorage.java
@@ -32,6 +32,58 @@ public class WorldNBTStorage implements IDataManager, IPlayerFileData {
@@ -31,6 +31,58 @@ public class WorldNBTStorage implements IPlayerFileData {
public WorldNBTStorage(File file, String s, @Nullable MinecraftServer minecraftserver, DataFixer datafixer) {
this.a = datafixer;

Datei anzeigen

@ -0,0 +1,24 @@
From ec527b882e52d49e8a77a9bd1cbd0438bb2bed2f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 29 Jul 2018 22:58:47 -0400
Subject: [PATCH] MC-111480: Start Entity ID's at 1
DataWatchers that store Entity ID's treat 0 as special,
and can break things such as Elytra Fireworks.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 99abf7f9c..2dfa7d251 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -89,7 +89,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
// CraftBukkit end
protected static final Logger LOGGER = LogManager.getLogger();
- private static final AtomicInteger entityCount = new AtomicInteger();
+ private static final AtomicInteger entityCount = new AtomicInteger(1); // paper - start entity count from 1
private static final List<ItemStack> c = Collections.emptyList();
private static final AxisAlignedBB d = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
private static double e = 1.0D;
--
2.21.0

Datei anzeigen

@ -1,4 +1,4 @@
From 5c69091e158c9b2c6cdfc776af3e1594baac8978 Mon Sep 17 00:00:00 2001
From 0d99d778d80601f15703e3b8ee3c48d17c20de5f Mon Sep 17 00:00:00 2001
From: willies952002 <admin@domnian.com>
Date: Thu, 26 Jul 2018 02:25:46 -0400
Subject: [PATCH] Implement Expanded ArmorStand API
@ -8,28 +8,28 @@ Add the following:
- Enable/Disable slot interactions
diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
index 694df9e185..c604182dd9 100644
index f8cd62199..8fb3ce17a 100644
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
@@ -36,7 +36,7 @@ public class EntityArmorStand extends EntityLiving {
private final NonNullList<ItemStack> bF;
private boolean bG;
public long h;
- private int bH;
+ private int bH;public void setDisabledSlots(int i) { bH = i;} public int getDisabledSlots() { return bH ;} // Paper - OBFHELPER
private boolean bI;
private final NonNullList<ItemStack> armorItems;
private boolean bD;
public long bt;
- private int bE;
+ private int bE; public void setDisabledSlots(int i) { bE = i;} public int getDisabledSlots() { return bE ;} // Paper - OBFHELPER
public Vector3f headPose;
public Vector3f bodyPose;
@@ -361,6 +361,7 @@ public class EntityArmorStand extends EntityLiving {
public Vector3f leftArmPose;
@@ -381,6 +381,7 @@ public class EntityArmorStand extends EntityLiving {
return enumitemslot;
}
+ public boolean isSlotDisabled(EnumItemSlot slot) { return this.c(slot); } // Paper - OBFHELPER
public boolean c(EnumItemSlot enumitemslot) {
return (this.bH & 1 << enumitemslot.c()) != 0 || enumitemslot.a() == EnumItemSlot.Function.HAND && !this.hasArms();
+ public boolean isSlotDisabled(EnumItemSlot slot) { return this.d(slot); } // Paper - OBFHELPER
public boolean d(EnumItemSlot enumitemslot) {
return (this.bE & 1 << enumitemslot.c()) != 0 || enumitemslot.a() == EnumItemSlot.Function.HAND && !this.hasArms();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
index 124c3185bc..9f5c3b92e3 100644
index 124c3185b..9f5c3b92e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
@@ -30,11 +30,13 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {

Datei anzeigen

@ -1,16 +1,16 @@
From f3de9936f9b7986b89d7a91927a574c46fdc85f3 Mon Sep 17 00:00:00 2001
From 21a3ebeee5774fdadd523bed39f01798f46cda9c Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Fri, 20 Jul 2018 23:37:03 -0500
Subject: [PATCH] AnvilDamageEvent
diff --git a/src/main/java/net/minecraft/server/ContainerAnvil.java b/src/main/java/net/minecraft/server/ContainerAnvil.java
index 1560dd382a..d206e04657 100644
index ada5cf982..64a992152 100644
--- a/src/main/java/net/minecraft/server/ContainerAnvil.java
+++ b/src/main/java/net/minecraft/server/ContainerAnvil.java
@@ -74,6 +74,16 @@ public class ContainerAnvil extends Container {
if (!world.isClientSide) {
if (!entityhuman1.abilities.canInstantlyBuild && iblockdata.a(TagsBlock.ANVIL) && entityhuman1.getRandom().nextFloat() < 0.12F) {
@@ -85,6 +85,16 @@ public class ContainerAnvil extends Container {
if (!entityhuman.abilities.canInstantlyBuild && iblockdata.a(TagsBlock.ANVIL) && entityhuman.getRandom().nextFloat() < 0.12F) {
IBlockData iblockdata1 = BlockAnvil.a_(iblockdata);
+ // Paper start
+ com.destroystokyo.paper.event.block.AnvilDamagedEvent event = new com.destroystokyo.paper.event.block.AnvilDamagedEvent(getBukkitView(), iblockdata1 != null ? org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(iblockdata1) : null);
@ -24,7 +24,7 @@ index 1560dd382a..d206e04657 100644
+ // Paper end
if (iblockdata1 == null) {
world.setAir(blockposition);
world.a(blockposition, false);
--
2.21.0

Datei anzeigen

@ -1,11 +1,11 @@
From 3ef265b92bb3d54b656801642ceeba93feae998c Mon Sep 17 00:00:00 2001
From 5157854b464ebc1aed770cb2e9227a363fd2d45b Mon Sep 17 00:00:00 2001
From: Mark Vainomaa <mikroskeem@mikroskeem.eu>
Date: Mon, 16 Jul 2018 00:05:05 +0300
Subject: [PATCH] Add TNTPrimeEvent
diff --git a/src/main/java/net/minecraft/server/BlockFire.java b/src/main/java/net/minecraft/server/BlockFire.java
index 3f421d46a0..0fbcd352c8 100644
index 73190ccba..4086d5ed2 100644
--- a/src/main/java/net/minecraft/server/BlockFire.java
+++ b/src/main/java/net/minecraft/server/BlockFire.java
@@ -2,6 +2,7 @@ package net.minecraft.server;
@ -16,29 +16,31 @@ index 3f421d46a0..0fbcd352c8 100644
import java.util.Map;
import java.util.Random;
import java.util.Map.Entry;
@@ -233,12 +234,19 @@ public class BlockFire extends Block {
@@ -237,7 +238,7 @@ public class BlockFire extends Block {
world.setTypeAndData(blockposition, (IBlockData) this.a((IBlockAccess) world, blockposition).set(BlockFire.AGE, l), 3);
} else {
- world.setAir(blockposition);
+ if(iblockdata.getBlock() != Blocks.TNT) world.setAir(blockposition); // Paper - TNTPrimeEvent - We might be cancelling it below, move the setAir down
- world.a(blockposition, false);
+ if(iblockdata.getBlock() != Blocks.TNT) world.a(blockposition, false); // Paper - TNTPrimeEvent - We might be cancelling it below, move the setAir down
}
Block block = iblockdata.getBlock();
@@ -245,6 +246,13 @@ public class BlockFire extends Block {
if (block instanceof BlockTNT) {
BlockTNT blocktnt = (BlockTNT) block;
+ // Paper start - TNTPrimeEvent
+ org.bukkit.block.Block tntBlock = MCUtil.toBukkitBlock(world, blockposition);
+ if (!new TNTPrimeEvent(tntBlock, TNTPrimeEvent.PrimeReason.FIRE, null).callEvent()) {
+ return;
+ }
+ world.setAir(blockposition); // setair after non cancelled event, it would usually be air by now
+ BlockTNT.a(world, blockposition);; // setair after non cancelled event, it would usually be air by now
+ // Paper end
((BlockTNT) block).a(world, blockposition);
BlockTNT.a(world, blockposition);
}
}
diff --git a/src/main/java/net/minecraft/server/BlockTNT.java b/src/main/java/net/minecraft/server/BlockTNT.java
index f97fccf562..c821e6b3b9 100644
index 8cb36ed3a..88d023871 100644
--- a/src/main/java/net/minecraft/server/BlockTNT.java
+++ b/src/main/java/net/minecraft/server/BlockTNT.java
@@ -1,6 +1,7 @@
@ -49,8 +51,8 @@ index f97fccf562..c821e6b3b9 100644
public class BlockTNT extends Block {
@@ -14,6 +15,11 @@ public class BlockTNT extends Block {
public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1) {
@@ -15,6 +16,11 @@ public class BlockTNT extends Block {
public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) {
if (iblockdata1.getBlock() != iblockdata.getBlock()) {
if (world.isBlockIndirectlyPowered(blockposition)) {
+ // Paper start - TNTPrimeEvent
@ -58,23 +60,23 @@ index f97fccf562..c821e6b3b9 100644
+ if(!new TNTPrimeEvent(tntBlock, TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent())
+ return;
+ // Paper end
this.a(world, blockposition);
world.setAir(blockposition);
a(world, blockposition);
world.a(blockposition, false);
}
@@ -23,6 +29,11 @@ public class BlockTNT extends Block {
public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) {
@@ -25,6 +31,11 @@ public class BlockTNT extends Block {
@Override
public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) {
if (world.isBlockIndirectlyPowered(blockposition)) {
+ // Paper start - TNTPrimeEvent
+ org.bukkit.block.Block tntBlock = MCUtil.toBukkitBlock(world, blockposition);;
+ if(!new TNTPrimeEvent(tntBlock, TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent())
+ return;
+ // Paper end
this.a(world, blockposition);
world.setAir(blockposition);
a(world, blockposition);
world.a(blockposition, false);
}
@@ -45,6 +56,12 @@ public class BlockTNT extends Block {
@@ -43,6 +54,12 @@ public class BlockTNT extends Block {
@Override
public void wasExploded(World world, BlockPosition blockposition, Explosion explosion) {
if (!world.isClientSide) {
+ // Paper start - TNTPrimeEvent
@ -86,19 +88,19 @@ index f97fccf562..c821e6b3b9 100644
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), explosion.getSource());
entitytntprimed.setFuseTicks((short) (world.random.nextInt(entitytntprimed.getFuseTicks() / 4) + entitytntprimed.getFuseTicks() / 8));
@@ -72,6 +89,11 @@ public class BlockTNT extends Block {
@@ -71,6 +88,11 @@ public class BlockTNT extends Block {
if (item != Items.FLINT_AND_STEEL && item != Items.FIRE_CHARGE) {
return super.interact(iblockdata, world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2);
return super.interact(iblockdata, world, blockposition, entityhuman, enumhand, movingobjectpositionblock);
} else {
+ // Paper start - TNTPrimeEvent
+ org.bukkit.block.Block tntBlock = MCUtil.toBukkitBlock(world, blockposition);
+ if(!new TNTPrimeEvent(tntBlock, TNTPrimeEvent.PrimeReason.ITEM, entityhuman.bukkitEntity).callEvent())
+ return true;
+ // Paper end
this.a(world, blockposition, (EntityLiving) entityhuman);
a(world, blockposition, (EntityLiving) entityhuman);
world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 11);
if (item == Items.FLINT_AND_STEEL) {
@@ -95,6 +117,12 @@ public class BlockTNT extends Block {
@@ -97,6 +119,12 @@ public class BlockTNT extends Block {
return;
}
// CraftBukkit end
@ -108,33 +110,33 @@ index f97fccf562..c821e6b3b9 100644
+ return;
+ }
+ // Paper end
this.a(world, blockposition, entity1 instanceof EntityLiving ? (EntityLiving) entity1 : null);
world.setAir(blockposition);
a(world, blockposition, entity1 instanceof EntityLiving ? (EntityLiving) entity1 : null);
world.a(blockposition, false);
}
diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java
index 79d8be8d46..fcc82d8eb5 100644
index 3a6ae654c..3abf89b74 100644
--- a/src/main/java/net/minecraft/server/EntityEnderDragon.java
+++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java
@@ -9,6 +9,7 @@ import org.apache.logging.log4j.Logger;
@@ -11,6 +11,7 @@ import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
// CraftBukkit end
+import com.destroystokyo.paper.event.block.TNTPrimeEvent; // Paper - TNTPrimeEvent
// PAIL: Fixme
public class EntityEnderDragon extends EntityInsentient implements IComplex, IMonster {
@@ -474,6 +475,11 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
BlockPosition pos = new BlockPosition(blockX, blockY, blockZ);
nmsBlock.dropNaturally(world.getType(pos), world, pos, event.getYield(), 0);
public class EntityEnderDragon extends EntityInsentient implements IMonster {
@@ -458,6 +459,11 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster {
Block.b(craftBlock.getNMS(), loottableinfo_builder);
}
+ // Paper start - TNTPrimeEvent
+ org.bukkit.block.Block tntBlock = world.getWorld().getBlockAt(blockX, blockY, blockZ);
+ org.bukkit.block.Block tntBlock = world.getWorld().getBlockAt(blockposition.x, blockposition.y, blockposition.z);
+ if(!new TNTPrimeEvent(tntBlock, TNTPrimeEvent.PrimeReason.EXPLOSION, explosionSource.getSource().bukkitEntity).callEvent())
+ continue;
+ // Paper end
nmsBlock.wasExploded(world, new BlockPosition(blockX, blockY, blockZ), explosionSource);
nmsBlock.wasExploded(world, blockposition, explosionSource);
this.world.setAir(new BlockPosition(blockX, blockY, blockZ));
this.world.a(blockposition, false);
--
2.21.0

Datei anzeigen

@ -1,4 +1,4 @@
From 72405ae2c700964a1c55d1dac670ce7346196459 Mon Sep 17 00:00:00 2001
From a2e3dece59e64c66222fca56cdae916c2636ae6c Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 29 Jul 2018 05:02:15 +0100
Subject: [PATCH] Break up and make tab spam limits configurable
@ -22,10 +22,10 @@ to take the burden of this into their own hand without having to rely on
plugins doing unsafe things.
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 63fdd94818..642e704ed6 100644
index 52adc671e..ef567579e 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -332,4 +332,18 @@ public class PaperConfig {
@@ -308,4 +308,18 @@ public class PaperConfig {
logger.log(Level.INFO, "******************************************************");
}
}
@ -45,26 +45,26 @@ index 63fdd94818..642e704ed6 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 6d04c5733c..9a96078004 100644
index a0f6addef..e59037211 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -76,6 +76,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -78,6 +78,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
// CraftBukkit start - multithreaded fields
private volatile int chatThrottle;
private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle");
+ private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits
// CraftBukkit end
private int j;
private final IntHashMap<Short> k = new IntHashMap<>();
@@ -204,6 +205,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
this.minecraftServer.methodProfiler.exit();
private final Int2ShortMap k = new Int2ShortOpenHashMap();
@@ -205,6 +206,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
this.minecraftServer.getMethodProfiler().exit();
// CraftBukkit start
for (int spam; (spam = this.chatThrottle) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1); ) ;
+ if (tabSpamLimiter.get() > 0) tabSpamLimiter.getAndDecrement(); // Paper - split to seperate variable
/* Use thread-safe field access instead
if (this.chatThrottle > 0) {
--this.chatThrottle;
@@ -509,7 +511,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -523,7 +525,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
public void a(PacketPlayInTabComplete packetplayintabcomplete) {
// PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); // Paper - run this async
// CraftBukkit start

Datei anzeigen

@ -1,14 +1,14 @@
From 23affd802a03fa9f0117265b7beaeee46350cf26 Mon Sep 17 00:00:00 2001
From 95f79c464f9dc2f145b415c7372eb6995e30215b Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Thu, 2 Aug 2018 08:44:35 -0500
Subject: [PATCH] Add hand to bucket events
diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java
index 5ac88166fd..5874d2993c 100644
index a17738f9f..d2c2e3cc3 100644
--- a/src/main/java/net/minecraft/server/EntityCow.java
+++ b/src/main/java/net/minecraft/server/EntityCow.java
@@ -65,7 +65,7 @@ public class EntityCow extends EntityAnimal {
@@ -62,7 +62,7 @@ public class EntityCow extends EntityAnimal {
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
// CraftBukkit start - Got milk?
org.bukkit.Location loc = this.getBukkitEntity().getLocation();
@ -18,10 +18,10 @@ index 5ac88166fd..5874d2993c 100644
if (event.isCancelled()) {
return false;
diff --git a/src/main/java/net/minecraft/server/ItemBucket.java b/src/main/java/net/minecraft/server/ItemBucket.java
index 6f5dda880b..a064897fc4 100644
index cb2891411..5dc967f8b 100644
--- a/src/main/java/net/minecraft/server/ItemBucket.java
+++ b/src/main/java/net/minecraft/server/ItemBucket.java
@@ -35,7 +35,7 @@ public class ItemBucket extends Item {
@@ -39,7 +39,7 @@ public class ItemBucket extends Item {
if (iblockdata.getBlock() instanceof IFluidSource) {
// CraftBukkit start
FluidType dummyFluid = ((IFluidSource) iblockdata.getBlock()).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata);
@ -30,34 +30,34 @@ index 6f5dda880b..a064897fc4 100644
if (event.isCancelled()) {
((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
@@ -62,7 +62,7 @@ public class ItemBucket extends Item {
@@ -66,7 +66,7 @@ public class ItemBucket extends Item {
iblockdata = world.getType(blockposition);
BlockPosition blockposition1 = this.a(iblockdata, blockposition, movingobjectposition);
BlockPosition blockposition1 = iblockdata.getBlock() instanceof IFluidContainer && this.fluidType == FluidTypes.WATER ? blockposition : movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection());
- if (this.a(entityhuman, world, blockposition1, movingobjectposition, movingobjectposition.direction, blockposition, itemstack)) { // CraftBukkit
+ if (this.a(entityhuman, world, blockposition1, movingobjectposition, movingobjectposition.direction, blockposition, itemstack, enumhand)) { // CraftBukkit // Paper - add enumHand
- if (this.a(entityhuman, world, blockposition1, movingobjectpositionblock, movingobjectpositionblock.getDirection(), blockposition, itemstack)) { // CraftBukkit
+ if (this.a(entityhuman, world, blockposition1, movingobjectpositionblock, movingobjectpositionblock.getDirection(), blockposition, itemstack, enumhand)) { // CraftBukkit // Paper - add enumHand
this.a(world, itemstack, blockposition1);
if (entityhuman instanceof EntityPlayer) {
CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition1, itemstack);
@@ -118,6 +118,12 @@ public class ItemBucket extends Item {
@@ -116,6 +116,12 @@ public class ItemBucket extends Item {
}
public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPosition movingobjectposition, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) {
public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) {
+ // Paper start - add enumHand
+ return a(entityhuman, world, blockposition, movingobjectposition, enumdirection, clicked, itemstack, null);
+ return a(entityhuman, world, blockposition, movingobjectpositionblock, enumdirection, clicked, itemstack, null);
+ }
+
+ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPosition movingobjectposition, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack, EnumHand enumhand) {
+ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack, EnumHand enumhand) {
+ // Paper end
// CraftBukkit end
if (!(this.fluidType instanceof FluidTypeFlowing)) {
return false;
@@ -128,11 +134,11 @@ public class ItemBucket extends Item {
@@ -126,11 +132,11 @@ public class ItemBucket extends Item {
boolean flag1 = material.isReplaceable();
if (!world.isEmpty(blockposition) && !flag && !flag1 && (!(iblockdata.getBlock() instanceof IFluidContainer) || !((IFluidContainer) iblockdata.getBlock()).canPlace(world, blockposition, iblockdata, this.fluidType))) {
- return movingobjectposition == null ? false : this.a(entityhuman, world, movingobjectposition.getBlockPosition().shift(movingobjectposition.direction), (MovingObjectPosition) null, enumdirection, clicked, itemstack); // CraftBukkit
+ return movingobjectposition == null ? false : this.a(entityhuman, world, movingobjectposition.getBlockPosition().shift(movingobjectposition.direction), (MovingObjectPosition) null, enumdirection, clicked, itemstack, enumhand); // CraftBukkit // Paper - add enumhand
- return movingobjectpositionblock == null ? false : this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null, enumdirection, clicked, itemstack); // CraftBukkit
+ return movingobjectpositionblock == null ? false : this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null, enumdirection, clicked, itemstack, enumhand); // CraftBukkit // Paper - add enumhand
} else {
// CraftBukkit start
if (entityhuman != null) {
@ -67,10 +67,10 @@ index 6f5dda880b..a064897fc4 100644
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity
((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 0a3a121cbc..e76862ef49 100644
index c09f7e7c4..50444ed94 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -234,6 +234,20 @@ public class CraftEventFactory {
@@ -340,6 +340,20 @@ public class CraftEventFactory {
}
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityHuman who, int clickedX, int clickedY, int clickedZ, EnumDirection clickedFace, ItemStack itemstack, net.minecraft.server.Item item) {
@ -91,7 +91,7 @@ index 0a3a121cbc..e76862ef49 100644
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
Material bucket = CraftMagicNumbers.getMaterial(itemstack.getItem());
@@ -246,10 +260,10 @@ public class CraftEventFactory {
@@ -352,10 +366,10 @@ public class CraftEventFactory {
PlayerEvent event = null;
if (isFilling) {

Datei anzeigen

@ -1,28 +1,29 @@
From 5afad697dd515d28b733f5064b9d4a5ebbfc3307 Mon Sep 17 00:00:00 2001
From af3edfe66552207de44f381e2c44ee59d9bf75cb Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 3 Aug 2018 00:04:54 -0400
Subject: [PATCH] MC-135506: Experience should save as Integers
diff --git a/src/main/java/net/minecraft/server/EntityExperienceOrb.java b/src/main/java/net/minecraft/server/EntityExperienceOrb.java
index 09d85764b0..3606b10143 100644
index 64d71a9a2..65c996961 100644
--- a/src/main/java/net/minecraft/server/EntityExperienceOrb.java
+++ b/src/main/java/net/minecraft/server/EntityExperienceOrb.java
@@ -205,14 +205,14 @@ public class EntityExperienceOrb extends Entity {
@@ -204,7 +204,7 @@ public class EntityExperienceOrb extends Entity {
public void b(NBTTagCompound nbttagcompound) {
nbttagcompound.setShort("Health", (short) this.d);
nbttagcompound.setShort("Age", (short) this.b);
nbttagcompound.setShort("Health", (short) this.e);
nbttagcompound.setShort("Age", (short) this.c);
- nbttagcompound.setShort("Value", (short) this.value);
+ nbttagcompound.setInt("Value", this.value); // Paper - save as Integer
savePaperNBT(nbttagcompound); // Paper
this.savePaperNBT(nbttagcompound); // Paper
}
@@ -212,7 +212,7 @@ public class EntityExperienceOrb extends Entity {
public void a(NBTTagCompound nbttagcompound) {
this.d = nbttagcompound.getShort("Health");
this.b = nbttagcompound.getShort("Age");
this.e = nbttagcompound.getShort("Health");
this.c = nbttagcompound.getShort("Age");
- this.value = nbttagcompound.getShort("Value");
+ this.value = nbttagcompound.getInt("Value"); // Paper - load as Integer
loadPaperNBT(nbttagcompound); // Paper
this.loadPaperNBT(nbttagcompound); // Paper
}
--

Datei anzeigen

@ -1,4 +1,4 @@
From 491d6c5a1e1cd26819ef555db2a1551c656a0a35 Mon Sep 17 00:00:00 2001
From ea5e6546dc45187eaec3b83d97971f36f49c301b Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 22 Nov 2016 00:40:42 -0500
Subject: [PATCH] Fix client rendering skulls from same user
@ -12,10 +12,10 @@ This allows the client to render multiple skull textures from the same user,
for when different skins were used when skull was made.
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
index c1b6eb52bf..0420589faa 100644
index 2acd02f2f..ca1bd0299 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -53,7 +53,7 @@ public final class ItemStack {
@@ -54,7 +54,7 @@ public final class ItemStack {
// Paper end
@Deprecated
private Item item;
@ -25,7 +25,7 @@ index c1b6eb52bf..0420589faa 100644
private EntityItemFrame i;
private ShapeDetectorBlock j;
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
index d05f1e02cf..b95836d443 100644
index 0d67676f7..fa2d3ce8c 100644
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
@@ -253,6 +253,15 @@ public class PacketDataSerializer extends ByteBuf {
@ -45,7 +45,7 @@ index d05f1e02cf..b95836d443 100644
this.a(nbttagcompound);
@@ -272,6 +281,16 @@ public class PacketDataSerializer extends ByteBuf {
itemstack.setTag(this.j());
itemstack.setTag(this.l());
// CraftBukkit start
if (itemstack.getTag() != null) {
+ // Paper start - Fix skulls of same owner - restore orig ID since we changed it on send to client
@ -62,32 +62,27 @@ index d05f1e02cf..b95836d443 100644
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
index f2159bc2dd..18ef7232ec 100644
index 363ab5da1..d19a30ad8 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
@@ -38,6 +38,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
@@ -51,6 +51,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
if (this.f() || (i & 1 << j) != 0) {
NBTTagCompound nbttagcompound = tileentity.aa_();
NBTTagCompound nbttagcompound = tileentity.b();
+ if (tileentity instanceof TileEntitySkull) { TileEntitySkull.sanitizeTileEntityUUID(nbttagcompound); } // Paper
this.e.add(nbttagcompound);
this.f.add(nbttagcompound);
}
@@ -122,7 +123,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
BiomeBase[] abiomebase = chunk.getBiomeIndex();
for (l = 0; l < abiomebase.length; ++l) {
- packetdataserializer.writeInt(IRegistry.BIOME.a((Object) abiomebase[l]));
+ packetdataserializer.writeInt(IRegistry.BIOME.a(abiomebase[l])); // Paper - Decompile fix
}
}
diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java
index 79c24cdc4c..6511bfda8d 100644
index e827d7605..4803b173a 100644
--- a/src/main/java/net/minecraft/server/TileEntitySkull.java
+++ b/src/main/java/net/minecraft/server/TileEntitySkull.java
@@ -142,9 +142,37 @@ public class TileEntitySkull extends TileEntity /*implements ITickable*/ { // Pa
return this.a;
@Nullable
@Override
public PacketPlayOutTileEntityData getUpdatePacket() {
- return new PacketPlayOutTileEntityData(this.position, 4, this.b());
+ return new PacketPlayOutTileEntityData(this.position, 4, sanitizeTileEntityUUID(this.b())); // Paper
}
+ // Paper start
@ -118,13 +113,9 @@ index 79c24cdc4c..6511bfda8d 100644
+ }
+ // Paper end
+
@Nullable
public PacketPlayOutTileEntityData getUpdatePacket() {
- return new PacketPlayOutTileEntityData(this.position, 4, this.aa_());
+ return new PacketPlayOutTileEntityData(this.position, 4, sanitizeTileEntityUUID(this.aa_())); // Paper
}
public NBTTagCompound aa_() {
@Override
public NBTTagCompound b() {
return this.save(new NBTTagCompound());
--
2.21.0

Datei anzeigen

@ -1,4 +1,4 @@
From 5519ce709faf9753a90a4d9b62f1c3e4f4fbb6fd Mon Sep 17 00:00:00 2001
From 0f6c50e8916f60aed820cc335e3346779445fcc2 Mon Sep 17 00:00:00 2001
From: miclebrick <miclebrick@outlook.com>
Date: Wed, 8 Aug 2018 15:30:52 -0400
Subject: [PATCH] Add Early Warning Feature to WatchDog
@ -9,7 +9,7 @@ thread dumps at an interval until the point of crash.
This will help diagnose what was going on in that time before the crash.
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 642e704ed6..2023b5af0f 100644
index ef567579e..8062054ab 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -25,6 +25,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
@ -20,7 +20,7 @@ index 642e704ed6..2023b5af0f 100644
public class PaperConfig {
@@ -333,6 +334,14 @@ public class PaperConfig {
@@ -309,6 +310,14 @@ public class PaperConfig {
}
}
@ -36,11 +36,11 @@ index 642e704ed6..2023b5af0f 100644
public static int tabSpamLimit = 500;
private static void tabSpamLimiters() {
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 476a729ddf..4565a56b3f 100644
index 359ce72fc..30952ade4 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -792,6 +792,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
this.a(this.m);
@@ -835,6 +835,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.a(this.serverPing);
// Spigot start
+ org.spigotmc.WatchdogThread.hasStarted = true; // Paper
@ -48,10 +48,10 @@ index 476a729ddf..4565a56b3f 100644
long start = System.nanoTime(), curTime, wait, tickSection = start; // Paper - Further improve server tick loop
lastTick = start - TICK_TIME; // Paper
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 268653acd1..d5ab1d11a2 100644
index 01ed56a2a..7b204d584 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -752,6 +752,7 @@ public final class CraftServer implements Server {
@@ -753,6 +753,7 @@ public final class CraftServer implements Server {
@Override
public void reload() {
@ -59,7 +59,7 @@ index 268653acd1..d5ab1d11a2 100644
reloadCount++;
configuration = YamlConfiguration.loadConfiguration(getConfigFile());
commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile());
@@ -857,6 +858,7 @@ public final class CraftServer implements Server {
@@ -851,6 +852,7 @@ public final class CraftServer implements Server {
enablePlugins(PluginLoadOrder.STARTUP);
enablePlugins(PluginLoadOrder.POSTWORLD);
getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.RELOAD));
@ -68,7 +68,7 @@ index 268653acd1..d5ab1d11a2 100644
@Override
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 9c442dee24..fb09fb097d 100644
index 062a24c3c..f06110d06 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -225,7 +225,7 @@ public class SpigotConfig
@ -81,7 +81,7 @@ index 9c442dee24..fb09fb097d 100644
public static boolean bungee;
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
index 0117c3d3de..5447bc9cc2 100644
index 9532aada8..a1d93200e 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -5,6 +5,7 @@ import java.lang.management.MonitorInfo;
@ -144,8 +144,8 @@ index 0117c3d3de..5447bc9cc2 100644
+ }
+ // Paper end - Different message for short timeout
log.log( Level.SEVERE, "------------------------------" );
log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" );
dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().primaryThread.getId(), Integer.MAX_VALUE ), log );
log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log );
log.log( Level.SEVERE, "------------------------------" );
//
+ // Paper start - Only print full dump on long timeouts

Datei anzeigen

@ -1,11 +1,11 @@
From d787919769890fd5e7fd0cef7e16c00cfd78de2c Mon Sep 17 00:00:00 2001
From 51a8e9921c23a32e7e76fffd689166f572e772df Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 10 Aug 2018 22:11:49 -0400
Subject: [PATCH] Make EnderDragon implement Mob
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexLivingEntity.java
index cc115cc368..4947249da2 100644
index cc115cc36..4947249da 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexLivingEntity.java
@@ -1,17 +1,18 @@

Datei anzeigen

@ -0,0 +1,115 @@
From d244977f87d982b0563cb1ab8a3c87141b808bbc Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 11 Aug 2018 00:49:20 -0400
Subject: [PATCH] Detect and repair corrupt Region Files
If the file has partial data written but not the full 8192 bytes,
then the server will be unable to load that region file...
I don't know why mojang only checks for 4096, when anything less than 8192 is a crash.
But to be safe, it will attempt to back up the file.
diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
index 4e6288e8b..e68f90194 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
@@ -27,13 +27,13 @@ public class RegionFile implements AutoCloseable {
// Spigot end
private static final byte[] a = new byte[4096];
private final RandomAccessFile b; private RandomAccessFile getDataFile() { return this.b; } // Paper - OBFHELPER
- private final int[] c = new int[1024];
- private final int[] d = new int[1024];
+ private final int[] c = new int[1024]; private int[] offsets = c; // Paper - OBFHELPER
+ private final int[] d = new int[1024];private int[] timestamps = d; // Paper - OBFHELPER
private final List<Boolean> e;
public RegionFile(File file) throws IOException {
this.b = new RandomAccessFile(file, "rw");
- if (this.b.length() < 4096L) {
+ if (this.b.length() < 8192L) { // Paper - headers should be 8192
this.b.write(RegionFile.a);
this.b.write(RegionFile.a);
}
@@ -83,7 +83,7 @@ public class RegionFile implements AutoCloseable {
this.b.seek(j * 4 + 4); // Go back to where we were
}
}
- if (k != 0 && (k >> 8) + (length) <= this.e.size()) {
+ if (k > 0 && (k >> 8) > 1 && (k >> 8) + (k & 255) <= this.e.size()) { // Paper >= 1 as 0/1 are the headers, and negative isnt valid
for (int l = 0; l < (length); ++l) {
// Spigot end
this.e.set((k >> 8) + l, false);
@@ -92,13 +92,14 @@ public class RegionFile implements AutoCloseable {
// Spigot start
else if (length > 0) {
org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Invalid chunk: ({0}, {1}) Offset: {2} Length: {3} runs off end file. {4}", new Object[]{j % 32, (int) (j / 32), k >> 8, length, file});
+ deleteChunk(j); // Paper
}
// Spigot end
}
for (j = 0; j < 1024; ++j) {
k = headerAsInts.get(); // Paper
- this.d[j] = k;
+ if (offsets[j] != 0) this.timestamps[j] = k; // Paper - don't set timestamp if it got 0'd above due to corruption
}
this.file = file; // Spigot
@@ -306,6 +307,53 @@ public class RegionFile implements AutoCloseable {
this.b.close();
}
+ // Paper start
+ public synchronized void deleteChunk(int j1) {
+ backup();
+ int k = offsets[j1];
+ int x = j1 & 1024;
+ int z = j1 >> 2;
+ int offset = (k >> 8);
+ int len = (k & 255);
+ String debug = "idx:" + + j1 + " - " + x + "," + z + " - offset: " + offset + " - len: " + len;
+ try {
+ timestamps[j1] = 0;
+ offsets[j1] = 0;
+ RandomAccessFile file = getDataFile();
+ file.seek(j1 * 4);
+ file.writeInt(0);
+ // clear the timestamp
+ file.seek(4096 + j1 * 4);
+ file.writeInt(0);
+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.SEVERE, "Deleted corrupt chunk (" + debug + ") " + this.file.getAbsolutePath(), e);
+ } catch (IOException e) {
+
+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.SEVERE, "Error deleting corrupt chunk (" + debug + ") " + this.file.getAbsolutePath(), e);
+ }
+ }
+ private boolean backedUp = false;
+ private synchronized void backup() {
+ if (backedUp) {
+ return;
+ }
+ backedUp = true;
+ java.text.DateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd");
+ java.util.Date today = new java.util.Date();
+ File corrupt = new File(file.getParentFile(), file.getName() + "." + formatter.format(today) + ".corrupt");
+ if (corrupt.exists()) {
+ return;
+ }
+ org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getLogger();
+ logger.error("Region file " + file.getAbsolutePath() + " was corrupt. Backing up to " + corrupt.getAbsolutePath() + " and repairing");
+ try {
+ java.nio.file.Files.copy(file.toPath(), corrupt.toPath());
+
+ } catch (IOException e) {
+ logger.error("Error backing up corrupt file" + file.getAbsolutePath(), e);
+ }
+ }
+ // Paper end
+
class ChunkBuffer extends ByteArrayOutputStream {
private final ChunkCoordIntPair b;
--
2.21.0

Datei anzeigen

@ -1,4 +1,4 @@
From e6e3558e1e76d3194351c3d52e45be5e9dd36579 Mon Sep 17 00:00:00 2001
From 726ccb6da79fd80fa6ac09f8cc41984960bbcc77 Mon Sep 17 00:00:00 2001
From: egg82 <phantom_zero@ymail.com>
Date: Tue, 7 Aug 2018 01:24:23 -0600
Subject: [PATCH] Use ConcurrentHashMap in JsonList
@ -25,11 +25,11 @@ The point of this is readability, but does have a side-benefit of a small microp
Finally, added a couple obfhelpers for the modified code
diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java
index 026ef7939e..b7cde4d418 100644
index 04f98167d..c169d0176 100644
--- a/src/main/java/net/minecraft/server/JsonList.java
+++ b/src/main/java/net/minecraft/server/JsonList.java
@@ -35,7 +35,8 @@ public class JsonList<K, V extends JsonListEntry<K>> {
protected static final Logger a = LogManager.getLogger();
protected static final Logger LOGGER = LogManager.getLogger();
protected final Gson b;
private final File c;
- private final Map<String, V> d = Maps.newHashMap();

Datei anzeigen

@ -1,4 +1,4 @@
From 8ccec06d6eade3bb1d4189c09a4baa8d7e31ad37 Mon Sep 17 00:00:00 2001
From f494013c45946ca64c7f307884d2b777738b3988 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 12 Aug 2018 02:33:39 -0400
Subject: [PATCH] Use a Queue for Queueing Commands
@ -6,19 +6,19 @@ Subject: [PATCH] Use a Queue for Queueing Commands
Lists are bad as Queues mmmkay.
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 437ac386ac..21a05b2b21 100644
index c2c676e3b..3d452fe0e 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -39,7 +39,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
@@ -41,7 +41,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
private static final Logger LOGGER = LogManager.getLogger();
private static final Pattern h = Pattern.compile("^[a-fA-F0-9]{40}$");
private static final Pattern j = Pattern.compile("^[a-fA-F0-9]{40}$");
- private final List<ServerCommand> serverCommandQueue = Collections.synchronizedList(Lists.newArrayList());
+ private final java.util.Queue<ServerCommand> serverCommandQueue = new java.util.concurrent.ConcurrentLinkedQueue<ServerCommand>(); // Paper - use a proper queue
private RemoteStatusListener j;
public final RemoteControlCommandListener remoteControlCommandListener = new RemoteControlCommandListener(this);
private RemoteControlListener l;
@@ -468,8 +468,10 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
private RemoteStatusListener l;
public final RemoteControlCommandListener remoteControlCommandListener;
private RemoteControlListener remoteControlListener;
@@ -442,8 +442,10 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
public void handleCommandQueue() {
MinecraftTimings.serverCommandTimer.startTiming(); // Spigot

Datei anzeigen

@ -1,14 +1,14 @@
From e336d8b44c1619f25f813d824d8c465d3399b2ce Mon Sep 17 00:00:00 2001
From 2c4cd6098df36181141f3e499fa650ce14057272 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 15 Aug 2018 01:16:34 -0400
Subject: [PATCH] Ability to get Tile Entities from a chunk without snapshots
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
index e657684995..9ba2fa5de0 100644
index b4fcf25d4..fa078eb0e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
@@ -99,7 +99,12 @@ public class CraftChunk implements Chunk {
@@ -111,7 +111,12 @@ public class CraftChunk implements Chunk {
return entities;
}
@ -21,7 +21,7 @@ index e657684995..9ba2fa5de0 100644
int index = 0;
net.minecraft.server.Chunk chunk = getHandle();
@@ -111,7 +116,7 @@ public class CraftChunk implements Chunk {
@@ -123,7 +128,7 @@ public class CraftChunk implements Chunk {
}
BlockPosition position = (BlockPosition) obj;

Datei anzeigen

@ -1,15 +1,15 @@
From 002645efa8e27923e6260c7b57956b4295567be9 Mon Sep 17 00:00:00 2001
From 8063a9d72baee8dbc08e972997de092741caf10f Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc>
Date: Wed, 15 Aug 2018 01:26:09 -0700
Subject: [PATCH] Allow disabling armour stand ticking
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 6c4cb61dc5..0b60ca82ce 100644
index f06bb3ae1..a5b4f9990 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -507,4 +507,10 @@ public class PaperWorldConfig {
break;
@@ -391,4 +391,10 @@ public class PaperWorldConfig {
log("Bed Search Radius: " + bedSearchRadius);
}
}
+
@ -20,10 +20,10 @@ index 6c4cb61dc5..0b60ca82ce 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
index c604182dd9..2c54e3e34a 100644
index 8fb3ce17a..7031dd0e4 100644
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
@@ -45,6 +45,11 @@ public class EntityArmorStand extends EntityLiving {
@@ -44,6 +44,11 @@ public class EntityArmorStand extends EntityLiving {
public Vector3f leftLegPose;
public Vector3f rightLegPose;
public boolean canMove = true; // Paper
@ -33,36 +33,36 @@ index c604182dd9..2c54e3e34a 100644
+ private boolean noTickEquipmentDirty = false;
+ // Paper end
public EntityArmorStand(World world) {
super(EntityTypes.ARMOR_STAND, world);
@@ -57,6 +62,7 @@ public class EntityArmorStand extends EntityLiving {
this.leftLegPose = EntityArmorStand.bB;
this.rightLegPose = EntityArmorStand.bC;
this.noclip = this.isNoGravity();
public EntityArmorStand(EntityTypes<? extends EntityArmorStand> entitytypes, World world) {
super(entitytypes, world);
@@ -55,6 +60,7 @@ public class EntityArmorStand extends EntityLiving {
this.rightArmPose = EntityArmorStand.bx;
this.leftLegPose = EntityArmorStand.by;
this.rightLegPose = EntityArmorStand.bz;
+ if (world != null) this.canTick = world.paperConfig.armorStandTick; // Paper - armour stand ticking
this.setSize(0.5F, 1.975F);
this.Q = 0.0F;
this.K = 0.0F;
}
@@ -128,6 +134,7 @@ public class EntityArmorStand extends EntityLiving {
this.bF.set(enumitemslot.b(), itemstack);
@@ -135,6 +141,7 @@ public class EntityArmorStand extends EntityLiving {
this.armorItems.set(enumitemslot.b(), itemstack);
}
+ this.noTickEquipmentDirty = true; // Paper - Allow equipment to be updated even when tick disabled
}
public boolean c(int i, ItemStack itemstack) {
@@ -199,6 +206,7 @@ public class EntityArmorStand extends EntityLiving {
@Override
@@ -215,6 +222,7 @@ public class EntityArmorStand extends EntityLiving {
}
nbttagcompound.set("Pose", this.z());
nbttagcompound.set("Pose", this.B());
+ nbttagcompound.setBoolean("Paper.CanTick", this.canTick); // Paper - persist no tick setting
}
public void a(NBTTagCompound nbttagcompound) {
@@ -230,6 +238,11 @@ public class EntityArmorStand extends EntityLiving {
@Override
@@ -246,6 +254,11 @@ public class EntityArmorStand extends EntityLiving {
this.setBasePlate(nbttagcompound.getBoolean("NoBasePlate"));
this.setMarker(nbttagcompound.getBoolean("Marker"));
this.bI = !this.isMarker();
this.noclip = this.isNoGravity();
this.noclip = !this.A();
+ // Paper start - persist no tick
+ if (nbttagcompound.hasKey("Paper.CanTick")) {
+ this.canTick = nbttagcompound.getBoolean("Paper.CanTick");
@ -71,9 +71,9 @@ index c604182dd9..2c54e3e34a 100644
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Pose");
this.g(nbttagcompound1);
@@ -553,7 +566,30 @@ public class EntityArmorStand extends EntityLiving {
}
@@ -583,7 +596,29 @@ public class EntityArmorStand extends EntityLiving {
@Override
public void tick() {
+ // Paper start
+ if (!this.canTick) {
@ -92,59 +92,58 @@ index c604182dd9..2c54e3e34a 100644
+ // Paper end
+
super.tick();
+
+ // Paper start - Split into separate method
+ updatePose();
+ }
+
+ public void updatePose() {
+ // Paper end
Vector3f vector3f = (Vector3f) this.datawatcher.get(EntityArmorStand.b);
Vector3f vector3f = (Vector3f) this.datawatcher.get(EntityArmorStand.c);
if (!this.headPose.equals(vector3f)) {
@@ -682,31 +718,37 @@ public class EntityArmorStand extends EntityLiving {
@@ -699,31 +734,37 @@ public class EntityArmorStand extends EntityLiving {
public void setHeadPose(Vector3f vector3f) {
this.headPose = vector3f;
this.datawatcher.set(EntityArmorStand.b, vector3f);
this.datawatcher.set(EntityArmorStand.c, vector3f);
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
}
public void setBodyPose(Vector3f vector3f) {
this.bodyPose = vector3f;
this.datawatcher.set(EntityArmorStand.c, vector3f);
this.datawatcher.set(EntityArmorStand.d, vector3f);
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
}
public void setLeftArmPose(Vector3f vector3f) {
this.leftArmPose = vector3f;
this.datawatcher.set(EntityArmorStand.d, vector3f);
this.datawatcher.set(EntityArmorStand.e, vector3f);
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
}
public void setRightArmPose(Vector3f vector3f) {
this.rightArmPose = vector3f;
this.datawatcher.set(EntityArmorStand.e, vector3f);
this.datawatcher.set(EntityArmorStand.f, vector3f);
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
}
public void setLeftLegPose(Vector3f vector3f) {
this.leftLegPose = vector3f;
this.datawatcher.set(EntityArmorStand.f, vector3f);
this.datawatcher.set(EntityArmorStand.g, vector3f);
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
}
public void setRightLegPose(Vector3f vector3f) {
this.rightLegPose = vector3f;
this.datawatcher.set(EntityArmorStand.g, vector3f);
this.datawatcher.set(EntityArmorStand.bs, vector3f);
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
}
public Vector3f r() {
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index bc1ab273bd..cb32d64bd0 100644
index 58bfe8c1c..2ed2960c5 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2083,52 +2083,7 @@ public abstract class EntityLiving extends Entity {
@@ -2259,52 +2259,7 @@ public abstract class EntityLiving extends Entity {
}
}
@ -157,10 +156,10 @@ index bc1ab273bd..cb32d64bd0 100644
-
- switch (enumitemslot.a()) {
- case HAND:
- itemstack = (ItemStack) this.bB.get(enumitemslot.b());
- itemstack = (ItemStack) this.bw.get(enumitemslot.b());
- break;
- case ARMOR:
- itemstack = (ItemStack) this.bC.get(enumitemslot.b());
- itemstack = (ItemStack) this.bx.get(enumitemslot.b());
- break;
- default:
- continue;
@ -176,7 +175,7 @@ index bc1ab273bd..cb32d64bd0 100644
- new PlayerArmorChangeEvent((Player) this.getBukkitEntity(), PlayerArmorChangeEvent.SlotType.valueOf(enumitemslot.name()), oldItem, newItem).callEvent();
- }
- // Paper end
- ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1)));
- ((WorldServer) this.world).getChunkProvider().broadcast(this, new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1));
- if (!itemstack.isEmpty()) {
- this.getAttributeMap().a(itemstack.a(enumitemslot));
- }
@ -187,10 +186,10 @@ index bc1ab273bd..cb32d64bd0 100644
-
- switch (enumitemslot.a()) {
- case HAND:
- this.bB.set(enumitemslot.b(), itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack());
- this.bw.set(enumitemslot.b(), itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack());
- break;
- case ARMOR:
- this.bC.set(enumitemslot.b(), itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack());
- this.bx.set(enumitemslot.b(), itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack());
- }
- }
- }
@ -198,7 +197,7 @@ index bc1ab273bd..cb32d64bd0 100644
if (this.ticksLived % 20 == 0) {
this.getCombatTracker().g();
@@ -2221,6 +2176,57 @@ public abstract class EntityLiving extends Entity {
@@ -2405,6 +2360,57 @@ public abstract class EntityLiving extends Entity {
}
}
@ -213,10 +212,10 @@ index bc1ab273bd..cb32d64bd0 100644
+
+ switch (enumitemslot.a()) {
+ case HAND:
+ itemstack = (ItemStack) this.bB.get(enumitemslot.b());
+ itemstack = (ItemStack) this.bw.get(enumitemslot.b());
+ break;
+ case ARMOR:
+ itemstack = (ItemStack) this.bC.get(enumitemslot.b());
+ itemstack = (ItemStack) this.bx.get(enumitemslot.b());
+ break;
+ default:
+ continue;
@ -232,7 +231,7 @@ index bc1ab273bd..cb32d64bd0 100644
+ new PlayerArmorChangeEvent((Player) this.getBukkitEntity(), PlayerArmorChangeEvent.SlotType.valueOf(enumitemslot.name()), oldItem, newItem).callEvent();
+ }
+ // Paper end
+ ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1)));
+ ((WorldServer) this.world).getChunkProvider().broadcast(this, new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1));
+ if (!itemstack.isEmpty()) {
+ this.getAttributeMap().a(itemstack.a(enumitemslot));
+ }
@ -243,10 +242,10 @@ index bc1ab273bd..cb32d64bd0 100644
+
+ switch (enumitemslot.a()) {
+ case HAND:
+ this.bB.set(enumitemslot.b(), itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack());
+ this.bw.set(enumitemslot.b(), itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack());
+ break;
+ case ARMOR:
+ this.bC.set(enumitemslot.b(), itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack());
+ this.bx.set(enumitemslot.b(), itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack());
+ }
+ }
+ }
@ -254,10 +253,10 @@ index bc1ab273bd..cb32d64bd0 100644
+ // Paper end
+
protected float e(float f, float f1) {
float f2 = MathHelper.g(f - this.aQ);
float f2 = MathHelper.g(f - this.aK);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
index 9f5c3b92e3..07ce93f17c 100644
index 9f5c3b92e..07ce93f17 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
@@ -297,5 +297,15 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {

Datei anzeigen

@ -1,4 +1,4 @@
From 8765ccb60e25a8512349974050b8c3450442d315 Mon Sep 17 00:00:00 2001
From 613b7fbd67ec494dff0c01c3a7880e3e86102e43 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Wed, 15 Aug 2018 12:05:12 -0700
Subject: [PATCH] Optimize BlockPosition helper methods
@ -6,10 +6,10 @@ Subject: [PATCH] Optimize BlockPosition helper methods
Resolves #1338
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
index 20cf9255ba..5ce18f54c6 100644
index a5e5a4eba..6ed584f8d 100644
--- a/src/main/java/net/minecraft/server/BlockPosition.java
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
@@ -59,55 +59,72 @@ public class BlockPosition extends BaseBlockPosition {
@@ -134,55 +134,72 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali
}
public BlockPosition up() {

Datei anzeigen

@ -1,14 +1,14 @@
From 90ad6938a623553a7766d7fc6338665b014ef3fd Mon Sep 17 00:00:00 2001
From 2984fd06f892aa0807e3c492261b4eb8b5200f2a Mon Sep 17 00:00:00 2001
From: Mystiflow <mystiflow@gmail.com>
Date: Fri, 6 Jul 2018 13:21:30 +0100
Subject: [PATCH] Send nearby packets from world player list not server list
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index ddaa73e83d..ec760325ba 100644
index 6d464a3dc..823329268 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -1201,8 +1201,25 @@ public abstract class PlayerList {
@@ -919,8 +919,25 @@ public abstract class PlayerList {
}
public void sendPacketNearby(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, double d3, DimensionManager dimensionmanager, Packet<?> packet) {
@ -36,7 +36,7 @@ index ddaa73e83d..ec760325ba 100644
// CraftBukkit start - Test if player receiving packet can see the source of the packet
if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
@@ -1210,7 +1227,7 @@ public abstract class PlayerList {
@@ -928,7 +945,7 @@ public abstract class PlayerList {
}
// CraftBukkit end
@ -45,70 +45,21 @@ index ddaa73e83d..ec760325ba 100644
double d4 = d0 - entityplayer.locX;
double d5 = d1 - entityplayer.locY;
double d6 = d2 - entityplayer.locZ;
diff --git a/src/main/java/net/minecraft/server/WorldManager.java b/src/main/java/net/minecraft/server/WorldManager.java
index b4225b58ec..0ba0eb661b 100644
--- a/src/main/java/net/minecraft/server/WorldManager.java
+++ b/src/main/java/net/minecraft/server/WorldManager.java
@@ -35,8 +35,8 @@ public class WorldManager implements IWorldAccess {
}
public void a(@Nullable EntityHuman entityhuman, SoundEffect soundeffect, SoundCategory soundcategory, double d0, double d1, double d2, float f, float f1) {
- // CraftBukkit - this.world.dimension
- this.a.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.world.dimension, new PacketPlayOutNamedSoundEffect(soundeffect, soundcategory, d0, d1, d2, f, f1));
+ // CraftBukkit - this.world.dimension, // Paper - this.world.dimension -> this.world
+ this.a.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.world, new PacketPlayOutNamedSoundEffect(soundeffect, soundcategory, d0, d1, d2, f, f1));
}
public void a(int i, int j, int k, int l, int i1, int j1) {}
@@ -51,7 +51,7 @@ public class WorldManager implements IWorldAccess {
public void a(EntityHuman entityhuman, int i, BlockPosition blockposition, int j) {
// CraftBukkit - this.world.dimension
- this.a.getPlayerList().sendPacketNearby(entityhuman, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 64.0D, this.world.dimension, new PacketPlayOutWorldEvent(i, blockposition, j, false));
+ this.a.getPlayerList().sendPacketNearby(entityhuman, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 64.0D, this.world, new PacketPlayOutWorldEvent(i, blockposition, j, false));
}
public void a(int i, BlockPosition blockposition, int j) {
@@ -59,7 +59,7 @@ public class WorldManager implements IWorldAccess {
}
public void b(int i, BlockPosition blockposition, int j) {
- Iterator iterator = this.a.getPlayerList().v().iterator();
+ // Iterator iterator = this.a.getPlayerList().v().iterator(); // Paper
// CraftBukkit start
EntityHuman entityhuman = null;
@@ -67,8 +67,14 @@ public class WorldManager implements IWorldAccess {
if (entity instanceof EntityHuman) entityhuman = (EntityHuman) entity;
// CraftBukkit end
+ // Paper start
+ java.util.List<? extends EntityHuman> list = entity != null ? entity.world.players : this.a.getPlayerList().v();
+ Iterator<? extends EntityHuman> iterator = list.iterator();
while (iterator.hasNext()) {
- EntityPlayer entityplayer = (EntityPlayer) iterator.next();
+ EntityHuman human = iterator.next();
+ if (!(human instanceof EntityPlayer)) continue;
+ EntityPlayer entityplayer = (EntityPlayer) human;
+ // Paper end
if (entityplayer != null && entityplayer.world == this.world && entityplayer.getId() != i) {
double d0 = (double) blockposition.getX() - entityplayer.locX;
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 4cda6cee2b..0ff3fe03dd 100644
index 3bfe40bb6..ffa5a0bee 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1064,7 +1064,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@@ -1183,7 +1183,7 @@ public class WorldServer extends World {
}
// CraftBukkit end
if (super.strikeLightning(entity)) {
- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, dimension, new PacketPlayOutSpawnEntityWeather(entity)); // CraftBukkit - Use dimension
+ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, this, new PacketPlayOutSpawnEntityWeather(entity)); // CraftBukkit - Use dimension, // Paper - use world instead of dimension
return true;
} else {
return false;
@@ -1124,8 +1124,8 @@ public class WorldServer extends World implements IAsyncTaskHandler {
BlockActionData blockactiondata = (BlockActionData) this.d.removeFirst();
this.globalEntityList.add(entitylightning);
- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entitylightning.locX, entitylightning.locY, entitylightning.locZ, 512.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutSpawnEntityWeather(entitylightning));
+ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entitylightning.locX, entitylightning.locY, entitylightning.locZ, 512.0D, this, new PacketPlayOutSpawnEntityWeather(entitylightning)); // Paper - use world instead of dimension
}
@Override
@@ -1318,8 +1318,8 @@ public class WorldServer extends World {
BlockActionData blockactiondata = (BlockActionData) this.J.removeFirst();
if (this.a(blockactiondata)) {
- // CraftBukkit - this.worldProvider.dimension -> this.dimension
@ -119,10 +70,10 @@ index 4cda6cee2b..0ff3fe03dd 100644
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 4594bab465..72eb8ed4f4 100644
index 03148879f..e336813bd 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1636,7 +1636,7 @@ public class CraftWorld implements World {
@@ -1817,7 +1817,7 @@ public class CraftWorld implements World {
double z = loc.getZ();
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), SoundCategory.valueOf(category.name()), new Vec3D(x, y, z), volume, pitch);

Datei anzeigen

@ -1,11 +1,11 @@
From ae427b2baebf83d6d9cf14f9ba02c25920420b55 Mon Sep 17 00:00:00 2001
From 5e6d091aa073f466fb7020fd320b928740071302 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 18 Aug 2018 12:43:16 -0400
Subject: [PATCH] Restore vanlla default mob-spawn-range
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 1d222eaff7..809ce1d6aa 100644
index 222adb40c..5a0b9567f 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -136,7 +136,7 @@ public class SpigotWorldConfig

Datei anzeigen

@ -1,4 +1,4 @@
From 299cee7fed5ab4af4ff1096312c690260696221f Mon Sep 17 00:00:00 2001
From 565714b3d1a1ba66f02cf327fdbe09672969c2e3 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 27 Apr 2016 22:09:52 -0400
Subject: [PATCH] Optimize Hoppers
@ -11,10 +11,10 @@ Subject: [PATCH] Optimize Hoppers
* Skip subsequent InventoryMoveItemEvents if a plugin does not use the item after first event fire for an iteration
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 0b60ca82ce..e87fb94c06 100644
index a5b4f9990..2b5402b00 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -429,6 +429,15 @@ public class PaperWorldConfig {
@@ -360,6 +360,15 @@ public class PaperWorldConfig {
squidMaxSpawnHeight = getDouble("squid-spawn-height.maximum", 0.0D);
}
@ -31,10 +31,10 @@ index 0b60ca82ce..e87fb94c06 100644
private void disableSprintInterruptionOnAttack() {
disableSprintInterruptionOnAttack = getBoolean("game-mechanics.disable-sprint-interruption-on-attack", false);
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
index 0420589faa..0d06db9355 100644
index ca1bd0299..2d83c9e79 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -485,8 +485,9 @@ public final class ItemStack {
@@ -482,8 +482,9 @@ public final class ItemStack {
return this.getItem().a(this, entityhuman, entityliving, enumhand);
}
@ -44,25 +44,25 @@ index 0420589faa..0d06db9355 100644
+ public ItemStack cloneItemStack(boolean origItem) { // Paper
+ ItemStack itemstack = new ItemStack(origItem ? this.item : this.getItem(), this.count); // Paper
itemstack.d(this.B());
itemstack.d(this.C());
if (this.tag != null) {
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 4565a56b3f..38c0201acb 100644
index 30952ade4..0cebf6f5a 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1048,6 +1048,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
@@ -1117,6 +1117,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
for (Iterator iterator = this.getWorlds().iterator(); iterator.hasNext();) {
WorldServer worldserver = (WorldServer) iterator.next();
WorldServer worldserver = (WorldServer) iterator.next();
worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper
+ TileEntityHopper.skipHopperEvents = worldserver.paperConfig.disableHopperMoveEvents || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper
i = SystemUtils.getMonotonicNanos();
if (true || worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD || this.getAllowNether()) { // CraftBukkit
this.methodProfiler.a(() -> {
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
index 29fe031d85..d67fd92d9d 100644
index 4ac97a59c..6f63b2867 100644
--- a/src/main/java/net/minecraft/server/TileEntity.java
+++ b/src/main/java/net/minecraft/server/TileEntity.java
@@ -52,6 +52,7 @@ public abstract class TileEntity implements KeyedObject { // Paper
@@ -53,6 +53,7 @@ public abstract class TileEntity implements KeyedObject { // Paper
public void setCurrentChunk(Chunk chunk) {
this.currentChunk = chunk != null ? new java.lang.ref.WeakReference<>(chunk) : null;
}
@ -70,19 +70,19 @@ index 29fe031d85..d67fd92d9d 100644
// Paper end
@Nullable
@@ -124,6 +125,7 @@ public abstract class TileEntity implements KeyedObject { // Paper
@@ -125,6 +126,7 @@ public abstract class TileEntity implements KeyedObject { // Paper
public void update() {
if (this.world != null) {
+ if (IGNORE_TILE_UPDATES) return; // Paper
this.f = this.world.getType(this.position);
this.c = this.world.getType(this.position);
this.world.b(this.position, this);
if (!this.f.isAir()) {
if (!this.c.isAir()) {
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
index 559eedfa66..7303a6fdda 100644
index 0ecfbcb4b..dfe51fc6f 100644
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
@@ -189,6 +189,154 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
@@ -191,6 +191,154 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
return false;
}
@ -234,18 +234,18 @@ index 559eedfa66..7303a6fdda 100644
+ }
+
+ // Paper end
private boolean s() {
IInventory iinventory = this.D();
private boolean t() {
IInventory iinventory = this.u();
@@ -200,6 +348,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
if (this.a(iinventory, enumdirection)) {
@@ -202,6 +350,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
if (this.b(iinventory, enumdirection)) {
return false;
} else {
+ return hopperPush(iinventory, enumdirection); /* // Paper - disable rest
for (int i = 0; i < this.getSize(); ++i) {
if (!this.getItem(i).isEmpty()) {
ItemStack itemstack = this.getItem(i).cloneItemStack();
@@ -237,7 +386,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
@@ -239,7 +388,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
}
}
@ -254,15 +254,15 @@ index 559eedfa66..7303a6fdda 100644
}
}
}
@@ -308,6 +457,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
if (b(iinventory, enumdirection)) {
return false;
}
+ skipPullModeEventFire = skipHopperEvents; // Paper
@@ -269,6 +418,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
EnumDirection enumdirection = EnumDirection.DOWN;
if (iinventory instanceof IWorldInventory) {
IWorldInventory iworldinventory = (IWorldInventory) iinventory;
@@ -350,6 +500,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
return c(iinventory, enumdirection) ? false : a(iinventory, enumdirection).anyMatch((i) -> {
+ skipPullModeEventFire = skipHopperEvents; // Paper
return a(ihopper, iinventory, i, enumdirection);
});
} else {
@@ -292,6 +442,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
ItemStack itemstack = iinventory.getItem(i);
if (!itemstack.isEmpty() && b(iinventory, itemstack, i, enumdirection)) {
@ -270,7 +270,7 @@ index 559eedfa66..7303a6fdda 100644
ItemStack itemstack1 = itemstack.cloneItemStack();
// ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.splitStack(i, 1), (EnumDirection) null);
// CraftBukkit start - Call event on collection of items from inventories into the hopper
@@ -386,7 +537,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
@@ -328,7 +479,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
}
itemstack1.subtract(origCount - itemstack2.getCount()); // Spigot
@ -279,7 +279,7 @@ index 559eedfa66..7303a6fdda 100644
}
return false;
@@ -395,7 +546,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
@@ -337,7 +488,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
public static boolean a(IInventory iinventory, EntityItem entityitem) {
boolean flag = false;
// CraftBukkit start
@ -288,8 +288,8 @@ index 559eedfa66..7303a6fdda 100644
entityitem.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;
@@ -449,7 +600,9 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
boolean flag1 = iinventory1.P_();
@@ -391,7 +542,9 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
boolean flag1 = iinventory1.isNotEmpty();
if (itemstack1.isEmpty()) {
+ IGNORE_TILE_UPDATES = true; // Paper

Datei anzeigen

@ -1,111 +0,0 @@
From 9668175b9daf82f6d0646d0b3a3569a0ff38cfd9 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 28 Jul 2018 12:18:27 -0400
Subject: [PATCH] Ignore Dead Entities in entityList iteration
A spigot change delays removal of entities from the entity list.
This causes a change in behavior from Vanilla where getEntities type
methods will return dead entities that they shouldn't otherwise be doing.
This will ensure that dead entities are skipped from iteration since
they shouldn't of been in the list in the first place.
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index f38179e983..8e1bda4de9 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -176,6 +176,7 @@ public class PaperCommand extends Command {
List<Entity> entities = world.entityList;
entities.forEach(e -> {
MinecraftKey key = e.getMinecraftKey();
+ if (e.shouldBeRemoved) return; // Paper
MutablePair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ());
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index ead5af991c..cf69a4d8a4 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -121,6 +121,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
protected boolean F;
private boolean az;
public boolean dead;
+ public boolean shouldBeRemoved; // Paper
public float width;
public float length;
public float J;
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 1cbe6e17b7..5d60b36678 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1046,6 +1046,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
entity.valid = true; // CraftBukkit
+ entity.shouldBeRemoved = false; // Paper - shouldn't be removed after being re-added
new com.destroystokyo.paper.event.entity.EntityAddToWorldEvent(entity.getBukkitEntity()).callEvent(); // Paper - fire while valid
}
@@ -1113,6 +1114,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
Chunk chunk = entity.getCurrentChunk(); // Paper
if (chunk != null) chunk.removeEntity(entity); // Paper
+ entity.shouldBeRemoved = true; // Paper
if (!guardEntityList) { // Spigot - It will get removed after the tick if we are ticking // Paper - always remove from current chunk above
// CraftBukkit start - Decrement loop variable field if we've already ticked this entity
@@ -2316,6 +2318,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
+ if (entity.shouldBeRemoved) continue; // Paper
if (oclass.isAssignableFrom(entity.getClass()) && predicate.test((T) entity)) { // CraftBukkit - decompile error
list.add((T) entity); // CraftBukkit - decompile error
@@ -2402,6 +2405,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
+ if (entity.shouldBeRemoved) continue; // Paper
// CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs
if (entity instanceof EntityInsentient) {
EntityInsentient entityinsentient = (EntityInsentient) entity;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 609b911265..4594bab465 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -634,6 +634,7 @@ public class CraftWorld implements World {
for (Object o : world.entityList) {
if (o instanceof net.minecraft.server.Entity) {
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
+ if (mcEnt.shouldBeRemoved) continue; // Paper
Entity bukkitEntity = mcEnt.getBukkitEntity();
// Assuming that bukkitEntity isn't null
@@ -652,6 +653,7 @@ public class CraftWorld implements World {
for (Object o : world.entityList) {
if (o instanceof net.minecraft.server.Entity) {
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
+ if (mcEnt.shouldBeRemoved) continue; // Paper
Entity bukkitEntity = mcEnt.getBukkitEntity();
// Assuming that bukkitEntity isn't null
@@ -676,6 +678,7 @@ public class CraftWorld implements World {
for (Object entity: world.entityList) {
if (entity instanceof net.minecraft.server.Entity) {
+ if (((net.minecraft.server.Entity) entity).shouldBeRemoved) continue; // Paper
Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity();
if (bukkitEntity == null) {
@@ -698,6 +701,7 @@ public class CraftWorld implements World {
for (Object entity: world.entityList) {
if (entity instanceof net.minecraft.server.Entity) {
+ if (((net.minecraft.server.Entity) entity).shouldBeRemoved) continue; // Paper
Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity();
if (bukkitEntity == null) {
--
2.21.0

Datei anzeigen

@ -1,24 +0,0 @@
From d68188e9997a3f9c1eac71c9bc79db8380475438 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 29 Jul 2018 22:58:47 -0400
Subject: [PATCH] MC-111480: Start Entity ID's at 1
DataWatchers that store Entity ID's treat 0 as special,
and can break things such as Elytra Fireworks.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index cf69a4d8a4..4dc7c8ba68 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -90,7 +90,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
private static final List<ItemStack> a = Collections.emptyList();
private static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
private static double c = 1.0D;
- private static int entityCount;
+ private static int entityCount = 1; // Paper - MC-111480 - ID 0 is treated as special for DataWatchers, start 1
private final EntityTypes<?> g; public EntityTypes<?> getEntityType() { return g; } // Paper - OBFHELPER
private int id;
public boolean j; public boolean blocksEntitySpawning() { return j; } // Paper - OBFHELPER
--
2.21.0

Datei anzeigen

@ -1,82 +0,0 @@
From df9635bc942ea00aedd136fdea9d06027e38b337 Mon Sep 17 00:00:00 2001
From: willies952002 <admin@domnian.com>
Date: Mon, 30 Jul 2018 02:42:49 -0400
Subject: [PATCH] World EntityHuman Lookup Optimizations
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 5d60b36678..3acea908c2 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -76,6 +76,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
private final List<TileEntity> c = Lists.newArrayList();
private final Set<TileEntity> tileEntityListUnload = com.google.common.collect.Sets.newHashSet(); // Paper
public final List<EntityHuman> players = Lists.newArrayList();
+ public final Map<String, EntityHuman> playersByName = Maps.newHashMap(); // Paper - World EntityHuman Lookup Optimizations
public final List<Entity> k = Lists.newArrayList();
protected final IntHashMap<Entity> entitiesById = new IntHashMap<>();
private final long F = 16777215L;
@@ -1030,6 +1031,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
EntityHuman entityhuman = (EntityHuman) entity;
this.players.add(entityhuman);
+ this.playersByName.put(entityhuman.getName(), entityhuman);
+ // Paper end
this.everyoneSleeping();
}
@@ -1072,6 +1075,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
entity.die();
if (entity instanceof EntityHuman) {
this.players.remove(entity);
+ this.playersByName.remove(entity.getName()); // Paper - World EntityHuman Lookup Optimizations
// Spigot start
for ( WorldPersistentData worldData : worldMaps.worldMap.values() )
{
@@ -1105,6 +1109,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
entity.die();
if (entity instanceof EntityHuman) {
this.players.remove(entity);
+ this.playersByName.remove(entity.getName()); // Paper - World EntityHuman Lookup Optimizations
this.everyoneSleeping();
}
@@ -2667,6 +2672,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@Nullable
public EntityHuman a(String s) {
+ // Paper start - World EntityHuman Lookup Optimizations
+ /*
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman = (EntityHuman) this.players.get(i);
@@ -2676,10 +2683,15 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
return null;
+ */
+ return this.playersByName.get(s);
+ // Paper end
}
@Nullable
public EntityHuman b(UUID uuid) {
+ // Paper start - World EntityHuman Lookup Optimizations
+ /*
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman = (EntityHuman) this.players.get(i);
@@ -2689,6 +2701,10 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
return null;
+ */
+ Entity entity = ((WorldServer)this).entitiesByUUID.get(uuid);
+ return entity instanceof EntityHuman ? (EntityHuman) entity : null;
+ // Paper end
}
public void checkSession() throws ExceptionWorldConflict {
--
2.21.0

Datei anzeigen

@ -1,95 +0,0 @@
From e14ede8e0e2799cd730248905844cb35c42989e5 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 31 Jul 2018 19:32:57 -0500
Subject: [PATCH] Make portal teleportation adjustment math more accurate
diff --git a/src/main/java/net/minecraft/server/EnumDirection.java b/src/main/java/net/minecraft/server/EnumDirection.java
index 13f0fb0b67..ce71811271 100644
--- a/src/main/java/net/minecraft/server/EnumDirection.java
+++ b/src/main/java/net/minecraft/server/EnumDirection.java
@@ -82,6 +82,7 @@ public enum EnumDirection implements INamable {
return this.i;
}
+ public final EnumDirection.EnumAxisDirection getAxisDirection() { return c(); } // Paper - OBFHELPER
public EnumDirection.EnumAxisDirection c() {
return this.l;
}
@@ -90,6 +91,7 @@ public enum EnumDirection implements INamable {
return fromType1(this.h);
}
+ public final EnumDirection rotateY() { return e(); } // Paper - OBFHELPER
public EnumDirection e() {
switch (this) {
case NORTH:
@@ -255,6 +257,7 @@ public enum EnumDirection implements INamable {
this.d = s;
}
+ public final int getOffset() { return a(); } // Paper - OBFHELPER
public int a() {
return this.c;
}
diff --git a/src/main/java/net/minecraft/server/MathHelper.java b/src/main/java/net/minecraft/server/MathHelper.java
index 52918b971f..8bb2593aa9 100644
--- a/src/main/java/net/minecraft/server/MathHelper.java
+++ b/src/main/java/net/minecraft/server/MathHelper.java
@@ -81,6 +81,7 @@ public class MathHelper {
return f < f1 ? f1 : (f > f2 ? f2 : f);
}
+ public static double clamp(double d0, double d1, double d2) { return a(d0, d1, d2); } // Paper - OBFHELPER
public static double a(double d0, double d1, double d2) {
return d0 < d1 ? d1 : (d0 > d2 ? d2 : d0);
}
diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java
index a24bd02d5b..d30a8a6bdd 100644
--- a/src/main/java/net/minecraft/server/PortalTravelAgent.java
+++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java
@@ -208,11 +208,27 @@ public class PortalTravelAgent {
++d4;
}
+ // Paper start - Prevent portal suffocation (and therefore getting teleported up in an attempt to avoid it)
+ // Based on work by CarpetMod - Licensed GPL-3.0
+ double offset = (1.0D - entity.getPortalOffset().x) * (double) shapedetector_shapedetectorcollection.getWidth() * (double) shapedetector_shapedetectorcollection.getFacing().rotateY().getAxisDirection().getOffset();
+ double adjustedRadius = 1.02 * entity.width / 2;
+ if (adjustedRadius >= shapedetector_shapedetectorcollection.getWidth() - adjustedRadius) {
+ // entity wider than portal, place it in the middle
+ adjustedRadius = (double) shapedetector_shapedetectorcollection.getWidth() / 2 - 0.001;
+ }
+
+ if (offset >= 0) {
+ offset = MathHelper.clamp(offset, adjustedRadius, (double) shapedetector_shapedetectorcollection.getWidth() - adjustedRadius);
+ } else {
+ offset = MathHelper.clamp(offset, (double) -shapedetector_shapedetectorcollection.getWidth() + adjustedRadius, -adjustedRadius);
+ }
+
if (shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X) {
- d3 = d4 + (1.0D - entity.getPortalOffset().x) * (double) shapedetector_shapedetectorcollection.d() * (double) shapedetector_shapedetectorcollection.getFacing().e().c().a();
+ d3 = d4 + offset;
} else {
- d2 = d4 + (1.0D - entity.getPortalOffset().x) * (double) shapedetector_shapedetectorcollection.d() * (double) shapedetector_shapedetectorcollection.getFacing().e().c().a();
+ d2 = d4 + offset;
}
+ // Paper end
float f1 = 0.0F;
float f2 = 0.0F;
diff --git a/src/main/java/net/minecraft/server/ShapeDetector.java b/src/main/java/net/minecraft/server/ShapeDetector.java
index 8ba4da0ea0..8716f5fd95 100644
--- a/src/main/java/net/minecraft/server/ShapeDetector.java
+++ b/src/main/java/net/minecraft/server/ShapeDetector.java
@@ -140,6 +140,7 @@ public class ShapeDetector {
return this.c;
}
+ public final int getWidth() { return this.d(); } // Paper - OBFHELPER
public int d() {
return this.e;
}
--
2.21.0

Datei anzeigen

@ -1,96 +0,0 @@
From caaa22ced1e3cc9e7c6c79192259a5436f1783e3 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 3 Aug 2018 22:47:46 -0400
Subject: [PATCH] Entity add to world fixes
1) Chunk Registration might kill an entity, don't add it to the world if it did!
2) By default, entities are added to the world per slice iteration.
This opens risk of the slices being manipulated during chunk add if an
EntityAddToWorldEvent spawns an entity into this chunk.
Fix this by differing entity add to world for all entities at the same time
3) If a duplicate entity is attempted to add to the world of an entity, and
the original entity is dead, overwrite it as the logic does for unloaod queued entities.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 01abe5e376..4502ece4dd 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -2,6 +2,8 @@ package net.minecraft.server;
// Paper start
import com.destroystokyo.paper.PaperWorldConfig.DuplicateUUIDMode;
+
+import java.util.Arrays;
import java.util.HashMap;
import java.util.UUID;
// Paper end
@@ -957,15 +959,16 @@ public class Chunk implements IChunkAccess {
// Paper end
// CraftBukkit start
- List<Entity> toRemove = new LinkedList<>();
- this.world.a(entityslice.stream().filter((entity) -> {
- if (this.needsDecoration && !CraftEventFactory.doEntityAddEventCalling(this.world, entity, CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) { // Only call for new chunks
- toRemove.add(entity);
- return false;
- }
- return !(entity instanceof EntityHuman);
- }));
- entityslice.removeAll(toRemove);
+ this.world.addChunkEntities(entityslice.stream() // Paper - add all at same time to avoid entities adding to world modifying slice state, skip already added entities (not normal, but can happen)
+ // Paper start - Inline event into stream
+ .filter((entity) -> {
+ if (!this.needsDecoration) {
+ return true;
+ }
+ return CraftEventFactory.doEntityAddEventCalling(this.world, entity, CreatureSpawnEvent.SpawnReason.CHUNK_GEN);
+ })
+ // Paper end - Inline event into stream
+ .filter((entity) -> !(entity instanceof EntityHuman || entity.valid))); // Paper - add all at same time to avoid entities adding to world modifying slice state, skip already added entities (not normal, but can happen)
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 3acea908c2..e31e366249 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1037,6 +1037,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
this.getChunkAt(i, j).a(entity);
+ if (entity.dead) return false; // Paper - don't add dead entities, chunk registration may of killed it
this.entityList.add(entity);
this.b(entity);
return true;
@@ -2434,9 +2435,13 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
return j;
}
+ public void addChunkEntities(Stream<Entity> collection) { a(collection); } // Paper - OBFHELPER
public void a(Stream<Entity> stream) {
org.spigotmc.AsyncCatcher.catchOp( "entity world add"); // Spigot
stream.forEach((entity) -> {
+ if (entity == null || entity.dead || entity.valid) { // Paper - prevent adding already added or dead entities
+ return;
+ }
this.entityList.add(entity);
this.b(entity);
});
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 293818b196..4cda6cee2b 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -967,7 +967,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
if (this.entitiesByUUID.containsKey(uuid)) {
Entity entity1 = (Entity) this.entitiesByUUID.get(uuid);
- if (this.g.contains(entity1)) {
+ if (this.g.contains(entity1) || entity1.dead) { // Paper - if dupe is dead, overwrite
this.g.remove(entity1);
} else {
if (!(entity instanceof EntityHuman)) {
--
2.21.0

Datei anzeigen

@ -1,139 +0,0 @@
From 4c3edd05499f6111fd2b4feadc51ebb6a864be3d Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 11 Aug 2018 00:49:20 -0400
Subject: [PATCH] Detect and repair corrupt Region Files
If the file has partial data written but not the full 8192 bytes,
then the server will be unable to load that region file...
I don't know why mojang only checks for 4096, when anything less than 8192 is a crash.
But to be safe, it will attempt to back up the file.
diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
index e2d4450e90..c20511588d 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
@@ -25,10 +25,10 @@ public class RegionFile {
private static final boolean ENABLE_EXTENDED_SAVE = Boolean.parseBoolean(System.getProperty("net.minecraft.server.RegionFile.enableExtendedSave", "true"));
// Spigot end
private static final byte[] a = new byte[4096];
- private final File b;
- private RandomAccessFile c;
- private final int[] d = new int[1024];
- private final int[] e = new int[1024];
+ private final File b;private File getFile() { return b; } // Paper - OBFHELPER
+ private RandomAccessFile c;private RandomAccessFile getDataFile() { return c; } // Paper - OBFHELPER
+ private final int[] d = new int[1024];private int[] offsets = d; // Paper - OBFHELPER
+ private final int[] e = new int[1024];private int[] timestamps = e; // Paper - OBFHELPER
private List<Boolean> f;
private int g;
private long h;
@@ -43,7 +43,7 @@ public class RegionFile {
}
this.c = new RandomAccessFile(file, "rw");
- if (this.c.length() < 4096L) {
+ if (this.c.length() < 8192L) { // Paper - headers should be 8192
this.c.write(RegionFile.a);
this.c.write(RegionFile.a);
this.g += 8192;
@@ -93,22 +93,23 @@ public class RegionFile {
this.c.seek(j * 4 + 4); // Go back to where we were
}
}
- if (k != 0 && (k >> 8) + (length) <= this.f.size()) {
+ if (k > 0 && (k >> 8) > 1 && (k >> 8) + (k & 255) <= this.f.size()) { // Paper >= 1 as 0/1 are the headers, and negative isnt valid
for (int l = 0; l < (length); ++l) {
// Spigot end
this.f.set((k >> 8) + l, false);
}
}
// Spigot start
- else if (length > 0) {
- org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Invalid chunk: ({0}, {1}) Offset: {2} Length: {3} runs off end file. {4}", new Object[]{j % 32, (int) (j / 32), k >> 8, length, file});
+ else if (k != 0) { // Paper
+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.SEVERE, "Invalid chunk: ({0}, {1}) Offset: {2} Length: {3} runs off end file. {4}", new Object[]{j % 32, (int) (j / 32), k >> 8, length, file}); // Paper
+ deleteChunk(j); // Paper
}
// Spigot end
}
for (j = 0; j < 1024; ++j) {
k = headerAsInts.get(); // Paper
- this.e[j] = k;
+ if (offsets[j] != 0) this.timestamps[j] = k; // Paper - don't set timestamp if it got 0'd above due to corruption
}
} catch (IOException ioexception) {
ioexception.printStackTrace();
@@ -144,10 +145,10 @@ public class RegionFile {
int j1 = this.c.readInt();
if (j1 > 4096 * i1) {
- org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Invalid chunk: ({0}, {1}) Offset: {2} Invalid Size: {3}>{4} {5}", new Object[]{i, j, l, j1, i1 * 4096, this.b}); // Spigot
+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.SEVERE, "Invalid chunk: ({0}, {1}) Offset: {2} Invalid Size: {3}>{4} {5}", new Object[]{i, j, l, j1, i1 * 4096, this.b}); // Spigot
return null;
} else if (j1 <= 0) {
- org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Invalid chunk: ({0}, {1}) Offset: {2} Invalid Size: {3} {4}", new Object[]{i, j, l, j1, this.b}); // Spigot
+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.SEVERE, "Invalid chunk: ({0}, {1}) Offset: {2} Invalid Size: {3} {4}", new Object[]{i, j, l, j1, this.b}); // Spigot
return null;
} else {
byte b0 = this.c.readByte();
@@ -327,6 +328,54 @@ public class RegionFile {
}
+ // Paper start
+ public synchronized void deleteChunk(int j1) {
+ backup();
+ int k = offsets[j1];
+ int x = j1 & 1024;
+ int z = j1 >> 2;
+ int offset = (k >> 8);
+ int len = (k & 255);
+ String debug = "idx:" + + j1 + " - " + x + "," + z + " - offset: " + offset + " - len: " + len;
+ try {
+ timestamps[j1] = 0;
+ offsets[j1] = 0;
+ RandomAccessFile file = getDataFile();
+ file.seek(j1 * 4);
+ file.writeInt(0);
+ // clear the timestamp
+ file.seek(4096 + j1 * 4);
+ file.writeInt(0);
+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.SEVERE, "Deleted corrupt chunk (" + debug + ") " + getFile().getAbsolutePath(), e);
+ } catch (IOException e) {
+
+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.SEVERE, "Error deleting corrupt chunk (" + debug + ") " + getFile().getAbsolutePath(), e);
+ }
+ }
+ private boolean backedUp = false;
+ private synchronized void backup() {
+ if (backedUp) {
+ return;
+ }
+ backedUp = true;
+ File file = this.getFile();
+ java.text.DateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd");
+ java.util.Date today = new java.util.Date();
+ File corrupt = new File(file.getParentFile(), file.getName() + "." + formatter.format(today) + ".corrupt");
+ if (corrupt.exists()) {
+ return;
+ }
+ org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getLogger();
+ logger.error("Region file " + file.getAbsolutePath() + " was corrupt. Backing up to " + corrupt.getAbsolutePath() + " and repairing");
+ try {
+ java.nio.file.Files.copy(file.toPath(), corrupt.toPath());
+
+ } catch (IOException e) {
+ logger.error("Error backing up corrupt file" + file.getAbsolutePath(), e);
+ }
+ }
+ // Paper end
+
class ChunkBuffer extends ByteArrayOutputStream {
private final int b;
--
2.21.0

Datei anzeigen

@ -1,229 +0,0 @@
From ea48b312bc5e985bd2c1654d8494d235bcd632a4 Mon Sep 17 00:00:00 2001
From: Colin Godsey <crgodsey@gmail.com>
Date: Wed, 8 Aug 2018 10:10:06 -0600
Subject: [PATCH] Cache World Entity Type counts
Optimizes mob spawning by keeping a count of entities by type
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldEntityList.java b/src/main/java/com/destroystokyo/paper/PaperWorldEntityList.java
new file mode 100644
index 0000000000..a10a5bc138
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldEntityList.java
@@ -0,0 +1,121 @@
+package com.destroystokyo.paper;
+
+import net.minecraft.server.Entity;
+import net.minecraft.server.EntityInsentient;
+import net.minecraft.server.EnumCreatureType;
+import net.minecraft.server.IAnimal;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.World;
+import net.minecraft.server.WorldServer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class PaperWorldEntityList extends ArrayList<Entity> {
+
+ private final WorldServer world;
+ private final int[] entityCounts = new int[EnumCreatureType.values().length];
+
+
+ public PaperWorldEntityList(World world) {
+ this.world = (WorldServer) world;
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Entity> c) {
+ for (Entity e : c) {
+ updateEntityCount(e, 1);
+ }
+
+ return super.addAll(c);
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ for (Object e : c) {
+ if (e instanceof Entity && ((Entity) e).getWorld() == world) {
+ updateEntityCount((Entity) e, -1);
+ }
+ }
+
+ return super.removeAll(c);
+ }
+
+ @Override
+ public boolean add(Entity e) {
+ updateEntityCount(e, 1);
+
+ return super.add(e);
+ }
+
+ @Override
+ public Entity remove(int index) {
+ guard();
+ Entity entity = super.remove(index);
+ if (entity != null) updateEntityCount(entity, -1);
+ return entity;
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ guard();
+ if (super.remove(o)) {
+ updateEntityCount((Entity) o, -1);
+ return true;
+ }
+ return false;
+ }
+
+ private void guard() {
+ if (world.guardEntityList) {
+ throw new java.util.ConcurrentModificationException();
+ }
+ }
+
+ public int getCreatureCount(EnumCreatureType type) {
+ return entityCounts[type.ordinal()];
+ }
+
+ private void updateEntityCount(EnumCreatureType type, int amt) {
+ int count = entityCounts[type.ordinal()];
+
+ count += amt;
+
+ if (count < 0) {
+ MinecraftServer.LOGGER.error("Paper - Entity count cache has gone negative");
+ count = 0;
+ }
+
+ entityCounts[type.ordinal()] = count;
+ }
+
+ public void updateEntityCount(Entity entity, int amt) {
+ if (!(entity instanceof IAnimal)) return;
+
+ if (entity instanceof EntityInsentient) {
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
+ if (amt > 0 && entityinsentient.isTypeNotPersistent() && entityinsentient.isPersistent()) {
+ return;
+ }
+ }
+ if (amt < 0) {
+ if (!entity.hasBeenCounted) {
+ return;
+ }
+ // Only remove once, we remove from if the entity list is guarded, but may be called later
+ entity.hasBeenCounted = false;
+ } else {
+ if (entity.hasBeenCounted) {
+ return;
+ }
+ entity.hasBeenCounted = true;
+ }
+
+ for (EnumCreatureType type : EnumCreatureType.values()) {
+ if (type.matches(entity)) {
+ updateEntityCount(type, amt);
+ break;
+ }
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 4dc7c8ba68..90e0d9d453 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -122,6 +122,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
private boolean az;
public boolean dead;
public boolean shouldBeRemoved; // Paper
+ public boolean hasBeenCounted = false; // Paper
public float width;
public float length;
public float J;
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index ee5078370c..856ddf2a74 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -259,6 +259,7 @@ public abstract class EntityInsentient extends EntityLiving {
public void tick() {
super.tick();
+ if (isTypeNotPersistent() && hasBeenCounted == this.isPersistent()) ((com.destroystokyo.paper.PaperWorldEntityList) this.world.entityList).updateEntityCount(this, hasBeenCounted ? -1 : 1); // Paper - adjust count if persistence state changes
if (!this.world.isClientSide) {
this.dl();
if (this.ticksLived % 5 == 0) {
diff --git a/src/main/java/net/minecraft/server/EnumCreatureType.java b/src/main/java/net/minecraft/server/EnumCreatureType.java
index 79e52f7bac..42f6a6a93a 100644
--- a/src/main/java/net/minecraft/server/EnumCreatureType.java
+++ b/src/main/java/net/minecraft/server/EnumCreatureType.java
@@ -16,6 +16,8 @@ public enum EnumCreatureType {
this.h = flag1;
}
+ public boolean matches(Entity entity) { return innerClass().isAssignableFrom(entity.getClass()); } // Paper
+ public Class<? extends IAnimal> innerClass() { return this.a(); } // Paper - OBFHELPER
public Class<? extends IAnimal> a() {
return this.e;
}
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
index e626165520..d125fae03b 100644
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
@@ -114,7 +114,7 @@ public final class SpawnerCreature {
if ((!enumcreaturetype.c() || flag1) && (enumcreaturetype.c() || flag) && (!enumcreaturetype.d() || flag2)) {
k = limit * i / SpawnerCreature.b; // CraftBukkit - use per-world limits
- int l1 = worldserver.a(enumcreaturetype.a(), k);
+ int l1 = ((com.destroystokyo.paper.PaperWorldEntityList) worldserver.entityList).getCreatureCount(enumcreaturetype); // Paper - entity count cache
if (l1 <= k) {
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index e31e366249..b007eb36c7 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -45,7 +45,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
private static final EnumDirection[] a = EnumDirection.values();
private int b = 63;
// Spigot start - guard entity list from removals
- public final List<Entity> entityList = new java.util.ArrayList<Entity>()
+ public final List<Entity> entityList = new com.destroystokyo.paper.PaperWorldEntityList(this);
+ /* // Paper start
{
@Override
public Entity remove(int index)
@@ -69,6 +70,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
}
};
+ */ // Paper end
// Spigot end
protected final Set<Entity> g = com.google.common.collect.Sets.newHashSet(); public Set<Entity> getEntityUnloadQueue() { return g; };// Paper - OBFHELPER
//public final List<TileEntity> tileEntityList = Lists.newArrayList(); // Paper - remove unused list
@@ -139,8 +141,10 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
- private boolean guardEntityList; // Spigot
+ public boolean guardEntityList; // Spigot // Paper - public
public static BlockPosition lastPhysicsProblem; // Spigot
+ public static boolean haveWeSilencedAPhysicsCrash;
+ public static String blockLocation;
private org.spigotmc.TickLimiter entityLimiter;
private org.spigotmc.TickLimiter tileLimiter;
private int tileTickPosition;
@@ -1121,6 +1125,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
Chunk chunk = entity.getCurrentChunk(); // Paper
if (chunk != null) chunk.removeEntity(entity); // Paper
entity.shouldBeRemoved = true; // Paper
+ ((com.destroystokyo.paper.PaperWorldEntityList) entityList).updateEntityCount(entity, -1); // Paper
if (!guardEntityList) { // Spigot - It will get removed after the tick if we are ticking // Paper - always remove from current chunk above
// CraftBukkit start - Decrement loop variable field if we've already ticked this entity
--
2.21.0