Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ------------------------------------ itemdumper.java
- // ---------------------------------------------------------------------------------------------------
- package oxinabox.itemdumper;
- import cpw.mods.fml.common.Mod;
- import cpw.mods.fml.common.Mod.PreInit; // used in 1.5.2
- import cpw.mods.fml.common.Mod.Init; // used in 1.5.2
- import cpw.mods.fml.common.Mod.PostInit; // used in 1.5.2
- import cpw.mods.fml.common.Mod.Instance;
- import cpw.mods.fml.common.SidedProxy;
- import cpw.mods.fml.common.event.FMLInitializationEvent;
- import cpw.mods.fml.common.event.FMLPostInitializationEvent;
- import cpw.mods.fml.common.event.FMLPreInitializationEvent;
- import cpw.mods.fml.common.network.NetworkMod;
- import cpw.mods.fml.common.registry.GameRegistry;
- @Mod(modid="ItemDumper", name="ItemDumper", version="0.0.0")
- @NetworkMod(clientSideRequired=true, serverSideRequired=false)
- public class ItemDumper {
- // The instance of your mod that Forge uses.
- @Instance("ItemDumper")
- public static ItemDumper instance;
- // Says where the client and server 'proxy' code is loaded.
- @SidedProxy(clientSide="oxinabox.itemdumper.client.ClientProxy", serverSide="oxinabox.itemdumper.CommonProxy")
- public static CommonProxy proxy;
- @PreInit // used in 1.5.2
- public void preInit(FMLPreInitializationEvent event) {
- // Stub Method
- }
- @Init // used in 1.5.2
- public void load(FMLInitializationEvent event) {
- proxy.registerRenderers();
- GameRegistry.registerPlayerTracker(new PlayerTracker());
- }
- @PostInit // used in 1.5.2
- public void postInit(FMLPostInitializationEvent event) {
- // Stub Method
- }
- }
- // --------------------------------------------------------------------------------------------------
- // ------------ PlayerTracker.java
- // Used to know that the player has logged in to the world, and then to run the mod
- package oxinabox.itemdumper;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.enchantment.Enchantment;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import cpw.mods.fml.common.IPlayerTracker;
- import java.io.FileNotFoundException;
- import java.io.PrintWriter;
- import java.io.UnsupportedEncodingException;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.List;
- public class PlayerTracker implements IPlayerTracker {
- private List<String> getAllItemInfo (EntityPlayer player)
- {
- ArrayList<ItemStack> itemsDiscovered = new ArrayList<ItemStack>();
- Item[] aitem = Item.itemsList;
- int i = aitem.length;
- int j;
- for (j = 0; j < i; ++j)
- {
- Item item = aitem[j];
- if (item != null && item.getCreativeTab() != null)
- {
- item.getSubItems(item.itemID, (CreativeTabs)null, itemsDiscovered); //Add the subitems
- }
- }
- List<String> info = new ArrayList<String>();
- for (ItemStack itemstack : itemsDiscovered)
- {
- Iterator toolTipIter = itemstack.getTooltip(player, true).iterator();
- String desc = "";
- while (toolTipIter.hasNext())
- {
- desc += " " + (String)toolTipIter.next();
- }
- info.add(itemstack.itemID + ":" + String.valueOf(itemstack.getItemDamage()) + " = " + itemstack.getDisplayName() + " = " + desc );
- }
- return info;
- }
- @Override
- public void onPlayerLogin(EntityPlayer player) {
- List<String> info = getAllItemInfo(player);
- try {
- PrintWriter writer = new PrintWriter("ItemDump.txt", "UTF-8");
- for (String line : info )
- {
- writer.write(line + "\n");
- }
- writer.close();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- @Override
- public void onPlayerLogout(EntityPlayer player) {
- }
- @Override
- public void onPlayerChangedDimension(EntityPlayer player) {
- }
- @Override
- public void onPlayerRespawn(EntityPlayer player) {
- }
- }
- // -----------------------
- The MIT License (MIT)
- Copyright (c) 2013 Lyndon White (aka Frames, aka oxinabox, aka magnotop)
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- ---------------
- Minecraft is the intelectual property of Mojang.
- This requires MCP and Forge, both of which have there own licenses.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement