mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-22 16:29:16 +00:00
Drop useless reduce movement allocations patch
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samsuik <kfian294ma4@gmail.com>
|
||||
Date: Wed, 22 May 2024 23:40:02 +0100
|
||||
Subject: [PATCH] Protect block shapes against plugins
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/CarpetBlock.java b/src/main/java/net/minecraft/world/level/block/CarpetBlock.java
|
||||
index 0cc3df1f8a7784af812a1519e0a508b67314ce9a..ab606a3ba037223898f1d947083aeeed13afdc4c 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/CarpetBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/CarpetBlock.java
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
public class CarpetBlock extends Block {
|
||||
public static final MapCodec<CarpetBlock> CODEC = simpleCodec(CarpetBlock::new);
|
||||
protected static final VoxelShape SHAPE = Block.box(0.0, 0.0, 0.0, 16.0, 1.0, 16.0);
|
||||
+ private static final VoxelShape SHAPE_COPY = SHAPE.copy(); // Sakura - protect block shapes against plugins
|
||||
|
||||
@Override
|
||||
public MapCodec<? extends CarpetBlock> codec() {
|
||||
@@ -26,7 +27,7 @@ public class CarpetBlock extends Block {
|
||||
|
||||
@Override
|
||||
protected VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
|
||||
- return SHAPE;
|
||||
+ return SHAPE_COPY; // Sakura - protect block shapes against plugins
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/LadderBlock.java b/src/main/java/net/minecraft/world/level/block/LadderBlock.java
|
||||
index 54781ea0771327f93a7cf672bb4b2945700c47e5..b03783b02176aad08123acf1fba2cf39daa5a0f2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/LadderBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/LadderBlock.java
|
||||
@@ -28,6 +28,12 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
|
||||
protected static final VoxelShape WEST_AABB = Block.box(13.0, 0.0, 0.0, 16.0, 16.0, 16.0);
|
||||
protected static final VoxelShape SOUTH_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 16.0, 3.0);
|
||||
protected static final VoxelShape NORTH_AABB = Block.box(0.0, 0.0, 13.0, 16.0, 16.0, 16.0);
|
||||
+ // Sakura start - protect block shapes against plugins
|
||||
+ private static final VoxelShape EAST_AABB_COPY = EAST_AABB.copy();
|
||||
+ private static final VoxelShape WEST_AABB_COPY = WEST_AABB.copy();
|
||||
+ private static final VoxelShape SOUTH_AABB_COPY = SOUTH_AABB.copy();
|
||||
+ private static final VoxelShape NORTH_AABB_COPY = NORTH_AABB.copy();
|
||||
+ // Sakura end - protect block shapes against plugins
|
||||
// Sakura start - physics version api
|
||||
protected static final VoxelShape LEGACY_EAST_AABB = Block.box(0.0, 0.0, 0.0, 2.0, 16.0, 16.0);
|
||||
protected static final VoxelShape LEGACY_WEST_AABB = Block.box(14.0, 0.0, 0.0, 16.0, 16.0, 16.0);
|
||||
@@ -68,14 +74,16 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
|
||||
// Sakura end - physics version api
|
||||
switch ((Direction)state.getValue(FACING)) {
|
||||
case NORTH:
|
||||
- return NORTH_AABB;
|
||||
+ // Sakura start - protect block shapes against plugins
|
||||
+ return NORTH_AABB_COPY;
|
||||
case SOUTH:
|
||||
- return SOUTH_AABB;
|
||||
+ return SOUTH_AABB_COPY;
|
||||
case WEST:
|
||||
- return WEST_AABB;
|
||||
+ return WEST_AABB_COPY;
|
||||
case EAST:
|
||||
default:
|
||||
- return EAST_AABB;
|
||||
+ return EAST_AABB_COPY;
|
||||
+ // Sakura end - protect block shapes against plugins
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java
|
||||
index 11824d39e72fa003b3a56aa9b8d679fe8e23a1a4..132dd7028384126cef5d1d404adee4fbdec4c31b 100644
|
||||
--- a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java
|
||||
+++ b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java
|
||||
@@ -539,6 +539,13 @@ public abstract class VoxelShape implements ca.spottedleaf.moonrise.patches.coll
|
||||
return this.isEmpty; // Paper - optimise collisions
|
||||
}
|
||||
|
||||
+ // Sakura start - protect block shapes against plugins
|
||||
+ public final VoxelShape copy() {
|
||||
+ this.cachedToAABBs = null;
|
||||
+ return this.move(0.0, 0.0, 0.0);
|
||||
+ }
|
||||
+ // Sakura end - protect block shapes against plugins
|
||||
+
|
||||
public VoxelShape move(double x, double y, double z) {
|
||||
// Paper start - optimise collisions
|
||||
if (this.isEmpty) {
|
||||
Reference in New Issue
Block a user