diff options
Diffstat (limited to 'src/Java/gtPlusPlus/plugin')
-rw-r--r-- | src/Java/gtPlusPlus/plugin/fishing/item/BaseFish.java | 116 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/plugin/fishing/misc/BaseFishTypes.java | 138 |
2 files changed, 252 insertions, 2 deletions
diff --git a/src/Java/gtPlusPlus/plugin/fishing/item/BaseFish.java b/src/Java/gtPlusPlus/plugin/fishing/item/BaseFish.java index b395240663..8ec03e500a 100644 --- a/src/Java/gtPlusPlus/plugin/fishing/item/BaseFish.java +++ b/src/Java/gtPlusPlus/plugin/fishing/item/BaseFish.java @@ -1,5 +1,117 @@ package gtPlusPlus.plugin.fishing.item; -public class BaseFish { +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.plugin.fishing.misc.BaseFishTypes; -} +import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.PotionHelper; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BaseFish extends ItemFood +{ + private final boolean isCooked; + + public BaseFish(boolean cooked) + { + super(0, 0.0F, false); + this.isCooked = cooked; + } + + public int func_150905_g(ItemStack p_150905_1_) + { + BaseFishTypes fishtype = BaseFishTypes.getFishTypeFromStackDamage(p_150905_1_); + return this.isCooked && fishtype.isCooked() ? fishtype.func_150970_e() : fishtype.func_150975_c(); + } + + public float func_150906_h(ItemStack p_150906_1_) + { + BaseFishTypes fishtype = BaseFishTypes.getFishTypeFromStackDamage(p_150906_1_); + return this.isCooked && fishtype.isCooked() ? fishtype.func_150977_f() : fishtype.func_150967_d(); + } + + /** + * Returns a string representing what this item does to a potion. + */ + public String getPotionEffect(ItemStack p_150896_1_) + { + return BaseFishTypes.getFishTypeFromStackDamage(p_150896_1_) == BaseFishTypes.PUFFERFISH ? PotionHelper.field_151423_m : null; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister p_94581_1_) + { + BaseFishTypes[] afishtype = BaseFishTypes.values(); + int i = afishtype.length; + + for (int j = 0; j < i; ++j) + { + BaseFishTypes fishtype = afishtype[j]; + fishtype.func_150968_a(p_94581_1_); + } + } + + protected void onFoodEaten(ItemStack fish, World world, EntityPlayer player) + { + BaseFishTypes fishtype = BaseFishTypes.getFishTypeFromStackDamage(fish); + + if (fishtype == BaseFishTypes.PUFFERFISH) + { + player.addPotionEffect(new PotionEffect(Potion.poison.id, 1200, 3)); + player.addPotionEffect(new PotionEffect(Potion.hunger.id, 300, 2)); + player.addPotionEffect(new PotionEffect(Potion.confusion.id, 300, 1)); + } + + super.onFoodEaten(fish, world, player); + } + + /** + * Gets an icon index based on an item's damage value + */ + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int dmg) + { + BaseFishTypes fishtype = BaseFishTypes.getFishTypeFromDamageValue(dmg); + return this.isCooked && fishtype.isCooked() ? fishtype.func_150979_h() : fishtype.func_150971_g(); + } + + /** + * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) + */ + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) + { + BaseFishTypes[] afishtype = BaseFishTypes.values(); + int i = afishtype.length; + + for (int j = 0; j < i; ++j) + { + BaseFishTypes fishtype = afishtype[j]; + + if (!this.isCooked || fishtype.isCooked()) + { + p_150895_3_.add(new ItemStack(this, 1, fishtype.getFishID())); + } + } + } + + /** + * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have + * different names based on their damage or NBT. + */ + public String getUnlocalizedName(ItemStack p_77667_1_) + { + BaseFishTypes fishtype = BaseFishTypes.getFishTypeFromStackDamage(p_77667_1_); + return this.getUnlocalizedName() + "." + fishtype.getFishName() + "." + (this.isCooked && fishtype.isCooked() ? "cooked" : "raw"); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/plugin/fishing/misc/BaseFishTypes.java b/src/Java/gtPlusPlus/plugin/fishing/misc/BaseFishTypes.java new file mode 100644 index 0000000000..56d5e218af --- /dev/null +++ b/src/Java/gtPlusPlus/plugin/fishing/misc/BaseFishTypes.java @@ -0,0 +1,138 @@ +package gtPlusPlus.plugin.fishing.misc; +import java.util.Map; + +import com.google.common.collect.Maps; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.plugin.fishing.item.BaseFish; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public enum BaseFishTypes{ + + COD(0, "cod", 2, 0.1F, 5, 0.6F), + SALMON(1, "salmon", 2, 0.1F, 6, 0.8F), + CLOWNFISH(2, "clownfish", 1, 0.1F), + PUFFERFISH(3, "pufferfish", 1, 0.1F); + + + + + private static final Map<Integer, BaseFishTypes> mFishMap = Maps.newHashMap(); + private final int mID; + private final String mFishName; + @SideOnly(Side.CLIENT) + private IIcon iicon; + @SideOnly(Side.CLIENT) + private IIcon iicon2; + private final int field_150991_j; + private final float field_150992_k; + private final int field_150989_l; + private final float field_150990_m; + private boolean isCooked = false; + + private BaseFishTypes(int p_i45336_3_, String p_i45336_4_, int p_i45336_5_, float p_i45336_6_, int p_i45336_7_, float p_i45336_8_) + { + this.mID = p_i45336_3_; + this.mFishName = p_i45336_4_; + this.field_150991_j = p_i45336_5_; + this.field_150992_k = p_i45336_6_; + this.field_150989_l = p_i45336_7_; + this.field_150990_m = p_i45336_8_; + this.isCooked = true; + } + + private BaseFishTypes(int p_i45337_3_, String p_i45337_4_, int p_i45337_5_, float p_i45337_6_) + { + this.mID = p_i45337_3_; + this.mFishName = p_i45337_4_; + this.field_150991_j = p_i45337_5_; + this.field_150992_k = p_i45337_6_; + this.field_150989_l = 0; + this.field_150990_m = 0.0F; + this.isCooked = false; + } + + public int getFishID() + { + return this.mID; + } + + public String getFishName() + { + return this.mFishName; + } + + public int func_150975_c() + { + return this.field_150991_j; + } + + public float func_150967_d() + { + return this.field_150992_k; + } + + public int func_150970_e() + { + return this.field_150989_l; + } + + public float func_150977_f() + { + return this.field_150990_m; + } + + @SideOnly(Side.CLIENT) + public void func_150968_a(IIconRegister p_150968_1_) + { + this.iicon = p_150968_1_.registerIcon("fish_" + this.mFishName + "_raw"); + + if (this.isCooked) + { + this.iicon2 = p_150968_1_.registerIcon("fish_" + this.mFishName + "_cooked"); + } + } + + @SideOnly(Side.CLIENT) + public IIcon func_150971_g() + { + return this.iicon; + } + + @SideOnly(Side.CLIENT) + public IIcon func_150979_h() + { + return this.iicon2; + } + + public boolean isCooked() + { + return this.isCooked; + } + + public static BaseFishTypes getFishTypeFromDamageValue(int dmg) + { + BaseFishTypes fishtype = (BaseFishTypes)mFishMap.get(Integer.valueOf(dmg)); + return fishtype == null ? COD : fishtype; + } + + public static BaseFishTypes getFishTypeFromStackDamage(ItemStack fish) + { + return fish.getItem() instanceof BaseFish ? getFishTypeFromDamageValue(fish.getItemDamage()) : COD; + } + + static + { + BaseFishTypes[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + BaseFishTypes var3 = var0[var2]; + mFishMap.put(Integer.valueOf(var3.getFishID()), var3); + } + } + }
\ No newline at end of file |