geforkt von Mirrors/Paper
01a13871de
Patch documentation to come Issues with the old system that are fixed now: - World generation does not scale with cpu cores effectively. - Relies on the main thread for scheduling and maintaining chunk state, dropping chunk load/generate rates at lower tps. - Unreliable prioritisation of chunk gen/load calls that block the main thread. - Shutdown logic is utterly unreliable, as it has to wait for all chunks to unload - is it guaranteed that the chunk system is in a state on shutdown that it can reliably do this? Watchdog shutdown also typically failed due to thread checks, which is now resolved. - Saving of data is not unified (i.e can save chunk data without saving entity data, poses problems for desync if shutdown is really abnormal. - Entities are not loaded with chunks. This caused quite a bit of headache for Chunk#getEntities API, but now the new chunk system loads entities with chunks so that they are ready whenever the chunk loads in. Effectively brings the behavior back to 1.16 era, but still storing entities in their own separate regionfiles. The above list is not complete. The patch documentation will complete it. New chunk system hard relies on starlight and dataconverter, and most importantly the new concurrent utilities in ConcurrentUtil. Some of the old async chunk i/o interface (i.e the old file io thread reroutes _some_ calls to the new file io thread) is kept for plugin compat reasons. It will be removed in the next major version of minecraft. The old legacy chunk system patches have been moved to the removed folder in case we need them again.
110 Zeilen
6.3 KiB
Diff
110 Zeilen
6.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Techcable <Techcable@outlook.com>
|
|
Date: Fri, 16 Dec 2016 21:25:39 -0600
|
|
Subject: [PATCH] Add ProjectileCollideEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
index 7cd802be238cedf166174a61e816d9d4b29b87d2..7f1f4813ac007fbf79e8ba254075c015fe15e3a1 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
@@ -226,6 +226,17 @@ public abstract class AbstractArrow extends Projectile {
|
|
}
|
|
}
|
|
|
|
+ // Paper start - Call ProjectileCollideEvent
|
|
+ // TODO: flag - noclip - call cancelled?
|
|
+ if (object instanceof EntityHitResult) {
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, (EntityHitResult)object);
|
|
+ if (event.isCancelled()) {
|
|
+ object = null;
|
|
+ movingobjectpositionentity = null;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
if (object != null && !flag) {
|
|
this.preOnHit((HitResult) object); // CraftBukkit - projectile hit event
|
|
this.hasImpulse = true;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
|
index 867e50769af3c5bdbed15cfd637e429dcfcb6920..d71dc286673fa7ed708be5bec4c5a6868874c090 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
|
@@ -11,6 +11,7 @@ import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.EntityType;
|
|
import net.minecraft.world.entity.LivingEntity;
|
|
import net.minecraft.world.level.Level;
|
|
+import net.minecraft.world.phys.EntityHitResult;
|
|
import net.minecraft.world.phys.HitResult;
|
|
import net.minecraft.world.phys.Vec3;
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
|
@@ -82,7 +83,16 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
|
|
|
HitResult movingobjectposition = ProjectileUtil.getHitResult(this, this::canHitEntity);
|
|
|
|
- if (movingobjectposition.getType() != HitResult.Type.MISS) {
|
|
+ // Paper start - Call ProjectileCollideEvent
|
|
+ if (movingobjectposition instanceof EntityHitResult) {
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = CraftEventFactory.callProjectileCollideEvent(this, (EntityHitResult)movingobjectposition);
|
|
+ if (event.isCancelled()) {
|
|
+ movingobjectposition = null;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
+ if (movingobjectposition != null && movingobjectposition.getType() != HitResult.Type.MISS) { // Paper - add null check in case cancelled
|
|
this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event
|
|
|
|
// CraftBukkit start - Fire ProjectileHitEvent
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java
|
|
index 88181c59e604ba3b132b9e695cef5eaf5b836029..94d09b05737679b133ec462815b010b19c01b4fa 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java
|
|
@@ -10,6 +10,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|
import net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.phys.BlockHitResult;
|
|
+import net.minecraft.world.phys.EntityHitResult;
|
|
import net.minecraft.world.phys.HitResult;
|
|
import net.minecraft.world.phys.Vec3;
|
|
|
|
@@ -66,7 +67,17 @@ public abstract class ThrowableProjectile extends Projectile {
|
|
}
|
|
|
|
if (movingobjectposition.getType() != HitResult.Type.MISS && !flag) {
|
|
+ // Paper start - Call ProjectileCollideEvent
|
|
+ if (movingobjectposition instanceof EntityHitResult) {
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, (EntityHitResult)movingobjectposition);
|
|
+ if (event.isCancelled()) {
|
|
+ movingobjectposition = null;
|
|
+ }
|
|
+ }
|
|
+ if (movingobjectposition != null) {
|
|
+ // Paper end
|
|
this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event
|
|
+ } // Paper
|
|
}
|
|
|
|
this.checkInsideBlocks();
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 09a5c7a95f87e35c43d07974f5884e28833f9777..e00f87e4a9384c60e5fe4c33a9f27541366ae81b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1256,6 +1256,16 @@ public class CraftEventFactory {
|
|
return CraftItemStack.asNMSCopy(bitem);
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public static com.destroystokyo.paper.event.entity.ProjectileCollideEvent callProjectileCollideEvent(Entity entity, EntityHitResult position) {
|
|
+ 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);
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
+ return event;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public static ProjectileLaunchEvent callProjectileLaunchEvent(Entity entity) {
|
|
Projectile bukkitEntity = (Projectile) entity.getBukkitEntity();
|
|
ProjectileLaunchEvent event = new ProjectileLaunchEvent(bukkitEntity);
|