This commit is contained in:
md_5 2013-06-20 19:37:15 +10:00
parent 715a18a7d9
commit 4e5ba04a5b
2 changed files with 92 additions and 148 deletions

View file

@ -1,4 +1,4 @@
From be31d26856f8eec9b73d506af26ae2de32a87c85 Mon Sep 17 00:00:00 2001
From 1ee15ef0c0ce6a8016991314892246011fded197 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 20 Feb 2013 11:58:47 -0500
Subject: [PATCH] Entity Tracking Ranges
@ -12,142 +12,92 @@ This has multiple benefits:
4) Less client lag - Not trying to render distant item frames and paintings and entities will reduce entity count on the client, which is major for shop/town worlds which may use tons of item frames.
diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java
index d7efe3e..f6f1ab0 100644
index d7efe3e..59586c2 100644
--- a/src/main/java/net/minecraft/server/EntityTracker.java
+++ b/src/main/java/net/minecraft/server/EntityTracker.java
@@ -90,6 +90,7 @@ public class EntityTracker {
public void addEntity(Entity entity, int i, int j, boolean flag) {
if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous entity track!"); // Spigot
+ i = org.bukkit.craftbukkit.Spigot.getEntityTrackingRange(entity, i); // Spigot
+ i = org.spigotmc.TrackingRange.getEntityTrackingRange(entity, i); // Spigot
if (i > this.d) {
i = this.d;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index ebf1a67..4439ebc 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -89,6 +89,12 @@ public class CraftWorld implements World {
public int miscEntityActivationRange = 16;
public int animalEntityActivationRange = 32;
public int monsterEntityActivationRange = 32;
+ // Tracking Ranges:
+ public int playerTrackingRange = 64;
+ public int miscTrackingRange = 32;
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 2824b17..86d6939 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -168,4 +168,19 @@ public class SpigotWorldConfig
miscActivationRange = getInt( "entity-activation-range.misc", miscActivationRange );
log( "Entity Activation Range: An " + animalActivationRange + " / Mo " + monsterActivationRange + " / Mi " + miscActivationRange );
}
+
+ public int playerTrackingRange = 48;
+ public int animalTrackingRange = 48;
+ public int monsterTrackingRange = 48;
+ public int miscTrackingRange = 32;
+ public int maxTrackingRange = 64;
// Spigot end
// Spigot start
@@ -128,6 +134,11 @@ public class CraftWorld implements World {
miscEntityActivationRange = configuration.getInt( "world-settings.default.entity-activation-range-misc" );
animalEntityActivationRange = configuration.getInt( "world-settings.default.entity-activation-range-animals" );
monsterEntityActivationRange = configuration.getInt( "world-settings.default.entity-activation-range-monsters" );
+ playerTrackingRange = configuration.getInt( "world-settings.default.entity-tracking-range-players" );
+ miscTrackingRange = configuration.getInt( "world-settings.default.entity-tracking-range-misc" );
+ animalTrackingRange = configuration.getInt( "world-settings.default.entity-tracking-range-animals" );
+ monsterTrackingRange = configuration.getInt( "world-settings.default.entity-tracking-range-monsters" );
+ maxTrackingRange = configuration.getInt( "world-settings.default.entity-tracking-range-max" );
// Override defaults with world specific, if they exist
info = configuration.getBoolean( "world-settings." + name + ".info", info );
@@ -147,10 +158,19 @@ public class CraftWorld implements World {
miscEntityActivationRange = configuration.getInt( "world-settings." + name + ".entity-activation-range-misc", miscEntityActivationRange );
animalEntityActivationRange = configuration.getInt( "world-settings." + name + ".entity-activation-range-animals", animalEntityActivationRange );
monsterEntityActivationRange = configuration.getInt( "world-settings." + name + ".entity-activation-range-monsters", monsterEntityActivationRange );
+ maxTrackingRange = configuration.getInt( "world-settings." + name + ".entity-tracking-range-max", maxTrackingRange );
+ playerTrackingRange = Math.min( maxTrackingRange, configuration.getInt( "world-settings." + name + ".entity-tracking-range-players", playerTrackingRange ) );
+ miscTrackingRange = Math.min( maxTrackingRange, configuration.getInt( "world-settings." + name + ".entity-tracking-range-misc", miscTrackingRange ) );
+ animalTrackingRange = Math.min( maxTrackingRange, configuration.getInt( "world-settings." + name + ".entity-tracking-range-animals", animalTrackingRange ) );
+ monsterTrackingRange = Math.min( maxTrackingRange, configuration.getInt( "world-settings." + name + ".entity-tracking-range-monsters", monsterTrackingRange ) );
viewDistance = Bukkit.getServer().getViewDistance();
viewDistance = configuration.getInt( "world-settings." + name + ".view-distance", viewDistance );
obfuscated = world.getServer().orebfuscatorEnabled && !world.getServer().orebfuscatorDisabledWorlds.contains( name );
+ if ( maxTrackingRange == 0 )
+ {
+ System.err.println( "Error! Should not have 0 maxRange" );
+ }
if ( info )
{
@@ -172,6 +192,7 @@ public class CraftWorld implements World {
server.getLogger().info( "View distance: " + viewDistance );
server.getLogger().info( "Orebfuscator: " + obfuscated );
server.getLogger().info( "Entity Activation Range: An " + animalEntityActivationRange + " / Mo " + monsterEntityActivationRange + " / Mi " + miscEntityActivationRange );
+ server.getLogger().info( "Entity Tracking Range: Pl " + playerTrackingRange + " / An " + animalTrackingRange + " / Mo " + monsterTrackingRange + " / Mi " + miscTrackingRange + " / Max " + maxTrackingRange );
server.getLogger().info( "-------------------------------------------------" );
}
// Spigot end
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 6a164ca..c434f14 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -16,11 +16,16 @@ import net.minecraft.server.EntityComplexPart;
import net.minecraft.server.EntityCreature;
import net.minecraft.server.EntityEnderCrystal;
import net.minecraft.server.EntityEnderDragon;
+ private void trackingRange()
+ {
+ playerTrackingRange = getInt( "entity-tracking-range.players", playerTrackingRange );
+ animalTrackingRange = getInt( "entity-tracking-range.animals", animalTrackingRange );
+ monsterTrackingRange = getInt( "entity-tracking-range.monsters", monsterTrackingRange );
+ miscTrackingRange = getInt( "entity-tracking-range.misc", miscTrackingRange );
+ maxTrackingRange = getInt( "entity-tracking-range.other", maxTrackingRange );
+ log( "Entity Tracking Range: Pl " + playerTrackingRange + " / An " + animalTrackingRange + " / Mo " + monsterTrackingRange + " / Mi " + miscTrackingRange + " / Other " + maxTrackingRange );
+ }
}
diff --git a/src/main/java/org/spigotmc/TrackingRange.java b/src/main/java/org/spigotmc/TrackingRange.java
new file mode 100644
index 0000000..bc6438d
--- /dev/null
+++ b/src/main/java/org/spigotmc/TrackingRange.java
@@ -0,0 +1,45 @@
+package org.spigotmc;
+
+import net.minecraft.server.Entity;
+import net.minecraft.server.EntityExperienceOrb;
import net.minecraft.server.EntityFireball;
import net.minecraft.server.EntityFireworks;
+import net.minecraft.server.EntityGhast;
import net.minecraft.server.EntityHuman;
+import net.minecraft.server.EntityItem;
+import net.minecraft.server.EntityItemFrame;
import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityMonster;
+import net.minecraft.server.EntityPainting;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityProjectile;
import net.minecraft.server.EntitySheep;
@@ -374,6 +379,30 @@ public class Spigot {
}
}
+import net.minecraft.server.EntityPlayer;
+
+public class TrackingRange
+{
+
+ /**
+ * Gets the range an entity should be 'tracked' by players and visible in the client.
+ * Gets the range an entity should be 'tracked' by players and visible in
+ * the client.
+ *
+ * @param entity
+ * @param defaultRange Default range defined by Mojang
+ * @return
+ */
+ public static int getEntityTrackingRange(Entity entity, int defaultRange) {
+ CraftWorld world = entity.world.getWorld();
+ public static int getEntityTrackingRange(Entity entity, int defaultRange)
+ {
+ SpigotWorldConfig config = entity.world.spigotConfig;
+ int range = defaultRange;
+ if (entity instanceof EntityPlayer) {
+ range = world.playerTrackingRange;
+ } else if (entity.defaultActivationState || entity instanceof EntityGhast) {
+ if ( entity instanceof EntityPlayer )
+ {
+ range = config.playerTrackingRange;
+ } else if ( entity.defaultActivationState || entity instanceof EntityGhast )
+ {
+ range = defaultRange;
+ } else if (entity.activationType == 1) {
+ range = world.monsterTrackingRange;
+ } else if (entity.activationType == 2) {
+ range = world.animalTrackingRange;
+ } else if (entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityExperienceOrb) {
+ range = world.miscTrackingRange;
+ } else if ( entity.activationType == 1 )
+ {
+ range = config.monsterTrackingRange;
+ } else if ( entity.activationType == 2 )
+ {
+ range = config.animalTrackingRange;
+ } else if ( entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityExperienceOrb )
+ {
+ range = config.miscTrackingRange;
+ }
+
+ return Math.min(world.maxTrackingRange, range);
+ return Math.min( config.maxTrackingRange, range );
+ }
+
public static boolean filterIp(PendingConnection con) {
if (filterIps) {
try {
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 53db120..28d13fb 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -55,6 +55,11 @@ world-settings:
entity-activation-range-animals: 32
entity-activation-range-monsters: 32
entity-activation-range-misc: 16
+ entity-tracking-range-players: 48
+ entity-tracking-range-animals: 48
+ entity-tracking-range-monsters: 48
+ entity-tracking-range-misc: 32
+ entity-tracking-range-max: 64
info: true
world:
growth-chunks-per-tick: 1000
+}
--
1.8.1.2

View file

@ -1,4 +1,4 @@
From c3be564e248a414047f94a896f9ee545f47805df Mon Sep 17 00:00:00 2001
From 994bb48cde58d9f7888008c5cc2585b7b5d12cb1 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Mar 2013 11:15:11 +1100
Subject: [PATCH] BungeeCord Support
@ -6,7 +6,7 @@ Subject: [PATCH] BungeeCord Support
- Allows BungeeCord to set the players real IP address very early in the login process, so that the BungeeCord proxy IP is never even seen by a plugin.
diff --git a/src/main/java/net/minecraft/server/PendingConnection.java b/src/main/java/net/minecraft/server/PendingConnection.java
index a945892..7ef9a6f 100644
index a945892..e78781e 100644
--- a/src/main/java/net/minecraft/server/PendingConnection.java
+++ b/src/main/java/net/minecraft/server/PendingConnection.java
@@ -221,4 +221,17 @@ public class PendingConnection extends Connection {
@ -17,7 +17,7 @@ index a945892..7ef9a6f 100644
+ // Spigot start
+ @Override
+ public void a(Packet250CustomPayload pcp) {
+ if (pcp.tag.equals("BungeeCord") && org.bukkit.craftbukkit.Spigot.bungeeIPs.contains(getSocket().getInetAddress().getHostAddress())) {
+ if (pcp.tag.equals("BungeeCord") && org.spigotmc.SpigotConfig.bungee && org.spigotmc.SpigotConfig.bungeeAddresses.contains(getSocket().getInetAddress().getHostAddress())) {
+ com.google.common.io.ByteArrayDataInput in = com.google.common.io.ByteStreams.newDataInput(pcp.data);
+ String subTag = in.readUTF();
+ if (subTag.equals("Login")) {
@ -28,7 +28,7 @@ index a945892..7ef9a6f 100644
+ // Spigot end
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 305855b..e6e9295 100644
index f748492..e9b4c18 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -293,7 +293,7 @@ public abstract class PlayerList {
@ -41,7 +41,7 @@ index 305855b..e6e9295 100644
SocketAddress socketaddress = pendingconnection.networkManager.getSocketAddress();
diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
index fcd4136..fb4ec7b 100644
index 1254e63..a4eae65 100644
--- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
+++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
@@ -45,11 +45,11 @@ class ThreadLoginVerifier extends Thread {
@ -58,26 +58,6 @@ index fcd4136..fb4ec7b 100644
if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) {
event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage());
}
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index c434f14..dd92087 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -55,6 +55,7 @@ public class Spigot {
private static boolean filterIps;
public static boolean tabPing = false;
private static Metrics metrics;
+ public static List<String> bungeeIPs;
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
@@ -91,6 +92,7 @@ public class Spigot {
}
tabPing = configuration.getBoolean("settings.tab-ping", tabPing);
+ bungeeIPs = configuration.getStringList("settings.bungee-proxies");
if (metrics == null) {
try {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 8ec84e1..d70c110 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@ -94,19 +74,33 @@ index 8ec84e1..d70c110 100644
};
public Spigot spigot()
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 28d13fb..2e3b242 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -37,6 +37,8 @@ settings:
timeout-time: 30
restart-on-crash: false
restart-script-location: /path/to/server/start.sh
+ bungee-proxies:
+ - 127.0.0.1
world-settings:
default:
growth-chunks-per-tick: 650
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 90d3193..4a80929 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -7,6 +7,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -175,4 +176,14 @@ public class SpigotConfig
this.listeners.add( new Listener( host, port, netty, connectionThrottle ) );
}
}
+ public static List<String> bungeeAddresses = Arrays.asList( new String[]
+ {
+ "127.0.0.1"
+ } );
+ public static boolean bungee = true;
+ private void bungee()
+ {
+ bungeeAddresses = getList( "settings.bungeecord-addresses", bungee );
+ bungee = getBoolean( "settings.bungeecord", true );
+ }
}
--
1.8.1.2