mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-21 07:49:29 +00:00
Add local storage and config api
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
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);
|
||||
Reference in New Issue
Block a user