diff options
Diffstat (limited to 'src/main/java/gtPlusPlus/plugin/fishing')
4 files changed, 325 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/plugin/fishing/Core_Fishing.java b/src/main/java/gtPlusPlus/plugin/fishing/Core_Fishing.java new file mode 100644 index 0000000000..48706bc986 --- /dev/null +++ b/src/main/java/gtPlusPlus/plugin/fishing/Core_Fishing.java @@ -0,0 +1,54 @@ +package gtPlusPlus.plugin.fishing; + +import gtPlusPlus.api.interfaces.IPlugin; +import gtPlusPlus.plugin.manager.Core_Manager; + +public class Core_Fishing implements IPlugin { + + final static Core_Fishing mInstance; + + static { + mInstance = new Core_Fishing(); + mInstance.log("Preparing "+mInstance.getPluginName()+" for use."); + } + + Core_Fishing() { + Core_Manager.registerPlugin(this); + } + + @Override + public boolean preInit() { + return false; + } + + @Override + public boolean init() { + return false; + } + + @Override + public boolean postInit() { + return false; + } + + @Override + public boolean serverStart() { + return false; + } + + @Override + public boolean serverStop() { + return false; + } + + @Override + public String getPluginName() { + return "GT++ Fishing Module"; + } + + @Override + public String getPluginAbbreviation() { + return "Fish"; + } + +} diff --git a/src/main/java/gtPlusPlus/plugin/fishing/block/BlockFishEggs.java b/src/main/java/gtPlusPlus/plugin/fishing/block/BlockFishEggs.java new file mode 100644 index 0000000000..c11d4fa333 --- /dev/null +++ b/src/main/java/gtPlusPlus/plugin/fishing/block/BlockFishEggs.java @@ -0,0 +1,12 @@ +package gtPlusPlus.plugin.fishing.block; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; + +public class BlockFishEggs extends Block{ + + protected BlockFishEggs() { + super(Material.water); + } + +} diff --git a/src/main/java/gtPlusPlus/plugin/fishing/item/BaseFish.java b/src/main/java/gtPlusPlus/plugin/fishing/item/BaseFish.java new file mode 100644 index 0000000000..d96d8d8cfd --- /dev/null +++ b/src/main/java/gtPlusPlus/plugin/fishing/item/BaseFish.java @@ -0,0 +1,119 @@ +package gtPlusPlus.plugin.fishing.item; + +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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; + +import gtPlusPlus.plugin.fishing.misc.BaseFishTypes; + +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/main/java/gtPlusPlus/plugin/fishing/misc/BaseFishTypes.java b/src/main/java/gtPlusPlus/plugin/fishing/misc/BaseFishTypes.java new file mode 100644 index 0000000000..ea8d04b5d3 --- /dev/null +++ b/src/main/java/gtPlusPlus/plugin/fishing/misc/BaseFishTypes.java @@ -0,0 +1,140 @@ +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 net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import gtPlusPlus.plugin.fishing.item.BaseFish; + +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 |