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.func_76131_a(junkChance, 0.0F, 1.0F); treasureChance = MathHelper.func_76131_a(treasureChance, 0.0F, 1.0F); if (chance < junkChance) { return ((WeightedRandomFishable)WeightedRandom.func_76271_a(rand, junk)).func_150708_a(rand); } chance -= junkChance; if (chance < treasureChance) { return ((WeightedRandomFishable)WeightedRandom.func_76271_a(rand, treasure)).func_150708_a(rand); } chance -= treasureChance; // this is done in EntityFishHook.func_146033_f. more loot types expected? { return ((WeightedRandomFishable)WeightedRandom.func_76271_a(rand, fish)).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); if (chance < junkChance) { return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, junk)).func_150708_a(rand); } chance -= junkChance; if (chance < treasureChance) { return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, treasure)).func_150708_a(rand); } chance -= treasureChance; // this is done in EntityFishHook.func_146033_f. more loot types expected? { return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, fish)).func_150708_a(rand); } }
private ItemStack getFishingResult() { float f = this.worldObj.rand.nextFloat(); int i = EnchantmentHelper.getLuckOfSeaModifier(this.angler); int j = EnchantmentHelper.getLureModifier(this.angler); 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.angler.triggerAchievement(StatList.junkFishedStat); return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, JUNK)).getItemStack(this.rand); } else { f = f - f1; if (f < f2) { this.angler.triggerAchievement(StatList.treasureFishedStat); return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, TREASURE)).getItemStack(this.rand); } else { float f3 = f - f2; this.angler.triggerAchievement(StatList.fishCaughtStat); return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, FISH)).getItemStack(this.rand); } } }
public static void init() { FishingHooks.addFish(new WeightedRandomFishable(new ItemStack(InitItems.fusion_fish), 100)); addItemToChest(ChestGenHooks.VILLAGE_BLACKSMITH, InitItems.steel.sword, 1, 1, 10); addItemToChest(ChestGenHooks.VILLAGE_BLACKSMITH, InitItems.steel.pickaxe, 1, 1, 10); addItemToChest(ChestGenHooks.VILLAGE_BLACKSMITH, InitItems.steel.helmet, 1, 1, 7); addItemToChest(ChestGenHooks.VILLAGE_BLACKSMITH, InitItems.steel.chestplate, 1, 1, 5); addItemToChest(ChestGenHooks.VILLAGE_BLACKSMITH, InitItems.steel.leggings, 1, 1, 5); addItemToChest(ChestGenHooks.VILLAGE_BLACKSMITH, InitItems.steel.boots, 1, 1, 7); }
private ItemStack func_146033_f() { float var1 = this.worldObj.rand.nextFloat(); int var2 = EnchantmentHelper.func_151386_g(this.field_146042_b); int var3 = EnchantmentHelper.func_151387_h(this.field_146042_b); float var4 = 0.1F - (float)var2 * 0.025F - (float)var3 * 0.01F; float var5 = 0.05F + (float)var2 * 0.01F - (float)var3 * 0.01F; var4 = MathHelper.clamp_float(var4, 0.0F, 1.0F); var5 = MathHelper.clamp_float(var5, 0.0F, 1.0F); if (var1 < var4) { 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 { var1 -= var4; if (var1 < var5) { 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 var10000 = var1 - var5; this.field_146042_b.addStat(StatList.fishCaughtStat, 1); return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, field_146036_f)).func_150708_a(this.rand); } } }
private ItemStack func_146033_f() { float f = this.worldObj.rand.nextFloat(); int i = EnchantmentHelper.func_151386_g(this.field_146042_b); int j = EnchantmentHelper.func_151387_h(this.field_146042_b); if (true) { 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); } 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, EntityFishHook.field_146036_f)).func_150708_a(this.rand); // CraftBukkit - fix static reference to fish list } } }
private ItemStack func_146033_f() { float f = this.worldObj.rand.nextFloat(); int i = EnchantmentHelper.func_151386_g(this.field_146042_b); int j = EnchantmentHelper.func_151387_h(this.field_146042_b); if (true) { 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); } 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); } } }
public static List<WeightedRandomFishable> func_174855_j() { return FISH; }
/** * Causes this Entity to drop a random item. */ protected void addRandomDrop() { ItemStack itemstack = ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, EntityFishHook.func_174855_j())).getItemStack(this.rand); this.entityDropItem(itemstack, 1.0F); }
private static void remove(Iterator<WeightedRandomFishable> iter, Predicate<WeightedRandomFishable> test) { while (iter.hasNext()) if (!test.apply(iter.next())) iter.remove(); }
@EventHandler public void preInit(FMLPreInitializationEvent event) { egg = new ItemFatCatEgg().setUnlocalizedName("fatcat_egg"); unko = new ItemFatCatUnko().setUnlocalizedName("fatcat_unko"); brush = new ItemCatBrush().setUnlocalizedName("fatcat_brush"); furball = new ItemFurball().setUnlocalizedName("furball"); feather_toy = new ItemFeatherToy().setUnlocalizedName("fatcat_feather_toy"); GameRegistry.registerItem(egg, egg.getUnlocalizedName().substring(5)); GameRegistry.registerItem(unko, unko.getUnlocalizedName().substring(5)); GameRegistry.registerItem(brush, brush.getUnlocalizedName().substring(5)); GameRegistry.registerItem(furball, furball.getUnlocalizedName().substring(5)); GameRegistry.registerItem(feather_toy, feather_toy.getUnlocalizedName().substring(5)); EntityRegistry.registerModEntity(EntityFatCat.class, "FatCat", ++modEntityIndex, this, 64, 10, true); EntityRegistry.registerModEntity(EntityItemUnko.class, "FatCatUnko", ++modEntityIndex, this, 64, 10, true); GameRegistry.addRecipe( new ItemStack(brush, 1), "BT ", "BT ", " T ", 'B', Blocks.hay_block, 'T', Items.stick); GameRegistry.addRecipe( new ItemStack(feather_toy, 1), " F ", " F ", " T ", 'F', furball, 'T', Items.stick); // Get a fatcat egg via fishing. FishingHooks.addTreasure(new WeightedRandomFishable(new ItemStack(egg), 1)); ChestGenHooks.addItem(ChestGenHooks.PYRAMID_DESERT_CHEST, new WeightedRandomChestContent(new ItemStack(egg, 1, 0), 1, 1, 15)); ChestGenHooks.addItem(ChestGenHooks.PYRAMID_JUNGLE_CHEST, new WeightedRandomChestContent(new ItemStack(egg, 1, 0), 1, 1, 15)); ChestGenHooks.addItem(ChestGenHooks.MINESHAFT_CORRIDOR, new WeightedRandomChestContent(new ItemStack(egg, 1, 0), 1, 1, 7)); Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load(); Property breeding_mode_property = config.get(Configuration.CATEGORY_GENERAL, "BreedingMode", true); breeding_mode_property.comment = "Breeding MODE(true/false): FatCat status is fixed if you disable this option"; breeding_mode = breeding_mode_property.getBoolean(true); Property logging_mode_property = config.get(Configuration.CATEGORY_GENERAL, "Logging", false); logging_mode_property.comment = "logging for debug"; logging = logging_mode_property.getBoolean(false); Property debug_property = config.get(Configuration.CATEGORY_GENERAL, "Debug", false); debug_property.comment = "debugging mode for development"; DEBUG = debug_property.getBoolean(false); config.save(); }
@SuppressWarnings("unused") private ItemStack getFishingResult() { FishingSkill anglerTracker = ((FishingSkill)this.tracker.GetSkillByID("fishing")); int skill = (int)anglerTracker.getBonusFactor(0, 40, 1); float f = this.worldObj.rand.nextFloat(); int i = EnchantmentHelper.getLuckOfSeaModifier(this.angler); int j = EnchantmentHelper.getLureModifier(this.angler); i += skill; if (true) { ((FishingSkill)this.tracker.GetSkillByID("fishing")).CatchEvent(this.angler,net.minecraftforge.common.FishingHooks.getFishableCategory(f, i, j)); this.angler.addStat(net.minecraftforge.common.FishingHooks.getFishableCategory(f, i, j).stat, 1); ItemStack item = net.minecraftforge.common.FishingHooks.getRandomFishable(this.rand, f, i, j); return item; } 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.angler.triggerAchievement(StatList.junkFishedStat); return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, JUNK)).getItemStack(this.rand); } else { f -= f1; if (f < f2) { this.angler.triggerAchievement(StatList.treasureFishedStat); return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, TREASURE)).getItemStack(this.rand); } else { float f3 = f - f2; this.angler.triggerAchievement(StatList.fishCaughtStat); return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, FISH)).getItemStack(this.rand); } } }
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 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); }