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:
@@ -613,10 +613,10 @@ index 0000000000000000000000000000000000000000..03b5e3243831b64b30c431134681ad37
|
||||
+}
|
||||
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..46599109e55da0e4ce91c9b0c137d286a8cca78c
|
||||
index 0000000000000000000000000000000000000000..3d58183f9f3748cfb35a9c70ad434b29064783f2
|
||||
--- /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;
|
||||
@@ -631,6 +631,7 @@ index 0000000000000000000000000000000000000000..46599109e55da0e4ce91c9b0c137d286
|
||||
+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;
|
||||
@@ -774,6 +775,11 @@ index 0000000000000000000000000000000000000000..46599109e55da0e4ce91c9b0c137d286
|
||||
+ 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 46599109e55da0e4ce91c9b0c137d286a8cca78c..2aa7dbad27dfd5dc37b36a1f05e4d3e2f9d36339 100644
|
||||
index 3d58183f9f3748cfb35a9c70ad434b29064783f2..eee7932c4adf769a01a65a8fc8bae41badfe573f 100644
|
||||
--- a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
|
||||
+++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
|
||||
@@ -69,8 +69,8 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||
@@ -70,8 +70,8 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||
public boolean preventAtWorldHeight = false;
|
||||
|
||||
public boolean isFallingBlockInBounds(FallingBlockEntity entity) {
|
||||
|
||||
54
patches/server/0059-Add-entity-travel-distance-limits.patch
Normal file
54
patches/server/0059-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 c2452f6c47533c7d921c55c4997c1be6471fe942..4eb9b1164e3b01b1285f63a33853f27255635748 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1218,6 +1218,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 93928be15becb270368f10f57428cd4a2586265d..b94b1270299f6600e50dc5661491d4fb82a56905 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -698,6 +698,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
return false;
|
||||
}
|
||||
// Sakura end
|
||||
+ // 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();
|
||||
@@ -745,6 +758,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
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