mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-19 14:59:30 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@4eda045 Backport fix for MC-296337 (Fixes #12617) (#12619) PaperMC/Paper@7ebc94c Add Registry#getTagValues (#12603) PaperMC/Paper@e87320d Fix UOE when using generateTree with pale oak (#12616) PaperMC/Paper@94f2903 Do not blow up accessing unregistered memories from API (Fixes #12618) (#12639) PaperMC/Paper@03efecf Do not fire PlayerDropItemEvent for /give command PaperMC/Paper@3527ccd feat: expose updateDemand and restock on Villager (#12608) PaperMC/Paper@320f25c fix sponge-absorb deleting chest content (#12647) PaperMC/Paper@95565e0 Add missing attribute serialization updater PaperMC/Paper@519e422 Fix infinite loop in RegionFile IO PaperMC/Paper@ba7fb23 Finish moving over to Holderable (#12646) PaperMC/Paper@39203a6 [ci skip] Publish PR API and dev bundles (#12672) PaperMC/Paper@a1b3058 Provide env environment variable and copy spigots sys prop for overriding default repository
90 lines
4.9 KiB
Diff
90 lines
4.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Fri, 9 Aug 2024 20:43:53 +0100
|
|
Subject: [PATCH] Configurable left shooting and adjusting limits
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index ffe5ad8f3936386fd1fa2b961837fbea5c230407..6eaef984b71881bc04f835d4773f18b754e2fcd4 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -598,6 +598,46 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return Math.max(x, z) >= this.travelDistanceLimit;
|
|
}
|
|
// Sakura end - entity travel distance limits
|
|
+ // Sakura start - configurable left shooting and adjusting limits
|
|
+ protected final void limitLeftShooting() {
|
|
+ Vec3 movement = this.getDeltaMovement();
|
|
+ int threshold = this.level.sakuraConfig().cannons.restrictions.leftShootingThreshold.or(-1);
|
|
+ if (threshold > 0 && (movement.x != 0.0 || movement.z != 0.0) && this.origin != null) {
|
|
+ double travelledX = Math.abs(this.getX() - this.origin.x());
|
|
+ double travelledZ = Math.abs(this.getZ() - this.origin.z());
|
|
+ boolean xSmaller = travelledX < travelledZ; // intended
|
|
+
|
|
+ // Once entities have travelled past the threshold changing direction is restricted.
|
|
+ if (xSmaller && travelledX > threshold) {
|
|
+ this.setDeltaMovement(movement.multiply(1.0, 1.0, 0.0)); // limit z
|
|
+ } else if (!xSmaller && travelledZ > threshold) {
|
|
+ this.setDeltaMovement(movement.multiply(0.0, 1.0, 1.0)); // limit x
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private void limitAdjustMovement(AABB currBoundingBox, double dir, boolean xAdjust, List<VoxelShape> shapes) {
|
|
+ int adjustDistance = this.level.sakuraConfig().cannons.restrictions.maxAdjustDistance.or(-1);
|
|
+ if (adjustDistance > 0 && Math.abs(dir) > adjustDistance) {
|
|
+ double minX = Double.NEGATIVE_INFINITY;
|
|
+ double minZ = Double.NEGATIVE_INFINITY;
|
|
+ double maxX = Double.POSITIVE_INFINITY;
|
|
+ double maxZ = Double.POSITIVE_INFINITY;
|
|
+ if (xAdjust) { // limit x adjust
|
|
+ minX = Math.floor(currBoundingBox.minX) - adjustDistance;
|
|
+ maxX = Math.floor(currBoundingBox.maxX) + adjustDistance + 1;
|
|
+ } else { // limit z adjust
|
|
+ minZ = Math.floor(currBoundingBox.minZ) - adjustDistance;
|
|
+ maxZ = Math.floor(currBoundingBox.maxZ) + adjustDistance + 1;
|
|
+ }
|
|
+ VoxelShape safeSpace = Shapes.box(
|
|
+ minX, Double.NEGATIVE_INFINITY, minZ,
|
|
+ maxX, Double.POSITIVE_INFINITY, maxZ
|
|
+ );
|
|
+ shapes.add(Shapes.join(Shapes.INFINITY, safeSpace, BooleanOp.ONLY_FIRST));
|
|
+ }
|
|
+ }
|
|
+ // Sakura end - configurable left shooting and adjusting limits
|
|
|
|
public Entity(EntityType<?> entityType, Level level) {
|
|
this.type = entityType;
|
|
@@ -1600,6 +1640,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
|
|
if (xSmaller && z != 0.0) {
|
|
+ this.limitAdjustMovement(currBoundingBox, z, false, voxelList); // Sakura - configurable left shooting and adjusting limits
|
|
z = this.scanZ(currBoundingBox, z, voxelList, bbList);
|
|
if (z != 0.0) {
|
|
currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetZ(currBoundingBox, z);
|
|
@@ -1607,6 +1648,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
|
|
if (x != 0.0) {
|
|
+ // Sakura start - configurable left shooting and adjusting limits
|
|
+ if (!xSmaller) {
|
|
+ this.limitAdjustMovement(currBoundingBox, x, true, voxelList);
|
|
+ }
|
|
+ // Sakura end - configurable left shooting and adjusting limits
|
|
x = this.scanX(currBoundingBox, x, voxelList, bbList);
|
|
if (x != 0.0) {
|
|
currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetX(currBoundingBox, x);
|
|
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
index 16c22f243fcb6b5ae1b43ea112251a9b731f91c8..cc57c4ea0ea4a39933ec6fe44c5d44bde3bc6dfb 100644
|
|
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
@@ -285,6 +285,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
|
|
// Sakura end - configure cannon physics
|
|
this.time++;
|
|
this.applyGravity();
|
|
+ this.limitLeftShooting(); // Sakura - configurable left shooting and adjusting limits
|
|
this.move(MoverType.SELF, this.getDeltaMovement());
|
|
this.applyEffectsFromBlocks();
|
|
// Paper start - Configurable falling blocks height nerf
|