From 4a5c3b2f93ca23e808c85dc9834817d3d078dc1b Mon Sep 17 00:00:00 2001 From: Robotia Date: Fri, 4 Mar 2016 10:20:50 -0500 Subject: [PATCH] Start work on #175 --- .../cauldron/configuration/CauldronConfig.java | 11 +++++++++++ .../craftbukkit/inventory/CraftContainer.java | 15 ++------------- .../thermite/ThermiteDynamicViewDistance.java | 15 +++++++++++++++ 3 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 src/main/java/thermos/thermite/ThermiteDynamicViewDistance.java diff --git a/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java b/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java index 80fca9f7..2c0c376e 100644 --- a/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java +++ b/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java @@ -72,6 +72,12 @@ public class CauldronConfig extends ConfigBase public final BoolSetting remapPluginFile = new BoolSetting(this, "plugin-settings.default.remap-plugin-file", false, "Remap the plugin file (dev)"); + // Dynamic view distance settings + public final IntSetting decreaseVD = new IntSetting(this, "optimized.view-distance.trigger-decrease-player-count", 30, "When to trigger the view distance decrease (default view-distance between this and increase trigger)"); + public final IntSetting increaseVD = new IntSetting(this, "optimized.view-distance.trigger-increase-player-count", 15, "When to trigger the view distance increase (default view-distance between this and decrease trigger)"); + public final IntSetting lowerVD = new IntSetting(this, "optimized.view-distance.lower-view-distance", 6, "What the lower view distance should be"); + public final IntSetting upperVD = new IntSetting(this, "optimized.view-distance.upper-view-distance", 10, "What the upper view distance should be"); + public final BoolSetting dynamicVD = new BoolSetting(this, "optimized.view-distance.enabled", false, "Use dynamic view distance?"); /* ======================================================================== */ public CauldronConfig(String fileName, String commandName) @@ -120,6 +126,11 @@ public void init() settings.put(redstoneTorchL.path, redstoneTorchL); settings.put(protectSP.path, protectSP); settings.put(realNames.path, realNames); + settings.put(dynamicVD.path, dynamicVD); + settings.put(increaseVD.path, increaseVD); + settings.put(decreaseVD.path, decreaseVD); + settings.put(lowerVD.path, lowerVD); + settings.put(upperVD.path, upperVD); load(); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java index ca279a0f..3e9978bf 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java @@ -84,7 +84,7 @@ public boolean isPlayerNotUsingContainer(net.minecraft.entity.player.EntityPlaye this.inventoryItemStacks.clear(); this.inventorySlots.clear(); if (typeChanged) { - setupSlots(top, bottom, entityhuman.openContainer); + setupSlots(top, bottom); } int size = getSize(); player.getHandle().playerNetServerHandler.sendPacket(new net.minecraft.network.play.server.S2DPacketOpenWindow(this.windowId, type, cachedTitle, size, true)); @@ -127,7 +127,7 @@ public static int getNotchInventoryType(InventoryType type) { return typeID; } - private void setupSlots(net.minecraft.inventory.IInventory top, net.minecraft.inventory.IInventory bottom, Container ... openContainer) { + private void setupSlots(net.minecraft.inventory.IInventory top, net.minecraft.inventory.IInventory bottom) { switch(cachedType) { case CREATIVE: break; // TODO: This should be an error? @@ -154,20 +154,9 @@ private void setupSlots(net.minecraft.inventory.IInventory top, net.minecraft.in case HOPPER: setupHopper(top, bottom); break; - default: // Thermos handle setup for custom inventories - if(openContainer.length > 0) - setupCustomInventory(top, bottom, openContainer[0]); - break; } } - private void setupCustomInventory(net.minecraft.inventory.IInventory top, net.minecraft.inventory.IInventory bottom, Container openContainer) { - for (Slot s : openContainer.inventorySlots) - { - this.addSlotToContainer(s); - } - } - private void setupChest(net.minecraft.inventory.IInventory top, net.minecraft.inventory.IInventory bottom) { int rows = top.getSizeInventory() / 9; int row; diff --git a/src/main/java/thermos/thermite/ThermiteDynamicViewDistance.java b/src/main/java/thermos/thermite/ThermiteDynamicViewDistance.java new file mode 100644 index 00000000..c0c42672 --- /dev/null +++ b/src/main/java/thermos/thermite/ThermiteDynamicViewDistance.java @@ -0,0 +1,15 @@ +package thermos.thermite; + +public class ThermiteDynamicViewDistance { + static net.minecraftforge.cauldron.configuration.CauldronConfig config; + static net.minecraft.server.MinecraftServer server; + static + { + config = net.minecraftforge.cauldron.configuration.CauldronConfig.instance; + server = net.minecraft.server.MinecraftServer.getServer(); + } + public static void checkAndUpdate(int size) { + + } + +}