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: 8c74d3126 Updated Upstream (Bukkit) (#5359) fd3c66a91 bug #5362 - correctly pass "render type" when registering a new scoreboard objective 39c487b37 Add per-command perms for paper command cdbf2578c Add Item Rarity API (#5352) d80e43647 [CI-SKIP] Removal from the MIT list (#5345) Tuinity Changes: aea6b8347 Merge dev/playerchunkloading 722c7ca8a Use hash table for maintaing changed block set 98ae59d85 Custom table implementation for blockstate state lookups 8b8704fb6 Oprimise map impl for tracked players ea71d6ba4 Optimise snow & ice in chunk ticking 9871d4ce5 Remove chunk lookup & lambda allocation from counting mobs 5a4a35f3e Add patreon 7d93d9618 Refactor data management for region manager c3035219f Change license from MIT to LGPLv3 Airplane Changes: 580f380b6 Updated Upstream (Tuinity) 82253fd36 Early return optimization for target finding 9572643bb Cache entityhuman display name 5df98254f Remove iterators from inventory contains 18d2be193 Merge pull request #14 from violetwtf/patch-1 f716d4c33 Merge pull request #13 from violetwtf/master 128cbe519 Reduce entity chunk ticking checks from 3 to 1 03ac0933b Skip copying unloading tile entities 97dd027b5 Smaller pool size for tracking 9e9f57be4 Only set up Flare if token is available
148 lines
9.9 KiB
Diff
148 lines
9.9 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/server/BlockBase.java b/src/main/java/net/minecraft/server/BlockBase.java
|
|
index b40f5167d2a9772658c115091f13706fbb4959b7..657885cdaa086293f6b5aa6f3058acd16df0ba35 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockBase.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockBase.java
|
|
@@ -250,6 +250,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/minecraft/server/BlockEnderPortal.java b/src/main/java/net/minecraft/server/BlockEnderPortal.java
|
|
index e731b6d811d179f07f84278d2cce75e0d98092ab..f0e5c378c4612192c1d4c74aa81e598f9370b8b8 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockEnderPortal.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockEnderPortal.java
|
|
@@ -25,7 +25,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/server/BlockPortal.java b/src/main/java/net/minecraft/server/BlockPortal.java
|
|
index bd78d55ee94f1359739a9d790092d07c613eac0f..a574ef929ac60584ff6e1b2c76722456cc3895ff 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockPortal.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockPortal.java
|
|
@@ -60,7 +60,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/server/TileEntityEndGateway.java b/src/main/java/net/minecraft/server/TileEntityEndGateway.java
|
|
index e616b3759561e0d6e471f914f3dc843fe7464f2e..4a443827a316415c2c047ca468d965a80fce1fb1 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityEndGateway.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityEndGateway.java
|
|
@@ -126,9 +126,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/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index e1b2a39ea8847716c44d265a62492b5e6cbe262d..2391e1ddbe062dde5cb9a240b0a6a85ed793e569 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -1881,4 +1881,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 5471422d23d261a06c67f9374cae933430ec03a0..4c592f6d4d6cbeb4c3225e7794f4b1d6c8d62394 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -522,6 +522,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 7b5ffe92430121eebe2866ac33b37a840eed90f1..98f4407848347dfc46b70d1c1fe466dce10f54b7 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -117,6 +117,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;
|
|
@@ -874,6 +875,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;
|
|
}
|
|
|