diff --git a/patches/server/0005-Fix-gravity-block-duper.patch b/patches/server/0005-Fix-gravity-block-duper.patch new file mode 100644 index 00000000..f91808e3 --- /dev/null +++ b/patches/server/0005-Fix-gravity-block-duper.patch @@ -0,0 +1,150 @@ +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 895c8d8c676bfd3e11cd8371b2ac115b6a2e52b4..f87ecc86046d8cc410a271c29651c56a68c2daec 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -361,36 +361,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n + } + // 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 resourcekey = world.getTypeKey() == DimensionType.END_LOCATION ? 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(); +@@ -2542,7 +2513,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n + } + + 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 8336ea928faa92c6f58f8cdfb9faf1d8e26c9ccf..31744a9c550c9fa36d456235701d5dad121e1ffa 100644 +--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java ++++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +@@ -1,7 +1,5 @@ + package net.minecraft.world.entity.item; + +-import java.util.Iterator; +-import java.util.function.Predicate; + import net.minecraft.CrashReportCategory; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; +@@ -43,7 +41,10 @@ import net.minecraft.world.level.material.Fluids; + import net.minecraft.world.phys.BlockHitResult; + import net.minecraft.world.phys.HitResult; + import net.minecraft.world.phys.Vec3; +-import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++ ++import java.util.Iterator; ++import java.util.function.Predicate; + + public class FallingBlockEntity extends Entity { + +@@ -106,11 +107,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 { +@@ -143,11 +140,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.fallingBlockHeightNerf != 0 && this.getY() > this.level.paperConfig.fallingBlockHeightNerf) { +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 62c2f947a77570228dfdf4dae16c64eb97ee2f40..9b84c84e2427bc5584fd0ddb94321776d6831957 100644 +--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java +@@ -1,6 +1,5 @@ + package net.minecraft.world.level.block; + +-import java.util.Random; + import net.minecraft.core.BlockPos; + import net.minecraft.core.particles.ParticleTypes; + import net.minecraft.resources.ResourceKey; +@@ -22,6 +21,8 @@ import net.minecraft.world.phys.shapes.Shapes; + import net.minecraft.world.phys.shapes.VoxelShape; + import org.bukkit.event.entity.EntityPortalEnterEvent; + import org.bukkit.event.player.PlayerTeleportEvent; ++ ++import java.util.Random; + // CraftBukkit end + + public class EndPortalBlock extends BaseEntityBlock { +@@ -53,10 +54,18 @@ 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 + } + + }