From fb09fe93c40d993ecaa985ec316d82127a2ec054 Mon Sep 17 00:00:00 2001 From: Prototik Date: Sun, 17 May 2015 10:16:04 +0700 Subject: [PATCH] Allow to specifly full checks rate --- build.gradle | 2 +- .../minecraft/inventory/Container.java.patch | 40 ++++++++++++++----- .../world/WorldServerMulti.java.patch | 2 +- src/main/java/org/spigotmc/SpigotConfig.java | 6 +++ 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index 345a003..bfc95d3 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ archivesBaseName = 'kcauldron' ext.mcVersion = "1.7.10" ext.cauldronVersion = "4" ext.forgeVersion = "1403" -ext.revision = "63" +ext.revision = "64" version = "${mcVersion}-${cauldronVersion}.${forgeVersion}.${revision}" launch4j { diff --git a/patches/net/minecraft/inventory/Container.java.patch b/patches/net/minecraft/inventory/Container.java.patch index 7c07985..65d1f34 100644 --- a/patches/net/minecraft/inventory/Container.java.patch +++ b/patches/net/minecraft/inventory/Container.java.patch @@ -1,24 +1,41 @@ --- ../src-base/minecraft/net/minecraft/inventory/Container.java +++ ../src-work/minecraft/net/minecraft/inventory/Container.java -@@ -13,6 +13,17 @@ +@@ -2,17 +2,34 @@ + + import cpw.mods.fml.relauncher.Side; + import cpw.mods.fml.relauncher.SideOnly; ++ + import java.util.ArrayList; + import java.util.HashSet; + import java.util.Iterator; + import java.util.List; + import java.util.Set; ++ + import net.minecraft.entity.player.EntityPlayer; + import net.minecraft.entity.player.InventoryPlayer; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; ++ +// CraftBukkit start +import java.util.HashMap; +import java.util.Map; ++ +import net.minecraft.entity.player.EntityPlayerMP; ++ +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.Event.Result; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.inventory.InventoryView; +// CraftBukkit end ++import org.spigotmc.SpigotConfig; + public abstract class Container { public List inventoryItemStacks = new ArrayList(); -@@ -21,12 +32,52 @@ +@@ -21,12 +38,53 @@ @SideOnly(Side.CLIENT) private short transactionID; private int field_94535_f = -1; @@ -27,6 +44,7 @@ private final Set field_94537_h = new HashSet(); + public InventoryView bukkitView = null; // Cauldron + private int tickCount = 0; // Spigot ++ private final int fullMatchRate = SpigotConfig.fullMatchRate; // Spigot protected List crafters = new ArrayList(); private Set playerList = new HashSet(); private static final String __OBFID = "CL_00001730"; @@ -72,7 +90,7 @@ protected Slot addSlotToContainer(Slot p_75146_1_) { p_75146_1_.slotNumber = this.inventorySlots.size(); -@@ -39,7 +90,11 @@ +@@ -39,7 +97,11 @@ { if (this.crafters.contains(p_75132_1_)) { @@ -85,7 +103,7 @@ } else { -@@ -74,7 +129,7 @@ +@@ -74,7 +136,7 @@ ItemStack itemstack = ((Slot)this.inventorySlots.get(i)).getStack(); ItemStack itemstack1 = (ItemStack)this.inventoryItemStacks.get(i); @@ -94,7 +112,7 @@ { itemstack1 = itemstack == null ? null : itemstack.copy(); this.inventoryItemStacks.set(i, itemstack1); -@@ -85,6 +140,7 @@ +@@ -85,6 +147,7 @@ } } } @@ -102,7 +120,7 @@ } public boolean enchantItem(EntityPlayer p_75140_1_, int p_75140_2_) -@@ -109,6 +165,10 @@ +@@ -109,6 +172,10 @@ public Slot getSlot(int p_75139_1_) { @@ -113,7 +131,7 @@ return (Slot)this.inventorySlots.get(p_75139_1_); } -@@ -168,6 +228,7 @@ +@@ -168,6 +235,7 @@ itemstack3 = inventoryplayer.getItemStack().copy(); i1 = inventoryplayer.getItemStack().stackSize; Iterator iterator = this.field_94537_h.iterator(); @@ -121,7 +139,7 @@ while (iterator.hasNext()) { -@@ -190,18 +251,55 @@ +@@ -190,18 +258,55 @@ } i1 -= itemstack1.stackSize - j1; @@ -182,7 +200,7 @@ } this.func_94533_d(); -@@ -235,10 +333,17 @@ +@@ -235,10 +340,17 @@ if (p_75144_2_ == 1) { @@ -201,14 +219,14 @@ inventoryplayer.setItemStack((ItemStack)null); } } -@@ -730,4 +835,10 @@ +@@ -730,4 +842,10 @@ return MathHelper.floor_float(f * 14.0F) + (i > 0 ? 1 : 0); } } + + // Spigot start + public boolean areItemStacksEqual(ItemStack is1, ItemStack is2) { -+ return tickCount % 20 == 0 ? ItemStack.areItemStacksEqual(is1, is2) : ItemStack.fastMatches(is1, is2); ++ return tickCount % fullMatchRate == 0 ? ItemStack.areItemStacksEqual(is1, is2) : ItemStack.fastMatches(is1, is2); + } + // Spigot } diff --git a/patches/net/minecraft/world/WorldServerMulti.java.patch b/patches/net/minecraft/world/WorldServerMulti.java.patch index 7382cf4..5843059 100644 --- a/patches/net/minecraft/world/WorldServerMulti.java.patch +++ b/patches/net/minecraft/world/WorldServerMulti.java.patch @@ -11,7 +11,7 @@ + // CraftBukkit end + this.mapStorage = p_i45283_6_.mapStorage; + this.worldScoreboard = p_i45283_6_.getScoreboard(); -+ //this.worldInfo = new DerivedWorldInfo(p_i45283_6_.getWorldInfo()); ++ this.worldInfo = new DerivedWorldInfo(p_i45283_6_.getWorldInfo()); + } + + // Cauldron start - vanilla compatibility diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java index 56bd065..e0a5207 100644 --- a/src/main/java/org/spigotmc/SpigotConfig.java +++ b/src/main/java/org/spigotmc/SpigotConfig.java @@ -267,4 +267,10 @@ public class SpigotConfig { playerShuffle = getInt( "settings.player-shuffle", 0 ); } + + public static int fullMatchRate; + private static void fullMatchRate() + { + fullMatchRate = getInt( "settings.fullMatchRate", 10); + } }