diff --git a/patches/minecraft/net/minecraft/entity/projectile/EntityFishHook.java.patch b/patches/minecraft/net/minecraft/entity/projectile/EntityFishHook.java.patch index 4346d15dc0..7a1428a701 100644 --- a/patches/minecraft/net/minecraft/entity/projectile/EntityFishHook.java.patch +++ b/patches/minecraft/net/minecraft/entity/projectile/EntityFishHook.java.patch @@ -1,37 +1,15 @@ --- ../src-base/minecraft/net/minecraft/entity/projectile/EntityFishHook.java +++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityFishHook.java -@@ -571,32 +571,8 @@ public class EntityFishHook extends Entity - float f = this.worldObj.rand.nextFloat(); +@@ -551,6 +551,12 @@ public class EntityFishHook extends Entity + float f = this.field_70170_p.field_73012_v.nextFloat(); int i = EnchantmentHelper.func_151386_g(this.field_146042_b); int j = EnchantmentHelper.func_151387_h(this.field_146042_b); -- float f1 = 0.1F - (float)i * 0.025F - (float)j * 0.01F; -- float f2 = 0.05F + (float)i * 0.01F - (float)j * 0.01F; -- f1 = MathHelper.clamp_float(f1, 0.0F, 1.0F); -- f2 = MathHelper.clamp_float(f2, 0.0F, 1.0F); -- -- if (f < f1) -- { -- this.field_146042_b.addStat(StatList.field_151183_A, 1); -- return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, field_146039_d)).func_150708_a(this.rand); -- } -- else -- { -- f -= f1; -- -- if (f < f2) -- { -- this.field_146042_b.addStat(StatList.field_151184_B, 1); -- return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, field_146041_e)).func_150708_a(this.rand); -- } -- else -- { -- float f3 = f - f2; -- this.field_146042_b.addStat(StatList.fishCaughtStat, 1); -- return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, field_146036_f)).func_150708_a(this.rand); -- } -- } -+ this.field_146042_b.addStat(net.minecraftforge.common.FishingHooks.getFishableCategory(f, i, j).stat, 1); -+ return net.minecraftforge.common.FishingHooks.getRandomFishable(this.rand, f, i, j); - } - - /** ++ if (true) ++ { ++ this.field_146042_b.func_71064_a(net.minecraftforge.common.FishingHooks.getFishableCategory(f, i, j).stat, 1); ++ return net.minecraftforge.common.FishingHooks.getRandomFishable(this.field_70146_Z, f, i, j); ++ } ++ + float f1 = 0.1F - (float)i * 0.025F - (float)j * 0.01F; + float f2 = 0.05F + (float)i * 0.01F - (float)j * 0.01F; + f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F); diff --git a/src/main/java/net/minecraftforge/common/FishingHooks.java b/src/main/java/net/minecraftforge/common/FishingHooks.java index f9aa18b55f..0b3eed511e 100644 --- a/src/main/java/net/minecraftforge/common/FishingHooks.java +++ b/src/main/java/net/minecraftforge/common/FishingHooks.java @@ -1,7 +1,12 @@ package net.minecraftforge.common; +import com.google.common.base.Predicate; + import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import java.util.Random; + import net.minecraft.entity.projectile.EntityFishHook; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatBase; @@ -12,87 +17,98 @@ import net.minecraft.util.WeightedRandomFishable; public class FishingHooks { - private static ArrayList fish = new ArrayList(); - private static ArrayList junk = new ArrayList(); - private static ArrayList treasure = new ArrayList(); + private static ArrayList fish = new ArrayList(); + private static ArrayList junk = new ArrayList(); + private static ArrayList treasure = new ArrayList(); - public static ItemStack getRandomfishable(Random rand, float chance) - { - return getRandomFishable(rand, chance, 0, 0); - } + public static void addFish(WeightedRandomFishable item) { fish.add(item); } + public static void addJunk(WeightedRandomFishable item) { junk.add(item); } + public static void addTreasure(WeightedRandomFishable item) { treasure.add(item); } - public static ItemStack getRandomFishable(Random rand, float chance, int luck, int speed) - { - float junkChance = 0.1F - luck * 0.025F - speed * 0.01F; - float treasureChance = 0.05F + luck * 0.01F - speed * 0.01F; - junkChance = MathHelper.clamp_float(junkChance, 0.0F, 1.0F); - treasureChance = MathHelper.clamp_float(treasureChance, 0.0F, 1.0F); + public static void removeFish(Predicate test) { remove(fish.iterator(), test); } + public static void removeJunk(Predicate test) { remove(junk.iterator(), test); } + public static void removeTreasure(Predicate test) { remove(treasure.iterator(), test); } - if (chance < junkChance) - { - return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, junk)).func_150708_a(rand); - } + public static ItemStack getRandomFishable(Random rand, float chance) + { + return getRandomFishable(rand, chance, 0, 0); + } - chance -= junkChance; - if (chance < treasureChance) - { - return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, treasure)).func_150708_a(rand); - } + public static ItemStack getRandomFishable(Random rand, float chance, int luck, int speed) + { + float junkChance = 0.1F - luck * 0.025F - speed * 0.01F; + float treasureChance = 0.05F + luck * 0.01F - speed * 0.01F; + junkChance = MathHelper.clamp_float(junkChance, 0.0F, 1.0F); + treasureChance = MathHelper.clamp_float(treasureChance, 0.0F, 1.0F); - chance -= treasureChance; - // this is done in EntityFishHook.func_146033_f. more loot types expected? - { - return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, fish)).func_150708_a(rand); - } - } + if (chance < junkChance) + { + return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, junk)).func_150708_a(rand); + } - public static FishableCategory getFishableCategory(float chance, int luck, int speed) - { - float junkChance = 0.1F - luck * 0.025F - speed * 0.01F; - float treasureChance = 0.05F + luck * 0.01F - speed * 0.01F; - junkChance = MathHelper.clamp_float(junkChance, 0.0F, 1.0F); - treasureChance = MathHelper.clamp_float(treasureChance, 0.0F, 1.0F); + chance -= junkChance; + if (chance < treasureChance) + { + return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, treasure)).func_150708_a(rand); + } - if (chance < junkChance) - { - return FishableCategory.JUNK; - } + chance -= treasureChance; + // this is done in EntityFishHook.func_146033_f. more loot types expected? + { + return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, fish)).func_150708_a(rand); + } + } - chance -= junkChance; - if (chance < treasureChance) - { - return FishableCategory.TREASURE; - } + public static FishableCategory getFishableCategory(float chance, int luck, int speed) + { + float junkChance = 0.1F - luck * 0.025F - speed * 0.01F; + float treasureChance = 0.05F + luck * 0.01F - speed * 0.01F; + junkChance = MathHelper.clamp_float(junkChance, 0.0F, 1.0F); + treasureChance = MathHelper.clamp_float(treasureChance, 0.0F, 1.0F); - chance -= treasureChance; - // this is done in EntityFishHook.func_146033_f. more loot types expected? - { - return FishableCategory.FISH; - } - } + if (chance < junkChance) + { + return FishableCategory.JUNK; + } - public static enum FishableCategory - { - JUNK(StatList.field_151183_A), - TREASURE(StatList.field_151184_B), - FISH(StatList.fishCaughtStat); + chance -= junkChance; + if (chance < treasureChance) + { + return FishableCategory.TREASURE; + } - public final StatBase stat; + chance -= treasureChance; + // this is done in EntityFishHook.func_146033_f. more loot types expected? + { + return FishableCategory.FISH; + } + } - FishableCategory(StatBase stat) - { - this.stat = stat; - } - } + private static void remove(Iterator iter, Predicate test) + { + while (iter.hasNext()) + if (!test.apply(iter.next())) + iter.remove(); + } - public static void addFish(WeightedRandomFishable item) { fish.add(item); } - public static void addJunk(WeightedRandomFishable item) { junk.add(item); } - public static void addTreasure(WeightedRandomFishable item) { treasure.add(item); } + static + { + fish.addAll(EntityFishHook.field_146036_f); + junk.addAll(EntityFishHook.field_146039_d); + treasure.addAll(EntityFishHook.field_146041_e); + } - static - { - fish.addAll(EntityFishHook.field_146036_f); - junk.addAll(EntityFishHook.field_146039_d); - treasure.addAll(EntityFishHook.field_146041_e); - } + public static enum FishableCategory + { + JUNK(StatList.field_151183_A), + TREASURE(StatList.field_151184_B), + FISH(StatList.fishCaughtStat); + + public final StatBase stat; + + FishableCategory(StatBase stat) + { + this.stat = stat; + } + } }