Update FishingHooks
This commit is contained in:
parent
906dcb999d
commit
cc169c3ea1
2 changed files with 96 additions and 102 deletions
|
@ -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);
|
||||
|
|
|
@ -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<WeightedRandomFishable> fish = new ArrayList<WeightedRandomFishable>();
|
||||
private static ArrayList<WeightedRandomFishable> junk = new ArrayList<WeightedRandomFishable>();
|
||||
private static ArrayList<WeightedRandomFishable> treasure = new ArrayList<WeightedRandomFishable>();
|
||||
private static ArrayList<WeightedRandomFishable> fish = new ArrayList<WeightedRandomFishable>();
|
||||
private static ArrayList<WeightedRandomFishable> junk = new ArrayList<WeightedRandomFishable>();
|
||||
private static ArrayList<WeightedRandomFishable> treasure = new ArrayList<WeightedRandomFishable>();
|
||||
|
||||
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<WeightedRandomFishable> test) { remove(fish.iterator(), test); }
|
||||
public static void removeJunk(Predicate<WeightedRandomFishable> test) { remove(junk.iterator(), test); }
|
||||
public static void removeTreasure(Predicate<WeightedRandomFishable> 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<WeightedRandomFishable> iter, Predicate<WeightedRandomFishable> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue