mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 2c6b1f048 Revert "Remove itneract event from boat" (Fixes #5677) aae1c54a9 Add command line option to load extra plugin jars not in the plugins folder 322886c86 Avoid NPE due to PlayerBedFailEnterEvent d3c9a195c removed duplicate ProjectileHitEvent for fireball (#5671) 7989028a5 More Enchantment API (#5588) c0cb5c129 Adds methods for checking item repairability (#5651) 22399b07f Actually use extended/ambient in BeaconEffectEvent (#5647) 979135878 Add cause and cancel message to PlayerGameModeChangeEvent (#5638) 51e1e58d2 Fix Adventure support in UnknownCommandEvent (#5664) 45e19ffb0 [Auto] Updated Upstream (CraftBukkit) 151457628 Fix Counter#decrement recursive call (#5665) 21ac7dc98 [Auto] Updated Upstream (CraftBukkit) 18ad2c9dd Add environment variable (PAPER_DISABLE_SERVER_GUI) to disable server gui
148 lines
10 KiB
Diff
148 lines
10 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Mariell Hoversholm <proximyst@proximyst.com>
|
|
Date: Sat, 9 Jan 2021 15:27:46 +0100
|
|
Subject: [PATCH] Add EntityTeleportHinderedEvent
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/BlockEnderPortal.java b/src/main/java/net/minecraft/world/level/block/BlockEnderPortal.java
|
|
index fc89b3bf5075497596885548d80e4ed0b800ea89..4900c90597358f7b701b8becd2ac58de11aacc71 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/BlockEnderPortal.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/BlockEnderPortal.java
|
|
@@ -43,7 +43,15 @@ public class BlockEnderPortal extends BlockTileEntity {
|
|
|
|
@Override
|
|
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
|
- if (world instanceof WorldServer && !entity.isPassenger() && !entity.isVehicle() && entity.canPortal() && VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) {
|
|
+ // Purpur start
|
|
+ if (world instanceof WorldServer && /*!entity.isPassenger() && !entity.isVehicle() &&*/ entity.canPortal() && VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) {
|
|
+ if (entity.isPassenger() || entity.isVehicle()) {
|
|
+ if (new net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent(entity.getBukkitEntity(), entity.isPassenger() ? net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent.Reason.IS_PASSENGER : net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent.Reason.IS_VEHICLE, PlayerTeleportEvent.TeleportCause.END_PORTAL).callEvent()) {
|
|
+ this.collideWithBlock(iblockdata, world, blockposition, entity);
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+ // Purpur end
|
|
ResourceKey<World> resourcekey = world.getTypeKey() == DimensionManager.THE_END ? World.OVERWORLD : World.THE_END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends
|
|
WorldServer worldserver = ((WorldServer) world).getMinecraftServer().getWorldServer(resourcekey);
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/BlockPortal.java b/src/main/java/net/minecraft/world/level/block/BlockPortal.java
|
|
index 5f797260eff317409a5039b88b01ad79ee2fdd91..ac5ce96ab62ec210816e7af85a4269073b7a9270 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/BlockPortal.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/BlockPortal.java
|
|
@@ -82,7 +82,15 @@ public class BlockPortal extends Block {
|
|
|
|
@Override
|
|
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
|
- if (!entity.isPassenger() && !entity.isVehicle() && entity.canPortal()) {
|
|
+ // Purpur start
|
|
+ if (/*!entity.isPassenger() && !entity.isVehicle() &&*/ entity.canPortal()) {
|
|
+ if (entity.isPassenger() || entity.isVehicle()) {
|
|
+ if (new net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent(entity.getBukkitEntity(), entity.isPassenger() ? net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent.Reason.IS_PASSENGER : net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent.Reason.IS_VEHICLE, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.NETHER_PORTAL).callEvent()) {
|
|
+ this.collideWithBlock(iblockdata, world, blockposition, entity);
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+ // Purpur end
|
|
// CraftBukkit start - Entity in portal
|
|
EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
|
world.getServer().getPluginManager().callEvent(event);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityEndGateway.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityEndGateway.java
|
|
index d918194e45953764fa3fd286b715714330a60941..70496562faa89e92da34a4f7b891f845d1d55012 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityEndGateway.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityEndGateway.java
|
|
@@ -151,9 +151,18 @@ public class TileEntityEndGateway extends TileEntityEnderPortal implements ITick
|
|
}
|
|
}
|
|
|
|
+ public final void teleportEntity(Entity entity) { this.b(entity); } // Purpur - OBFHELPER
|
|
public void b(Entity entity) {
|
|
if (this.world instanceof WorldServer && !this.f()) {
|
|
if (!entity.canPortal()) return; // Purpur
|
|
+ // Purpur start
|
|
+ if (this.world.purpurConfig.imposeTeleportRestrictionsOnGateways && (entity.isVehicle() || entity.isPassenger())) {
|
|
+ if (new net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent(entity.getBukkitEntity(), entity.isPassenger() ? net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent.Reason.IS_PASSENGER : net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent.Reason.IS_VEHICLE, PlayerTeleportEvent.TeleportCause.END_GATEWAY).callEvent()) {
|
|
+ this.teleportEntity(entity);
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+ // Purpur end
|
|
this.c = 100;
|
|
if (this.exitPortal == null && this.world.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit - work in alternate worlds
|
|
this.a((WorldServer) this.world);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBase.java b/src/main/java/net/minecraft/world/level/block/state/BlockBase.java
|
|
index df595dc52858807479584ce8da49390a25695990..0990eb8b2e2d8a5f7c1a2640727d86c37a50298e 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBase.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBase.java
|
|
@@ -303,6 +303,7 @@ public abstract class BlockBase {
|
|
return 0;
|
|
}
|
|
|
|
+ @Deprecated public final void collideWithBlock(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { this.a(iblockdata, world, blockposition, entity); } // Purpur - OBFHELPER
|
|
@Deprecated
|
|
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {}
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index a0df754d98e4be46720ba0962bdf7bf62f3425bb..c8b510a49ba5c299ec38ea1a56f5245ec6161b55 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -1941,4 +1941,9 @@ public class PurpurWorldConfig {
|
|
zombieVillagerMaxHealth = getDouble("mobs.zombie_villager.attributes.max_health", zombieVillagerMaxHealth);
|
|
zombieVillagerSpawnReinforcements = getDouble("mobs.zombie_villager.attributes.spawn_reinforcements", zombieVillagerSpawnReinforcements);
|
|
}
|
|
+
|
|
+ public boolean imposeTeleportRestrictionsOnGateways = false;
|
|
+ private void imposeTeleportRestrictionsOnGateways() {
|
|
+ imposeTeleportRestrictionsOnGateways = getBoolean("gameplay-mechanics.impose-teleport-restrictions-on-gateways", imposeTeleportRestrictionsOnGateways);
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
index dcdc82b42689b4962323938a62cf7ded49afd6f4..4a70d657fd83627e8d66b52cb5f87381b43ad76a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -550,6 +550,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
location.checkFinite();
|
|
|
|
if (entity.isVehicle() || entity.dead) {
|
|
+ // Purpur start
|
|
+ if (!entity.dead && new net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent(entity.getBukkitEntity(), net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent.Reason.IS_VEHICLE, cause).callEvent())
|
|
+ return teleport(location, cause);
|
|
+ // Purpur end
|
|
return false;
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index e557157c5128ea89d728de2ab92b5e1a7b3437ef..dbac5843088e221cd7d654a0c872ef4451b53075 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -126,6 +126,7 @@ import org.bukkit.entity.EntityType;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.player.PlayerRegisterChannelEvent;
|
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
|
import org.bukkit.event.player.PlayerUnregisterChannelEvent;
|
|
import org.bukkit.inventory.InventoryView.Property;
|
|
import org.bukkit.inventory.ItemStack;
|
|
@@ -881,6 +882,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
}
|
|
|
|
if (entity.isVehicle()) {
|
|
+ // Purpur start
|
|
+ if (new net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent(entity.getBukkitEntity(), net.pl3x.purpur.event.entity.EntityTeleportHinderedEvent.Reason.IS_VEHICLE, cause).callEvent())
|
|
+ return teleport(location, cause);
|
|
+ // Purpur end
|
|
return false;
|
|
}
|
|
|