diff options
Diffstat (limited to 'TF2 Crates/src/main/java/tf2crates')
26 files changed, 3930 insertions, 0 deletions
diff --git a/TF2 Crates/src/main/java/tf2crates/ClientProxyTC.java b/TF2 Crates/src/main/java/tf2crates/ClientProxyTC.java new file mode 100755 index 0000000..09478a3 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/ClientProxyTC.java @@ -0,0 +1,19 @@ +package tf2crates;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+import net.minecraftforge.common.MinecraftForge;
+import tf2crates.handler.EventHandler;
+import tf2crates.handler.TooltipHandler;
+import tlhpoeCore.TLHPoE;
+
+public class ClientProxyTC extends ServerProxyTC {
+ @Override
+ public void initClient() {
+ TLHPoE.registerUpdateDetector(ReferenceTC.ID, ReferenceTC.NAME,
+ ReferenceTC.VERSION, "0B6mhkrh-GwwwWFFnNFlqWklCVFE");
+
+ MinecraftForge.EVENT_BUS.register(new TooltipHandler());
+
+ FMLCommonHandler.instance().bus().register(new EventHandler());
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/ReferenceTC.java b/TF2 Crates/src/main/java/tf2crates/ReferenceTC.java new file mode 100755 index 0000000..a73a7c3 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/ReferenceTC.java @@ -0,0 +1,9 @@ +package tf2crates;
+
+public class ReferenceTC {
+ public static final String ID = "tf2crates";
+ public static final String NAME = "TF2 Crates";
+ public static final String VERSION = "1.5";
+
+ public static String CURRENT_SPECIAL_CRATE = null;
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/ServerProxyTC.java b/TF2 Crates/src/main/java/tf2crates/ServerProxyTC.java new file mode 100755 index 0000000..326f7e7 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/ServerProxyTC.java @@ -0,0 +1,556 @@ +package tf2crates;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import baubles.api.IBauble;
+import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry;
+import cpw.mods.fml.common.registry.GameData;
+import cpw.mods.fml.common.registry.GameRegistry;
+import net.minecraft.block.BlockFence;
+import net.minecraft.block.BlockStairs;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.Item.ToolMaterial;
+import net.minecraft.item.ItemArmor;
+import net.minecraft.item.ItemArmor.ArmorMaterial;
+import net.minecraft.item.ItemAxe;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemBow;
+import net.minecraft.item.ItemFood;
+import net.minecraft.item.ItemHoe;
+import net.minecraft.item.ItemPickaxe;
+import net.minecraft.item.ItemSlab;
+import net.minecraft.item.ItemSpade;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.ItemSword;
+import net.minecraft.item.ItemTool;
+import net.minecraft.potion.Potion;
+import net.minecraft.util.WeightedRandomChestContent;
+import net.minecraftforge.common.ChestGenHooks;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.config.Configuration;
+import net.minecraftforge.common.config.Property;
+import net.minecraftforge.common.util.EnumHelper;
+import net.minecraftforge.oredict.OreDictionary;
+import tf2crates.crate.Crates;
+import tf2crates.crate.RandomLoot;
+import tf2crates.crate.RandomRandomLoot;
+import tf2crates.handler.AnvilHandler;
+import tf2crates.handler.AttackHandler;
+import tf2crates.handler.DeathHandler;
+import tf2crates.handler.TickHandler;
+import tf2crates.item.ItemCrate;
+import tf2crates.item.ItemKey;
+import tf2crates.item.ItemKnife;
+import tf2crates.item.ItemModAxe;
+import tf2crates.item.ItemModPickaxe;
+import tf2crates.item.ItemModShovel;
+import tf2crates.item.ItemNoiseMaker;
+import tf2crates.item.ItemPaint;
+import tf2crates.item.ItemSandvich;
+import tf2crates.item.ItemScrap;
+import tf2crates.item.ItemUnusualEffect;
+
+public class ServerProxyTC {
+ public static boolean unbreakableSuperWeapons;
+ public static int keyRarity;
+ public static boolean sandvichEnabled;
+ public static boolean difficultKeyRecipe;
+ public static int numRandomCrates;
+
+ public static ToolMaterial MOD_WEAPON;
+
+ public static Item unusualEffect;
+ public static Item strangifier;
+
+ public static Item paint;
+ public static Item crate;
+ public static Item key;
+ public static Item scrap;
+
+ public static Item equalizer;
+ public static Item escapePlan;
+
+ public static Item marketGardener;
+
+ public static Item axtinguisher;
+ public static Item sharpenedVolcanoFragment;
+ public static Item powerJack;
+
+ public static Item conniversKunai;
+
+ public static Item sandvich;
+
+ public static Item noiseMakerBirthday;
+ public static Item noiseMakerSpooky;
+ public static Item noiseMakerFestive;
+
+ public void initServer() {
+ initConfig();
+
+ MOD_WEAPON = EnumHelper.addToolMaterial("MOD_WEAPON", 2,
+ unbreakableSuperWeapons ? -1 : 1561, 2F, 5F, 22);
+
+ strangifier = new Item().setUnlocalizedName("strangifier")
+ .setTextureName(ReferenceTC.ID + ":strangifier")
+ .setMaxStackSize(1).setCreativeTab(tab);
+ unusualEffect = new ItemUnusualEffect().setCreativeTab(tab);
+
+ GameRegistry.registerItem(unusualEffect, "unusualEffect");
+ GameRegistry.registerItem(strangifier, "strangifier");
+
+ paint = new ItemPaint().setCreativeTab(tab);
+ crate = new ItemCrate().setCreativeTab(tab);
+ key = new ItemKey().setCreativeTab(tab);
+ scrap = new ItemScrap().setCreativeTab(tab);
+
+ GameRegistry.registerItem(paint, "paint");
+ GameRegistry.registerItem(crate, "crate");
+ GameRegistry.registerItem(key, "key");
+ GameRegistry.registerItem(scrap, "scrap");
+
+ equalizer = new ItemModPickaxe("equalizer").setCreativeTab(tab);
+ escapePlan = new ItemModPickaxe("escapePlan").setCreativeTab(tab);
+ marketGardener = new ItemModShovel("marketGardener", 5)
+ .setCreativeTab(tab);
+ axtinguisher = new ItemModAxe("axtinguisher", 6)
+ .setCreativeTab(tab);
+ sharpenedVolcanoFragment = new ItemModAxe(
+ "sharpenedVolcanoFragment", 4).setCreativeTab(tab);
+ powerJack = new ItemModAxe("powerJack").setCreativeTab(tab);
+ conniversKunai = new ItemKnife("conniversKunai", 3)
+ .setCreativeTab(tab);
+
+ GameRegistry.registerItem(equalizer, "equalizer");
+ GameRegistry.registerItem(escapePlan, "escapePlan");
+ GameRegistry.registerItem(marketGardener, "marketGardener");
+ GameRegistry.registerItem(axtinguisher, "axtinguisher");
+ GameRegistry.registerItem(sharpenedVolcanoFragment,
+ "sharpenedVolcanoFragment");
+ GameRegistry.registerItem(powerJack, "powerJack");
+ GameRegistry.registerItem(conniversKunai, "conniversKunai");
+
+ if (sandvichEnabled) {
+ sandvich = new ItemSandvich().setCreativeTab(tab);
+ GameRegistry.registerItem(sandvich, "sandvich");
+ }
+
+ noiseMakerBirthday = new ItemNoiseMaker("noiseMakerBirthday",
+ ReferenceTC.ID + ":tf2crates.birthday")
+ .setCreativeTab(tab);
+ noiseMakerSpooky = new ItemNoiseMaker("noiseMakerSpooky",
+ "mob.blaze.breath", "mob.creeper.say", "mob.endermen.idle",
+ "mob.endermen.stare", "mob.endermen.scream",
+ "mob.ghast.charge", "mob.ghast.death", "mob.ghast.moan",
+ "mob.silverfish.say", "mob.skeleton.say",
+ "mob.skeleton.step", "mob.spider.say", "mob.zombie.say")
+ .setCreativeTab(tab);
+ noiseMakerFestive = new ItemNoiseMaker("noiseMakerFestive",
+ ReferenceTC.ID + ":tf2crates.hohohohoho",
+ ReferenceTC.ID + ":tf2crates.sleighbells")
+ .setCreativeTab(tab);
+
+ GameRegistry.registerItem(noiseMakerBirthday,
+ "noiseMakerBirthday");
+ GameRegistry.registerItem(noiseMakerSpooky, "noiseMakerSpooky");
+ GameRegistry.registerItem(noiseMakerFestive, "noiseMakerFestive");
+
+ MinecraftForge.EVENT_BUS.register(new AnvilHandler());
+ MinecraftForge.EVENT_BUS.register(new DeathHandler());
+ MinecraftForge.EVENT_BUS.register(new AttackHandler());
+
+ FMLCommonHandler.instance().bus().register(new TickHandler());
+
+ GameRegistry.addShapelessRecipe(new ItemStack(scrap, 3, 0),
+ new ItemStack(Items.iron_ingot, 1),
+ new ItemStack(Items.iron_ingot, 1),
+ new ItemStack(Items.gold_ingot, 1));
+ GameRegistry.addShapelessRecipe(new ItemStack(scrap, 1, 1),
+ new ItemStack(scrap, 1, 0), new ItemStack(scrap, 1, 0),
+ new ItemStack(scrap, 1, 0));
+ GameRegistry.addShapelessRecipe(new ItemStack(scrap, 1, 2),
+ new ItemStack(scrap, 1, 1), new ItemStack(scrap, 1, 1),
+ new ItemStack(scrap, 1, 1));
+
+ if (difficultKeyRecipe) {
+ GameRegistry.addShapelessRecipe(new ItemStack(key, 1),
+ new ItemStack(scrap, 1, 2), new ItemStack(scrap, 1, 2),
+ new ItemStack(scrap, 1, 2),
+ new ItemStack(scrap, 1, 2));
+ } else {
+ GameRegistry.addShapelessRecipe(new ItemStack(key, 1),
+ new ItemStack(scrap, 1, 2), new ItemStack(scrap, 1, 2),
+ new ItemStack(scrap, 1, 2));
+ }
+
+ GameRegistry.addShapelessRecipe(new ItemStack(strangifier, 1),
+ new ItemStack(scrap, 1, 1), new ItemStack(scrap, 1, 0),
+ new ItemStack(scrap, 1, 0));
+
+ GameRegistry.addSmelting(new ItemStack(scrap, 1, 2),
+ new ItemStack(scrap, 3, 1), 0);
+ GameRegistry.addSmelting(new ItemStack(scrap, 1, 1),
+ new ItemStack(scrap, 3, 0), 0);
+
+ OreDictionary.registerOre("dye",
+ new ItemStack(paint, 1, OreDictionary.WILDCARD_VALUE));
+
+ String[] dyes = { "Black", "Red", "Green", "Brown", "Blue",
+ "Purple", "Cyan", "LightGray", "Gray", "Pink", "Lime",
+ "Yellow", "LightBlue", "Magenta", "Orange", "White" };
+
+ for (int i = 0; i < 16; i++) {
+ OreDictionary.registerOre("dye" + dyes[i],
+ new ItemStack(paint, 1, i));
+ }
+ }
+
+ public void postInitServer() {
+ FMLControlledNamespacedRegistry<
+ Item> items = GameData.getItemRegistry();
+
+ int i;
+
+ for (Iterator<Item> iterator = items.iterator();
+ iterator.hasNext();) {
+ Item item = iterator.next();
+
+ if (item != null) {
+ if (item instanceof ItemTool) {
+ ItemTool tool = (ItemTool) item;
+
+ addToolToCategory(item, tool.func_150913_i());
+
+ if (tool instanceof ItemPickaxe) {
+ RandomLoot.PICKAXES.add(tool);
+ } else if (tool instanceof ItemSpade) {
+ RandomLoot.SHOVELS.add(tool);
+ } else if (tool instanceof ItemAxe) {
+ RandomLoot.AXES.add(tool);
+ }
+ } else if (item instanceof ItemSword) {
+ RandomLoot.SWORDS.add(item);
+
+ try {
+ addToolToCategory(item, ToolMaterial.valueOf(
+ ((ItemSword) item).getToolMaterialName()));
+ } catch (IllegalArgumentException iaex) {
+ // Do nothing. DragonAPI compatibility
+ }
+ } else if (item instanceof ItemBow) {
+ RandomLoot.BOWS.add(item);
+ } else if (item instanceof ItemHoe) {
+
+ RandomLoot.HOES.add(item);
+
+ try {
+ addToolToCategory(item, ToolMaterial.valueOf(
+ ((ItemHoe) item).getToolMaterialName()));
+ } catch (IllegalArgumentException iaex) {
+ // Do nothing. DragonAPI compatibility
+ }
+ } else if (item instanceof ItemArmor) {
+ ItemArmor armor = (ItemArmor) item;
+
+ addArmorToCategory(item, armor.getArmorMaterial());
+
+ switch (armor.armorType) {
+ case 0:
+ RandomLoot.HELMETS.add(armor);
+ break;
+ case 1:
+ RandomLoot.CHESTPLATES.add(armor);
+ break;
+ case 2:
+ RandomLoot.LEGGINGS.add(armor);
+ break;
+ case 3:
+ RandomLoot.BOOTS.add(armor);
+ break;
+ }
+ } else if (item instanceof ItemFood) {
+ RandomLoot.FOOD.add(item);
+ } else if (item instanceof ItemSlab) {
+ RandomLoot.SLABS.add(new ItemStack(item, 1));
+ } else if (item instanceof ItemBlock
+ && ((ItemBlock) item).field_150939_a instanceof BlockStairs) {
+ RandomLoot.STAIRS.add(new ItemStack(item, 1));
+ } else if (item instanceof ItemBlock
+ && ((ItemBlock) item).field_150939_a instanceof BlockFence) {
+ RandomLoot.FENCES.add(new ItemStack(item, 1));
+ } else if (item instanceof IBauble) {
+ IBauble bauble = (IBauble) item;
+
+ try {
+ switch (bauble
+ .getBaubleType(new ItemStack(item, 1))) {
+
+ case AMULET:
+ RandomLoot.AMULETS.add(item);
+ break;
+ case BELT:
+ RandomLoot.BELTS.add(item);
+ break;
+ case RING:
+ RandomLoot.RINGS.add(item);
+ break;
+ default:
+ break;
+
+ }
+ } catch (NullPointerException npex) {
+ // Do nothing, a bauble failed to load properly
+ }
+ }
+ }
+ }
+
+ for (i = 0; i < Potion.potionTypes.length; i++) {
+ RandomLoot.POTIONS
+ .add(new ItemStack(Items.potionitem, 1, 8193 + i));
+ RandomLoot.POTIONS
+ .add(new ItemStack(Items.potionitem, 1, 8225 + i));
+ RandomLoot.POTIONS
+ .add(new ItemStack(Items.potionitem, 1, 8257 + i));
+
+ RandomLoot.SPLASH_POTIONS
+ .add(new ItemStack(Items.potionitem, 1, 16385 + i));
+ RandomLoot.SPLASH_POTIONS
+ .add(new ItemStack(Items.potionitem, 1, 16417 + i));
+ RandomLoot.SPLASH_POTIONS
+ .add(new ItemStack(Items.potionitem, 1, 16449 + i));
+ }
+
+ for (String oreName : OreDictionary.getOreNames()) {
+ try {
+ if (oreName.startsWith("dust")) {
+ if (!oreName.startsWith("dustSmall")
+ && !oreName.startsWith("dustTiny")) {
+ RandomLoot.DUSTS.add(
+ OreDictionary.getOres(oreName).get(0));
+ } else {
+
+ }
+ } else if (oreName.startsWith("arrow")) {
+ RandomLoot.ARROWS
+ .add(OreDictionary.getOres(oreName).get(0));
+ } else if (oreName.startsWith("block")) {
+ RandomLoot.BLOCKS
+ .add(OreDictionary.getOres(oreName).get(0));
+ } else if (oreName.startsWith("crate")) {
+ RandomLoot.CRATES
+ .add(OreDictionary.getOres(oreName).get(0));
+ } else if (oreName.startsWith("crop")) {
+ RandomLoot.CROPS
+ .add(OreDictionary.getOres(oreName).get(0));
+ } else if (oreName.startsWith("gem")) {
+ RandomLoot.GEMS
+ .add(OreDictionary.getOres(oreName).get(0));
+ } else if (oreName.startsWith("ingot")) {
+ RandomLoot.INGOTS
+ .add(OreDictionary.getOres(oreName).get(0));
+ } else if (oreName.startsWith("ore")) {
+ RandomLoot.ORES
+ .add(OreDictionary.getOres(oreName).get(0));
+ } else if (oreName.startsWith("seed")) {
+ RandomLoot.SEEDS
+ .add(OreDictionary.getOres(oreName).get(0));
+ } else if (oreName.startsWith("stone")) {
+ RandomLoot.STONES
+ .addAll(OreDictionary.getOres(oreName));
+ } else if (oreName.startsWith("toolHead")) {
+ RandomLoot.TOOL_HEADS
+ .add(OreDictionary.getOres(oreName).get(0));
+ }
+ } catch (IndexOutOfBoundsException ioobex) {
+ // Do nothing. Handle someone giving us a oredict entry
+ // without anything actually in it
+ }
+ }
+
+ RandomLoot.GLASS.addAll(OreDictionary.getOres("blockGlass"));
+ RandomLoot.GLASS.addAll(OreDictionary.getOres("paneGlass"));
+
+ RandomLoot.WOOL.addAll(OreDictionary.getOres("blockCloth"));
+
+ RandomLoot.DYES.addAll(OreDictionary.getOres("dye"));
+
+ RandomLoot.LOGS.addAll(OreDictionary.getOres("logWood"));
+
+ RandomLoot.PLANKS.addAll(OreDictionary.getOres("plankWood"));
+
+ RandomLoot.RECORDS.addAll(OreDictionary.getOres("record"));
+
+ RandomLoot.SAPLINGS.addAll(OreDictionary.getOres("treeSapling"));
+
+ RandomRandomLoot.init();
+
+ Crates.init();
+
+ WeightedRandomChestContent keyWRCC = new WeightedRandomChestContent(
+ new ItemStack(key, 1), 1, 1, keyRarity);
+
+ ChestGenHooks.addItem(ChestGenHooks.DUNGEON_CHEST, keyWRCC);
+
+ ChestGenHooks.addItem(ChestGenHooks.BONUS_CHEST, keyWRCC);
+
+ ChestGenHooks.addItem(ChestGenHooks.MINESHAFT_CORRIDOR, keyWRCC);
+
+ ChestGenHooks.addItem(ChestGenHooks.PYRAMID_DESERT_CHEST, keyWRCC);
+
+ ChestGenHooks.addItem(ChestGenHooks.PYRAMID_JUNGLE_CHEST, keyWRCC);
+
+ ChestGenHooks.addItem(ChestGenHooks.VILLAGE_BLACKSMITH, keyWRCC);
+
+ ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CORRIDOR, keyWRCC);
+ ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CROSSING, keyWRCC);
+ ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_LIBRARY, keyWRCC);
+ }
+
+ public void initClient() {
+ }
+
+ public static CreativeTabs tab = new CreativeTabs("tf2Crates") {
+ @Override
+ public Item getTabIconItem() {
+ return crate;
+ }
+ };
+
+ private static void addToolToCategory(Item item,
+ ToolMaterial material) {
+ ArrayList<Item> list = RandomLoot.MATERIAL_TOOLS.get(material);
+
+ if (list == null) {
+ list = new ArrayList<Item>();
+ }
+
+ list.add(item);
+
+ RandomLoot.MATERIAL_TOOLS.remove(material);
+ RandomLoot.MATERIAL_TOOLS.put(material, list);
+ }
+
+ private static void addArmorToCategory(Item armor,
+ ArmorMaterial material) {
+ ArrayList<Item> list = RandomLoot.MATERIAL_ARMOR.get(material);
+
+ if (list == null) {
+ list = new ArrayList<Item>();
+ }
+
+ list.add(armor);
+
+ RandomLoot.MATERIAL_ARMOR.remove(material);
+ RandomLoot.MATERIAL_ARMOR.put(material, list);
+ }
+
+ private static void initConfig() {
+ Configuration config = new Configuration(
+ new File("./config/TF2 Crates.cfg"), true);
+
+ config.load();
+
+ Property prop = config.get("Chances",
+ "Chance of Crate from Mob Death", new int[] { 5, 100 });
+
+ prop.comment = "default: 5 out of 100 (5% chance)";
+
+ DeathHandler.crateChance = prop.getIntList();
+
+ prop = config.get("Chances", "Chance of Key from Mob Death",
+ new int[] { 2, 100 });
+
+ prop.comment = "default: 2 out of 100 (2% chance)";
+
+ DeathHandler.keyChance = prop.getIntList();
+
+ prop = config.get("Chances", "Chance of Unusual Effect",
+ new int[] { 2, 100 });
+
+ prop.comment = "default: 2 out of 100 (2% chance)";
+
+ ItemCrate.unusualChance = prop.getIntList();
+
+ prop = config.get("Chances", "Chance of Rare Weapon",
+ new int[] { 5, 100 });
+
+ prop.comment = "default: 5 out of 100 (5% chance)";
+
+ ItemCrate.weaponChance = prop.getIntList();
+
+ prop = config.get("Chances", "Key Rarity", 25);
+
+ prop.comment = "default: 25 | The rarity of keys generated inside of chests. The lower the rarer.";
+
+ keyRarity = prop.getInt();
+
+ prop = config.get("Recipe Tweaks", "Keys are Hard to Make", false);
+
+ prop.comment = "default: false | If false, keys cost 3 refined. If true, keys cost 4 refined.";
+
+ difficultKeyRecipe = prop.getBoolean();
+
+ prop = config.get("Weapons",
+ "Market Gardener Minimum Fall Distance", 0.75D);
+
+ prop.comment = "default: 0.75 | This is to prevent players from just jumping to get the crit :)";
+
+ AttackHandler.marketGardenerMinimumFall = prop.getDouble();
+
+ prop = config.get("Unusual Effect Stuff", "Repair Hat", true);
+
+ prop.comment = "default: true | If true, the helmet is repaired when combined with an unusual effect.";
+
+ AnvilHandler.repairHat = prop.getBoolean();
+
+ prop = config.get("Unusual Effect Stuff", "Make Hat Unbreakable",
+ true);
+
+ prop.comment = "default: false | If true, the helmet is made unbreakable when combined with an unusual effect.";
+
+ AnvilHandler.makeUnbreakable = prop.getBoolean();
+
+ prop = config.get("Weapons", "Unbreakable Rare Weapons", true);
+
+ prop.comment = "default: true | If true, all weapons added by this mod are unbrekable.";
+
+ unbreakableSuperWeapons = prop.getBoolean();
+
+ prop = config.get("Anvil Recipes", "Strangifier Cost", 15);
+
+ prop.comment = "default: 15 | The cost of adding a strangifier to an item.";
+
+ AnvilHandler.strangeCost = prop.getInt();
+
+ prop = config.get("Anvil Recipes", "Unusual Cost", 30);
+
+ prop.comment = "default: 30 | The cost of adding an unusual effect to a helmet.";
+
+ AnvilHandler.unusualCost = prop.getInt();
+
+ prop = config.get("Weapons", "Backstab Difficulty", 0.95D);
+
+ prop.comment = "default: 0.95D | The lower, the more difficult it is to get a backstab. 1 is very easy, and 0 is impossible.";
+
+ ItemKnife.backstabDifficulty = prop.getDouble();
+
+ prop = config.get("Weapons", "Enable Sandvich", true);
+
+ prop.comment = "default: true | If true, enables the sandvich.";
+
+ sandvichEnabled = prop.getBoolean();
+
+ prop = config.get("Chances", "Random Crates", 64);
+
+ prop.comment = "Number of series of crates with randomly determined loot to create";
+
+ numRandomCrates = prop.getInt();
+
+ config.save();
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/TF2Crates.java b/TF2 Crates/src/main/java/tf2crates/TF2Crates.java new file mode 100755 index 0000000..4670a31 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/TF2Crates.java @@ -0,0 +1,34 @@ +package tf2crates;
+
+import static tf2crates.ReferenceTC.ID;
+import static tf2crates.ReferenceTC.NAME;
+import static tf2crates.ReferenceTC.VERSION;
+
+import cpw.mods.fml.common.Mod;
+import cpw.mods.fml.common.Mod.EventHandler;
+import cpw.mods.fml.common.Mod.Instance;
+import cpw.mods.fml.common.SidedProxy;
+import cpw.mods.fml.common.event.FMLPostInitializationEvent;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+
+@Mod(modid = ID, name = NAME, version = VERSION,
+ dependencies = "required-after:tlhpoeCore")
+public class TF2Crates { // TODO: Release
+ @Instance(ID)
+ public static TF2Crates instance;
+
+ @SidedProxy(clientSide = ID + ".ClientProxyTC",
+ serverSide = ID + ".ServerProxyTC")
+ public static ServerProxyTC proxy;
+
+ @EventHandler
+ public void preInit(FMLPreInitializationEvent event) {
+ proxy.initServer();
+ proxy.initClient();
+ }
+
+ @EventHandler
+ public void postInit(FMLPostInitializationEvent event) {
+ proxy.postInitServer();
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/crate/Crates.java b/TF2 Crates/src/main/java/tf2crates/crate/Crates.java new file mode 100755 index 0000000..542b88a --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/crate/Crates.java @@ -0,0 +1,313 @@ +package tf2crates.crate;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.Item.ToolMaterial;
+import net.minecraft.item.ItemArmor.ArmorMaterial;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StatCollector;
+import tf2crates.ServerProxyTC;
+import tlhpoeCore.ReferenceT;
+import tlhpoeCore.util.MathUtil;
+
+public class Crates {
+ public static final Map<Integer,
+ Object[]> CRATE_LOOT = new HashMap<
+ Integer, Object[]>();
+ public static final Map<String,
+ Integer> SPECIAL_CRATES = new HashMap<
+ String, Integer>();
+ public static final Map<Integer,
+ String> SCRATES_REVERSE = new HashMap<
+ Integer, String>();
+
+ public static void init() {
+ addNormalCrates();
+
+ addSpecialCrates();
+
+ List<Integer> IDs = new ArrayList<Integer>();
+ List<String> names = new ArrayList<String>();
+
+ IDs.addAll(SPECIAL_CRATES.values());
+ names.addAll(SPECIAL_CRATES.keySet());
+
+ for (int i = 0; i < SPECIAL_CRATES.size(); i++) {
+ SCRATES_REVERSE.put(IDs.get(i), names.get(i));
+ }
+
+ if (ReferenceT.DEOBFUSCATED) {
+ for (int i = 1; i < getNumberOfSeries() + 1; i++) {
+ Object[] lootItems = getLootForCrate(i);
+
+ if (SPECIAL_CRATES.containsValue(i)) {
+ System.out.println("* '''"
+ + StatCollector.translateToLocal("crate."
+ + SCRATES_REVERSE.get(i) + ".name")
+ + "''' <br />");
+ } else {
+ System.out.println(
+ "* '''Crate Series #" + i + "''' <br />");
+ }
+
+ for (int j = 0; j < lootItems.length; j++) {
+ Object loot = lootItems[j];
+ String name = null;
+
+ if (loot instanceof ItemStack) {
+ name = ((ItemStack) loot).getDisplayName();
+ } else if (loot instanceof RandomLoot) {
+ name = ((RandomLoot) loot).getDisplayName();
+ }
+
+ System.out.println("** " + name + " <br />");
+ }
+
+ System.out
+ .println("** or an Exceedingly Rare Special Item!"
+ + " <br /> <br />");
+ System.out.println(" ");
+ }
+ }
+ }
+
+ private static void addSpecialCrates() {
+ addSpecialCrateLoot("spookyCrate",
+ new ItemStack(ServerProxyTC.noiseMakerSpooky, 1),
+ new RandomLoot.SpecificItem(Items.emerald, 8, 16),
+ new RandomLoot.SpecificItem(Items.diamond, 8, 16),
+ new RandomLoot.SpecificItem(Items.gold_ingot, 16, 32),
+ new RandomLoot.SpecificItem(Items.iron_ingot, 32, 64),
+ new RandomLoot.SpecificItem(Items.cookie, 48, 64));
+
+ addSpecialCrateLoot("festiveCrate",
+ new ItemStack(ServerProxyTC.noiseMakerFestive, 1),
+ new RandomLoot.SpecificItem(Items.emerald, 8, 16),
+ new RandomLoot.SpecificItem(Items.diamond, 8, 16),
+ new RandomLoot.SpecificItem(Items.gold_ingot, 16, 32),
+ new RandomLoot.SpecificItem(Items.iron_ingot, 32, 64),
+ new RandomLoot.SpecificItem(Items.experience_bottle, 48,
+ 64));
+
+ addSpecialCrateLoot("birthdayCrate",
+ new ItemStack(ServerProxyTC.noiseMakerBirthday, 1),
+ new RandomLoot.SpecificItem(Items.emerald, 8, 16),
+ new RandomLoot.SpecificItem(Items.diamond, 8, 16),
+ new RandomLoot.SpecificItem(Items.gold_ingot, 16, 32),
+ new RandomLoot.SpecificItem(Items.iron_ingot, 32, 64),
+ new RandomLoot.SpecificItem(Items.cake, 16, 64));
+ }
+
+ private static void addNormalCrates() {
+ addCrateLoot(new ItemStack(Items.name_tag, 1),
+ new ItemStack(ServerProxyTC.paint, 1, 0),
+ new ItemStack(ServerProxyTC.paint, 1, 15),
+ new RandomLoot.Pickaxe(true));
+
+ addCrateLoot(new RandomLoot.Pickaxe(true),
+ new RandomLoot.Sword(true), new RandomLoot.EnchantedBook(),
+ new RandomLoot.Food());
+
+ addCrateLoot(new RandomLoot.Food(), new RandomLoot.Potion(),
+ new RandomLoot.Chestplate(false),
+ new RandomLoot.Boot(false));
+
+ addCrateLoot(new ItemStack(Items.nether_wart, 32),
+ new RandomLoot.SpecificItem(Items.blaze_rod, 16, 32),
+ new RandomLoot.SpecificItem(Items.ghast_tear, 8, 16),
+ new RandomLoot.SpecificItem(
+ Item.getItemFromBlock(Blocks.enchanting_table), 2,
+ 4),
+ new RandomLoot.SpecificItem(
+ Item.getItemFromBlock(Blocks.beacon), 2, 4));
+
+ addCrateLoot(new ItemStack(Items.name_tag, 1),
+ new ItemStack(ServerProxyTC.paint, 1, 7),
+ new ItemStack(ServerProxyTC.paint, 1, 8),
+ new RandomLoot.Hoe(true));
+
+ addCrateLoot(new RandomLoot.Food(), new RandomLoot.Potion(),
+ new RandomLoot.Axe(false), new RandomLoot.Sword(false));
+
+ addCrateLoot(new ItemStack(Items.name_tag, 1),
+ new ItemStack(ServerProxyTC.paint, 1, 1),
+ new ItemStack(ServerProxyTC.paint, 1, 14),
+ new RandomLoot.Shovel(true));
+
+ addCrateLoot(new RandomLoot.Shovel(true), new RandomLoot.Axe(true),
+ new RandomLoot.EnchantedBook(), new RandomLoot.Food());
+
+ addCrateLoot(new RandomLoot.Pickaxe(false),
+ new RandomLoot.Shovel(false), new RandomLoot.Axe(false),
+ new RandomLoot.Sword(false), new RandomLoot.Hoe(false));
+
+ addCrateLoot(new ItemStack(Items.name_tag, 1),
+ new ItemStack(ServerProxyTC.paint, 1, 5),
+ new ItemStack(ServerProxyTC.paint, 1, 10),
+ new RandomLoot.Shovel(true));
+
+ addCrateLoot(new ItemStack(ServerProxyTC.paint, 1, 12),
+ new RandomLoot.CertainMaterialArmor(ArmorMaterial.DIAMOND,
+ true),
+ new RandomLoot.CertainMaterialTool(ToolMaterial.EMERALD,
+ true));
+
+ addCrateLoot(new RandomLoot.Helmet(true),
+ new RandomLoot.Legging(true),
+ new RandomLoot.EnchantedBook(), new RandomLoot.Food());
+
+ addCrateLoot(
+ new RandomLoot.SpecificItem(Items.carrot_on_a_stick, 1, 4),
+ new RandomLoot.SpecificItem(Items.bone, 32, 64),
+ new RandomLoot.Food(),
+ new RandomLoot.SpecificItem(Items.nether_star, 1, 4),
+ new RandomLoot.Pickaxe(true));
+
+ addCrateLoot(new ItemStack(Items.name_tag, 1),
+ new ItemStack(ServerProxyTC.paint, 1, 2),
+ new ItemStack(ServerProxyTC.paint, 1, 13),
+ new RandomLoot.Sword(true));
+
+ addCrateLoot(new RandomLoot.Food(), new RandomLoot.SplashPotion(),
+ new RandomLoot.Shovel(false),
+ new RandomLoot.Pickaxe(false));
+
+ addCrateLoot(new ItemStack(Items.name_tag, 1),
+ new ItemStack(ServerProxyTC.paint, 1, 3),
+ new ItemStack(ServerProxyTC.paint, 1, 12),
+ new RandomLoot.Axe(true));
+
+ addCrateLoot(new RandomLoot.Helmet(false),
+ new RandomLoot.Legging(false), new RandomLoot.Boot(false),
+ new RandomLoot.Axe(false), new RandomLoot.Hoe(false));
+
+ addCrateLoot(new ItemStack(ServerProxyTC.paint, 1, 11),
+ new RandomLoot.CertainMaterialArmor(ArmorMaterial.GOLD,
+ true),
+ new RandomLoot.CertainMaterialTool(ToolMaterial.GOLD,
+ true));
+
+ addCrateLoot(new RandomLoot.Chestplate(true),
+ new RandomLoot.Boot(true), new RandomLoot.Shovel(true),
+ new RandomLoot.Axe(true));
+
+ addCrateLoot(new RandomLoot.Hoe(true), new RandomLoot.Axe(true),
+ new RandomLoot.EnchantedBook(), new RandomLoot.Food());
+
+ addCrateLoot(new ItemStack(Items.name_tag, 1),
+ new ItemStack(ServerProxyTC.paint, 1, 6),
+ new ItemStack(ServerProxyTC.paint, 1, 9),
+ new RandomLoot.Pickaxe(true));
+
+ addCrateLoot(new RandomLoot.Chestplate(false),
+ new RandomLoot.Pickaxe(false), new RandomLoot.Sword(true),
+ new RandomLoot.Food(), new RandomLoot.Boot(true));
+
+ addCrateLoot(new RandomLoot.Food(), new RandomLoot.SplashPotion(),
+ new RandomLoot.Helmet(true), new RandomLoot.Legging(true),
+ new RandomLoot.Chestplate(false));
+
+ addCrateLoot(new RandomLoot.Chestplate(true),
+ new RandomLoot.Boot(true), new RandomLoot.EnchantedBook(),
+ new RandomLoot.Food());
+
+ addCrateLoot(new ItemStack(Items.name_tag, 1),
+ new ItemStack(ServerProxyTC.paint, 1, 4),
+ new ItemStack(ServerProxyTC.paint, 1, 11),
+ new RandomLoot.Sword(true));
+
+ addCrateLoot(new RandomLoot.Helmet(false),
+ new RandomLoot.Chestplate(false),
+ new RandomLoot.Legging(false), new RandomLoot.Boot(false));
+
+ addCrateLoot(new RandomLoot.Paint(), new RandomLoot.Potion(),
+ new RandomLoot.SplashPotion(), new RandomLoot.Food());
+
+ addCrateLoot(new ItemStack(ServerProxyTC.paint, 1, 7),
+ new RandomLoot.CertainMaterialArmor(ArmorMaterial.IRON,
+ true),
+ new RandomLoot.CertainMaterialTool(ToolMaterial.IRON,
+ true));
+
+ addCrateLoot(new RandomLoot.Helmet(true),
+ new RandomLoot.Legging(true), new RandomLoot.Pickaxe(true),
+ new RandomLoot.Sword(true));
+
+ addCrateLoot(new RandomLoot.EnchantedBook(), new RandomLoot.Food(),
+ new RandomLoot.Paint(), new RandomLoot.FishingRod());
+
+ addCrateLoot(new RandomLoot.Bow(true), new RandomLoot.Arrow(),
+ new RandomLoot.FishingRod(),
+ new RandomLoot.SplashPotion());
+
+ addCrateLoot(new RandomLoot.SpecificItem(Items.dye, 16, 32, 15),
+ new RandomLoot.Hoe(true), new RandomLoot.Seed(),
+ new RandomLoot.Saplings());
+
+ addCrateLoot(new RandomLoot.Amulet(), new RandomLoot.Belt(),
+ new RandomLoot.Ring());
+
+ // Add in random random crates - per MC load
+ for (int i = 0; i < ServerProxyTC.numRandomCrates; i++) {
+ int numInCrate = MathUtil.getRandomIntegerBetween(0, 2) + 3;
+
+ List<RandomLoot> crateContents = new ArrayList<RandomLoot>(numInCrate);
+
+ for (int j = 0; j < numInCrate; j++) {
+ RandomLoot possibleLoot = RandomRandomLoot.getRandomLoot();
+
+ while (crateContents.contains(possibleLoot)) {
+ possibleLoot = RandomRandomLoot.getRandomLoot();
+ }
+
+ crateContents.add(possibleLoot);
+ }
+
+ CRATE_LOOT.put(CRATE_LOOT.size() + 1, crateContents.toArray());
+ }
+ }
+
+ private static void addCrateLoot(Object... lootItems) {
+ CRATE_LOOT.put(CRATE_LOOT.size() + 1, lootItems);
+ }
+
+ public static Object[] getLootForCrate(int series) {
+ return CRATE_LOOT.get(series);
+ }
+
+ public static int getNumberOfSeries() {
+ return CRATE_LOOT.size();
+ }
+
+ private static void addSpecialCrateLoot(String name,
+ Object... lootItems) {
+ addCrateLoot(lootItems);
+ SPECIAL_CRATES.put(name, CRATE_LOOT.size());
+ }
+
+ public static Object[] getLootForSpecialCreate(String crateName) {
+ return CRATE_LOOT.get(SPECIAL_CRATES.get(crateName));
+ }
+
+ public static String getNameFromSeries(int series) {
+ return SCRATES_REVERSE.get(series);
+ }
+
+ public static boolean isSeriesSpecial(int series) {
+ return SPECIAL_CRATES.containsValue(series);
+ }
+
+ public static int getNumberOfSpecialCrates() {
+ return SPECIAL_CRATES.size();
+ }
+
+ public static int getSeriesFromName(String name) {
+ return SPECIAL_CRATES.get(name);
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/crate/RandomLoot.java b/TF2 Crates/src/main/java/tf2crates/crate/RandomLoot.java new file mode 100755 index 0000000..ee7ef5a --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/crate/RandomLoot.java @@ -0,0 +1,1065 @@ +package tf2crates.crate;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnchantmentData;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.Item.ToolMaterial;
+import net.minecraft.item.ItemArmor.ArmorMaterial;
+import net.minecraft.item.ItemStack;
+import tf2crates.ServerProxyTC;
+import tf2crates.item.ItemPaint;
+import tlhpoeCore.util.MathUtil;
+
+public abstract class RandomLoot {
+ private static int nextID = 0;
+ private int ID;
+
+ private List<Item> possibleLoot;
+ protected boolean enchanted;
+ public int min = 1, max = 1;
+
+ protected RandomLoot(List<Item> possibleLoot, boolean enchanted) {
+ this.possibleLoot = possibleLoot;
+ this.enchanted = enchanted;
+
+ ID = nextID++;
+ }
+
+ public ItemStack getLoot() {
+ ItemStack loot = new ItemStack(
+ possibleLoot.get(MathUtil.nextInt(possibleLoot.size())),
+ MathUtil.getRandomIntegerBetween(min, max));
+
+ if (enchanted) {
+ EnchantmentHelper.addRandomEnchantment(MathUtil.getRandom(),
+ loot, MathUtil.getRandomIntegerBetween(25, 30));
+ }
+
+ return loot;
+ }
+
+ public abstract String getDisplayName();
+
+ public int getID() {
+ return ID;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ID;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ RandomLoot other = (RandomLoot) obj;
+
+ if (ID != other.ID) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public static class SpecificItem extends RandomLoot {
+ private ItemStack itemStack;
+ private Item item;
+ private int meta = -1;
+
+ public SpecificItem(Item item, int min, int max) {
+ super(null, false);
+
+ this.itemStack = new ItemStack(item, 1);
+ this.item = item;
+ this.min = min;
+ this.max = max;
+ }
+
+ public SpecificItem(Item item, int min, int max, int meta) {
+ this(item, min, max);
+
+ this.meta = meta;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return min != max ? (min + " to " + max + " "
+ + itemStack.getDisplayName() + (min > 1 ? "s" : ""))
+ : ((min > 1 ? (min + " ") : "A ")
+ + itemStack.getDisplayName()
+ + (min > 1 ? "s" : ""));
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ return new ItemStack(item,
+ MathUtil.getRandomIntegerBetween(min, max), meta);
+ }
+ }
+
+ public static class Pickaxe extends RandomLoot {
+ public Pickaxe(boolean enchanted) {
+ super(PICKAXES, enchanted);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return enchanted ? "An Enchanted Random Pickaxe"
+ : "A Random Pickaxe";
+ }
+ }
+
+ public static class Shovel extends RandomLoot {
+ public Shovel(boolean enchanted) {
+ super(SHOVELS, enchanted);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return enchanted ? "An Enchanted Random Shovel"
+ : "A Random Shovel";
+ }
+ }
+
+ public static class Axe extends RandomLoot {
+ public Axe(boolean enchanted) {
+ super(AXES, enchanted);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return enchanted ? "An Enchanted Random Axe" : "A Random Axe";
+ }
+ }
+
+ public static class Hoe extends RandomLoot {
+ public Hoe(boolean enchanted) {
+ super(HOES, enchanted);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return enchanted ? "An Enchanted Random Hoe" : "A Random Hoe";
+ }
+ }
+
+ public static class ToolHead extends RandomLoot {
+ public ToolHead() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack head = TOOL_HEADS
+ .get(MathUtil.getRandomIntegerBetween(0,
+ RandomLoot.TOOL_HEADS.size()))
+ .copy();
+
+ return head;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "A Random Tool Head";
+ }
+
+ }
+
+ public static class Sword extends RandomLoot {
+ public Sword(boolean enchanted) {
+ super(SWORDS, enchanted);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return enchanted ? "An Enchanted Random Sword"
+ : "A Random Sword";
+ }
+ }
+
+ public static class Bow extends RandomLoot {
+ public Bow(boolean enchanted) {
+ super(BOWS, enchanted);
+
+ this.min = 1;
+ this.max = 1;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return enchanted ? "An Enchanted Random Bow" : "A Random Bow";
+ }
+ }
+
+ public static class Seed extends RandomLoot {
+ public Seed() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack seedType = SEEDS
+ .get(MathUtil.getRandomIntegerBetween(0, SEEDS.size()))
+ .copy();
+
+ seedType.stackSize = MathUtil.getRandomIntegerBetween(16, 32);
+
+ return seedType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 32 Seeds of a Random Type";
+ }
+ }
+
+ public static class Saplings extends RandomLoot {
+ public Saplings() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack saplingType = SAPLINGS.get(
+ MathUtil.getRandomIntegerBetween(0, SAPLINGS.size()))
+ .copy();
+
+ saplingType.stackSize = MathUtil.getRandomIntegerBetween(16,
+ 32);
+
+ return saplingType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 32 Saplings of a Random Type";
+ }
+ }
+
+ public static class Arrow extends RandomLoot {
+ public Arrow() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack arrowType = ARROWS.get(
+ MathUtil.getRandomIntegerBetween(0, ARROWS.size()))
+ .copy();
+
+ arrowType.stackSize = MathUtil.getRandomIntegerBetween(16, 32);
+
+ return arrowType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 32 Arrows of a Random Type";
+ }
+ }
+
+ public static class Helmet extends RandomLoot {
+ public Helmet(boolean enchanted) {
+ super(HELMETS, enchanted);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return enchanted ? "An Enchanted Random Helmet"
+ : "A Random Helmet";
+ }
+ }
+
+ public static class Chestplate extends RandomLoot {
+ public Chestplate(boolean enchanted) {
+ super(CHESTPLATES, enchanted);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return enchanted ? "An Enchanted Random Chestplate"
+ : "A Random Chestplate";
+ }
+ }
+
+ public static class Legging extends RandomLoot {
+ public Legging(boolean enchanted) {
+ super(LEGGINGS, enchanted);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return enchanted ? "Enchanted Random Leggings"
+ : "Random Leggings";
+ }
+ }
+
+ public static class Boot extends RandomLoot {
+ public Boot(boolean enchanted) {
+ super(BOOTS, enchanted);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return enchanted ? "Enchanted Random Boots" : "Random Boots";
+ }
+ }
+
+ public static class Food extends RandomLoot {
+ public Food() {
+ super(FOOD, false);
+
+ this.min = 16;
+ this.max = 64;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 64 of a Random Food Item";
+ }
+ }
+
+ public static class Potion extends RandomLoot {
+ public Potion() {
+ super(null, false);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "4 to 16 of a Random Potion";
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack loot = POTIONS.get(MathUtil.nextInt(POTIONS.size()))
+ .copy();
+
+ loot.stackSize = MathUtil.getRandomIntegerBetween(4, 16);
+
+ return loot;
+ }
+ }
+
+ public static class SplashPotion extends RandomLoot {
+ public SplashPotion() {
+ super(null, false);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "4 to 16 of a Random Splash Potion";
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack loot = SPLASH_POTIONS
+ .get(MathUtil.nextInt(SPLASH_POTIONS.size())).copy();
+
+ loot.stackSize = MathUtil.getRandomIntegerBetween(4, 16);
+
+ return loot;
+ }
+ }
+
+ public static class CertainMaterialTool extends RandomLoot {
+ private ToolMaterial material;
+
+ public CertainMaterialTool(ToolMaterial material,
+ boolean enchanted) {
+ super(MATERIAL_TOOLS.get(material), enchanted);
+
+ this.material = material;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return enchanted
+ ? "Enchanted Random " + material.name() + " Tool"
+ : "Random " + material.name() + " Tool";
+ }
+ }
+
+ public static class CertainMaterialArmor extends RandomLoot {
+ private ArmorMaterial material;
+
+ public CertainMaterialArmor(ArmorMaterial material,
+ boolean enchanted) {
+ super(MATERIAL_ARMOR.get(material), enchanted);
+
+ this.material = material;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return enchanted
+ ? "Enchanted Random " + material.name() + " Armor"
+ : "Random " + material.name() + " Armor";
+ }
+ }
+
+ public static class Paint extends RandomLoot {
+ public Paint() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ int dmg = MathUtil.nextInt(ItemPaint.TYPES.length);
+
+ if (MathUtil.getChance(1, 50)) {
+ dmg = 11;
+ }
+
+ return new ItemStack(ServerProxyTC.paint, 1, dmg);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "A Random Paint";
+ }
+ }
+
+ public static class EnchantedBook extends RandomLoot {
+ public EnchantedBook() {
+ super(null, true);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack loot = new ItemStack(Items.enchanted_book,
+ MathUtil.getRandomIntegerBetween(2, 8));
+ Enchantment enchantment = Enchantment.enchantmentsBookList[MathUtil
+ .nextInt(Enchantment.enchantmentsBookList.length)];
+
+ Items.enchanted_book.addEnchantment(loot,
+ new EnchantmentData(enchantment,
+ MathUtil.getRandomIntegerBetween(
+ enchantment.getMinLevel(),
+ enchantment.getMaxLevel())));
+
+ return loot;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "2 to 8 Random Enchanted Books";
+ }
+ }
+
+ public static class FishingRod extends RandomLoot {
+ public FishingRod() {
+ super(null, true);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack loot = new ItemStack(Items.fishing_rod, 1);
+
+ EnchantmentHelper.addRandomEnchantment(MathUtil.getRandom(),
+ loot, 30);
+
+ return loot;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "A Randomly Enchanted Fishing Rod";
+ }
+ }
+
+ public static class Slab extends RandomLoot {
+ public Slab() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack slabType = SLABS
+ .get(MathUtil.getRandomIntegerBetween(0, SLABS.size()))
+ .copy();
+
+ slabType.stackSize = MathUtil.getRandomIntegerBetween(16, 64);
+
+ return slabType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 64 Slabs of a Random Type";
+ }
+ }
+
+ public static class Stair extends RandomLoot {
+ public Stair() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack stairType = STAIRS.get(
+ MathUtil.getRandomIntegerBetween(0, STAIRS.size()))
+ .copy();
+
+ stairType.stackSize = MathUtil.getRandomIntegerBetween(16, 64);
+
+ return stairType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 64 Stairs of a Random Type";
+ }
+ }
+
+ public static class Fence extends RandomLoot {
+ public Fence() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack fenceType = FENCES.get(
+ MathUtil.getRandomIntegerBetween(0, FENCES.size()))
+ .copy();
+
+ fenceType.stackSize = MathUtil.getRandomIntegerBetween(16, 64);
+
+ return fenceType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 64 Fences of a Random Type";
+ }
+ }
+
+ public static class Planks extends RandomLoot {
+ public Planks() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack plankType = PLANKS.get(
+ MathUtil.getRandomIntegerBetween(0, PLANKS.size()))
+ .copy();
+
+ plankType.stackSize = MathUtil.getRandomIntegerBetween(16, 64);
+
+ return plankType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 64 Planks of a Random Type";
+ }
+ }
+
+ public static class Logs extends RandomLoot {
+ public Logs() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack logType = LOGS
+ .get(MathUtil.getRandomIntegerBetween(0, LOGS.size()))
+ .copy();
+
+ logType.stackSize = MathUtil.getRandomIntegerBetween(16, 32);
+
+ return logType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 32 Logs of a Random Type";
+ }
+ }
+
+ public static class Crop extends RandomLoot {
+ public Crop() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack cropType = CROPS
+ .get(MathUtil.getRandomIntegerBetween(0, CROPS.size()))
+ .copy();
+
+ cropType.stackSize = MathUtil.getRandomIntegerBetween(16, 32);
+
+ return cropType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "8 to 16 Crops of a Random Type";
+ }
+ }
+
+ public static class Dye extends RandomLoot {
+ public Dye() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack dyeType = DYES
+ .get(MathUtil.getRandomIntegerBetween(0, DYES.size()))
+ .copy();
+
+ dyeType.stackSize = MathUtil.getRandomIntegerBetween(16, 32);
+
+ return dyeType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 32 Logs of a Random Type";
+ }
+ }
+
+ public static class Record extends RandomLoot {
+ public Record() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack dyeType = RECORDS.get(
+ MathUtil.getRandomIntegerBetween(0, RECORDS.size()))
+ .copy();
+
+ dyeType.stackSize = 1;
+
+ return dyeType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "A Random Record";
+ }
+ }
+
+ public static class Glass extends RandomLoot {
+ public Glass() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack glassType = GLASS.get(MathUtil
+ .getRandomIntegerBetween(0, RandomLoot.GLASS.size()))
+ .copy();
+
+ glassType.stackSize = MathUtil.getRandomIntegerBetween(32, 64);
+
+ return glassType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "32 to 64 Glass of a Random Type";
+ }
+ }
+
+ public static class Wool extends RandomLoot {
+ public Wool() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack woolType = WOOL.get(MathUtil
+ .getRandomIntegerBetween(0, RandomLoot.WOOL.size()))
+ .copy();
+
+ woolType.stackSize = MathUtil.getRandomIntegerBetween(8, 32);
+
+ return woolType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "8 to 32 Wool of a Random Type";
+ }
+ }
+
+ public static class Stone extends RandomLoot {
+ public Stone() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack stoneType = STONES.get(MathUtil
+ .getRandomIntegerBetween(0, RandomLoot.STONES.size()))
+ .copy();
+
+ stoneType.stackSize = MathUtil.getRandomIntegerBetween(16, 48);
+
+ return stoneType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 48 Stone of a Random Type";
+ }
+ }
+
+ public static class Dust extends RandomLoot {
+ public Dust() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack dustType = RandomLoot.DUSTS.get(MathUtil
+ .getRandomIntegerBetween(0, RandomLoot.DUSTS.size()))
+ .copy();
+
+ dustType.stackSize = MathUtil.getRandomIntegerBetween(8, 16);
+
+ return dustType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "8 to 16 Dust of a Random Type";
+ }
+ }
+
+ public static class Block extends RandomLoot {
+ public Block() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack blockType = RandomLoot.DUSTS.get(MathUtil
+ .getRandomIntegerBetween(0, RandomLoot.DUSTS.size()))
+ .copy();
+
+ blockType.stackSize = MathUtil.getRandomIntegerBetween(4, 8);
+
+ return blockType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "4 to 8 Random Blocks";
+ }
+ }
+
+ public static class Crate extends RandomLoot {
+ public Crate() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack crateType = RandomLoot.CRATES.get(MathUtil
+ .getRandomIntegerBetween(0, RandomLoot.CRATES.size()))
+ .copy();
+
+ crateType.stackSize = MathUtil.getRandomIntegerBetween(4, 8);
+
+ return crateType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "4 to 8 Storage Crates of a Random Type";
+ }
+ }
+
+ public static class Gem extends RandomLoot {
+ public Gem() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack gemType = RandomLoot.GEMS.get(MathUtil
+ .getRandomIntegerBetween(0, RandomLoot.GEMS.size()))
+ .copy();
+
+ gemType.stackSize = MathUtil.getRandomIntegerBetween(8, 16);
+
+ return gemType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "8 to 16 Gems of a Random Type";
+ }
+ }
+
+ public static class Ingot extends RandomLoot {
+ public Ingot() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack ingotType = RandomLoot.INGOTS.get(MathUtil
+ .getRandomIntegerBetween(0, RandomLoot.INGOTS.size()))
+ .copy();
+
+ ingotType.stackSize = MathUtil.getRandomIntegerBetween(16, 32);
+
+ return ingotType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 32 Ingots of a Random Type";
+ }
+ }
+
+ public static class Ore extends RandomLoot {
+ public Ore() {
+ super(null, false);
+ }
+
+ @Override
+ public ItemStack getLoot() {
+ ItemStack oreType = RandomLoot.ORES.get(MathUtil
+ .getRandomIntegerBetween(0, RandomLoot.ORES.size()))
+ .copy();
+
+ oreType.stackSize = MathUtil.getRandomIntegerBetween(16, 32);
+
+ return oreType;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "16 to 32 Ores of a Random Type";
+ }
+ }
+
+ public static class Belt extends RandomLoot {
+ public Belt() {
+ super(RandomLoot.BELTS, false);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "A Random Belt";
+ }
+
+ }
+
+ public static class Amulet extends RandomLoot {
+ public Amulet() {
+ super(RandomLoot.AMULETS, false);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "A Random Amulet";
+ }
+
+ }
+
+ public static class Ring extends RandomLoot {
+ public Ring() {
+ super(RandomLoot.RINGS, false);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "A Random Ring";
+ }
+ }
+
+ /*
+ * Tool Loot
+ */
+ public static final List<
+ Item> PICKAXES = new ArrayList<
+ Item>();
+ public static final List<
+ Item> SHOVELS = new ArrayList<
+ Item>();
+ public static final List<
+ Item> AXES = new ArrayList<
+ Item>();
+ public static final List<
+ Item> HOES = new ArrayList<
+ Item>();
+ public static final List<
+ ItemStack> TOOL_HEADS = new ArrayList<
+ ItemStack>();
+
+ /*
+ * Weapon Loot
+ */
+ public static final List<
+ Item> SWORDS = new ArrayList<
+ Item>();
+ public static final List<
+ Item> BOWS = new ArrayList<
+ Item>();
+ public static final List<
+ ItemStack> ARROWS = new ArrayList<
+ ItemStack>();
+
+ /*
+ * Tool Material Loot
+ */
+ public static final Map<ToolMaterial,
+ ArrayList<
+ Item>> MATERIAL_TOOLS = new HashMap<
+ ToolMaterial, ArrayList<Item>>();
+
+ /*
+ * Armor Loot
+ */
+ public static final List<
+ Item> HELMETS = new ArrayList<
+ Item>();
+ public static final List<
+ Item> CHESTPLATES = new ArrayList<
+ Item>();
+ public static final List<
+ Item> LEGGINGS = new ArrayList<
+ Item>();
+ public static final List<
+ Item> BOOTS = new ArrayList<
+ Item>();
+
+ /*
+ * Armor Material Loot
+ */
+ public static final Map<ArmorMaterial,
+ ArrayList<
+ Item>> MATERIAL_ARMOR = new HashMap<
+ ArmorMaterial, ArrayList<Item>>();
+
+ /*
+ * Food Loot
+ */
+ public static final List<
+ Item> FOOD = new ArrayList<
+ Item>();
+ public static final List<
+ ItemStack> CROPS = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> SEEDS = new ArrayList<
+ ItemStack>();
+
+ /*
+ * Potion Loot
+ */
+ public static final List<
+ ItemStack> POTIONS = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> SPLASH_POTIONS = new ArrayList<
+ ItemStack>();
+
+ /*
+ * Resource Loot
+ */
+ public static final List<
+ ItemStack> DUSTS = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> BLOCKS = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> CRATES = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> GEMS = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> INGOTS = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> ORES = new ArrayList<
+ ItemStack>();
+
+ /*
+ * Decorative Loot
+ */
+ public static final List<
+ ItemStack> GLASS = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> WOOL = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> DYES = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> FENCES = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> LOGS = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> PLANKS = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> RECORDS = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> SLABS = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> STAIRS = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> STONES = new ArrayList<
+ ItemStack>();
+ public static final List<
+ ItemStack> SAPLINGS = new ArrayList<
+ ItemStack>();
+
+ /*
+ * List of weapons
+ */
+ public static final List<
+ Item> WEAPONS = new ArrayList<
+ Item>();
+
+ /*
+ * List of baubles
+ */
+ public static final List<
+ Item> BELTS = new ArrayList<
+ Item>();
+ public static final List<
+ Item> AMULETS = new ArrayList<
+ Item>();
+ public static final List<
+ Item> RINGS = new ArrayList<
+ Item>();
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/crate/RandomRandomLoot.java b/TF2 Crates/src/main/java/tf2crates/crate/RandomRandomLoot.java new file mode 100755 index 0000000..f8f184d --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/crate/RandomRandomLoot.java @@ -0,0 +1,158 @@ +package tf2crates.crate; + +import java.util.ArrayList; +import java.util.List; + +import tconstruct.library.crafting.ToolBuilder; +import tconstruct.library.crafting.ToolRecipe; +import tlhpoeCore.util.MathUtil; + +/** + * Get random instances of random loot :) + * + * @author ben + * + */ +public class RandomRandomLoot { + private static List<RandomLoot> loot; + + public static void init() { + loot = new ArrayList<RandomLoot>(); + + // Tool loot + addToolLoot(); + + // Weapon loot + addWeaponLoot(); + + // Armor loot + addArmorLoot(); + + // Potion loot + addPotionLoot(); + + // Plant loot + addPlantLoot(); + addPlantLoot(); + + // Dye loot + addDyeLoot(); + addDyeLoot(); + + // Decorative loot + addDecorativeLoot(); + addDecorativeLoot(); + + // Valuble loot + addValubleLoot(); + + // Bauble loot + addBaubleLoot(); + + // Misc Loot + addMiscLoot(); + addMiscLoot(); + + addTinkersLoot(); + } + + private static void addTinkersLoot() { + List<ToolRecipe> combos = ToolBuilder.instance.combos; + for (ToolRecipe toolRecipe : combos) { + boolean isLegendary; + + if (MathUtil.nextDouble() > .8) { + isLegendary = true; + } else { + isLegendary = false; + } + + loot.add(new RandomTinkersTool(isLegendary, toolRecipe)); + } + } + + private static void addToolLoot() { + loot.add(new RandomLoot.Pickaxe(false)); + loot.add(new RandomLoot.Pickaxe(true)); + loot.add(new RandomLoot.Shovel(false)); + loot.add(new RandomLoot.Shovel(true)); + loot.add(new RandomLoot.Axe(false)); + loot.add(new RandomLoot.Axe(true)); + loot.add(new RandomLoot.Hoe(false)); + loot.add(new RandomLoot.Hoe(true)); + + loot.add(new RandomLoot.ToolHead()); + } + + private static void addWeaponLoot() { + loot.add(new RandomLoot.Sword(false)); + loot.add(new RandomLoot.Sword(true)); + loot.add(new RandomLoot.Bow(false)); + loot.add(new RandomLoot.Bow(true)); + loot.add(new RandomLoot.Arrow()); + } + + private static void addArmorLoot() { + loot.add(new RandomLoot.Helmet(false)); + loot.add(new RandomLoot.Helmet(true)); + loot.add(new RandomLoot.Chestplate(false)); + loot.add(new RandomLoot.Chestplate(true)); + loot.add(new RandomLoot.Legging(false)); + loot.add(new RandomLoot.Legging(true)); + loot.add(new RandomLoot.Boot(false)); + loot.add(new RandomLoot.Boot(true)); + } + + private static void addPotionLoot() { + loot.add(new RandomLoot.Potion()); + loot.add(new RandomLoot.SplashPotion()); + } + + private static void addPlantLoot() { + loot.add(new RandomLoot.Food()); + loot.add(new RandomLoot.Seed()); + loot.add(new RandomLoot.Crop()); + loot.add(new RandomLoot.Saplings()); + loot.add(new RandomLoot.Logs()); + loot.add(new RandomLoot.Planks()); + } + + private static void addDyeLoot() { + loot.add(new RandomLoot.Paint()); + loot.add(new RandomLoot.Dye()); + } + + private static void addDecorativeLoot() { + loot.add(new RandomLoot.Slab()); + loot.add(new RandomLoot.Stair()); + loot.add(new RandomLoot.Fence()); + loot.add(new RandomLoot.Glass()); + loot.add(new RandomLoot.Stone()); + } + + private static void addValubleLoot() { + loot.add(new RandomLoot.Dust()); + loot.add(new RandomLoot.Block()); + loot.add(new RandomLoot.Crate()); + loot.add(new RandomLoot.Gem()); + loot.add(new RandomLoot.Ingot()); + loot.add(new RandomLoot.Ore()); + } + + private static void addBaubleLoot() { + loot.add(new RandomLoot.Amulet()); + loot.add(new RandomLoot.Belt()); + loot.add(new RandomLoot.Ring()); + } + + private static void addMiscLoot() { + loot.add(new RandomLoot.EnchantedBook()); + loot.add(new RandomLoot.FishingRod()); + loot.add(new RandomLoot.Record()); + } + + public static RandomLoot getRandomLoot() { + return loot + .get(MathUtil.getRandomIntegerBetween(0, loot.size() - 1)); + } +} diff --git a/TF2 Crates/src/main/java/tf2crates/crate/RandomTinkersTool.java b/TF2 Crates/src/main/java/tf2crates/crate/RandomTinkersTool.java new file mode 100755 index 0000000..c79ea86 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/crate/RandomTinkersTool.java @@ -0,0 +1,143 @@ +package tf2crates.crate; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.ModifyBuilder; +import tconstruct.library.crafting.ToolBuilder; +import tconstruct.library.crafting.ToolRecipe; +import tconstruct.library.modifier.ItemModifier; +import tconstruct.library.tools.ToolCore; +import tconstruct.library.tools.ToolMaterial; +import tconstruct.library.util.IToolPart; +import tlhpoeCore.util.MathUtil; + +public class RandomTinkersTool extends RandomLoot { + private boolean isLegendary; + + private ToolRecipe toolType; + + private ArrayList<Integer> materialIDs; + + public RandomTinkersTool(boolean isLegendary, ToolRecipe toolType) { + super(null, isLegendary); + + this.isLegendary = isLegendary; + this.toolType = toolType; + } + + @Override + public String getDisplayName() { + return "A Random " + (isLegendary ? " Legendary" : "") + + " Tinker's " + toolType.getType().getLocalizedToolName(); + } + + @Override + public ItemStack getLoot() { + if (materialIDs == null) { + prepareMaterials(); + } + + // determine type + ToolRecipe recipe = toolType; + ToolCore type = recipe.getType(); + + ItemStack tool = null; + int tries = 0; + // try to build the tool + do { + tries++; + // get components + ItemStack[] parts = new ItemStack[] { null, null, null, null }; + + Item[] items = new Item[4]; + items[0] = type.getHeadItem(); + items[1] = type.getHandleItem(); + items[2] = type.getAccessoryItem(); + items[3] = type.getExtraItem(); + + for (int i = 0; i < 4; i++) { + if (items[i] == null) { + continue; + } + + do { + // get a material + Integer matId = materialIDs + .get(MathUtil.nextInt(materialIDs.size())); + + parts[i] = new ItemStack(items[i], 1, matId); + } while (((IToolPart) items[i]) + .getMaterialID(parts[i]) == -1); + } + // build the tool + tool = ToolBuilder.instance.buildTool(parts[0], parts[1], + parts[2], parts[3], ""); + } while (tool == null && tries < 200); + + if (tool == null) { + ItemStack oops = new ItemStack(Items.stick); + + oops.setStackDisplayName("Crate Malfunction"); + + return oops; + } + + int modCount = MathUtil.nextInt(3); + + for (int i = modCount; i > 0; i--) { + doModifyWeapon(tool); + } + + if (isLegendary) { + EnchantmentHelper.addRandomEnchantment(MathUtil.getRandom(), + tool, MathUtil.getRandomIntegerBetween(25, 30)); + } + + return tool; + } + + private void doModifyWeapon(ItemStack tool) { + List<ItemModifier> modifiers = ModifyBuilder.instance.itemModifiers; + + ItemModifier mod = modifiers + .get(MathUtil.nextInt(modifiers.size())); + + ItemStack[] stacks = stackFromModifier(mod); + + if (!mod.matches(stacks, tool)) { + return; + } + + mod.addMatchingEffect(tool); + + mod.modify(stacks, tool); + } + + private static ItemStack[] stackFromModifier(ItemModifier modifier) { + ItemStack[] stack = new ItemStack[modifier.stacks.size()]; + int i = 0; + for (Object s : modifier.stacks) + stack[i++] = (ItemStack) s; + + return stack; + } + + private void prepareMaterials() { + materialIDs = new ArrayList<Integer>(); // converted to list for + // indexed access for + // random + + for (Map.Entry<Integer, + ToolMaterial> entry : TConstructRegistry.toolMaterials + .entrySet()) { + materialIDs.add(entry.getKey()); + } + } +} diff --git a/TF2 Crates/src/main/java/tf2crates/entity/EntityDamageSourceBackstab.java b/TF2 Crates/src/main/java/tf2crates/entity/EntityDamageSourceBackstab.java new file mode 100755 index 0000000..bfbc58d --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/entity/EntityDamageSourceBackstab.java @@ -0,0 +1,17 @@ +package tf2crates.entity;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.util.EntityDamageSource;
+
+public class EntityDamageSourceBackstab extends EntityDamageSource {
+ private EntityDamageSourceBackstab(Entity attacker) {
+ super("backstab", attacker);
+
+ this.setDamageBypassesArmor();
+ }
+
+ public static EntityDamageSourceBackstab
+ causeBackstabDamage(Entity attacker) {
+ return new EntityDamageSourceBackstab(attacker);
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/handler/AnvilHandler.java b/TF2 Crates/src/main/java/tf2crates/handler/AnvilHandler.java new file mode 100755 index 0000000..f846696 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/handler/AnvilHandler.java @@ -0,0 +1,118 @@ +package tf2crates.handler;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import net.minecraft.item.ItemArmor;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.ItemTool;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraftforge.event.AnvilUpdateEvent;
+import tf2crates.ServerProxyTC;
+import tf2crates.crate.RandomLoot;
+import tf2crates.item.ItemUnusualEffect;
+
+public class AnvilHandler {
+ public static boolean repairHat, makeUnbreakable;
+
+ public static int strangeCost, unusualCost, descriptionCost;
+
+ @SubscribeEvent
+ public void anvilUpdate(AnvilUpdateEvent event) {
+ ItemStack left = event.left;
+ ItemStack right = event.right;
+
+ if (left != null && right != null) {
+ String leftN = left.getItem().getUnlocalizedName();
+
+ if (left.getItem() instanceof ItemTool
+ || leftN.contains("sword") || leftN.contains("Sword")
+ || leftN.contains("hoe") || leftN.contains("Hoe")) {
+ if (left.getItemDamage() > 0) {
+ if (right.stackSize == 1
+ && right.getItem() == ServerProxyTC.scrap) {
+ ItemStack res = left.copy();
+
+ double amt = 0.1111D;
+ int dmg = right.getItemDamage();
+
+ if (dmg == 1) {
+ amt = 0.3333D;
+ } else if (dmg == 2) {
+ amt = 1D;
+ }
+
+ res.setItemDamage((int) (res.getItemDamage()
+ - (res.getMaxDamage() * amt)));
+
+ event.output = res;
+ event.cost = 2;
+
+ return;
+ }
+ }
+ }
+
+ NBTTagCompound lNbt = left.getTagCompound();
+
+ if (lNbt == null) {
+ left.setTagCompound(lNbt = new NBTTagCompound());
+ }
+
+ if (RandomLoot.WEAPONS.contains(left.getItem())
+ && !lNbt.getBoolean("Golden")) {
+ if (right.getItem() == ServerProxyTC.paint
+ && right.getItemDamage() == 11) {
+ ItemStack res = left.copy();
+
+ res.getTagCompound().setBoolean("Golden", true);
+ res.setItemDamage(0);
+
+ res.setStackDisplayName(EnumChatFormatting.YELLOW
+ + "Strange Minecraftium "
+ + res.getDisplayName());
+
+ event.output = res;
+ event.cost = 1;
+ }
+ }
+
+ if (!lNbt.hasKey("UnusualEffect")) {
+ if (left.getItem() instanceof ItemArmor) {
+ ItemArmor armor = (ItemArmor) left.getItem();
+
+ if (armor.armorType == 0) {
+ if (right.getItem() instanceof ItemUnusualEffect) {
+ ItemStack result = left.copy();
+
+ result.getTagCompound().setInteger(
+ "UnusualEffect",
+ right.getItemDamage());
+
+ if (makeUnbreakable) {
+ result.getTagCompound()
+ .setBoolean("Unbreakable", true);
+ } else if (repairHat) {
+ result.setItemDamage(0);
+ }
+
+ event.output = result;
+ event.cost = unusualCost;
+ }
+
+ }
+ }
+ }
+
+ if (!lNbt.hasKey("Strange") && left.stackSize == 1) {
+ if (right.getItem() == ServerProxyTC.strangifier) {
+ ItemStack result = left.copy();
+
+ result.getTagCompound().setInteger("Strange", 0);
+
+ event.output = result;
+ event.cost = strangeCost;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/handler/AttackHandler.java b/TF2 Crates/src/main/java/tf2crates/handler/AttackHandler.java new file mode 100755 index 0000000..0d6e2ff --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/handler/AttackHandler.java @@ -0,0 +1,76 @@ +package tf2crates.handler;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.event.entity.living.LivingHurtEvent;
+import tf2crates.ReferenceTC;
+import tf2crates.ServerProxyTC;
+import tlhpoeCore.network.MessagePlaySound;
+
+public class AttackHandler {
+ public static double marketGardenerMinimumFall;
+
+ @SubscribeEvent
+ public void attackHandler(LivingHurtEvent event) {
+ Entity attackerE = event.source.getEntity();
+
+ if (attackerE != null && attackerE instanceof EntityLivingBase) {
+ EntityLivingBase attacker = (EntityLivingBase) attackerE;
+ ItemStack heldItem = attacker.getHeldItem();
+
+ if (heldItem != null && heldItem.getItem() != null) {
+ Item item = heldItem.getItem();
+ boolean playSound = false;
+
+ if (item == ServerProxyTC.equalizer) {
+ float per =
+ attacker.getHealth() / attacker.getMaxHealth();
+
+ if (per <= 0.25F) {
+ event.ammount += 8;
+ } else if (per <= 0.5F) {
+ event.ammount += 4;
+ } else if (per <= 0.75F) {
+ event.ammount += 2;
+ }
+ } else if (item == ServerProxyTC.marketGardener) {
+ if (attacker.fallDistance >= marketGardenerMinimumFall) {
+ event.ammount += 15;
+
+ playSound = true;
+ }
+ } else if (item == ServerProxyTC.axtinguisher) {
+ if (event.entityLiving.isBurning()) {
+ event.ammount += 8;
+
+ playSound = true;
+ }
+ } else if (item == ServerProxyTC.sharpenedVolcanoFragment) {
+ event.entityLiving.setFire(10);
+ }
+
+ if (playSound && attacker instanceof EntityPlayerMP) {
+ new MessagePlaySound(
+ ReferenceTC.ID + ":tf2crates.crit")
+ .sendTo((EntityPlayerMP) attacker);
+ }
+ }
+ }
+
+ ItemStack heldItem = event.entityLiving.getHeldItem();
+
+ if (heldItem != null && heldItem.getItem() != null) {
+ Item item = heldItem.getItem();
+
+ if (item == ServerProxyTC.powerJack) {
+ event.ammount *= 1.5;
+ } else if (item == ServerProxyTC.conniversKunai) {
+ event.ammount *= 2;
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/handler/DeathHandler.java b/TF2 Crates/src/main/java/tf2crates/handler/DeathHandler.java new file mode 100755 index 0000000..b680e40 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/handler/DeathHandler.java @@ -0,0 +1,88 @@ +package tf2crates.handler;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.monster.EntityMob;
+import net.minecraft.entity.projectile.EntityArrow;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.event.entity.living.LivingDropsEvent;
+import tf2crates.ReferenceTC;
+import tf2crates.ServerProxyTC;
+import tf2crates.crate.Crates;
+import tlhpoeCore.util.MathUtil;
+
+public class DeathHandler {
+ public static int[] crateChance;
+ public static int[] keyChance;
+
+ @SubscribeEvent
+ public void mobDeath(LivingDropsEvent event) {
+ EntityLivingBase entity = event.entityLiving;
+
+ if (entity instanceof EntityMob) {
+ if (MathUtil.getChance(crateChance[0], crateChance[1])) {
+ String special = ReferenceTC.CURRENT_SPECIAL_CRATE;
+
+ if (special != null && MathUtil.getChance(1, 5)) {
+ event.drops.add(new EntityItem(entity.worldObj,
+ entity.posX, entity.posY + 1, entity.posZ,
+ new ItemStack(ServerProxyTC.crate, 1,
+ Crates.getSeriesFromName(special))));
+ } else {
+ event.drops.add(new EntityItem(entity.worldObj,
+ entity.posX, entity.posY + 1, entity.posZ,
+ new ItemStack(ServerProxyTC.crate, 1, MathUtil
+ .nextInt(Crates.getNumberOfSeries()
+ - Crates.getNumberOfSpecialCrates()))));
+ }
+ }
+
+ if (MathUtil.getChance(keyChance[0], keyChance[1])) {
+ event.drops.add(new EntityItem(entity.worldObj,
+ entity.posX, entity.posY + 1, entity.posZ,
+ new ItemStack(ServerProxyTC.key, 1)));
+ }
+
+ Entity attacker = event.source.getSourceOfDamage();
+
+ if (attacker != null) {
+ EntityLivingBase attackerL = null;
+
+ if (attacker instanceof EntityLivingBase) {
+ attackerL = (EntityLivingBase) attacker;
+ } else if (attacker instanceof EntityArrow) {
+ EntityArrow arrow = (EntityArrow) attacker;
+
+ if (arrow.shootingEntity != null
+ && arrow.shootingEntity instanceof EntityLivingBase) {
+ attackerL =
+ (EntityLivingBase) arrow.shootingEntity;
+ }
+ }
+
+ if (attackerL != null) {
+ ItemStack held = attackerL.getHeldItem();
+
+ if (held != null) {
+ NBTTagCompound nbt = held.getTagCompound();
+
+ if (nbt != null && (nbt.hasKey("Strange")
+ || nbt.hasKey("Golden"))) {
+ nbt.setInteger("Strange",
+ nbt.getInteger("Strange") + 1);
+ }
+
+ if (held.getItem() != null && held
+ .getItem() == ServerProxyTC.powerJack) {
+ attackerL.heal(
+ attackerL.getMaxHealth() * 0.25F);
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/handler/EventHandler.java b/TF2 Crates/src/main/java/tf2crates/handler/EventHandler.java new file mode 100755 index 0000000..212c13f --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/handler/EventHandler.java @@ -0,0 +1,284 @@ +package tf2crates.handler;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import cpw.mods.fml.common.gameevent.TickEvent;
+import cpw.mods.fml.common.gameevent.TickEvent.Phase;
+import net.minecraft.client.Minecraft;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import tlhpoeCore.util.MCUtil;
+import tlhpoeCore.util.MathUtil;
+
+public class EventHandler {
+ @SubscribeEvent
+ public void playerTick(TickEvent.PlayerTickEvent event) {
+ EntityPlayer player = event.player;
+
+ if (event.phase == Phase.START) {
+ Minecraft mc = MCUtil.getMC();
+ if (player != mc.thePlayer || (player == mc.thePlayer
+ && mc.gameSettings.thirdPersonView != 0)) {
+ ItemStack helmet = player.getEquipmentInSlot(4);
+
+ if (helmet != null) {
+ NBTTagCompound nbt = helmet.getTagCompound();
+ if (nbt != null && nbt.hasKey("UnusualEffect")) {
+ int unusualEffect =
+ nbt.getInteger("UnusualEffect");
+
+ switch (unusualEffect) {
+ case (0):
+ if (MathUtil.getChance(1, 5)) {
+ player.worldObj.spawnParticle("flame",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(16), rDouble(16),
+ rDouble(16));
+ }
+
+ break;
+
+ case (1):
+ if (MathUtil.getChance(1, 5)) {
+ player.worldObj.spawnParticle(
+ "explode",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ }
+
+ break;
+
+ case (2):
+ if (MathUtil.getChance(1, 5)) {
+ player.worldObj.spawnParticle(
+ "fireworksSpark",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ }
+
+ break;
+ case (3):
+
+ if (MathUtil.getChance(1, 2)) {
+ player.worldObj.spawnParticle(
+ "depthsuspend",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ player.worldObj.spawnParticle(
+ "depthsuspend",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ }
+
+ break;
+
+ case (4):
+ if (MathUtil.getChance(1, 4)) {
+ player.worldObj.spawnParticle("crit",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ player.worldObj.spawnParticle("crit",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ }
+
+ break;
+
+ case (5):
+ if (MathUtil.getChance(1, 4)) {
+ player.worldObj.spawnParticle(
+ "magicCrit",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ player.worldObj.spawnParticle(
+ "magicCrit",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ }
+
+ break;
+
+ case (6):
+ if (MathUtil.getChance(1, 5)) {
+ player.worldObj.spawnParticle("note",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ }
+
+ break;
+
+ case (7):
+ if (MathUtil.getChance(1, 2)) {
+ player.worldObj.spawnParticle("portal",
+ player.posX + rDouble(4),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(4),
+ rDouble(16), rDouble(16),
+ rDouble(16));
+ player.worldObj.spawnParticle("portal",
+ player.posX + rDouble(4),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(4),
+ rDouble(16), rDouble(16),
+ rDouble(16));
+ }
+
+ break;
+
+ case (8):
+ if (MathUtil.getChance(1, 5)) {
+ player.worldObj.spawnParticle(
+ "enchantmenttable",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(2), rDouble(2),
+ rDouble(2));
+ player.worldObj.spawnParticle(
+ "enchantmenttable",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(2), rDouble(2),
+ rDouble(2));
+ }
+
+ break;
+
+ case (9):
+ if (MathUtil.getChance(1, 5)) {
+ player.worldObj.spawnParticle("lava",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), 0, rDouble(8));
+ }
+
+ break;
+
+ case (10):
+ if (MathUtil.getChance(1, 5)) {
+ player.worldObj.spawnParticle(
+ "largesmoke",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ player.worldObj.spawnParticle(
+ "reddust",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ }
+
+ break;
+
+ case (11):
+ if (MathUtil.getChance(1, 5)) {
+ player.worldObj.spawnParticle("slime",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ player.worldObj.spawnParticle("slime",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ }
+
+ break;
+
+ case (12):
+ if (MathUtil.getChance(1, 5)) {
+ player.worldObj.spawnParticle("heart",
+ player.posX + rDouble(1.25),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1.25),
+ rDouble(8), rDouble(16),
+ rDouble(8));
+ }
+
+ break;
+
+ case (13):
+ if (MathUtil.getChance(1, 5)) {
+ player.worldObj.spawnParticle(
+ MathUtil.getChance(1, 10)
+ ? "angryVillager"
+ : "happyVillager",
+ player.posX + rDouble(1),
+ player.posY + 0.5D
+ + rDouble(4),
+ player.posZ + rDouble(1),
+ rDouble(2), rDouble(16),
+ rDouble(2));
+ }
+
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private static double rDouble(double randomness) {
+ return (MathUtil.nextDouble() / randomness)
+ - (MathUtil.nextDouble() / randomness);
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/handler/TickHandler.java b/TF2 Crates/src/main/java/tf2crates/handler/TickHandler.java new file mode 100755 index 0000000..08af067 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/handler/TickHandler.java @@ -0,0 +1,40 @@ +package tf2crates.handler;
+
+import java.util.Calendar;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import cpw.mods.fml.common.gameevent.TickEvent;
+import tf2crates.ReferenceTC;
+
+public class TickHandler {
+ private short counter = 0;
+
+ @SubscribeEvent
+ public void playerTick(TickEvent.WorldTickEvent event) {
+ if (event.phase == TickEvent.Phase.START) {
+ if (counter >= 36000) {
+ counter = 0;
+
+ Calendar date = Calendar.getInstance();
+
+ int month = date.get(Calendar.MONTH);
+ int day = date.getMaximum(Calendar.DAY_OF_MONTH);
+
+ if ((month == Calendar.OCTOBER && day >= 29)
+ || (month == Calendar.NOVEMBER && day < 12)) {
+ ReferenceTC.CURRENT_SPECIAL_CRATE = "spookyCrate";
+ } else if (month == Calendar.DECEMBER
+ && (day >= 20 && day <= 31)) {
+ ReferenceTC.CURRENT_SPECIAL_CRATE = "festiveCrate";
+ } else if (month == Calendar.AUGUST
+ && (day >= 24 && day <= 31)) {
+ ReferenceTC.CURRENT_SPECIAL_CRATE = "birthdayCrate";
+ } else {
+ ReferenceTC.CURRENT_SPECIAL_CRATE = null;
+ }
+ } else {
+ counter++;
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/handler/TooltipHandler.java b/TF2 Crates/src/main/java/tf2crates/handler/TooltipHandler.java new file mode 100755 index 0000000..630463a --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/handler/TooltipHandler.java @@ -0,0 +1,40 @@ +package tf2crates.handler;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.event.entity.player.ItemTooltipEvent;
+import tf2crates.item.ItemUnusualEffect;
+
+public class TooltipHandler {
+ @SubscribeEvent
+ public void toolTip(ItemTooltipEvent event) {
+ if (event.itemStack != null) {
+ NBTTagCompound nbt = event.itemStack.getTagCompound();
+
+ if (nbt != null) {
+ if (nbt.hasKey("UnusualEffect")) {
+ event.toolTip.add("Unusual Effect: "
+ + EnumChatFormatting.LIGHT_PURPLE
+ + StatCollector
+ .translateToLocal("unusualEffect."
+ + ItemUnusualEffect.TYPES[nbt
+ .getInteger(
+ "UnusualEffect")]
+ + ".name"));
+ }
+
+ if (nbt.hasKey("Strange") || nbt.hasKey("Golden")) {
+ event.toolTip.add("# of Mobs Killed: "
+ + EnumChatFormatting.YELLOW
+ + nbt.getInteger("Strange"));
+ }
+
+ if (nbt.hasKey("Description")) {
+ event.toolTip.add(nbt.getString("Description"));
+ }
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/item/ItemCrate.java b/TF2 Crates/src/main/java/tf2crates/item/ItemCrate.java new file mode 100755 index 0000000..90be581 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/item/ItemCrate.java @@ -0,0 +1,196 @@ +package tf2crates.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.entity.player.EntityPlayerMP;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import tf2crates.ReferenceTC;
+import tf2crates.ServerProxyTC;
+import tf2crates.crate.Crates;
+import tf2crates.crate.RandomLoot;
+import tlhpoeCore.network.MessagePlaySound;
+import tlhpoeCore.util.MathUtil;
+
+public class ItemCrate extends Item {
+ public static IIcon[] sCrateTextures;
+ public static int[] unusualChance;
+ public static int[] weaponChance;
+
+ public ItemCrate() {
+ super();
+
+ this.setUnlocalizedName("crate");
+ this.setTextureName(ReferenceTC.ID + ":crate");
+ this.setMaxStackSize(1);
+
+ this.hasSubtypes = true;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register) {
+ super.registerIcons(register);
+
+ sCrateTextures = new IIcon[Crates.getNumberOfSeries() + 1];
+
+ for (int i = 0; i < sCrateTextures.length; i++) {
+ if (Crates.isSeriesSpecial(i)) {
+ sCrateTextures[i] = register.registerIcon(ReferenceTC.ID
+ + ":" + Crates.getNameFromSeries(i));
+ }
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconIndex(ItemStack itemStack) {
+ int series = 1 + itemStack.getItemDamage();
+
+ if (Crates.isSeriesSpecial(series)) {
+ return sCrateTextures[series];
+ }
+
+ return super.getIconIndex(itemStack);
+ }
+
+ @Override
+ public IIcon getIcon(ItemStack itemStack, int pass) {
+ int series = 1 + itemStack.getItemDamage();
+
+ if (Crates.isSeriesSpecial(series)) {
+ return sCrateTextures[series];
+ }
+
+ return super.getIcon(itemStack, pass);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item item, CreativeTabs tabs, List list) {
+ for (int i = 0; i < Crates.getNumberOfSeries(); i++) {
+ list.add(new ItemStack(item, 1, i));
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void addInformation(ItemStack itemStack, EntityPlayer player,
+ List info, boolean f) {
+ int series = itemStack.getItemDamage() + 1;
+
+ info.add(Crates.isSeriesSpecial(series)
+ ? (EnumChatFormatting.GREEN
+ + (StatCollector.translateToLocal(
+ "crate." + Crates.getNameFromSeries(series)
+ + ".name")))
+ : EnumChatFormatting.YELLOW + "Crate Series #" + series);
+
+ Object[] lootItems = Crates.getLootForCrate(series);
+
+ for (int i = 0; i < lootItems.length; i++) {
+ Object loot = lootItems[i];
+ String name = null;
+
+ if (loot instanceof ItemStack) {
+ name = ((ItemStack) loot).getDisplayName();
+ } else if (loot instanceof RandomLoot) {
+ name = ((RandomLoot) loot).getDisplayName();
+ }
+
+ info.add(EnumChatFormatting.GRAY + name);
+ }
+
+ info.add(EnumChatFormatting.AQUA
+ + "or an Exceedingly Rare Special Item!");
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemStack, World world,
+ EntityPlayer player) {
+ if (!world.isRemote) {
+ if (player.capabilities.isCreativeMode || player.inventory
+ .consumeInventoryItem(ServerProxyTC.key)) {
+ int series = itemStack.getItemDamage() + 1;
+ Object[] lootItems = Crates.getLootForCrate(series);
+
+ ItemStack stackLoot = null;
+
+ if (MathUtil.getChance(unusualChance[0],
+ unusualChance[1])) {
+ stackLoot = new ItemStack(ServerProxyTC.unusualEffect,
+ 1, MathUtil.nextInt(
+ ItemUnusualEffect.TYPES.length));
+ } else if (MathUtil.getChance(weaponChance[0],
+ weaponChance[1])) {
+ stackLoot = new ItemStack(
+ RandomLoot.WEAPONS.get(MathUtil
+ .nextInt(RandomLoot.WEAPONS.size())),
+ 1);
+ } else {
+ Object loot =
+ lootItems[MathUtil.nextInt(lootItems.length)];
+
+ if (loot instanceof ItemStack) {
+ stackLoot = (ItemStack) loot;
+ } else if (loot instanceof RandomLoot) {
+ stackLoot = ((RandomLoot) loot).getLoot();
+ }
+ }
+
+ boolean full = true;
+
+ for (int i = 0; i < player.inventory.getSizeInventory();
+ i++) {
+ if (player.inventory.getStackInSlot(i) == null) {
+ full = false;
+ }
+ }
+
+ if (!full) {
+ player.inventory
+ .addItemStackToInventory(stackLoot.copy());
+ } else {
+ player.entityDropItem(stackLoot.copy(), 1F);
+ }
+
+ MinecraftServer.getServer().getConfigurationManager()
+ .sendChatMsg(new ChatComponentText(player
+ .getDisplayName()
+ + " just uncrated "
+ + (stackLoot.stackSize > 1
+ ? (EnumChatFormatting.AQUA + ""
+ + stackLoot.stackSize
+ + " ")
+ : "a ")
+ + EnumChatFormatting.YELLOW
+ + stackLoot.getDisplayName()
+ + (stackLoot.stackSize > 1 ? "s" : "")
+ + EnumChatFormatting.WHITE + "!!!"));
+
+ new MessagePlaySound(ReferenceTC.ID + ":tf2crates.uncrate")
+ .sendTo((EntityPlayerMP) player);
+
+ itemStack.stackSize--;
+ } else {
+ player.addChatMessage(new ChatComponentText("You need a "
+ + EnumChatFormatting.YELLOW
+ + "Steve Co. Supply Crate Key"
+ + EnumChatFormatting.WHITE + " to open this!"));
+ }
+ }
+
+ return itemStack;
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/item/ItemKey.java b/TF2 Crates/src/main/java/tf2crates/item/ItemKey.java new file mode 100755 index 0000000..242f1a2 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/item/ItemKey.java @@ -0,0 +1,35 @@ +package tf2crates.item;
+
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import tf2crates.ReferenceTC;
+
+public class ItemKey extends Item {
+ public ItemKey() {
+ super();
+
+ this.setUnlocalizedName("key");
+ this.setTextureName(ReferenceTC.ID + ":key");
+ this.setMaxStackSize(1);
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack itemStack) {
+ return EnumRarity.rare;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void addInformation(ItemStack itemStack, EntityPlayer player,
+ List info, boolean f) {
+ info.add(EnumChatFormatting.YELLOW
+ + "Used to open locked supply crates.");
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/item/ItemKnife.java b/TF2 Crates/src/main/java/tf2crates/item/ItemKnife.java new file mode 100755 index 0000000..46412ee --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/item/ItemKnife.java @@ -0,0 +1,106 @@ +package tf2crates.item;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.ItemSword;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.IIcon;
+import tf2crates.ReferenceTC;
+import tf2crates.ServerProxyTC;
+import tf2crates.crate.RandomLoot;
+import tf2crates.entity.EntityDamageSourceBackstab;
+import tlhpoeCore.network.MessagePlaySound;
+import tlhpoeCore.util.MiscUtil;
+
+public class ItemKnife extends ItemSword {
+ public static double backstabDifficulty = 0.75D;
+
+ public IIcon goldTexture;
+
+ public ItemKnife(String name) {
+ super(ServerProxyTC.MOD_WEAPON);
+
+ this.setUnlocalizedName(name);
+ this.setTextureName(ReferenceTC.ID + ":weapon/" + name);
+
+ RandomLoot.WEAPONS.add(this);
+ }
+
+ public ItemKnife(String name, float dmg) {
+ this(name);
+
+ MiscUtil.replaceField("field_150934_a", ItemSword.class, dmg,
+ this);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register) {
+ super.registerIcons(register);
+
+ this.goldTexture =
+ register.registerIcon(ReferenceTC.ID + ":weapon/gold/"
+ + this.getUnlocalizedName().substring(5));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconIndex(ItemStack itemStack) {
+ NBTTagCompound nbt = itemStack.getTagCompound();
+
+ if (nbt != null && nbt.getBoolean("Golden")) {
+ return this.goldTexture;
+ }
+
+ return super.getIconIndex(itemStack);
+ }
+
+ @Override
+ public IIcon getIcon(ItemStack itemStack, int pass) {
+ NBTTagCompound nbt = itemStack.getTagCompound();
+
+ if (nbt != null && nbt.getBoolean("Golden")) {
+ return this.goldTexture;
+ }
+
+ return super.getIcon(itemStack, pass);
+ }
+
+ @Override
+ public boolean hitEntity(ItemStack itemStack, EntityLivingBase prey,
+ EntityLivingBase attacker) {
+ itemStack.damageItem(1, attacker);
+
+ float pYaw = prey.rotationYawHead % 360F;
+
+ pYaw = pYaw < 0 ? 360 + pYaw : prey.rotationYawHead;
+
+ float aYaw = attacker.rotationYawHead < 0
+ ? 360 + attacker.rotationYawHead
+ : attacker.rotationYawHead;
+
+ float newRot = pYaw - aYaw;
+
+ if (newRot < (90 * backstabDifficulty)
+ && newRot > (-90 * backstabDifficulty)) {
+ if (!attacker.worldObj.isRemote) {
+ new MessagePlaySound(ReferenceTC.ID + ":tf2crates.crit")
+ .sendTo((EntityPlayerMP) attacker);
+ }
+
+ if (itemStack.getItem() == ServerProxyTC.conniversKunai) {
+ attacker.heal(prey.getMaxHealth());
+ }
+
+ prey.attackEntityFrom(EntityDamageSourceBackstab
+ .causeBackstabDamage(attacker),
+ prey.getMaxHealth() * 600);
+ }
+
+ return false;
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/item/ItemModAxe.java b/TF2 Crates/src/main/java/tf2crates/item/ItemModAxe.java new file mode 100755 index 0000000..78dea2c --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/item/ItemModAxe.java @@ -0,0 +1,88 @@ +package tf2crates.item;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.item.ItemAxe;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.ItemTool;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.World;
+import tf2crates.ReferenceTC;
+import tf2crates.ServerProxyTC;
+import tf2crates.crate.RandomLoot;
+import tlhpoeCore.util.MiscUtil;
+
+public class ItemModAxe extends ItemAxe {
+ public IIcon goldTexture;
+
+ public ItemModAxe(String name) {
+ super(ServerProxyTC.MOD_WEAPON);
+
+ this.setUnlocalizedName(name);
+ this.setTextureName(ReferenceTC.ID + ":weapon/" + name);
+
+ RandomLoot.WEAPONS.add(this);
+ }
+
+ public ItemModAxe(String name, float dmg) {
+ this(name);
+
+ MiscUtil.replaceField("damageVsEntity", ItemTool.class, dmg, this);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register) {
+ super.registerIcons(register);
+
+ this.goldTexture =
+ register.registerIcon(ReferenceTC.ID + ":weapon/gold/"
+ + this.getUnlocalizedName().substring(5));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconIndex(ItemStack itemStack) {
+ NBTTagCompound nbt = itemStack.getTagCompound();
+
+ if (nbt != null && nbt.getBoolean("Golden")) {
+ return this.goldTexture;
+ }
+
+ return super.getIconIndex(itemStack);
+ }
+
+ @Override
+ public IIcon getIcon(ItemStack itemStack, int pass) {
+ NBTTagCompound nbt = itemStack.getTagCompound();
+
+ if (nbt != null && nbt.getBoolean("Golden")) {
+ return this.goldTexture;
+ }
+
+ return super.getIcon(itemStack, pass);
+ }
+
+ @Override
+ public void onUpdate(ItemStack itemStack, World world, Entity entity,
+ int f, boolean f2) {
+ if (this == ServerProxyTC.powerJack) {
+ if (entity instanceof EntityLivingBase) {
+ EntityLivingBase living = (EntityLivingBase) entity;
+ ItemStack heldItem = living.getHeldItem();
+
+ if (heldItem != null && heldItem.getItem() != null
+ && heldItem.getItem() == ServerProxyTC.powerJack) {
+ living.addPotionEffect(new PotionEffect(
+ Potion.moveSpeed.id, 2, 0, true));
+ }
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/item/ItemModPickaxe.java b/TF2 Crates/src/main/java/tf2crates/item/ItemModPickaxe.java new file mode 100755 index 0000000..ddcd915 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/item/ItemModPickaxe.java @@ -0,0 +1,100 @@ +package tf2crates.item;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.item.ItemPickaxe;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.World;
+import tf2crates.ReferenceTC;
+import tf2crates.ServerProxyTC;
+import tf2crates.crate.RandomLoot;
+
+public class ItemModPickaxe extends ItemPickaxe {
+ public IIcon goldTexture;
+
+ public ItemModPickaxe(String name) {
+ super(ServerProxyTC.MOD_WEAPON);
+
+ this.setUnlocalizedName(name);
+ this.setTextureName(ReferenceTC.ID + ":weapon/" + name);
+
+ RandomLoot.WEAPONS.add(this);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register) {
+ super.registerIcons(register);
+
+ this.goldTexture =
+ register.registerIcon(ReferenceTC.ID + ":weapon/gold/"
+ + this.getUnlocalizedName().substring(5));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconIndex(ItemStack itemStack) {
+ NBTTagCompound nbt = itemStack.getTagCompound();
+
+ if (nbt != null && nbt.getBoolean("Golden")) {
+ return this.goldTexture;
+ }
+
+ return super.getIconIndex(itemStack);
+ }
+
+ @Override
+ public IIcon getIcon(ItemStack itemStack, int pass) {
+ NBTTagCompound nbt = itemStack.getTagCompound();
+
+ if (nbt != null && nbt.getBoolean("Golden")) {
+ return this.goldTexture;
+ }
+
+ return super.getIcon(itemStack, pass);
+ }
+
+ @Override
+ public void onUpdate(ItemStack itemStack, World world, Entity entity,
+ int f, boolean f2) {
+ if (this == ServerProxyTC.escapePlan) {
+ if (entity instanceof EntityLivingBase) {
+ EntityLivingBase living = (EntityLivingBase) entity;
+ ItemStack heldItem = living.getHeldItem();
+
+ if (heldItem != null && heldItem.getItem() != null
+ && heldItem
+ .getItem() == ServerProxyTC.escapePlan) {
+ float per = living.getHealth() / living.getMaxHealth();
+ int amplifier = -1;
+
+ if (per <= 0.25F) {
+ amplifier = 2;
+ } else if (per <= 0.5F) {
+ amplifier = 1;
+ } else if (per <= 0.75F) {
+ amplifier = 0;
+ }
+
+ if (amplifier != -1) {
+ living.addPotionEffect(new PotionEffect(
+ Potion.moveSpeed.id, 2, amplifier, true));
+ }
+
+ if (amplifier > 0) {
+ living.addPotionEffect(
+ new PotionEffect(Potion.digSpeed.id, 2,
+ amplifier - 1, true));
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/item/ItemModShovel.java b/TF2 Crates/src/main/java/tf2crates/item/ItemModShovel.java new file mode 100755 index 0000000..e43b713 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/item/ItemModShovel.java @@ -0,0 +1,66 @@ +package tf2crates.item;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.item.ItemSpade;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.ItemTool;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.IIcon;
+import tf2crates.ReferenceTC;
+import tf2crates.ServerProxyTC;
+import tf2crates.crate.RandomLoot;
+import tlhpoeCore.util.MiscUtil;
+
+public class ItemModShovel extends ItemSpade {
+ public IIcon goldTexture;
+
+ public ItemModShovel(String name) {
+ super(ServerProxyTC.MOD_WEAPON);
+
+ this.setUnlocalizedName(name);
+ this.setTextureName(ReferenceTC.ID + ":weapon/" + name);
+
+ RandomLoot.WEAPONS.add(this);
+ }
+
+ public ItemModShovel(String name, float dmg) {
+ this(name);
+
+ MiscUtil.replaceField("damageVsEntity", ItemTool.class, dmg, this);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register) {
+ super.registerIcons(register);
+
+ this.goldTexture =
+ register.registerIcon(ReferenceTC.ID + ":weapon/gold/"
+ + this.getUnlocalizedName().substring(5));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconIndex(ItemStack itemStack) {
+ NBTTagCompound nbt = itemStack.getTagCompound();
+
+ if (nbt != null && nbt.getBoolean("Golden")) {
+ return this.goldTexture;
+ }
+
+ return super.getIconIndex(itemStack);
+ }
+
+ @Override
+ public IIcon getIcon(ItemStack itemStack, int pass) {
+ NBTTagCompound nbt = itemStack.getTagCompound();
+
+ if (nbt != null && nbt.getBoolean("Golden")) {
+ return this.goldTexture;
+ }
+
+ return super.getIcon(itemStack, pass);
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/item/ItemNoiseMaker.java b/TF2 Crates/src/main/java/tf2crates/item/ItemNoiseMaker.java new file mode 100755 index 0000000..807e9ab --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/item/ItemNoiseMaker.java @@ -0,0 +1,50 @@ +package tf2crates.item;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumAction;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+import tf2crates.ReferenceTC;
+import tlhpoeCore.util.MathUtil;
+
+public class ItemNoiseMaker extends Item {
+ public String[] noises;
+
+ public ItemNoiseMaker(String name, String... noises) {
+ super();
+
+ this.setUnlocalizedName(name);
+ this.setTextureName(ReferenceTC.ID + ":" + name);
+ this.setMaxStackSize(1);
+
+ this.noises = noises;
+ }
+
+ @Override
+ public void onPlayerStoppedUsing(ItemStack itemStack, World world,
+ EntityPlayer player, int time) {
+ if (this.getMaxItemUseDuration(itemStack) - time > 10) {
+ player.playSound(noises[MathUtil.nextInt(noises.length)],
+ 0.25F + ((float) (MathUtil.nextDouble() / 8)), 1F);
+ }
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemStack, World world,
+ EntityPlayer player) {
+ player.setItemInUse(itemStack,
+ this.getMaxItemUseDuration(itemStack));
+ return itemStack;
+ }
+
+ @Override
+ public int getMaxItemUseDuration(ItemStack itemStack) {
+ return Integer.MAX_VALUE;
+ }
+
+ @Override
+ public EnumAction getItemUseAction(ItemStack itemStack) {
+ return EnumAction.block;
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/item/ItemPaint.java b/TF2 Crates/src/main/java/tf2crates/item/ItemPaint.java new file mode 100755 index 0000000..f1d4f51 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/item/ItemPaint.java @@ -0,0 +1,124 @@ +package tf2crates.item;
+
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import tf2crates.ReferenceTC;
+
+public class ItemPaint extends Item { // make paint able to change the
+ // color of wool blocks
+ public static final String[] TYPES = { "black", "red", "green",
+ "brown", "blue", "purple", "cyan", "silver", "gray", "pink",
+ "lime", "yellow", "lightBlue", "magenta", "orange", "white" };
+ public IIcon[] textures;
+
+ public ItemPaint() {
+ super();
+
+ this.setUnlocalizedName("paint");
+ this.setMaxStackSize(1);
+
+ this.hasSubtypes = true;
+
+ this.setContainerItem(this);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister iconRegister) {
+ textures = new IIcon[TYPES.length];
+
+ for (int i = 0; i < TYPES.length; i++) {
+ textures[i] = iconRegister
+ .registerIcon(ReferenceTC.ID + ":paint/" + TYPES[i]);
+ }
+ }
+
+ @Override
+ public String getItemStackDisplayName(ItemStack itemStack) {
+ return StatCollector.translateToLocal(
+ "paint." + TYPES[itemStack.getItemDamage()] + ".name");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item item, CreativeTabs tabs, List list) {
+ for (int i = 0; i < TYPES.length; i++) {
+ list.add(new ItemStack(item, 1, i));
+ }
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack itemStack) {
+ return EnumRarity.rare;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int dmg) {
+ return textures[dmg];
+ }
+
+ @Override
+ public boolean
+ doesContainerItemLeaveCraftingGrid(ItemStack itemStack) {
+ return false;
+ }
+
+ @Override
+ public boolean hasContainerItem(ItemStack stack) {
+ return true;
+ }
+
+ @Override
+ public ItemStack getContainerItem(ItemStack itemStack) {
+ return itemStack;
+ }
+
+ @Override
+ public boolean onItemUse(ItemStack itemStack, EntityPlayer player,
+ World world, int x, int y, int z, int meta, float p_77648_8_,
+ float p_77648_9_, float p_77648_10_) {
+ Block block = world.getBlock(x, y, z);
+
+ if (block == Blocks.wool || block == Blocks.carpet
+ || block == Blocks.glass || block == Blocks.stained_glass
+ || block == Blocks.glass_pane
+ || block == Blocks.stained_glass_pane
+ || block == Blocks.hardened_clay
+ || block == Blocks.stained_hardened_clay) {
+ if (!world.isRemote) {
+ if (block == Blocks.glass) {
+ block = Blocks.stained_glass;
+ }
+
+ if (block == Blocks.glass_pane) {
+ block = Blocks.stained_glass_pane;
+ }
+
+ if (block == Blocks.hardened_clay) {
+ block = Blocks.stained_hardened_clay;
+ }
+
+ world.setBlock(x, y, z, block,
+ 15 - itemStack.getItemDamage(), 2);
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/item/ItemSandvich.java b/TF2 Crates/src/main/java/tf2crates/item/ItemSandvich.java new file mode 100755 index 0000000..0a58246 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/item/ItemSandvich.java @@ -0,0 +1,78 @@ +package tf2crates.item;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemFood;
+import net.minecraft.item.ItemStack;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import net.minecraft.world.World;
+import tf2crates.ReferenceTC;
+import tf2crates.crate.RandomLoot;
+
+public class ItemSandvich extends ItemFood {
+ public ItemSandvich() {
+ super(20, 0.32F, true);
+
+ this.setUnlocalizedName("sandvich");
+ this.setTextureName(ReferenceTC.ID + ":sandvich");
+ this.setMaxStackSize(1);
+ this.setMaxDamage(6001);
+ this.setAlwaysEdible();
+
+ RandomLoot.WEAPONS.add(this);
+ }
+
+ @Override
+ protected void onFoodEaten(ItemStack itemStack, World world,
+ EntityPlayer player) {
+ if (!world.isRemote) {
+ player.addPotionEffect(
+ new PotionEffect(Potion.regeneration.id, 600, 2));
+ player.addPotionEffect(
+ new PotionEffect(Potion.digSpeed.id, 600, 2));
+ player.addPotionEffect(
+ new PotionEffect(Potion.moveSpeed.id, 600, 1));
+
+ player.heal(player.getMaxHealth());
+
+ itemStack.setItemDamage(6000);
+ }
+ }
+
+ @Override
+ public ItemStack onEaten(ItemStack itemStack, World world,
+ EntityPlayer player) {
+ player.getFoodStats().func_151686_a(this, itemStack);
+
+ world.playSoundAtEntity(player, "random.burp", 0.5F,
+ world.rand.nextFloat() * 0.1F + 0.9F);
+
+ this.onFoodEaten(itemStack, world, player);
+
+ return itemStack;
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemStack, World world,
+ EntityPlayer player) {
+ if (itemStack.getItemDamage() == 0) {
+ player.setItemInUse(itemStack,
+ this.getMaxItemUseDuration(itemStack));
+ }
+
+ return itemStack;
+ }
+
+ @Override
+ public void onUpdate(ItemStack itemStack, World world, Entity entity,
+ int f, boolean f2) {
+ if (!world.isRemote) {
+ int dmg = itemStack.getItemDamage();
+
+ if (dmg > 0) {
+ itemStack.setItemDamage(dmg - 1);
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/item/ItemScrap.java b/TF2 Crates/src/main/java/tf2crates/item/ItemScrap.java new file mode 100755 index 0000000..900851d --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/item/ItemScrap.java @@ -0,0 +1,66 @@ +package tf2crates.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.item.EnumRarity;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.StatCollector;
+import tf2crates.ReferenceTC;
+
+public class ItemScrap extends Item {
+ public static final String[] TYPES =
+ { "scrap", "reclaimed", "refined" };
+ public static final EnumRarity[] RARITIES =
+ { EnumRarity.uncommon, EnumRarity.rare, EnumRarity.epic };
+ public IIcon[] textures;
+
+ public ItemScrap() {
+ super();
+
+ this.setUnlocalizedName("scrap");
+
+ this.hasSubtypes = true;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister iconRegister) {
+ textures = new IIcon[TYPES.length];
+
+ for (int i = 0; i < TYPES.length; i++) {
+ textures[i] = iconRegister
+ .registerIcon(ReferenceTC.ID + ":" + TYPES[i]);
+ }
+ }
+
+ @Override
+ public String getItemStackDisplayName(ItemStack itemStack) {
+ return StatCollector.translateToLocal(
+ "item." + TYPES[itemStack.getItemDamage()] + ".name");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item item, CreativeTabs tabs, List list) {
+ for (int i = 0; i < TYPES.length; i++) {
+ list.add(new ItemStack(item, 1, i));
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int dmg) {
+ return textures[dmg];
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack itemStack) {
+ return RARITIES[itemStack.getItemDamage()];
+ }
+}
\ No newline at end of file diff --git a/TF2 Crates/src/main/java/tf2crates/item/ItemUnusualEffect.java b/TF2 Crates/src/main/java/tf2crates/item/ItemUnusualEffect.java new file mode 100755 index 0000000..03ac2b0 --- /dev/null +++ b/TF2 Crates/src/main/java/tf2crates/item/ItemUnusualEffect.java @@ -0,0 +1,61 @@ +package tf2crates.item;
+
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+import tf2crates.ReferenceTC;
+
+public class ItemUnusualEffect extends Item {
+ public static final String[] TYPES = { "burningFlames", "poof",
+ "whiteSparkles", "flies", "critical", "magicalCrit", "musical",
+ "end", "enchanted", "volcano", "smoking", "slime", "loving",
+ "villager" };
+
+ public ItemUnusualEffect() {
+ super();
+
+ this.setUnlocalizedName("unusualEffect");
+ this.setTextureName(ReferenceTC.ID + ":unusualEffect");
+ this.setMaxStackSize(1);
+ this.setFull3D();
+
+ this.hasSubtypes = true;
+ }
+
+ @Override
+ public String getItemStackDisplayName(ItemStack itemStack) {
+ return StatCollector
+ .translateToLocal("unusualEffect."
+ + TYPES[itemStack.getItemDamage()] + ".name")
+ + " Unusual Effect";
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item item, CreativeTabs tabs, List list) {
+ for (int i = 0; i < TYPES.length; i++) {
+ list.add(new ItemStack(item, 1, i));
+ }
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack itemStack) {
+ return EnumRarity.epic;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void addInformation(ItemStack itemStack, EntityPlayer player,
+ List info, boolean f) {
+ info.add(EnumChatFormatting.YELLOW
+ + "Combine this with the helmet of your choice!");
+ }
+}
\ No newline at end of file |
