9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-19 14:59:30 +00:00
Files
SakuraMC/patches/server/0024-Cache-MovingBlockEntity-collision-shape.patch
Samsuik 2570c66290 start fresh with commit history
dw, they're kept up on a private repository
2023-10-17 22:36:39 +01:00

42 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Mon, 16 Oct 2023 22:41:12 +0100
Subject: [PATCH] Cache MovingBlockEntity collision shape
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
index 1ef87580574919796dbba707f44a413ee5c5781b..a971bb30ef8620f016a5968a9da40187ee31a3ef 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
@@ -43,6 +43,11 @@ public class PistonMovingBlockEntity extends BlockEntity {
private float progressO;
private long lastTicked;
private int deathTicks;
+ // Sakura start
+ private VoxelShape collisionShape = Shapes.empty();
+ private Direction shapeDirection = null;
+ private float shapeProgress = Float.MIN_VALUE;
+ // Sakura end
public PistonMovingBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityType.PISTON, pos, state);
@@ -336,6 +341,18 @@ public class PistonMovingBlockEntity extends BlockEntity {
}
public VoxelShape getCollisionShape(BlockGetter world, BlockPos pos) {
+ // Sakura start
+ var direction = NOCLIP.get();
+ if (progress == shapeProgress && direction == shapeDirection) {
+ return collisionShape;
+ } else {
+ shapeProgress = progress;
+ shapeDirection = direction;
+ return collisionShape = createCollisionShape(world, pos);
+ }
+ }
+ private VoxelShape createCollisionShape(BlockGetter world, BlockPos pos) {
+ // Sakura end
VoxelShape voxelShape;
if (!this.extending && this.isSourcePiston && this.movedState.getBlock() instanceof PistonBaseBlock) {
voxelShape = this.movedState.setValue(PistonBaseBlock.EXTENDED, Boolean.valueOf(true)).getCollisionShape(world, pos);