more patches
This commit is contained in:
parent
716a3139b7
commit
a968aefd32
26 changed files with 535 additions and 730 deletions
|
@ -1,37 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 4 Jul 2018 15:30:22 -0400
|
||||
Subject: [PATCH] Vex#getSummoner API
|
||||
|
||||
Get's the NPC that summoned this Vex
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vex.java b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||
index 3204ae9a9243818727bedfa060c07bc34d3b4c66..ec4f6d96360e759ffc19de838fdbf3027164a424 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||
@@ -124,6 +124,7 @@ public class Vex extends Monster {
|
||||
|
||||
}
|
||||
|
||||
+ public Mob getOwner() { return getOwner(); } // Paper - OBFHELPER
|
||||
public Mob getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java
|
||||
index 2b4e9ddca5c6429c01d780d65a64ef6a59446c69..56bec4350f36a94d4dfa71a234872a795c2dcb3f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java
|
||||
@@ -15,6 +15,13 @@ public class CraftVex extends CraftMonster implements Vex {
|
||||
return (net.minecraft.world.entity.monster.Vex) super.getHandle();
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public org.bukkit.entity.Mob getSummoner() {
|
||||
+ net.minecraft.world.entity.Mob owner = getHandle().getOwner();
|
||||
+ return owner != null ? (org.bukkit.entity.Mob) owner.getBukkitEntity() : null;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftVex";
|
|
@ -1,29 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Minecrell <minecrell@minecrell.net>
|
||||
Date: Fri, 13 Jul 2018 14:54:43 +0200
|
||||
Subject: [PATCH] Refresh player inventory when cancelling
|
||||
PlayerInteractEntityEvent
|
||||
|
||||
When interacting with entities with an item, the client will assume
|
||||
the interaction is successful, and update the held item on the
|
||||
client. However, if the interaction is cancelled on the server side,
|
||||
the client will still mistakenly remove/replace the item in hand.
|
||||
|
||||
Examples for this are milking cows with a bucket or dyeing sheep.
|
||||
The bucket is replaced with milk and the dye removed from inventory.
|
||||
|
||||
Refresh the player inventory when PlayerInteractEntityEvent is
|
||||
cancelled to avoid this problem.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index d322e99170b3cb6594efc824a879ab9a538ea1eb..645f7b7c862acf77d70ca0b05308945424bc4d32 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2222,6 +2222,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
+ this.player.refreshContainer(this.player.containerMenu); // Paper - Refresh player inventory
|
||||
return;
|
||||
}
|
||||
// CraftBukkit end
|
|
@ -1,22 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 19 Jul 2018 01:08:05 -0400
|
||||
Subject: [PATCH] Re-add vanilla entity warnings for duplicates
|
||||
|
||||
These are a critical sign that somethin went wrong, and you've lost some data....
|
||||
|
||||
We should kind of know about these things you know.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index ea1b15495481157912140bf5de9bf4a949c16910..914241a57c304fde220bc546261d6e959445772a 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1071,7 +1071,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||
if (entity1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
- // WorldServer.LOGGER.warn("Trying to add entity with duplicated UUID {}. Existing {}#{}, new: {}#{}", uuid, EntityTypes.getName(entity1.getEntityType()), entity1.getId(), EntityTypes.getName(entity.getEntityType()), entity.getId()); // CraftBukkit
|
||||
+ ServerLevel.LOGGER.warn("Trying to add entity with duplicated UUID {}. Existing {}#{}, new: {}#{}", uuid, EntityType.getKey(entity1.getType()), entity1.getId(), EntityType.getKey(entity.getType()), entity.getId()); // CraftBukkit // Paper
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Hugo Manrique <hugmanrique@gmail.com>
|
||||
Date: Mon, 16 Jul 2018 12:42:20 +0200
|
||||
Subject: [PATCH] Avoid item merge if stack size above max stack size
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
index de69f7c3c0ee1e74682b0db91bdaae09175690e9..70f719ba3c68c8e9414e6b4bc68002f7c962e2b9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -208,6 +208,10 @@ public class ItemEntity extends Entity {
|
||||
|
||||
private void mergeWithNeighbours() {
|
||||
if (this.isMergable()) {
|
||||
+ // Paper start - avoid item merge if stack size above max stack size
|
||||
+ ItemStack stack = getItem();
|
||||
+ if (stack.getCount() >= stack.getMaxStackSize()) return;
|
||||
+ // Paper end
|
||||
// Spigot start
|
||||
double radius = level.spigotConfig.itemMerge;
|
||||
List<ItemEntity> list = this.level.getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(radius, radius, radius), (entityitem) -> {
|
|
@ -1,55 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Minecrell <minecrell@minecrell.net>
|
||||
Date: Tue, 17 Jul 2018 16:42:17 +0200
|
||||
Subject: [PATCH] Use asynchronous Log4j 2 loggers
|
||||
|
||||
|
||||
diff --git a/pom.xml b/pom.xml
|
||||
index f5429f2f1979542fd93956d2f436d20d0e3a66b8..4c8a057e790c96b0ab5123549d0566371acacb46 100644
|
||||
--- a/pom.xml
|
||||
+++ b/pom.xml
|
||||
@@ -88,6 +88,13 @@
|
||||
<artifactId>log4j-iostreams</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
+ <!-- Paper - Async loggers -->
|
||||
+ <dependency>
|
||||
+ <groupId>com.lmax</groupId>
|
||||
+ <artifactId>disruptor</artifactId>
|
||||
+ <version>3.4.2</version>
|
||||
+ <scope>runtime</scope>
|
||||
+ </dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/log/LogFullPolicy.java b/src/main/java/com/destroystokyo/paper/log/LogFullPolicy.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..db652a1f7abc80bc751fd94925abaec58ab1a563
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/log/LogFullPolicy.java
|
||||
@@ -0,0 +1,17 @@
|
||||
+package com.destroystokyo.paper.log;
|
||||
+
|
||||
+import org.apache.logging.log4j.Level;
|
||||
+import org.apache.logging.log4j.core.async.AsyncQueueFullPolicy;
|
||||
+import org.apache.logging.log4j.core.async.EventRoute;
|
||||
+
|
||||
+public final class LogFullPolicy implements AsyncQueueFullPolicy {
|
||||
+
|
||||
+ /*
|
||||
+ * Prevents log calls being logged out of order when the log queue is full.
|
||||
+ */
|
||||
+
|
||||
+ @Override
|
||||
+ public EventRoute getRoute(final long backgroundThreadId, final Level level) {
|
||||
+ return EventRoute.ENQUEUE;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/resources/log4j2.component.properties b/src/main/resources/log4j2.component.properties
|
||||
index 0694b21465fb9e4164e71862ff24b62241b191f2..30efeb5faf8e7faccf1b252fa0ed6a9fc31c40a7 100644
|
||||
--- a/src/main/resources/log4j2.component.properties
|
||||
+++ b/src/main/resources/log4j2.component.properties
|
||||
@@ -1 +1,3 @@
|
||||
+Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
|
||||
+log4j2.AsyncQueueFullPolicy="com.destroystokyo.paper.log.LogFullPolicy"
|
||||
log4j.skipJansi=true
|
|
@ -1,20 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 19 Jul 2018 01:13:28 -0400
|
||||
Subject: [PATCH] add more information to Entity.toString()
|
||||
|
||||
UUID, ticks lived, valid, dead
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 7e70bae5bc54ad17980789fa965fd539a7f193ea..e49fe2de6a53bdd16f0cd09b691f01f1866ffb4f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -2526,7 +2526,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
- return String.format(Locale.ROOT, "%s['%s'/%d, l='%s', x=%.2f, y=%.2f, z=%.2f]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.level == null ? "~NULL~" : this.level.toString(), this.getX(), this.getY(), this.getZ());
|
||||
+ return String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cx=%d, cz=%d, tl=%d, v=%b, d=%b]", new Object[] { this.getClass().getSimpleName(), this.getName().getString(), Integer.valueOf(this.id), this.uuid.toString(), this.level == null ? "~NULL~" : this.level.toString(), Double.valueOf(this.getX()), Double.valueOf(this.getY()), Double.valueOf(this.getZ()), xChunk, zChunk, this.tickCount, this.valid, this.removed}); // Paper - add more information
|
||||
}
|
||||
|
||||
public boolean isInvulnerableTo(DamageSource damageSource) {
|
|
@ -1,131 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 21 Jul 2018 08:25:40 -0400
|
||||
Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues
|
||||
|
||||
Add -Ddebug.entities=true to your JVM flags to gain more information
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 97d5437df10a6d0124e944404e88650547b7d8a8..083db6c1899b5391231b6d5d5044a334212f148c 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1145,6 +1145,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
} else {
|
||||
ChunkMap.TrackedEntity playerchunkmap_entitytracker = new ChunkMap.TrackedEntity(entity, i, j, entitytypes.trackDeltas());
|
||||
|
||||
+ entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker
|
||||
this.entityMap.put(entity.getId(), playerchunkmap_entitytracker);
|
||||
playerchunkmap_entitytracker.updatePlayers(this.level.players());
|
||||
if (entity instanceof ServerPlayer) {
|
||||
@@ -1186,7 +1187,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
if (playerchunkmap_entitytracker1 != null) {
|
||||
playerchunkmap_entitytracker1.broadcastRemoved();
|
||||
}
|
||||
-
|
||||
+ entity.tracker = null; // Paper - We're no longer tracked
|
||||
}
|
||||
|
||||
protected void tick() {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 914241a57c304fde220bc546261d6e959445772a..a5d7781b13a6d61238d026f064512f7162e1e868 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -191,6 +191,9 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||
public final LevelStorageSource.LevelStorageAccess convertable;
|
||||
public final UUID uuid;
|
||||
public boolean hasPhysicsEvent = true; // Paper
|
||||
+ private static Throwable getAddToWorldStackTrace(Entity entity) {
|
||||
+ return new Throwable(entity + " Added to world at " + new java.util.Date());
|
||||
+ }
|
||||
|
||||
@Override public LevelChunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
|
||||
return this.chunkSource.getChunk(x, z, false);
|
||||
@@ -1032,8 +1035,28 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||
// CraftBukkit start
|
||||
private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot
|
||||
- if (entity.valid) { MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable()); return true; } // Paper
|
||||
+ // Paper start
|
||||
+ if (entity.valid) {
|
||||
+ MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable());
|
||||
+
|
||||
+ if (DEBUG_ENTITIES) {
|
||||
+ Throwable thr = entity.addedToWorldStack;
|
||||
+ if (thr == null) {
|
||||
+ MinecraftServer.LOGGER.error("Double add entity has no add stacktrace");
|
||||
+ } else {
|
||||
+ MinecraftServer.LOGGER.error("Double add stacktrace: ", thr);
|
||||
+ }
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (entity.removed) {
|
||||
+ // Paper start
|
||||
+ if (DEBUG_ENTITIES) {
|
||||
+ new Throwable("Tried to add entity " + entity + " but it was marked as removed already").printStackTrace(); // CraftBukkit
|
||||
+ getAddToWorldStackTrace(entity).printStackTrace();
|
||||
+ }
|
||||
+ // Paper end
|
||||
// WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); // CraftBukkit
|
||||
return false;
|
||||
} else if (this.isUUIDUsed(entity)) {
|
||||
@@ -1231,7 +1254,24 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||
}
|
||||
}
|
||||
|
||||
- this.entitiesByUuid.put(entity.getUUID(), entity);
|
||||
+ if (DEBUG_ENTITIES) {
|
||||
+ entity.addedToWorldStack = getAddToWorldStackTrace(entity);
|
||||
+ }
|
||||
+
|
||||
+ Entity old = this.entitiesByUuid.put(entity.getUUID(), entity);
|
||||
+ if (old != null && old.getId() != entity.getId() && old.valid) {
|
||||
+ Logger logger = LogManager.getLogger();
|
||||
+ logger.error("Overwrote an existing entity " + old + " with " + entity);
|
||||
+ if (DEBUG_ENTITIES) {
|
||||
+ if (old.addedToWorldStack != null) {
|
||||
+ old.addedToWorldStack.printStackTrace();
|
||||
+ } else {
|
||||
+ logger.error("Oddly, the old entity was not added to the world in the normal way. Plugins?");
|
||||
+ }
|
||||
+ entity.addedToWorldStack.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
this.getChunkSource().addEntity(entity);
|
||||
// CraftBukkit start - SPIGOT-5278
|
||||
if (entity instanceof Drowned) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index e49fe2de6a53bdd16f0cd09b691f01f1866ffb4f..9d8682d367522bd85894947ad2f2a53cf0aa123a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -47,6 +47,7 @@ import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.TicketType;
|
||||
@@ -160,6 +161,8 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
|
||||
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
+ ChunkMap.TrackedEntity tracker; // Paper
|
||||
+ public Throwable addedToWorldStack; // Paper - entity debug
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null) {
|
||||
bukkitEntity = CraftEntity.getEntity(level.getCraftServer(), this);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index b4248d46ccb1a95e21601bca1198512287edcabf..0c6c3b211b05eda8f9ab47ef0a01cc520ae28201 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -121,6 +121,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
public boolean pvpMode;
|
||||
public boolean keepSpawnInMemory = true;
|
||||
public org.bukkit.generator.ChunkGenerator generator;
|
||||
+ public static final boolean DEBUG_ENTITIES = Boolean.getBoolean("debug.entities"); // Paper
|
||||
|
||||
public boolean captureBlockStates = false;
|
||||
public boolean captureTreeGeneration = false;
|
|
@ -1,62 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 21 Jul 2018 01:51:27 -0500
|
||||
Subject: [PATCH] EnderDragon Events
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java
|
||||
index 0c2a5f5c4d7d7516793eba20205b5703fe1450d5..6b28cfb1e79903c43702f6e78e226dc78e3ccec2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java
|
||||
@@ -80,7 +80,11 @@ public class DragonSittingFlamingPhase extends AbstractDragonSittingPhase {
|
||||
this.flame.setDuration(200);
|
||||
this.flame.setParticle(ParticleTypes.DRAGON_BREATH);
|
||||
this.flame.addEffect(new MobEffectInstance(MobEffects.HARM));
|
||||
+ if (new com.destroystokyo.paper.event.entity.EnderDragonFlameEvent((org.bukkit.entity.EnderDragon) this.dragon.getBukkitEntity(), (org.bukkit.entity.AreaEffectCloud) this.flame.getBukkitEntity()).callEvent()) { // Paper
|
||||
this.dragon.level.addFreshEntity(this.flame);
|
||||
+ } else {
|
||||
+ this.removeAreaEffect();
|
||||
+ }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -91,8 +95,8 @@ public class DragonSittingFlamingPhase extends AbstractDragonSittingPhase {
|
||||
++this.flameCount;
|
||||
}
|
||||
|
||||
- @Override
|
||||
- public void end() {
|
||||
+ public final void removeAreaEffect() { this.end(); } // Paper - OBFHELPER
|
||||
+ @Override public void end() {
|
||||
if (this.flame != null) {
|
||||
this.flame.remove();
|
||||
this.flame = null;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java
|
||||
index 01442af7b0c7340f0ece2fa0faa0f783b1b81c48..a43ef94f8a5c7a9d1581667beb4516cc26f30a0d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java
|
||||
@@ -81,7 +81,9 @@ public class DragonStrafePlayerPhase extends AbstractDragonPhaseInstance {
|
||||
DragonFireball entitydragonfireball = new DragonFireball(this.dragon.level, this.dragon, d9, d10, d11);
|
||||
|
||||
entitydragonfireball.moveTo(d6, d7, d8, 0.0F, 0.0F);
|
||||
+ if (new com.destroystokyo.paper.event.entity.EnderDragonShootFireballEvent((org.bukkit.entity.EnderDragon) dragon.getBukkitEntity(), (org.bukkit.entity.DragonFireball) entitydragonfireball.getBukkitEntity()).callEvent()) // Paper
|
||||
this.dragon.level.addFreshEntity(entitydragonfireball);
|
||||
+ else entitydragonfireball.remove(); // Paper
|
||||
this.fireballCharge = 0;
|
||||
if (this.currentPath != null) {
|
||||
while (!this.currentPath.isDone()) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java b/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
|
||||
index 76dc15e07ce9ef01ad7908e289a0d695b65b2fc9..1629e409a83b11b76e1627247a838c9ebd11a648 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
|
||||
@@ -58,8 +58,10 @@ public class DragonFireball extends AbstractHurtingProjectile {
|
||||
}
|
||||
}
|
||||
|
||||
+ if (new com.destroystokyo.paper.event.entity.EnderDragonFireballHitEvent((org.bukkit.entity.DragonFireball) this.getBukkitEntity(), list.stream().map(LivingEntity::getBukkitLivingEntity).collect(java.util.stream.Collectors.toList()), (org.bukkit.entity.AreaEffectCloud) entityareaeffectcloud.getBukkitEntity()).callEvent()) { // Paper
|
||||
this.level.levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1);
|
||||
this.level.addFreshEntity(entityareaeffectcloud);
|
||||
+ } else entityareaeffectcloud.remove(); // Paper
|
||||
this.remove();
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 21 Jul 2018 01:59:59 -0500
|
||||
Subject: [PATCH] PlayerElytraBoostEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||||
index dba52063d402eb2371441fa244b730a3313444fc..28cffbe299acccc59c34d5dbd2cf458704be5ee5 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||||
@@ -45,11 +45,16 @@ public class FireworkRocketItem extends Item {
|
||||
// Paper start
|
||||
final FireworkRocketEntity entityfireworks = new FireworkRocketEntity(world, itemstack, user);
|
||||
entityfireworks.spawningEntity = user.getUUID();
|
||||
- world.addFreshEntity(entityfireworks);
|
||||
- // Paper end
|
||||
- if (!user.abilities.instabuild) {
|
||||
- itemstack.shrink(1);
|
||||
+ // Paper start
|
||||
+ com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Firework) entityfireworks.getBukkitEntity());
|
||||
+ if (event.callEvent() && world.addFreshEntity(entityfireworks)) {
|
||||
+ if (event.shouldConsume() && !user.abilities.instabuild) {
|
||||
+ itemstack.shrink(1);
|
||||
+ } else ((EntityPlayer) user).getBukkitEntity().updateInventory();
|
||||
+ } else if (user instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) user).getBukkitEntity().updateInventory();
|
||||
}
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(user.getItemInHand(hand), world.isClientSide());
|
|
@ -1,75 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@outlook.com>
|
||||
Date: Wed, 30 Nov 2016 20:56:58 -0600
|
||||
Subject: [PATCH] Improve BlockPosition inlining
|
||||
|
||||
Normally the JVM can inline virtual getters by having two sets of code, one is the 'optimized' code and the other is the 'deoptimized' code.
|
||||
If a single type is used 99% of the time, then its worth it to inline, and to revert to 'deoptimized' the 1% of the time we encounter other types.
|
||||
But if two types are encountered commonly, then the JVM can't inline them both, and the call overhead remains.
|
||||
|
||||
This scenario also occurs with BlockPos and MutableBlockPos.
|
||||
The variables in BlockPos are final, so MutableBlockPos can't modify them.
|
||||
MutableBlockPos fixes this by adding custom mutable variables, and overriding the getters to access them.
|
||||
|
||||
This approach with utility methods that operate on MutableBlockPos and BlockPos.
|
||||
Specific examples are BlockPosition.up(), and World.isValidLocation().
|
||||
It makes these simple methods much slower than they need to be.
|
||||
|
||||
This should result in an across the board speedup in anything that accesses blocks or does logic with positions.
|
||||
|
||||
This is based upon conclusions drawn from inspecting the assenmbly generated bythe JIT compiler on my microbenchmarks.
|
||||
They had 'callq' (invoke) instead of 'mov' (get from memory) instructions.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
index 6a58059a05e16d96894b67a544c2f595d9546c78..c5089b0da33a68e7cadbc4841b07f9d772d224a0 100644
|
||||
--- a/src/main/java/net/minecraft/core/BlockPos.java
|
||||
+++ b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
@@ -88,6 +88,7 @@ public class BlockPos extends Vec3i {
|
||||
return asLong(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
|
||||
+ public static long asLong(int x, int y, int z) { return asLong(x, y, z); } // Paper - OBFHELPER
|
||||
public static long asLong(int x, int y, int z) {
|
||||
long l = 0L;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/Vec3i.java b/src/main/java/net/minecraft/core/Vec3i.java
|
||||
index c22de593be404c4e921724bba6a69c13759a95fd..fc4e652ada7b228cb99a3c8fb372ae9af5ddfba4 100644
|
||||
--- a/src/main/java/net/minecraft/core/Vec3i.java
|
||||
+++ b/src/main/java/net/minecraft/core/Vec3i.java
|
||||
@@ -41,7 +41,7 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||
this(Mth.floor(x), Mth.floor(y), Mth.floor(z));
|
||||
}
|
||||
|
||||
- public boolean equals(Object object) {
|
||||
+ public final boolean equals(Object object) { // Paper
|
||||
if (this == object) {
|
||||
return true;
|
||||
} else if (!(object instanceof Vec3i)) {
|
||||
@@ -53,7 +53,7 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||
}
|
||||
}
|
||||
|
||||
- public int hashCode() {
|
||||
+ public final int hashCode() { // Paper
|
||||
return (this.getY() + this.getZ() * 31) * 31 + this.getX();
|
||||
}
|
||||
|
||||
@@ -61,15 +61,15 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||
return this.getY() == baseblockposition.getY() ? (this.getZ() == baseblockposition.getZ() ? this.getX() - baseblockposition.getX() : this.getZ() - baseblockposition.getZ()) : this.getY() - baseblockposition.getY();
|
||||
}
|
||||
|
||||
- public int getX() {
|
||||
+ public final int getX() { // Paper
|
||||
return this.x;
|
||||
}
|
||||
|
||||
- public int getY() {
|
||||
+ public final int getY() { // Paper
|
||||
return this.y;
|
||||
}
|
||||
|
||||
- public int getZ() {
|
||||
+ public final int getZ() { // Paper
|
||||
return this.z;
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Mon, 23 Jul 2018 13:08:19 -0400
|
||||
Subject: [PATCH] Optimize RegistryID.c()
|
||||
|
||||
This is a frequent hotspot for world loading/saving.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java b/src/main/java/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java
|
||||
index 66ad412e4368a8615cc66a97ac442c572813a3dd..fa4a2d29b3b4c20d7396e973801d69c4acadddda 100644
|
||||
--- a/src/main/java/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java
|
||||
+++ b/src/main/java/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java
|
||||
@@ -15,12 +15,14 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
private K[] byId;
|
||||
private int nextId;
|
||||
private int size;
|
||||
+ private java.util.BitSet usedIds; // Paper
|
||||
|
||||
public CrudeIncrementalIntIdentityHashBiMap(int size) {
|
||||
size = (int) ((float) size / 0.8F);
|
||||
this.keys = (K[]) (new Object[size]); // Paper - decompile fix
|
||||
this.values = new int[size];
|
||||
this.byId = (K[]) (new Object[size]); // Paper - decompile fix
|
||||
+ this.usedIds = new java.util.BitSet(); // Paper
|
||||
}
|
||||
|
||||
// Paper start - decompile fix
|
||||
@@ -52,9 +54,14 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
}
|
||||
|
||||
private int nextId() {
|
||||
- while (this.nextId < this.byId.length && this.byId[this.nextId] != null) {
|
||||
- ++this.nextId;
|
||||
+ // Paper start
|
||||
+ /*
|
||||
+ while (this.e < this.d.length && this.d[this.e] != null) {
|
||||
+ ++this.e;
|
||||
}
|
||||
+ */
|
||||
+ this.nextId = this.usedIds.nextClearBit(0);
|
||||
+ // Paper end
|
||||
|
||||
return this.nextId;
|
||||
}
|
||||
@@ -68,6 +75,7 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
this.byId = (K[]) (new Object[newSize]); // Paper - decompile fix
|
||||
this.nextId = 0;
|
||||
this.size = 0;
|
||||
+ this.usedIds.clear(); // Paper
|
||||
|
||||
for (int j = 0; j < ak.length; ++j) {
|
||||
if (ak[j] != null) {
|
||||
@@ -93,6 +101,7 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
this.keys[k] = value;
|
||||
this.values[k] = id;
|
||||
this.byId[id] = value;
|
||||
+ this.usedIds.set(id); // Paper
|
||||
++this.size;
|
||||
if (id == this.nextId) {
|
||||
++this.nextId;
|
||||
@@ -157,6 +166,7 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
Arrays.fill(this.byId, (Object) null);
|
||||
this.nextId = 0;
|
||||
this.size = 0;
|
||||
+ this.usedIds.clear(); // Paper
|
||||
}
|
||||
|
||||
public int size() {
|
|
@ -1,58 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Hugo Manrique <hugmanrique@gmail.com>
|
||||
Date: Mon, 23 Jul 2018 12:57:39 +0200
|
||||
Subject: [PATCH] Option to prevent armor stands from doing entity lookups
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index 4813f62d1e382d5ac6971b2244df3f13c80d1950..3562950df4868b1393790b1a1ff1fe0dc589c155 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -379,4 +379,9 @@ public class PaperWorldConfig {
|
||||
private void scanForLegacyEnderDragon() {
|
||||
scanForLegacyEnderDragon = getBoolean("game-mechanics.scan-for-legacy-ender-dragon", true);
|
||||
}
|
||||
+
|
||||
+ public boolean armorStandEntityLookups = true;
|
||||
+ private void armorStandEntityLookups() {
|
||||
+ armorStandEntityLookups = getBoolean("armor-stands-do-collision-entity-lookups", true);
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
||||
index 59239e202e8e99870ce3be515d2f040ad9786892..7fc69adc8afa971ee3cf815c6002628ae2149a5b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
||||
@@ -352,6 +352,7 @@ public class ArmorStand extends LivingEntity {
|
||||
|
||||
@Override
|
||||
protected void pushEntities() {
|
||||
+ if (!level.paperConfig.armorStandEntityLookups) return; // Paper
|
||||
List<Entity> list = this.level.getEntities(this, this.getBoundingBox(), ArmorStand.RIDABLE_MINECARTS);
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 0c6c3b211b05eda8f9ab47ef0a01cc520ae28201..7b135a3951bc168ccebdbb4e3acdc07397a820d3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -39,6 +39,7 @@ import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
+import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -854,6 +855,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
// Paper end
|
||||
}
|
||||
}
|
||||
+ // Paper start - Prevent armor stands from doing entity lookups
|
||||
+ @Override
|
||||
+ public boolean noCollision(@Nullable Entity entity, AABB box) {
|
||||
+ if (entity instanceof ArmorStand && !entity.level.paperConfig.armorStandEntityLookups) return false;
|
||||
+ return LevelAccessor.super.noCollision(entity, box);
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public Explosion explode(@Nullable Entity entity, double x, double y, double z, float power, Explosion.BlockInteraction destructionType) {
|
||||
return this.explode(entity, (DamageSource) null, (ExplosionDamageCalculator) null, x, y, z, power, false, destructionType);
|
|
@ -1,194 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Hugo Manrique <hugmanrique@gmail.com>
|
||||
Date: Mon, 23 Jul 2018 14:22:26 +0200
|
||||
Subject: [PATCH] Vanished players don't have rights
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 9d8682d367522bd85894947ad2f2a53cf0aa123a..a2cc3e58d59ed3d9f443b77c44d8200cc09b4da9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -183,7 +183,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
|
||||
private static double viewScale = 1.0D;
|
||||
private final EntityType<?> type;
|
||||
private int id;
|
||||
- public boolean blocksBuilding;
|
||||
+ public boolean blocksBuilding; public final boolean blocksEntitySpawning() { return this.blocksBuilding; } // Paper - OBFHELPER
|
||||
public final List<Entity> passengers;
|
||||
protected int boardingCooldown;
|
||||
@Nullable
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
index 16b554675a276471851846d4f2bea06fdcc166d9..d1dd173c11d751b15c3afd4309e386931fd9cf8d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
@@ -5,6 +5,7 @@ import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -157,8 +158,14 @@ public abstract class Projectile extends Entity {
|
||||
protected boolean canHitEntity(Entity entity) {
|
||||
if (!entity.isSpectator() && entity.isAlive() && entity.isPickable()) {
|
||||
Entity entity1 = this.getOwner();
|
||||
-
|
||||
+ // Paper start - Cancel hit for vanished players
|
||||
+ if (entity1 instanceof ServerPlayer && entity instanceof ServerPlayer) {
|
||||
+ org.bukkit.entity.Player collided = (org.bukkit.entity.Player) entity.getBukkitEntity();
|
||||
+ org.bukkit.entity.Player shooter = (org.bukkit.entity.Player) entity1.getBukkitEntity();
|
||||
+ if (!shooter.canSee(collided)) return false;
|
||||
+ }
|
||||
return entity1 == null || this.leftOwner || !entity1.isPassengerOfSameVehicle(entity);
|
||||
+ // Paper end
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java
|
||||
index 1ba89fa106dc24abf68d5d13c39a8d80f5582f1f..59522e367327224e5fe0fe2307858077ed812ba6 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/BlockItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/BlockItem.java
|
||||
@@ -174,7 +174,8 @@ public class BlockItem extends Item {
|
||||
Player entityhuman = context.getPlayer();
|
||||
CollisionContext voxelshapecollision = entityhuman == null ? CollisionContext.empty() : CollisionContext.of((Entity) entityhuman);
|
||||
// CraftBukkit start - store default return
|
||||
- boolean defaultReturn = (!this.mustSurvive() || state.canSurvive(context.getLevel(), context.getClickedPos())) && context.getLevel().isUnobstructed(state, context.getClickedPos(), voxelshapecollision);
|
||||
+ Level world = context.getLevel(); // Paper
|
||||
+ boolean defaultReturn = (!this.mustSurvive() || state.canSurvive(context.getLevel(), context.getClickedPos())) && world.checkEntityCollision(state, entityhuman, voxelshapecollision, context.getClickedPos(), true); // Paper
|
||||
org.bukkit.entity.Player player = (context.getPlayer() instanceof ServerPlayer) ? (org.bukkit.entity.Player) context.getPlayer().getBukkitEntity() : null;
|
||||
|
||||
BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(context.getLevel(), context.getClickedPos()), player, CraftBlockData.fromData(state), defaultReturn);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 7b135a3951bc168ccebdbb4e3acdc07397a820d3..7a9ccd203885b9b369767d1fb8c53783201d0f0f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -30,6 +30,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.tags.TagContainer;
|
||||
@@ -69,6 +70,10 @@ import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
|
||||
import net.minecraft.world.level.storage.LevelData;
|
||||
import net.minecraft.world.level.storage.WritableLevelData;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
+import net.minecraft.world.phys.shapes.BooleanOp;
|
||||
+import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
+import net.minecraft.world.phys.shapes.Shapes;
|
||||
+import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -232,6 +237,46 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ // ret true if no collision
|
||||
+ public final boolean checkEntityCollision(BlockState data, Entity source, CollisionContext voxelshapedcollision,
|
||||
+ BlockPos position, boolean checkCanSee) {
|
||||
+ // Copied from IWorldReader#a(IBlockData, BlockPosition, VoxelShapeCollision) & EntityAccess#a(Entity, VoxelShape)
|
||||
+ VoxelShape voxelshape = data.getCollisionShape(this, position, voxelshapedcollision);
|
||||
+ if (voxelshape.isEmpty()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ voxelshape = voxelshape.offset((double) position.getX(), (double) position.getY(), (double) position.getZ());
|
||||
+ if (voxelshape.isEmpty()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ List<Entity> entities = this.getEntities(null, voxelshape.bounds());
|
||||
+ for (int i = 0, len = entities.size(); i < len; ++i) {
|
||||
+ Entity entity = entities.get(i);
|
||||
+
|
||||
+ if (checkCanSee && source instanceof ServerPlayer && entity instanceof ServerPlayer
|
||||
+ && !((ServerPlayer) source).getBukkitEntity().canSee(((ServerPlayer) entity).getBukkitEntity())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ // !entity1.dead && entity1.i && (entity == null || !entity1.x(entity));
|
||||
+ // elide the last check since vanilla calls with entity = null
|
||||
+ // only we care about the source for the canSee check
|
||||
+ if (entity.removed || !entity.blocksEntitySpawning()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (Shapes.applyOperation(voxelshape, Shapes.of(entity.getBoundingBox()), BooleanOp.AND)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public boolean isClientSide() {
|
||||
return this.isClientSide;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
index e6928557a79f51302975f2832ec911c2692eaaeb..5d7794c9533bd37193f196bda616adaaace2bbde 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
@@ -504,6 +504,7 @@ public abstract class BlockBehaviour {
|
||||
return this.cache != null ? this.cache.collisionShape : this.getCollisionShape(world, pos, CollisionContext.empty());
|
||||
}
|
||||
|
||||
+ public final VoxelShape getCollisionShape(BlockGetter iblockaccess, BlockPos blockposition, CollisionContext voxelshapecollision) { return this.getCollisionShape(iblockaccess, blockposition, voxelshapecollision); } // Paper - OBFHELPER
|
||||
public VoxelShape getCollisionShape(BlockGetter world, BlockPos pos, CollisionContext context) {
|
||||
return this.getBlock().getCollisionShape(this.asState(), world, pos, context);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
|
||||
index 2371b52b450e2b43fa9b9549a91f853c702a9dc0..fa2942d0b0424390daee2121f8959034c5352e0b 100644
|
||||
--- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
|
||||
+++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
|
||||
@@ -45,6 +45,7 @@ public final class Shapes {
|
||||
return create(new AABB(xMin, yMin, zMin, xMax, yMax, zMax));
|
||||
}
|
||||
|
||||
+ public static final VoxelShape of(AABB axisAlignedbb) { return Shapes.create(axisAlignedbb); } // Paper - OBFHELPER
|
||||
public static VoxelShape create(AABB box) {
|
||||
int i = findBits(box.minX, box.maxX);
|
||||
int j = findBits(box.minY, box.maxY);
|
||||
@@ -139,6 +140,7 @@ public final class Shapes {
|
||||
}
|
||||
}
|
||||
|
||||
+ public static final boolean applyOperation(VoxelShape voxelshape, VoxelShape voxelshape1, BooleanOp operatorboolean) { return Shapes.joinIsNotEmpty(voxelshape, voxelshape1, operatorboolean); } // Paper - OBFHELPER
|
||||
public static boolean joinIsNotEmpty(VoxelShape shape1, VoxelShape shape2, BooleanOp predicate) {
|
||||
if (predicate.apply(false, false)) {
|
||||
throw (IllegalArgumentException) Util.pauseInIde((Throwable) (new IllegalArgumentException()));
|
||||
diff --git a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java
|
||||
index 026759567c58b5e7687ed1eec26fb4ffc60f9fa7..67ecdaada9f87304a9ae83d7917c7aca4676d195 100644
|
||||
--- a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java
|
||||
+++ b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java
|
||||
@@ -54,6 +54,7 @@ public abstract class VoxelShape {
|
||||
return this.shape.isEmpty();
|
||||
}
|
||||
|
||||
+ public final VoxelShape offset(double x, double y, double z) { return this.move(x, y, z); } // Paper - OBFHELPER
|
||||
public VoxelShape move(double x, double y, double z) {
|
||||
return (VoxelShape) (this.isEmpty() ? Shapes.empty() : new ArrayVoxelShape(this.shape, new OffsetDoubleList(this.getCoords(Direction.Axis.X), x), new OffsetDoubleList(this.getCoords(Direction.Axis.Y), y), new OffsetDoubleList(this.getCoords(Direction.Axis.Z), z)));
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index c2f58b95db41b2205fbf2728c6a99419c6a63dfa..4cd08821305590e21a01cc4dda05370c2b721ac2 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -1211,6 +1211,14 @@ public class CraftEventFactory {
|
||||
Projectile projectile = (Projectile) entity.getBukkitEntity();
|
||||
org.bukkit.entity.Entity collided = position.getEntity().getBukkitEntity();
|
||||
com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = new com.destroystokyo.paper.event.entity.ProjectileCollideEvent(projectile, collided);
|
||||
+
|
||||
+ if (projectile.getShooter() instanceof Player && collided instanceof Player) {
|
||||
+ if (!((Player) projectile.getShooter()).canSee((Player) collided)) {
|
||||
+ event.setCancelled(true);
|
||||
+ return event;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 6 Oct 2018 21:47:44 -0500
|
||||
Subject: [PATCH] Allow setting the vex's summoner
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vex.java b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||
index ec4f6d96360e759ffc19de838fdbf3027164a424..a4be2bddc5f51601d419647a280c89f7101371f2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||
@@ -165,6 +165,7 @@ public class Vex extends Monster {
|
||||
this.setVexFlag(1, charging);
|
||||
}
|
||||
|
||||
+ public void setOwner(Mob entityinsentient) { setOwner(entityinsentient); } // Paper - OBFHELPER
|
||||
public void setOwner(Mob owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java
|
||||
index 56bec4350f36a94d4dfa71a234872a795c2dcb3f..07c470f8b049bea930337abc1cc87f4669d2f11a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java
|
||||
@@ -20,6 +20,10 @@ public class CraftVex extends CraftMonster implements Vex {
|
||||
net.minecraft.world.entity.Mob owner = getHandle().getOwner();
|
||||
return owner != null ? (org.bukkit.entity.Mob) owner.getBukkitEntity() : null;
|
||||
}
|
||||
+
|
||||
+ public void setSummoner(org.bukkit.entity.Mob summoner) {
|
||||
+ getHandle().setOwner(summoner == null ? null : ((CraftMob) summoner).getHandle());
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Override
|
|
@ -1,351 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 21 Jul 2018 03:11:03 -0500
|
||||
Subject: [PATCH] PlayerLaunchProjectileEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/InteractionResultHolder.java b/src/main/java/net/minecraft/world/InteractionResultHolder.java
|
||||
index 3bc22b977e00c1901a9025112e354e59fcc08a74..c12e2a65d30ca22db0c522e4b245009bcc38c4f4 100644
|
||||
--- a/src/main/java/net/minecraft/world/InteractionResultHolder.java
|
||||
+++ b/src/main/java/net/minecraft/world/InteractionResultHolder.java
|
||||
@@ -10,6 +10,7 @@ public class InteractionResultHolder<T> {
|
||||
this.object = value;
|
||||
}
|
||||
|
||||
+ public InteractionResult getResult() { return this.getResult(); } // Paper - OBFHELPER
|
||||
public InteractionResult getResult() {
|
||||
return this.result;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/EggItem.java b/src/main/java/net/minecraft/world/item/EggItem.java
|
||||
index d2c4241104343a2d2283c358ab2247e333cf0dbf..5d03dcaf79a14946934a6732c94a195d3d65c56d 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/EggItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/EggItem.java
|
||||
@@ -25,21 +25,35 @@ public class EggItem extends Item {
|
||||
|
||||
entityegg.setItem(itemstack);
|
||||
entityegg.shootFromRotation(user, user.xRot, user.yRot, 0.0F, 1.5F, 1.0F);
|
||||
- // CraftBukkit start
|
||||
- if (!world.addFreshEntity(entityegg)) {
|
||||
+ // Paper start
|
||||
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entityegg.getBukkitEntity());
|
||||
+ if (event.callEvent() && world.addFreshEntity(entityegg)) {
|
||||
+ if (event.shouldConsume() && !user.abilities.instabuild) {
|
||||
+ itemstack.shrink(1);
|
||||
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+
|
||||
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.EGG_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (net.minecraft.world.entity.Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||
+ } else {
|
||||
if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||
((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
}
|
||||
- return InteractionResultHolder.fail(itemstack);
|
||||
+ return new InteractionResultHolder<ItemStack>(net.minecraft.world.InteractionResult.FAIL, itemstack);
|
||||
}
|
||||
- // CraftBukkit end
|
||||
+ // Paper end
|
||||
+
|
||||
+
|
||||
}
|
||||
world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.EGG_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (EggItem.random.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - from above
|
||||
|
||||
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||
- if (!user.abilities.instabuild) {
|
||||
- itemstack.shrink(1);
|
||||
+ /* // Paper start - moved up
|
||||
+ entityhuman.b(StatisticList.ITEM_USED.b(this));
|
||||
+ if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
+ itemstack.subtract(1);
|
||||
}
|
||||
+ */ // Paper end
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/EnderpearlItem.java b/src/main/java/net/minecraft/world/item/EnderpearlItem.java
|
||||
index 347e95cc393e773de98b74e18cebbe05f612bdf6..a57c59b330766a2c784ddb7431719e9c1cc2fca8 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/EnderpearlItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/EnderpearlItem.java
|
||||
@@ -25,22 +25,37 @@ public class EnderpearlItem extends Item {
|
||||
|
||||
entityenderpearl.setItem(itemstack);
|
||||
entityenderpearl.shootFromRotation(user, user.xRot, user.yRot, 0.0F, 1.5F, 1.0F);
|
||||
- if (!world.addFreshEntity(entityenderpearl)) {
|
||||
+ // Paper start
|
||||
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entityenderpearl.getBukkitEntity());
|
||||
+ if (event.callEvent() && world.addFreshEntity(entityenderpearl)) {
|
||||
+ if (event.shouldConsume() && !user.abilities.instabuild) {
|
||||
+ itemstack.shrink(1);
|
||||
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+
|
||||
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (net.minecraft.world.entity.Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||
+ user.getCooldowns().addCooldown(this, 20);
|
||||
+ } else {
|
||||
+ // Paper end
|
||||
if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||
((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
}
|
||||
- return InteractionResultHolder.fail(itemstack);
|
||||
+ return new InteractionResultHolder<ItemStack>(net.minecraft.world.InteractionResult.FAIL, itemstack);
|
||||
}
|
||||
}
|
||||
|
||||
- world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (EnderpearlItem.random.nextFloat() * 0.4F + 0.8F));
|
||||
- user.getCooldowns().addCooldown(this, 20);
|
||||
- // CraftBukkit end
|
||||
-
|
||||
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||
- if (!user.abilities.instabuild) {
|
||||
- itemstack.shrink(1);
|
||||
- }
|
||||
+ // Paper start - moved up
|
||||
+// world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
+// entityhuman.getCooldownTracker().setCooldown(this, 20);
|
||||
+// // CraftBukkit end
|
||||
+//
|
||||
+// entityhuman.b(StatisticList.ITEM_USED.b(this));
|
||||
+// if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
+// itemstack.subtract(1);
|
||||
+// }
|
||||
+ // Paper end - moved up
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java b/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java
|
||||
index 032c476892c58a873242b00ca71fe084c719dcaa..0bd65165eacf6a54cdcc348991cf9adb44077bee 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java
|
||||
@@ -1,10 +1,13 @@
|
||||
package net.minecraft.world.item;
|
||||
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
+import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.projectile.ThrownExperienceBottle;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -24,19 +27,38 @@ public class ExperienceBottleItem extends Item {
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
||||
ItemStack itemstack = user.getItemInHand(hand);
|
||||
|
||||
- world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.EXPERIENCE_BOTTLE_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (ExperienceBottleItem.random.nextFloat() * 0.4F + 0.8F));
|
||||
+ //world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EXPERIENCE_BOTTLE_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemExpBottle.RANDOM.nextFloat() * 0.4F + 0.8F)); // Paper - moved down
|
||||
if (!world.isClientSide) {
|
||||
ThrownExperienceBottle entitythrownexpbottle = new ThrownExperienceBottle(world, user);
|
||||
|
||||
entitythrownexpbottle.setItem(itemstack);
|
||||
entitythrownexpbottle.shootFromRotation(user, user.xRot, user.yRot, -20.0F, 0.7F, 1.0F);
|
||||
- world.addFreshEntity(entitythrownexpbottle);
|
||||
+ // Paper start
|
||||
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entitythrownexpbottle.getBukkitEntity());
|
||||
+ if (event.callEvent() && world.addFreshEntity(entitythrownexpbottle)) {
|
||||
+ if (event.shouldConsume() && !user.abilities.instabuild) {
|
||||
+ itemstack.shrink(1);
|
||||
+ } else if (user instanceof ServerPlayer) {
|
||||
+ ((ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+
|
||||
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.EXPERIENCE_BOTTLE_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||
+ } else {
|
||||
+ if (user instanceof ServerPlayer) {
|
||||
+ ((ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return new InteractionResultHolder<ItemStack>(InteractionResult.FAIL, itemstack);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||
- if (!user.abilities.instabuild) {
|
||||
- itemstack.shrink(1);
|
||||
+ /* // Paper start - moved up
|
||||
+ entityhuman.b(StatisticList.ITEM_USED.b(this));
|
||||
+ if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
+ itemstack.subtract(1);
|
||||
}
|
||||
+ */ // Paper end
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||||
index 28cffbe299acccc59c34d5dbd2cf458704be5ee5..4a70582bada607e1efcd826d58d725a0cc95e3c3 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||||
@@ -3,6 +3,7 @@ package net.minecraft.world.item;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import net.minecraft.core.Direction;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
@@ -29,8 +30,12 @@ public class FireworkRocketItem extends Item {
|
||||
FireworkRocketEntity entityfireworks = new FireworkRocketEntity(world, context.getPlayer(), vec3d.x + (double) enumdirection.getStepX() * 0.15D, vec3d.y + (double) enumdirection.getStepY() * 0.15D, vec3d.z + (double) enumdirection.getStepZ() * 0.15D, itemstack);
|
||||
entityfireworks.spawningEntity = context.getPlayer().getUUID(); // Paper
|
||||
|
||||
- world.addFreshEntity(entityfireworks);
|
||||
- itemstack.shrink(1);
|
||||
+ // Paper start - PlayerLaunchProjectileEvent
|
||||
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) context.getPlayer().getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Firework) entityfireworks.getBukkitEntity());
|
||||
+ if (!event.callEvent() || !world.addFreshEntity(entityfireworks)) return InteractionResult.PASS;
|
||||
+ if (event.shouldConsume() && !context.getPlayer().abilities.instabuild) itemstack.shrink(1);
|
||||
+ else if (context.getPlayer() instanceof ServerPlayer) ((ServerPlayer) context.getPlayer()).getBukkitEntity().updateInventory();
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(world.isClientSide);
|
||||
@@ -50,9 +55,9 @@ public class FireworkRocketItem extends Item {
|
||||
if (event.callEvent() && world.addFreshEntity(entityfireworks)) {
|
||||
if (event.shouldConsume() && !user.abilities.instabuild) {
|
||||
itemstack.shrink(1);
|
||||
- } else ((EntityPlayer) user).getBukkitEntity().updateInventory();
|
||||
- } else if (user instanceof EntityPlayer) {
|
||||
- ((EntityPlayer) user).getBukkitEntity().updateInventory();
|
||||
+ } else ((ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
+ } else if (user instanceof ServerPlayer) {
|
||||
+ ((ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/LingeringPotionItem.java b/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
|
||||
index 813a9c8464e253b9baa15af666111be104b4aa29..1957561f83645a57df5925b4b0b54153ebf4aeef 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
|
||||
@@ -3,6 +3,7 @@ package net.minecraft.world.item;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
+import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -15,7 +16,12 @@ public class LingeringPotionItem extends ThrowablePotionItem {
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
||||
- world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.LINGERING_POTION_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (LingeringPotionItem.random.nextFloat() * 0.4F + 0.8F));
|
||||
- return super.use(world, user, hand);
|
||||
+ // Paper start
|
||||
+ InteractionResultHolder<ItemStack> wrapper = super.use(world, user, hand);
|
||||
+ if (wrapper.getResult() != InteractionResult.FAIL) {
|
||||
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.LINGERING_POTION_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (LingeringPotionItem.random.nextFloat() * 0.4F + 0.8F));
|
||||
+ }
|
||||
+ return wrapper;
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/SnowballItem.java b/src/main/java/net/minecraft/world/item/SnowballItem.java
|
||||
index 50adbfc5d57b2b5f25c0efdc51da1701197c66e6..b053d105a1513a6b138972cdb9d28116fc6b8c81 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/SnowballItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/SnowballItem.java
|
||||
@@ -26,14 +26,20 @@ public class SnowballItem extends Item {
|
||||
|
||||
entitysnowball.setItem(itemstack);
|
||||
entitysnowball.shootFromRotation(user, user.xRot, user.yRot, 0.0F, 1.5F, 1.0F);
|
||||
- if (world.addFreshEntity(entitysnowball)) {
|
||||
- if (!user.abilities.instabuild) {
|
||||
+ // Paper start
|
||||
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entitysnowball.getBukkitEntity());
|
||||
+ if (event.callEvent() && world.addFreshEntity(entitysnowball)) {
|
||||
+ if (event.shouldConsume() && !user.abilities.instabuild) {
|
||||
+ // Paper end
|
||||
itemstack.shrink(1);
|
||||
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) { // Paper
|
||||
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper
|
||||
}
|
||||
|
||||
world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.SNOWBALL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (SnowballItem.random.nextFloat() * 0.4F + 0.8F));
|
||||
- } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||
- ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
+ } else { // Paper
|
||||
+ if (user instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper
|
||||
+ return new InteractionResultHolder<ItemStack>(net.minecraft.world.InteractionResult.FAIL, itemstack); // Paper
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/net/minecraft/world/item/SplashPotionItem.java b/src/main/java/net/minecraft/world/item/SplashPotionItem.java
|
||||
index 9c7547988fe90e9b87868636a1c1a7b4dff32622..6d3ab7fea3b5ebba4c304cdec5dd36dbea31f2c6 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/SplashPotionItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/SplashPotionItem.java
|
||||
@@ -3,6 +3,7 @@ package net.minecraft.world.item;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
+import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -15,7 +16,12 @@ public class SplashPotionItem extends ThrowablePotionItem {
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
||||
+ // Paper start
|
||||
+ InteractionResultHolder<ItemStack> wrapper = super.use(world, user, hand);
|
||||
+ if (wrapper.getResult() != InteractionResult.FAIL) {
|
||||
world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.SPLASH_POTION_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (SplashPotionItem.random.nextFloat() * 0.4F + 0.8F));
|
||||
- return super.use(world, user, hand);
|
||||
+ }
|
||||
+ return wrapper;
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java b/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
|
||||
index 3615bc9222db4489189537f7f5d7a7d338053d6d..e12c7ebc0a4ff4f132512dc1677db7f79db41b03 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
|
||||
@@ -1,7 +1,9 @@
|
||||
package net.minecraft.world.item;
|
||||
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
+import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.projectile.ThrownPotion;
|
||||
@@ -22,13 +24,31 @@ public class ThrowablePotionItem extends PotionItem {
|
||||
|
||||
entitypotion.setItem(itemstack);
|
||||
entitypotion.shootFromRotation(user, user.xRot, user.yRot, -20.0F, 0.5F, 1.0F);
|
||||
- world.addFreshEntity(entitypotion);
|
||||
+ // Paper start
|
||||
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entitypotion.getBukkitEntity());
|
||||
+ if (event.callEvent() && world.addFreshEntity(entitypotion)) {
|
||||
+ if (event.shouldConsume() && !user.abilities.instabuild) {
|
||||
+ itemstack.shrink(1);
|
||||
+ } else if (user instanceof ServerPlayer) {
|
||||
+ ((ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+
|
||||
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||
+ } else {
|
||||
+ if (user instanceof ServerPlayer) {
|
||||
+ ((ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return new InteractionResultHolder<ItemStack>(InteractionResult.FAIL, itemstack);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||
- if (!user.abilities.instabuild) {
|
||||
- itemstack.shrink(1);
|
||||
+ /* // Paper start - moved up
|
||||
+ entityhuman.b(StatisticList.ITEM_USED.b(this));
|
||||
+ if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
+ itemstack.subtract(1);
|
||||
}
|
||||
+ */ // Paper end
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BlackHole <black-hole@live.com>
|
||||
Date: Sun, 15 Dec 2019 19:12:39 +0100
|
||||
Subject: [PATCH] Add CraftMagicNumbers.isSupportedApiVersion()
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index 21052d0e88351b075733331d71e07b086354b820..86b319337fc41a09dd45df466df60cadaed1343f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -373,6 +373,11 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
|
||||
return new com.destroystokyo.paper.PaperVersionFetcher();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isSupportedApiVersion(String apiVersion) {
|
||||
+ return apiVersion != null && SUPPORTED_API.contains(apiVersion);
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
Loading…
Add table
Add a link
Reference in a new issue