mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-23 00:39:22 +00:00
117 lines
8.0 KiB
Diff
117 lines
8.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Sat, 24 Dec 2022 23:30:35 +0100
|
|
Subject: [PATCH] Make max interaction distance configurable
|
|
|
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
index 58f972832c39a27a8ccd606f9144e1c54adbf6f3..c0b368b8137ca6d90c4e6ec931e07b7ea69f8d9b 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
@@ -174,7 +174,7 @@ public class ServerPlayerGameMode {
|
|
private void debugLogging(BlockPos pos, boolean success, int sequence, String reason) {}
|
|
|
|
public void handleBlockBreakAction(BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight, int sequence) {
|
|
- if (this.player.getEyePosition().distanceToSqr(Vec3.atCenterOf(pos)) > ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) {
|
|
+ if (this.player.getEyePosition().distanceToSqr(Vec3.atCenterOf(pos)) > ServerGamePacketListenerImpl.getMaxInteractionDistanceSquared(this.player.level())) { // Gale - make max interaction distance configurable
|
|
if (true) return; // Paper - Don't notify if unreasonably far away
|
|
this.debugLogging(pos, false, sequence, "too far");
|
|
} else if (pos.getY() >= worldHeight) {
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 347b1d225d2e7084d13ea9a633f50e08bf8e58b4..7b955100e39a935259887475278b24cf29905577 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -251,7 +251,7 @@ import org.bukkit.inventory.SmithingInventory;
|
|
public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener {
|
|
|
|
static final Logger LOGGER = LogUtils.getLogger();
|
|
- public static final double MAX_INTERACTION_DISTANCE = Mth.square(6.0D);
|
|
+ public static final double DEFAULT_MAX_INTERACTION_DISTANCE_SQUARED = Mth.square(6.0D); // Gale - make max interaction distance configurable
|
|
private static final int NO_BLOCK_UPDATES_TO_ACK = -1;
|
|
private static final int TRACKED_MESSAGE_DISCONNECT_THRESHOLD = 4096;
|
|
private static final Component CHAT_VALIDATION_FAILED = Component.translatable("multiplayer.disconnect.chat_validation_failed");
|
|
@@ -330,6 +330,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
private boolean hasMoved; // Spigot
|
|
// CraftBukkit end
|
|
|
|
+ // Gale start - make max interaction distance configurable
|
|
+ public static double getMaxInteractionDistanceSquared(Level level) {
|
|
+ var config = level.galeConfig().gameplayMechanics;
|
|
+ return config.playerMaxInteractionDistance < 0 ? ServerGamePacketListenerImpl.DEFAULT_MAX_INTERACTION_DISTANCE_SQUARED : config.playerMaxInteractionDistanceSquared;
|
|
+ }
|
|
+ // Gale end - make max interaction distance configurable
|
|
+
|
|
@Override
|
|
public void tick() {
|
|
if (this.ackBlockChangesUpTo > -1) {
|
|
@@ -1928,7 +1935,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
|
|
Vec3 vec3d1 = Vec3.atCenterOf(blockposition);
|
|
|
|
- if (this.player.getEyePosition().distanceToSqr(vec3d1) <= ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) {
|
|
+ if (this.player.getEyePosition().distanceToSqr(vec3d1) <= ServerGamePacketListenerImpl.getMaxInteractionDistanceSquared(this.player.level())) { // Gale - make max interaction distance configurable
|
|
Vec3 vec3d2 = vec3d.subtract(vec3d1);
|
|
double d0 = 1.0000001D;
|
|
|
|
@@ -2713,7 +2720,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
|
|
AABB axisalignedbb = entity.getBoundingBox();
|
|
|
|
- if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) {
|
|
+ if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < ServerGamePacketListenerImpl.getMaxInteractionDistanceSquared(this.player.level())) { // Gale - make max interaction distance configurable
|
|
packet.dispatch(new ServerboundInteractPacket.Handler() {
|
|
private void performInteraction(InteractionHand enumhand, ServerGamePacketListenerImpl.EntityInteraction playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit
|
|
ItemStack itemstack = ServerGamePacketListenerImpl.this.player.getItemInHand(enumhand);
|
|
diff --git a/src/main/java/net/minecraft/world/item/BrushItem.java b/src/main/java/net/minecraft/world/item/BrushItem.java
|
|
index f46c16dd6ff9cd09ea579eecf99ce78c7eb39d49..430b8a2bb1639eeb7338e0f7b1030248d66ef31e 100644
|
|
--- a/src/main/java/net/minecraft/world/item/BrushItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/BrushItem.java
|
|
@@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.core.particles.BlockParticleOption;
|
|
import net.minecraft.core.particles.ParticleTypes;
|
|
+import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
|
import net.minecraft.sounds.SoundEvent;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.sounds.SoundSource;
|
|
@@ -110,7 +111,7 @@ public class BrushItem extends Item {
|
|
private HitResult calculateHitResult(Player user) {
|
|
return ProjectileUtil.getHitResultOnViewVector(user, (entity) -> {
|
|
return !entity.isSpectator() && entity.isPickable();
|
|
- }, (double)Player.getPickRange(user.isCreative()));
|
|
+ }, Math.sqrt(ServerGamePacketListenerImpl.getMaxInteractionDistanceSquared(user.level())) - 1.0D); // Gale - make max interaction distance configurable
|
|
}
|
|
|
|
private void spawnDustParticles(Level world, BlockHitResult hitResult, BlockState state, Vec3 userRotation, HumanoidArm arm) {
|
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
|
index 492a279f080432b2340007be159d9bcba02f174b..68373c02373d9452613710915beb0d5951c2b531 100644
|
|
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
|
@@ -9,6 +9,7 @@ import io.papermc.paper.configuration.PaperConfigurations;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import org.slf4j.Logger;
|
|
import org.spigotmc.SpigotWorldConfig;
|
|
+import org.spongepowered.configurate.objectmapping.meta.PostProcess;
|
|
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
|
|
|
@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"})
|
|
@@ -132,6 +133,16 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
|
public boolean hideFlamesOnEntitiesWithFireResistance = false; // Gale - Slice - hide flames on entities with fire resistance
|
|
public boolean tryRespawnEnderDragonAfterEndCrystalPlace = true; // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable
|
|
|
|
+ // Gale start - make max interaction distance configurable
|
|
+ public double playerMaxInteractionDistance = -1.0;
|
|
+ public transient double playerMaxInteractionDistanceSquared;
|
|
+ // Gale end - make max interaction distance configurable
|
|
+
|
|
+ @PostProcess
|
|
+ public void postProcess() {
|
|
+ this.playerMaxInteractionDistanceSquared = this.playerMaxInteractionDistance * this.playerMaxInteractionDistance; // Gale - make max interaction distance configurable
|
|
+ }
|
|
+
|
|
}
|
|
|
|
}
|