13
0
geforkt von Mirrors/Paper
Dieser Commit ist enthalten in:
Jake Potrebic 2021-06-12 14:31:35 -07:00 committet von MiniDigger | Martin
Ursprung 716a3139b7
Commit a968aefd32
26 geänderte Dateien mit 535 neuen und 730 gelöschten Zeilen

Datei anzeigen

@ -38,8 +38,8 @@ c net/minecraft/world/entity/projectile/EntityTippedArrow net/minecraft/world/en
# CraftBukkit adds a new `a` method which allows passing the Entity parameter
# It uses `a` to match the original method (with just 1 param), so this patch makes them match
#c net/minecraft/server/level/WorldServer net/minecraft/server/level/ServerLevel
# m (Lnet/minecraft/server/level/WorldServer;Lnet/minecraft/world/entity/Entity;)V a makeObsidianPlatform
c net/minecraft/server/level/WorldServer net/minecraft/server/level/ServerLevel
m (Lnet/minecraft/server/level/WorldServer;Lnet/minecraft/world/entity/Entity;)V a makeObsidianPlatform
# CraftBukkit adds `getMinecraftWorld()` to `GeneratorAccess`, which matches `WorldAccess.getMinecraftWorld()`
# But that method in `WorldAccess` is called `getLevel()` in Mojang mappings

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Entity#getChunk API
Get the chunk the entity is currently registered to
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
index fdc95c87a6020bdcaee5b0b8ab5a996c0e241b33..76c20d84fee011af4f1850d0cab8ac00a69f2b34 100644
index fdc95c87a6020bdcaee5b0b8ab5a996c0e241b33..ef95afb92f7a6fea77fe483e26ee3cf6d1bdd041 100644
--- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -3,6 +3,7 @@ package org.bukkit.entity;
@ -17,7 +17,7 @@ index fdc95c87a6020bdcaee5b0b8ab5a996c0e241b33..76c20d84fee011af4f1850d0cab8ac00
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Nameable;
@@ -672,5 +673,13 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
@@ -672,5 +673,16 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
* @return True if entity spawned from a mob spawner
*/
boolean fromMobSpawner();
@ -28,6 +28,9 @@ index fdc95c87a6020bdcaee5b0b8ab5a996c0e241b33..76c20d84fee011af4f1850d0cab8ac00
+ * @return The current, or most recent chunk if the entity is invalid (which may load the chunk)
+ */
+ @NotNull
+ Chunk getChunk();
+ default Chunk getChunk() {
+ // TODO remove impl here
+ return getLocation().getChunk();
+ }
// Paper end
}

Datei anzeigen

@ -7,6 +7,8 @@ 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.
Spigot did not remove the warning in 1.17
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

Datei anzeigen

@ -5,6 +5,8 @@ Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues
Add -Ddebug.entities=true to your JVM flags to gain more information
1.17: Needs to be reworked for new entity storage system
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

Datei anzeigen

@ -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());

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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

Datei anzeigen

@ -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());
}

Datei anzeigen

@ -1,35 +1,32 @@
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
Subject: [PATCH] Vex#get/setSummoner API
Get's the NPC that summoned this Vex
Get's the NPC that summoned this Vex and
Allow setting the vex's summoner
Co-authored-by: BillyGalbreath <Blake.Galbreath@GMail.com>
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
index d07d956e727483bb0b85dce618acb2adc8d89872..0f5c81c0d599d3b58f7864d1527391ad50983c4e 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 {
@@ -15,6 +15,19 @@ public class CraftVex extends CraftMonster implements Vex {
return (net.minecraft.world.entity.monster.Vex) super.getHandle();
}
+ // Paper start
+ @Override
+ public org.bukkit.entity.Mob getSummoner() {
+ net.minecraft.world.entity.Mob owner = getHandle().getOwner();
+ return owner != null ? (org.bukkit.entity.Mob) owner.getBukkitEntity() : null;
+ }
+
+ @Override
+ public void setSummoner(org.bukkit.entity.Mob summoner) {
+ getHandle().setOwner(summoner == null ? null : ((CraftMob) summoner).getHandle());
+ }
+ // Paper end
+
@Override

Datei anzeigen

@ -16,14 +16,14 @@ 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
index ce88f701f296e67afc67d7e3882406e86147408e..902eab82912b9a7002485f73df7ae25e370b7e25 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 {
}
@@ -2217,6 +2217,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
}
if (event.isCancelled()) {
+ this.player.refreshContainer(this.player.containerMenu); // Paper - Refresh player inventory
return;
}
// CraftBukkit end
if (event.isCancelled()) {
+ ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); // Paper - Refresh player inventory
return;
}
// CraftBukkit end

Datei anzeigen

@ -5,10 +5,10 @@ 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
index 54025e401eb02fceb47afb182f0ede620ca23a8d..0741dcbd06395b4696eb6083128a5d9b679cb3fb 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 {
@@ -223,6 +223,10 @@ public class ItemEntity extends Entity {
private void mergeWithNeighbours() {
if (this.isMergable()) {

Datei anzeigen

@ -4,13 +4,25 @@ Date: Tue, 17 Jul 2018 16:42:17 +0200
Subject: [PATCH] Use asynchronous Log4j 2 loggers
diff --git a/build.gradle.kts b/build.gradle.kts
index ac607a3be84bc02dedb95cab9a5eace40e33b511..b967ab10155bbf26e864bedadb8ae2ab5fdd38c1 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -42,6 +42,7 @@ dependencies {
}
runtimeOnly("org.xerial:sqlite-jdbc:3.34.0")
runtimeOnly("mysql:mysql-connector-java:8.0.23") // Paper
+ runtimeOnly("com.lmax:disruptor:3.4.2") // Paper
runtimeOnly("org.apache.maven:maven-resolver-provider:3.8.1")
runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.0")
diff --git a/pom.xml b/pom.xml
index f5429f2f1979542fd93956d2f436d20d0e3a66b8..4c8a057e790c96b0ab5123549d0566371acacb46 100644
index f5e74f74e32095c4ad1f8094a0dd64be8e193f0c..86cce7143abd317326cc755118bf61435e82e479 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,6 +88,13 @@
<artifactId>log4j-iostreams</artifactId>
<scope>compile</scope>
@@ -57,6 +57,13 @@
</exclusion>
</exclusions>
</dependency>
+ <!-- Paper - Async loggers -->
+ <dependency>

Datei anzeigen

@ -6,15 +6,15 @@ 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
index 1603a0ff6a0c82e18ef5446c129a1c05488abf86..960c3e75a60ef33141e615bd8b256528eeaf399c 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
@@ -2784,7 +2784,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
}
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
+ return String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b, rR=%s]", 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()), this.chunkPosition(), this.tickCount, this.valid, this.removalReason}); // Paper - add more information
}
public boolean isInvulnerableTo(DamageSource damageSource) {

Datei anzeigen

@ -5,7 +5,7 @@ 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
index c49d2dd323e7164ded499e561821da2c0e4be9da..ad8d6a84e1a66e03ae15269e36bc787148f12396 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 {

Datei anzeigen

@ -5,58 +5,49 @@ 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
index df44bfce8cc492cd901dfa86331b9be7f1e13837..7490674d59d152a70e24a790bdbc717998ed2c52 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 {
@@ -81,7 +81,13 @@ 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);
+ // Paper start
+ } else {
+ this.removeAreaEffect();
+ this.end();
+ }
+ // Paper end
}
}
@@ -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
index 974895ef23e9d2b8c520abd262a2e80d28be5860..318a288a9170254b682955d96a150e99ca89b345 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);
@@ -71,7 +71,9 @@ public class DragonStrafePlayerPhase extends AbstractDragonPhaseInstance {
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
DragonFireball dragonFireball = new DragonFireball(this.dragon.level, this.dragon, r, s, t);
dragonFireball.moveTo(o, p, q, 0.0F, 0.0F);
+ if (new com.destroystokyo.paper.event.entity.EnderDragonShootFireballEvent((org.bukkit.entity.EnderDragon) dragon.getBukkitEntity(), (org.bukkit.entity.DragonFireball) dragonFireball.getBukkitEntity()).callEvent()) // Paper
this.dragon.level.addFreshEntity(dragonFireball);
+ else dragonFireball.discard(); // Paper
this.fireballCharge = 0;
if (this.currentPath != null) {
while (!this.currentPath.isDone()) {
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
index a7935042497a108a21814c28b01a0ab27aefbbc4..6afe37e42d88701af38df5793a9ea9d7d2cda5c5 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 {
@@ -52,8 +52,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
+ 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) areaEffectCloud.getBukkitEntity()).callEvent()) { // Paper
this.level.levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1);
this.level.addFreshEntity(entityareaeffectcloud);
+ } else entityareaeffectcloud.remove(); // Paper
this.remove();
this.level.addFreshEntity(areaEffectCloud);
+ } else areaEffectCloud.discard(); // Paper
this.discard();
}

Datei anzeigen

@ -0,0 +1,33 @@
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 10385dcb851bb435821afba322ed11f59e7ad3e6..561f98b442788814cbc6cbb7e144207d14f67ff8 100644
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
@@ -61,12 +61,19 @@ public class FireworkRocketItem extends Item {
if (!world.isClientSide) {
FireworkRocketEntity fireworkRocketEntity = new FireworkRocketEntity(world, itemStack, user);
fireworkRocketEntity.spawningEntity = user.getUUID(); // Paper
- world.addFreshEntity(fireworkRocketEntity);
- if (!user.getAbilities().instabuild) {
+ // 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) fireworkRocketEntity.getBukkitEntity());
+ if (event.callEvent() && world.addFreshEntity(fireworkRocketEntity)) {
+ user.awardStat(Stats.ITEM_USED.get(this));
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
itemStack.shrink(1);
+ } else ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
+ // Paper end
}
- user.awardStat(Stats.ITEM_USED.get(this));
+ // user.awardStat(Stats.ITEM_USED.get(this)); // Paper - move up
}
return InteractionResultHolder.sidedSuccess(user.getItemInHand(hand), world.isClientSide());

Datei anzeigen

@ -0,0 +1,276 @@
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/item/EggItem.java b/src/main/java/net/minecraft/world/item/EggItem.java
index 3516cd8ec5816e13df9850c6dc62ddd69b5cfaed..784c5c2b8299a5309ae190fef9923778fcfa00b4 100644
--- a/src/main/java/net/minecraft/world/item/EggItem.java
+++ b/src/main/java/net/minecraft/world/item/EggItem.java
@@ -23,21 +23,33 @@ public class EggItem extends Item {
entityegg.setItem(itemstack);
entityegg.shootFromRotation(user, user.getXRot(), user.getYRot(), 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.getAbilities().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(), net.minecraft.sounds.SoundEvents.EGG_THROW, net.minecraft.sounds.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);
}
- // CraftBukkit end
+ // Paper end
}
// world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // CraftBukkit - from above
+ /* // Paper start - moved up
user.awardStat(Stats.ITEM_USED.get(this));
if (!user.getAbilities().instabuild) {
itemstack.shrink(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 c7d4745aed77b23562cde7c68b8870fa239428d4..749ab72edc0d2e9c6f1161415ab8d59d3d6ca976 100644
--- a/src/main/java/net/minecraft/world/item/EnderpearlItem.java
+++ b/src/main/java/net/minecraft/world/item/EnderpearlItem.java
@@ -25,7 +25,20 @@ public class EnderpearlItem extends Item {
entityenderpearl.setItem(itemstack);
entityenderpearl.shootFromRotation(user, user.getXRot(), user.getYRot(), 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.getAbilities().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();
}
@@ -33,6 +46,7 @@ public class EnderpearlItem extends Item {
}
}
+ /* // Paper start - moved up
world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
user.getCooldowns().addCooldown(this, 20);
// CraftBukkit end
@@ -41,6 +55,7 @@ public class EnderpearlItem extends Item {
if (!user.getAbilities().instabuild) {
itemstack.shrink(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 72dfb7b652f515bf9df201d524a851ab56706544..b80bedb5f27b474d7f66e9e1cc38ca3b692fc92b 100644
--- a/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java
+++ b/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java
@@ -22,18 +22,37 @@ public class ExperienceBottleItem extends Item {
@Override
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 / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ // world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.EXPERIENCE_BOTTLE_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // Paper - moved down
if (!world.isClientSide) {
ThrownExperienceBottle thrownExperienceBottle = new ThrownExperienceBottle(world, user);
thrownExperienceBottle.setItem(itemStack);
thrownExperienceBottle.shootFromRotation(user, user.getXRot(), user.getYRot(), -20.0F, 0.7F, 1.0F);
- world.addFreshEntity(thrownExperienceBottle);
+ // 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) thrownExperienceBottle.getBukkitEntity());
+ if (event.callEvent() && world.addFreshEntity(thrownExperienceBottle)) {
+ if (event.shouldConsume() && !user.getAbilities().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.EXPERIENCE_BOTTLE_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));
+ } else {
+ if (user instanceof net.minecraft.server.level.ServerPlayer) {
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
+ }
+ return InteractionResultHolder.fail(itemStack);
+ }
+ // Paper end
}
+ /* // Paper start - moved up
user.awardStat(Stats.ITEM_USED.get(this));
if (!user.getAbilities().instabuild) {
itemStack.shrink(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 561f98b442788814cbc6cbb7e144207d14f67ff8..543a08f920319a2547258640bafebb1e70af65c4 100644
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
@@ -13,6 +13,7 @@ import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.stats.Stats;
+import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
@@ -47,8 +48,12 @@ public class FireworkRocketItem extends Item {
Direction direction = context.getClickedFace();
FireworkRocketEntity fireworkRocketEntity = new FireworkRocketEntity(level, context.getPlayer(), vec3.x + (double)direction.getStepX() * 0.15D, vec3.y + (double)direction.getStepY() * 0.15D, vec3.z + (double)direction.getStepZ() * 0.15D, itemStack);
fireworkRocketEntity.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID(); // Paper
- level.addFreshEntity(fireworkRocketEntity);
- 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) fireworkRocketEntity.getBukkitEntity());
+ if (!event.callEvent() || !level.addFreshEntity(fireworkRocketEntity)) return InteractionResult.PASS;
+ if (event.shouldConsume() && !context.getPlayer().getAbilities().instabuild) itemStack.shrink(1);
+ else if (context.getPlayer() instanceof ServerPlayer) ((ServerPlayer) context.getPlayer()).getBukkitEntity().updateInventory();
+ // Paper end
}
return InteractionResult.sidedSuccess(level.isClientSide);
diff --git a/src/main/java/net/minecraft/world/item/LingeringPotionItem.java b/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
index db0492f6337de562210ef062f46e98992c908200..f2d1b4e3fc08f6a06beb391bc6e60f62a9bf82b9 100644
--- a/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
+++ b/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
@@ -23,7 +23,12 @@ public class LingeringPotionItem 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() != net.minecraft.world.InteractionResult.FAIL) {
world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.LINGERING_POTION_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().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/SnowballItem.java b/src/main/java/net/minecraft/world/item/SnowballItem.java
index 516afa893035539a879a71eb327eed0596c31d48..717f90a2ca41734f7ee09401f21474820fa1cf48 100644
--- a/src/main/java/net/minecraft/world/item/SnowballItem.java
+++ b/src/main/java/net/minecraft/world/item/SnowballItem.java
@@ -26,18 +26,26 @@ public class SnowballItem extends Item {
entitysnowball.setItem(itemstack);
entitysnowball.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F);
- if (world.addFreshEntity(entitysnowball)) {
- if (!user.getAbilities().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)) {
+ user.awardStat(Stats.ITEM_USED.get(this));
+ if (event.shouldConsume() && !user.getAbilities().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 / (world.getRandom().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 InteractionResultHolder.fail(itemstack); // Paper
}
}
// CraftBukkit end
+ /* // Paper tart - moved up
user.awardStat(Stats.ITEM_USED.get(this));
// CraftBukkit start - moved up
/*
@@ -45,6 +53,7 @@ public class SnowballItem extends Item {
itemstack.subtract(1);
}
*/
+ // Paper end
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
}
diff --git a/src/main/java/net/minecraft/world/item/SplashPotionItem.java b/src/main/java/net/minecraft/world/item/SplashPotionItem.java
index 317e20052bcac9118e1adeb619bedaacc6fcd690..ece19f30064e9f59d4df077683e1f894455a84b7 100644
--- a/src/main/java/net/minecraft/world/item/SplashPotionItem.java
+++ b/src/main/java/net/minecraft/world/item/SplashPotionItem.java
@@ -14,7 +14,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() != net.minecraft.world.InteractionResult.FAIL) {
world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.SPLASH_POTION_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (world.getRandom().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 0673f62f25532955f3552b64f122e644d42027e4..de5bdceb4c8578fb972a2fd5ee0dfdae509e46dc 100644
--- a/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
+++ b/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
@@ -19,13 +19,31 @@ public class ThrowablePotionItem extends PotionItem {
ThrownPotion thrownPotion = new ThrownPotion(world, user);
thrownPotion.setItem(itemStack);
thrownPotion.shootFromRotation(user, user.getXRot(), user.getYRot(), -20.0F, 0.5F, 1.0F);
- world.addFreshEntity(thrownPotion);
+ // 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) thrownPotion.getBukkitEntity());
+ if (event.callEvent() && world.addFreshEntity(thrownPotion)) {
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
+ itemStack.shrink(1);
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
+ }
+
+ 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);
+ }
+ // Paper end
}
+ /* // Paper start - moved up
user.awardStat(Stats.ITEM_USED.get(this));
if (!user.getAbilities().instabuild) {
itemStack.shrink(1);
}
+ */ // Paper end
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
}

Datei anzeigen

@ -20,42 +20,30 @@ This should result in an across the board speedup in anything that accesses bloc
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
index c66ae4d9eea993f3b7fcc6e253259db3346229d1..ea496a990e7e49bc83f7a8b98f71f2b11d9fc56c 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));
}
@Override
- 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> {
}
@@ -59,7 +59,7 @@ public class Vec3i implements Comparable<Vec3i> {
}
@Override
- 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();
@@ -72,15 +72,15 @@ public class Vec3i implements Comparable<Vec3i> {
}
}
- public int getX() {

Datei anzeigen

@ -1,39 +1,38 @@
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()
Subject: [PATCH] Optimize IntIdentityHashBiMiap#nextId()
Optimizes CrudeIncrementalIntIdentityHashBiMap#nextId()
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
index feaa9572a450b88a26659d850a269d09465259ee..62440dbb35263cddc90ba594c3d5777d7643e527 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> {
@@ -16,12 +16,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
size = (int)((float)size / 0.8F);
this.keys = (K[])(new Object[size]);
this.values = new int[size];
this.byId = (K[]) (new Object[size]); // Paper - decompile fix
this.byId = (K[])(new Object[size]);
+ this.usedIds = new java.util.BitSet(); // Paper
}
// Paper start - decompile fix
@@ -52,9 +54,14 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
@Override
@@ -54,9 +56,13 @@ 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;
+ /* // Paper start
while(this.nextId < this.byId.length && this.byId[this.nextId] != null) {
++this.nextId;
}
+ */
+ this.nextId = this.usedIds.nextClearBit(0);
@ -41,15 +40,15 @@ index 66ad412e4368a8615cc66a97ac442c572813a3dd..fa4a2d29b3b4c20d7396e973801d69c4
return this.nextId;
}
@@ -68,6 +75,7 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
this.byId = (K[]) (new Object[newSize]); // Paper - decompile fix
@@ -69,6 +75,7 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
this.byId = (K[])(new Object[newSize]);
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> {
for(int i = 0; i < objects.length; ++i) {
if (objects[i] != null) {
@@ -92,6 +99,7 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
this.keys[k] = value;
this.values[k] = id;
this.byId[id] = value;
@ -57,8 +56,8 @@ index 66ad412e4368a8615cc66a97ac442c572813a3dd..fa4a2d29b3b4c20d7396e973801d69c4
++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);
@@ -153,6 +161,7 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
Arrays.fill(this.byId, (Object)null);
this.nextId = 0;
this.size = 0;
+ this.usedIds.clear(); // Paper

Datei anzeigen

@ -5,10 +5,10 @@ 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
index 8f8a3ea51823a9cfba985efeb7e320ae42e0da8a..1f6b37bd3cbc825abab5ad2f673200ef5061746a 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 {
@@ -373,4 +373,9 @@ public class PaperWorldConfig {
private void scanForLegacyEnderDragon() {
scanForLegacyEnderDragon = getBoolean("game-mechanics.scan-for-legacy-ender-dragon", true);
}
@ -19,10 +19,10 @@ index 4813f62d1e382d5ac6971b2244df3f13c80d1950..3562950df4868b1393790b1a1ff1fe0d
+ }
}
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
index cda073a8ab9daed75f284cbbe4459991fba348f0..449f9b87ea6ff313f7e0e9104a641f1bf7729f24 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 {
@@ -339,6 +339,7 @@ public class ArmorStand extends LivingEntity {
@Override
protected void pushEntities() {
@ -31,25 +31,17 @@ index 59239e202e8e99870ce3be515d2f040ad9786892..7fc69adc8afa971ee3cf815c6002628a
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
index 8859b0483ca71e1a36c164f7d386684540f0bf18..2c86a5ae8bbf7d80e7ce8cd08319ed6a17b86dbb 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 {
@@ -767,6 +767,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;
+ if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level.paperConfig.armorStandEntityLookups) return false;
+ return LevelAccessor.super.noCollision(entity, box);
+ }
+ // Paper end

Datei anzeigen

@ -0,0 +1,119 @@
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/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
index c25cb17ef1a7c56e10ce3ccb5665c9dce3e6efa6..30118ff975da9491fa41db2133d217c2a797a8e3 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
@@ -209,7 +209,14 @@ public abstract class Projectile extends Entity {
if (!entity.isSpectator() && entity.isAlive() && entity.isPickable()) {
Entity entity1 = this.getOwner();
+ // Paper start - Cancel hit for vanished players
+ if (entity1 instanceof net.minecraft.server.level.ServerPlayer && entity instanceof net.minecraft.server.level.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 86d245c9a817be5fd2be7f331d3a3a5f3169e8c2..44b28773fe8e79931e738d493bd9405e0ee3dca9 100644
--- a/src/main/java/net/minecraft/world/item/BlockItem.java
+++ b/src/main/java/net/minecraft/world/item/BlockItem.java
@@ -191,7 +191,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 2c86a5ae8bbf7d80e7ce8cd08319ed6a17b86dbb..c1cf7f5bff2878281d4a9787ea7160e984268352 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -71,6 +71,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;
@@ -248,6 +252,45 @@ 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.move((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 net.minecraft.server.level.ServerPlayer && entity instanceof net.minecraft.server.level.ServerPlayer
+ && !((net.minecraft.server.level.ServerPlayer) source).getBukkitEntity().canSee(((net.minecraft.server.level.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.isRemoved() || !entity.blocksBuilding) {
+ continue;
+ }
+
+ if (Shapes.joinIsNotEmpty(voxelshape, Shapes.create(entity.getBoundingBox()), BooleanOp.AND)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ // Paper end
@Override
public boolean isClientSide() {
return this.isClientSide;
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 375e9e45331d5be237c67f11af94c6998409418b..966d06e2da7e6f9b4e78ca8ed02f3a6472bc8c05 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1190,6 +1190,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;
}