9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00
Files
LeavesMC/leaves-server/minecraft-patches/features/0003-Leaves-Utils.patch
MC_XiaoHei 90080d238e 1.21.10 (#752)
---------

Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com>
Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com>
2025-11-28 03:15:54 +08:00

112 lines
5.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
Date: Tue, 22 Apr 2025 23:32:41 +0800
Subject: [PATCH] Leaves Utils
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 2e3e038874757049445a91bf590d5a1a427a3f6d..9b122a3dc18c6dbc84683ab54e5a503d0a5b7e4b 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -373,6 +373,8 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
public boolean isTemporarilyActive;
public long activatedImmunityTick = Integer.MIN_VALUE;
+ private net.minecraft.nbt.CompoundTag leavesData = new net.minecraft.nbt.CompoundTag(); // Leaves - Leaves ex data
+
public void inactiveTick() {
}
// Paper end - EAR 2
@@ -2634,6 +2636,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
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 crashReport = CrashReport.forThrowable(var7, "Saving entity NBT");
CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being saved");
@@ -2754,6 +2757,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
}
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 crashReport = CrashReport.forThrowable(var7, "Loading entity NBT");
CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being loaded");
@@ -4512,7 +4516,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
return this.getType().is(EntityTypeTags.DEFLECTS_PROJECTILES) ? ProjectileDeflection.REVERSE : ProjectileDeflection.NONE;
}
- @Nullable
+ @org.jetbrains.annotations.NotNull // Leaves - notnull
public net.minecraft.world.entity.LivingEntity getControllingPassenger() {
return null;
}
@@ -5402,4 +5406,9 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
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
}
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index d225267b1b07854b76c88ce461d7817a86d023a0..01e0dc28ef63456a45b800e72d76180b40811a72 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -916,7 +916,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
return this.isClientSide;
}
- @Nullable
+ @org.jetbrains.annotations.NotNull // Leaves - notnull
@Override
public MinecraftServer getServer() {
return null;
diff --git a/net/minecraft/world/level/LevelAccessor.java b/net/minecraft/world/level/LevelAccessor.java
index e4a9e59661f5b51caf5b4fb12b0c90b14c1f9647..f5e9e395f04d5335d5d9a220f94962a72e38577d 100644
--- a/net/minecraft/world/level/LevelAccessor.java
+++ b/net/minecraft/world/level/LevelAccessor.java
@@ -46,7 +46,7 @@ public interface LevelAccessor extends CommonLevelAccessor, LevelTimeAccess, Sch
DifficultyInstance getCurrentDifficultyAt(BlockPos pos);
- @Nullable
+ @org.jetbrains.annotations.NotNull // Leaves - notnull
MinecraftServer getServer();
default Difficulty getDifficulty() {
diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java
index 572fcb33b14d16334e2ab92ddf8699f1ba975aff..c431d0c45e71e0c8b880784181c92967e40779bd 100644
--- a/net/minecraft/world/level/block/Block.java
+++ b/net/minecraft/world/level/block/Block.java
@@ -649,6 +649,13 @@ public class Block extends BlockBehaviour implements ItemLike {
}
// CraftBukkit end
+ // Leaves start - reset push reaction
+ @org.jetbrains.annotations.Nullable
+ public net.minecraft.world.level.material.PushReaction getResetPushReaction() {
+ return null;
+ }
+ // Leaves end - reset push reaction
+
record ShapePairKey(VoxelShape first, VoxelShape second) {
@Override
public boolean equals(Object other) {
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
index d31da50baeb7f47f0e1d81ee3c05023370df8cd3..a38618c28819405f0fb35aa686d1f3f0e94e5da2 100644
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -766,7 +766,7 @@ public abstract class BlockBehaviour implements FeatureElement {
}
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() {