From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrHua269 Date: Sat, 2 May 2026 23:06:28 +0800 Subject: [PATCH] Leaves Utilities This is a part of Leaves(https://github.com/LeavesMC/Leaves/blob/2f7f7165765b6373a101bc5e2f04a4573d79185a/leaves-server/minecraft-patches/features/0003-Leaves-Utils.patch) Original License: https://github.com/LeavesMC/Leaves/blob/2f7f7165765b6373a101bc5e2f04a4573d79185a/LICENSE.md diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java index 0e543348e48fdf2131dfa1460e37db238d02988c..60a8c2edc34030a5269313750817515664117df8 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -389,6 +389,8 @@ public abstract class Entity public long activatedImmunityTick = Integer.MIN_VALUE; public int teleportTickType = 0;// Luminol - Entity portal-teleport speed fix + private net.minecraft.nbt.CompoundTag leavesData = new net.minecraft.nbt.CompoundTag(); // Leaves - Leaves ex data + public void inactiveTick() { } // Paper end - EAR 2 @@ -2723,6 +2725,7 @@ public abstract class Entity output.putBoolean("Paper.FreezeLock", true); } // Paper end + output.store("Leaves.Data", net.minecraft.nbt.CompoundTag.CODEC, leavesData); // Leaves - leaves ex data } catch (Throwable var7) { CrashReport report = CrashReport.forThrowable(var7, "Saving entity NBT"); CrashReportCategory category = report.addCategory("Entity being saved"); @@ -2845,6 +2848,7 @@ public abstract class Entity } freezeLocked = input.getBooleanOr("Paper.FreezeLock", false); // Paper end + leavesData = input.read("Leaves.Data", net.minecraft.nbt.CompoundTag.CODEC).orElse(new net.minecraft.nbt.CompoundTag()); } catch (Throwable var7) { CrashReport report = CrashReport.forThrowable(var7, "Loading entity NBT"); CrashReportCategory category = report.addCategory("Entity being loaded"); @@ -6410,6 +6414,11 @@ public abstract class Entity return ((ServerLevel) this.level()).isPositionEntityTicking(this.blockPosition()); } // Paper end - Expose entity id counter + // Leaves start - leaves ex data + public net.minecraft.nbt.CompoundTag getLeavesData() { + return leavesData; + } + // Leaves end - leaves ex data public boolean shouldTickHot() { return this.tickCount > 20 * 10 && this.isAlive(); } // KioCG } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java index e06e48dd9c997ac1dc6e404aa0bc590c851e1ba8..67763966f751087ac5136c3d4288dc5c5b3d38f6 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -999,7 +999,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } // Paper start - if loaded - @Nullable + @org.jetbrains.annotations.NotNull // Leaves - notnull @Override public final ChunkAccess getChunkIfLoadedImmediately(int x, int z) { return ((ServerLevel)this).chunkSource.getChunkAtIfLoadedImmediately(x, z); diff --git a/net/minecraft/world/level/LevelAccessor.java b/net/minecraft/world/level/LevelAccessor.java index 58dcd774b00f171a94faf7581b79675ebc43030b..232720a391819d0ce51f77a5e57de0a5a2ac05ef 100644 --- a/net/minecraft/world/level/LevelAccessor.java +++ b/net/minecraft/world/level/LevelAccessor.java @@ -48,7 +48,7 @@ public interface LevelAccessor extends CommonLevelAccessor, ScheduledTickAccess return this.getLevelData().getGameTime(); } - @Nullable MinecraftServer getServer(); + @org.jetbrains.annotations.NotNull MinecraftServer getServer(); // Leaves - notnull default Difficulty getDifficulty() { return this.getLevelData().getDifficulty(); diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java index 0cdd88e530c660b65f3eb331b37cbd2c69fc2ff5..194f79d346bb671029eb20ad43bdb962be7d9e5f 100644 --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java @@ -712,4 +712,12 @@ public class Block extends BlockBehaviour implements ItemLike { @org.intellij.lang.annotations.MagicConstant(flags = {UPDATE_NEIGHBORS, UPDATE_CLIENTS, UPDATE_INVISIBLE, UPDATE_IMMEDIATE, UPDATE_KNOWN_SHAPE, UPDATE_SUPPRESS_DROPS, UPDATE_MOVE_BY_PISTON, UPDATE_SKIP_SHAPE_UPDATE_ON_WIRE, UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS, UPDATE_SKIP_ON_PLACE}) // Paper - add back source-retention annotation for IDE public @interface UpdateFlags { } + + // Leaves start - reset push reaction + @org.jetbrains.annotations.Nullable + public net.minecraft.world.level.material.PushReaction getResetPushReaction() { + return null; + } + // Leaves end - reset push reaction + } diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java index 0fbdf810c785c8a596d461e7651361fdedbb6217..6c20082a094bd98a7a0cd9aca2f9bc0ede065fb5 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java @@ -782,7 +782,7 @@ public abstract class BlockBehaviour implements FeatureElement, org.leavesmc.lea } public PushReaction getPistonPushReaction() { - return !this.isDestroyable() ? PushReaction.BLOCK : this.pushReaction; // Paper - Protect Bedrock and End Portal/Frames from being destroyed + return !this.isDestroyable() ? PushReaction.BLOCK : this.getBlock().getResetPushReaction() == null ? this.pushReaction : this.getBlock().getResetPushReaction(); // Paper - Protect Bedrock and End Portal/Frames from being destroyed // Leaves - reset push reaction } public boolean isSolidRender() {