9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00
Files
LeavesMC/patches/server/0005-Fix-gravity-block-duper.patch
2022-12-10 10:48:39 +08:00

126 lines
6.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <58360096+s-yh-china@users.noreply.github.com>
Date: Sat, 30 Oct 2021 21:07:43 +0800
Subject: [PATCH] Fix gravity block duper
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 7f94da8059147760cbdc2476d0e8beda4a105f40..9b3dda86d8094fa221f3cf88ef99b88b0edd105e 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -510,36 +510,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return chunkMap.playerEntityTrackerTrackMaps[type.ordinal()].getObjectsInRange(MCUtil.getCoordinateKey(this));
}
// Paper end - optimise entity tracking
- // Paper start - make end portalling safe
- public BlockPos portalBlock;
- public ServerLevel portalWorld;
- public void tickEndPortal() {
- BlockPos pos = this.portalBlock;
- ServerLevel world = this.portalWorld;
- this.portalBlock = null;
- this.portalWorld = null;
-
- if (pos == null || world == null || world != this.level) {
- return;
- }
-
- if (this.isPassenger() || this.isVehicle() || !this.canChangeDimensions() || this.isRemoved() || !this.valid || !this.isAlive()) {
- return;
- }
- ResourceKey<Level> resourcekey = world.getTypeKey() == LevelStem.END ? Level.OVERWORLD : Level.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends
- ServerLevel worldserver = world.getServer().getLevel(resourcekey);
-
- org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(this.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
- event.callEvent();
-
- if (this instanceof ServerPlayer) {
- ((ServerPlayer)this).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL);
- return;
- }
- this.teleportTo(worldserver, null);
- }
- // Paper end - make end portalling safe
+ // Leaves - fix gravity block duper
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -2917,7 +2889,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
this.processPortalCooldown();
- this.tickEndPortal(); // Paper - make end portalling safe
+ // Leaves - fix gravity block duper
}
}
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 72f1866226269396ba0f0c1be269e237925d9322..f7585c4cbe9b22b6ddfe928763314e1f7af711c4 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -63,7 +63,7 @@ public class FallingBlockEntity extends Entity {
@Nullable
public CompoundTag blockData;
protected static final EntityDataAccessor<BlockPos> DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS);
- public boolean autoExpire = true; // Paper - Auto expire setting
+ public boolean autoExpire = false; // Paper - Auto expire setting -> Leaves - close it
public FallingBlockEntity(EntityType<? extends FallingBlockEntity> type, Level world) {
super(type, world);
@@ -129,11 +129,7 @@ public class FallingBlockEntity extends Entity {
@Override
public void tick() {
- // Paper start - fix sand duping
- if (this.isRemoved()) {
- return;
- }
- // Paper end - fix sand duping
+ // Leaves - fix gravity block duper
if (this.blockState.isAir()) {
this.discard();
} else {
@@ -146,11 +142,7 @@ public class FallingBlockEntity extends Entity {
this.move(MoverType.SELF, this.getDeltaMovement());
- // Paper start - fix sand duping
- if (this.isRemoved()) {
- return;
- }
- // Paper end - fix sand duping
+ // Leaves - fix gravity block duper
// Paper start - Configurable EntityFallingBlock height nerf
if (this.level.paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) {
diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
index 15c5cccfe02c924c02f605eb47dd0b420b189891..d3b286e145c7eda30f3e2419d20feee107a4f42f 100644
--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
@@ -53,12 +53,19 @@ public class EndPortalBlock extends BaseEntityBlock {
// return; // CraftBukkit - always fire event in case plugins wish to change it
}
- // Paper start - move all of this logic into portal tick
- entity.portalWorld = ((ServerLevel)world);
- entity.portalBlock = pos.immutable();
- // Paper end - move all of this logic into portal tick
- }
+ // Leaves start - fix gravity block duper
+ // CraftBukkit start - Entity in portal
+ EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
+ world.getCraftServer().getPluginManager().callEvent(event);
+ if (entity instanceof ServerPlayer) {
+ ((ServerPlayer) entity).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL);
+ return;
+ }
+ // CraftBukkit end
+ entity.changeDimension(worldserver);
+ // Leaves end - fix gravity block duper
+ }
}
@Override