From ffb71dce8cc0bc653f947e3fca6a95c1c6ec7f4a Mon Sep 17 00:00:00 2001 From: Samuel-Harbord Date: Wed, 9 Aug 2017 16:22:09 -0400 Subject: [PATCH] Add Ability to Override PotionEffect Default Sort Order (#4172) --- .../net/minecraft/potion/Potion.java.patch | 13 ++++++++++++- .../net/minecraft/potion/PotionEffect.java.patch | 9 +++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/patches/minecraft/net/minecraft/potion/Potion.java.patch b/patches/minecraft/net/minecraft/potion/Potion.java.patch index e31341268f..c3d3aba35e 100644 --- a/patches/minecraft/net/minecraft/potion/Potion.java.patch +++ b/patches/minecraft/net/minecraft/potion/Potion.java.patch @@ -20,7 +20,7 @@ public boolean func_76398_f() { return this.field_76418_K; -@@ -293,7 +292,74 @@ +@@ -293,7 +292,85 @@ return p_111183_2_.func_111164_d() * (double)(p_111183_1_ + 1); } @@ -88,6 +88,17 @@ + ret.add(new net.minecraft.item.ItemStack(net.minecraft.init.Items.field_151117_aB)); + return ret; + } ++ ++ /** ++ * Used for determining {@code PotionEffect} sort order in GUIs. ++ * Defaults to the {@code PotionEffect}'s liquid color. ++ * @param potionEffect the {@code PotionEffect} instance containing the potion ++ * @return a value used to sort {@code PotionEffect}s in GUIs ++ */ ++ public int getGuiSortColor(PotionEffect potionEffect) ++ { ++ return this.func_76401_j(); ++ } + + /* ======================================== FORGE END =====================================*/ + diff --git a/patches/minecraft/net/minecraft/potion/PotionEffect.java.patch b/patches/minecraft/net/minecraft/potion/PotionEffect.java.patch index b72902d0b0..346bced079 100644 --- a/patches/minecraft/net/minecraft/potion/PotionEffect.java.patch +++ b/patches/minecraft/net/minecraft/potion/PotionEffect.java.patch @@ -41,6 +41,15 @@ } } +@@ -232,7 +236,7 @@ + public int compareTo(PotionEffect p_compareTo_1_) + { + int i = 32147; +- return (this.func_76459_b() <= 32147 || p_compareTo_1_.func_76459_b() <= 32147) && (!this.func_82720_e() || !p_compareTo_1_.func_82720_e()) ? ComparisonChain.start().compare(Boolean.valueOf(this.func_82720_e()), Boolean.valueOf(p_compareTo_1_.func_82720_e())).compare(this.func_76459_b(), p_compareTo_1_.func_76459_b()).compare(this.func_188419_a().func_76401_j(), p_compareTo_1_.func_188419_a().func_76401_j()).result() : ComparisonChain.start().compare(Boolean.valueOf(this.func_82720_e()), Boolean.valueOf(p_compareTo_1_.func_82720_e())).compare(this.func_188419_a().func_76401_j(), p_compareTo_1_.func_188419_a().func_76401_j()).result(); ++ return (this.func_76459_b() <= 32147 || p_compareTo_1_.func_76459_b() <= 32147) && (!this.func_82720_e() || !p_compareTo_1_.func_82720_e()) ? ComparisonChain.start().compare(Boolean.valueOf(this.func_82720_e()), Boolean.valueOf(p_compareTo_1_.func_82720_e())).compare(this.func_76459_b(), p_compareTo_1_.func_76459_b()).compare(this.func_188419_a().getGuiSortColor(this), p_compareTo_1_.func_188419_a().getGuiSortColor(p_compareTo_1_)).result() : ComparisonChain.start().compare(Boolean.valueOf(this.func_82720_e()), Boolean.valueOf(p_compareTo_1_.func_82720_e())).compare(this.func_188419_a().getGuiSortColor(this), p_compareTo_1_.func_188419_a().getGuiSortColor(p_compareTo_1_)).result(); + } + + @SideOnly(Side.CLIENT) @@ -240,4 +244,85 @@ { return this.field_100013_f;