mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-27 18:59:06 +00:00
Add entity travel distance limits
Configuration example chunk-travel-limit: ender_pearl: 6 arrow: 6 falling_block: 60 tnt: 60
This commit is contained in:
@@ -634,10 +634,10 @@ index 0000000000000000000000000000000000000000..74d4e257440842d40bfd72ff0741f1d7
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..9bbd239ee24fb0d31d216287af480a70b93ca192
|
||||
index 0000000000000000000000000000000000000000..1ec5190fe6755e5be10aa30f98bcfd6f1d8ce84b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
|
||||
@@ -0,0 +1,171 @@
|
||||
@@ -0,0 +1,177 @@
|
||||
+package me.samsuik.sakura.configuration;
|
||||
+
|
||||
+import com.mojang.logging.LogUtils;
|
||||
@@ -652,6 +652,7 @@ index 0000000000000000000000000000000000000000..9bbd239ee24fb0d31d216287af480a70
|
||||
+import me.samsuik.sakura.physics.PhysicsVersion;
|
||||
+import net.minecraft.Util;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.world.entity.EntityType;
|
||||
+import net.minecraft.world.entity.item.FallingBlockEntity;
|
||||
+import net.minecraft.world.item.Item;
|
||||
+import net.minecraft.world.level.block.Block;
|
||||
@@ -795,6 +796,11 @@ index 0000000000000000000000000000000000000000..9bbd239ee24fb0d31d216287af480a70
|
||||
+ public class Items extends ConfigurationPart {
|
||||
+ public List<Item> explosionResistantItems = List.of();
|
||||
+ }
|
||||
+
|
||||
+ @Comment("Entity travel distance limits")
|
||||
+ public Map<EntityType<?>, Integer> chunkTravelLimit = Util.make(new Reference2ObjectOpenHashMap<>(), map -> {
|
||||
+ map.put(EntityType.ENDER_PEARL, 8);
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ public Environment environment;
|
||||
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Falling Block Stacking Restrictions
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
|
||||
index 9bbd239ee24fb0d31d216287af480a70b93ca192..348ab32d0b0fb8c7ecda36028c0be73b670cbbce 100644
|
||||
index 1ec5190fe6755e5be10aa30f98bcfd6f1d8ce84b..bc9360ff3e50d5199cf31c331690272050001b88 100644
|
||||
--- a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
|
||||
+++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
|
||||
@@ -69,7 +69,7 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||
@@ -70,7 +70,7 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||
public boolean preventAtWorldHeight = false;
|
||||
|
||||
public boolean isFallingBlockInBounds(FallingBlockEntity entity) {
|
||||
|
||||
54
patches/server/0062-Add-entity-travel-distance-limits.patch
Normal file
54
patches/server/0062-Add-entity-travel-distance-limits.patch
Normal file
@@ -0,0 +1,54 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samsuik <kfian294ma4@gmail.com>
|
||||
Date: Tue, 20 Feb 2024 19:16:16 +0000
|
||||
Subject: [PATCH] Add entity travel distance limits
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 1db051b952cb893d9aa1bfef4dd6439f11285ec2..ee8bae340448eaa0753833b222de96ccff205939 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1417,6 +1417,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
if (isActive) { // Paper - EAR 2
|
||||
TimingHistory.activatedEntityTicks++;
|
||||
entity.tick();
|
||||
+ // Sakura start - entity travel distance limits
|
||||
+ if (entity.isPastTravelDistanceLimit()) {
|
||||
+ entity.discard();
|
||||
+ }
|
||||
+ // Sakura end - entity travel distance limits
|
||||
entity.postTick(); // CraftBukkit
|
||||
} else { entity.inactiveTick(); } // Paper - EAR 2
|
||||
this.getProfiler().pop();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index af422f8e5d89c4ac10ea91265fd84cf65cbf28cb..8baa9da071a55f691031668b3f5baf42bc923c98 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -729,6 +729,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
return this.physics;
|
||||
}
|
||||
// Sakura end - physics version api
|
||||
+ // Sakura start - entity travel distance limits
|
||||
+ private final double travelDistanceLimit;
|
||||
+
|
||||
+ public final boolean isPastTravelDistanceLimit() {
|
||||
+ if (origin == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ double x = Math.pow(origin.getX() - position.x(), 2);
|
||||
+ double z = Math.pow(origin.getZ() - position.z(), 2);
|
||||
+ return Math.max(x, z) >= travelDistanceLimit;
|
||||
+ }
|
||||
+ // Sakura end - entity travel distance limits
|
||||
|
||||
public Entity(EntityType<?> type, Level world) {
|
||||
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
||||
@@ -778,6 +791,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
this.setPos(0.0D, 0.0D, 0.0D);
|
||||
this.eyeHeight = this.getEyeHeight(net.minecraft.world.entity.Pose.STANDING, this.dimensions);
|
||||
this.mergeLevel = level.sakuraConfig().cannons.mergeLevel; // Sakura
|
||||
+ this.travelDistanceLimit = Math.pow(level.sakuraConfig().entity.chunkTravelLimit.getOrDefault(type, Integer.MAX_VALUE) * 16.0, 2); // Sakura - entity travel distance limits
|
||||
}
|
||||
|
||||
public boolean isColliding(BlockPos pos, BlockState state) {
|
||||
Reference in New Issue
Block a user