Converting mod to Bukkit help...

Discussion in 'Plugin Development' started by TheUnseenForce, Feb 14, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    TheUnseenForce

    I recently finished a mod for SSP that allows users to craft nether materials and get bones from cows. I hope to get this into plugin form so I can add it to the server I play on (the same one as Mischgasm). Anyway, I'm gonna be honest with you, making plugins for this is rather confusing to me. I would appreciate it if you guys could walk me through turning these following scripts into a bukkit plugin.

    Code:
    package net.minecraft.src;
    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: [URL]http://www.kpdus.com/jad.html[/URL]
    // Decompiler options: packimports(3) braces deadcode
    
    public class EntityCow extends EntityAnimals
    {
        public EntityCow(World world)
        {
            super(world);
            texture = "/mob/cow.png";
            setSize(0.9F, 1.3F);
        }
        public void writeEntityToNBT(NBTTagCompound nbttagcompound)
        {
            super.writeEntityToNBT(nbttagcompound);
        }
        public void readEntityFromNBT(NBTTagCompound nbttagcompound)
        {
            super.readEntityFromNBT(nbttagcompound);
        }
        protected String getLivingSound()
        {
            return "mob.cow";
        }
        protected String getHurtSound()
        {
            return "mob.cowhurt";
        }
        protected String getDeathSound()
        {
            return "mob.cowhurt";
        }
        protected float getSoundVolume()
        {
            return 0.4F;
        }
        protected void func_21066_o()
        {
            int i = rand.nextInt(3);
            for(int j = 0; j < i; j++)
            {
                dropItem(Item.field_21020_aV.shiftedIndex, 1);
            }
            i = rand.nextInt(3);
            for(int k = 0; k < i; k++)
            {
                dropItem(Item.leather.shiftedIndex, 1);
            }
        }
     
     
        public boolean interact(EntityPlayer entityplayer)
        {
            ItemStack itemstack = entityplayer.inventory.getCurrentItem();
            if(itemstack != null && itemstack.itemID == Item.bucketEmpty.shiftedIndex)
            {
                entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, new ItemStack(Item.bucketMilk));
                return true;
            } else
            {
                return false;
            }
        }
    }
    
    Code:
    package net.minecraft.src;
    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: [URL]http://www.kpdus.com/jad.html[/URL]
    // Decompiler options: packimports(3) braces deadcode
    import java.io.PrintStream;
    import java.util.*;
    public class CraftingManager
    {
        public static final CraftingManager getInstance()
        {
            return instance;
        }
        private CraftingManager()
        {
            recipes = new ArrayList();
            (new RecipesTools()).addRecipes(this);
            (new RecipesWeapons()).addRecipes(this);
            (new RecipesIngots()).addRecipes(this);
            (new RecipesFood()).addRecipes(this);
            (new RecipesCrafting()).addRecipes(this);
            (new RecipesArmor()).addRecipes(this);
            (new RecipesDyes()).func_21157_a(this);
            addRecipe(new ItemStack(Item.paper, 3), new Object[] {
                "###", Character.valueOf('#'), Item.reed
            });
            addRecipe(new ItemStack(Item.book, 1), new Object[] {
                "#", "#", "#", Character.valueOf('#'), Item.paper
            });
            addRecipe(new ItemStack(Block.fence, 2), new Object[] {
                "###", "###", Character.valueOf('#'), Item.stick
            });
            addRecipe(new ItemStack(Block.jukebox, 1), new Object[] {
                "###", "#X#", "###", Character.valueOf('#'), Block.planks, Character.valueOf('X'), Item.diamond
            });
            addRecipe(new ItemStack(Block.field_9263_R, 1), new Object[] {
                "###", "#X#", "###", Character.valueOf('#'), Block.planks, Character.valueOf('X'), Item.redstone
            });
            addRecipe(new ItemStack(Block.bookShelf, 1), new Object[] {
                "###", "XXX", "###", Character.valueOf('#'), Block.planks, Character.valueOf('X'), Item.book
            });
            addRecipe(new ItemStack(Block.blockSnow, 1), new Object[] {
                "##", "##", Character.valueOf('#'), Item.snowball
            });
            addRecipe(new ItemStack(Block.blockClay, 1), new Object[] {
                "##", "##", Character.valueOf('#'), Item.clay
            });
            addRecipe(new ItemStack(Block.brick, 1), new Object[] {
                "##", "##", Character.valueOf('#'), Item.brick
            });
            addRecipe(new ItemStack(Block.lightStone, 1), new Object[] {
                "###", "###", "###", Character.valueOf('#'), Item.lightStoneDust
            });
            addRecipe(new ItemStack(Block.cloth, 1), new Object[] {
                "###", "###", "###", Character.valueOf('#'), Item.silk
            });
            addRecipe(new ItemStack(Block.tnt, 1), new Object[] {
                "X#X", "#X#", "X#X", Character.valueOf('X'), Item.gunpowder, Character.valueOf('#'), Block.sand
            });
            addRecipe(new ItemStack(Block.stairSingle, 3), new Object[] {
                "###", Character.valueOf('#'), Block.cobblestone
            });
            addRecipe(new ItemStack(Block.ladder, 1), new Object[] {
                "# #", "###", "# #", Character.valueOf('#'), Item.stick
            });
            addRecipe(new ItemStack(Item.doorWood, 1), new Object[] {
                "##", "##", "##", Character.valueOf('#'), Block.planks
            });
            addRecipe(new ItemStack(Item.doorSteel, 1), new Object[] {
                "##", "##", "##", Character.valueOf('#'), Item.ingotIron
            });
            addRecipe(new ItemStack(Item.sign, 1), new Object[] {
                "###", "###", " X ", Character.valueOf('#'), Block.planks, Character.valueOf('X'), Item.stick
            });
            addRecipe(new ItemStack(Item.field_21022_aX, 1), new Object[] {
                "AAA", "BEB", "CCC", Character.valueOf('A'), Item.bucketMilk, Character.valueOf('B'), Item.field_21019_aW, Character.valueOf('C'), Item.wheat, Character.valueOf('E'), 
                Item.egg
            });
            addRecipe(new ItemStack(Item.field_21019_aW, 1), new Object[] {
                "#", Character.valueOf('#'), Item.reed
            });
            addRecipe(new ItemStack(Block.planks, 4), new Object[] {
                "#", Character.valueOf('#'), Block.wood
            });
            addRecipe(new ItemStack(Item.stick, 4), new Object[] {
                "#", "#", Character.valueOf('#'), Block.planks
            });
            addRecipe(new ItemStack(Block.torchWood, 4), new Object[] {
                "X", "#", Character.valueOf('X'), Item.coal, Character.valueOf('#'), Item.stick
            });
            addRecipe(new ItemStack(Block.torchWood, 4), new Object[] {
                "X", "#", Character.valueOf('X'), new ItemStack(Item.coal, 1, 1), Character.valueOf('#'), Item.stick
            });
            addRecipe(new ItemStack(Item.bowlEmpty, 4), new Object[] {
                "# #", " # ", Character.valueOf('#'), Block.planks
            });
            addRecipe(new ItemStack(Block.minecartTrack, 16), new Object[] {
                "X X", "X#X", "X X", Character.valueOf('X'), Item.ingotIron, Character.valueOf('#'), Item.stick
            });
            addRecipe(new ItemStack(Item.minecartEmpty, 1), new Object[] {
                "# #", "###", Character.valueOf('#'), Item.ingotIron
            });
            addRecipe(new ItemStack(Block.pumpkinLantern, 1), new Object[] {
                "A", "B", Character.valueOf('A'), Block.pumpkin, Character.valueOf('B'), Block.torchWood
            });
            addRecipe(new ItemStack(Item.minecartCrate, 1), new Object[] {
                "A", "B", Character.valueOf('A'), Block.crate, Character.valueOf('B'), Item.minecartEmpty
            });
            addRecipe(new ItemStack(Item.minecartPowered, 1), new Object[] {
                "A", "B", Character.valueOf('A'), Block.stoneOvenIdle, Character.valueOf('B'), Item.minecartEmpty
            });
            addRecipe(new ItemStack(Item.boat, 1), new Object[] {
                "# #", "###", Character.valueOf('#'), Block.planks
            });
            addRecipe(new ItemStack(Item.bucketEmpty, 1), new Object[] {
                "# #", " # ", Character.valueOf('#'), Item.ingotIron
            });
            addRecipe(new ItemStack(Item.flintAndSteel, 1), new Object[] {
                "A ", " B", Character.valueOf('A'), Item.ingotIron, Character.valueOf('B'), Item.flint
            });
            addRecipe(new ItemStack(Item.bread, 1), new Object[] {
                "###", Character.valueOf('#'), Item.wheat
            });
            addRecipe(new ItemStack(Block.stairCompactPlanks, 4), new Object[] {
                "#  ", "## ", "###", Character.valueOf('#'), Block.planks
            });
            addRecipe(new ItemStack(Item.fishingRod, 1), new Object[] {
                "  #", " #X", "# X", Character.valueOf('#'), Item.stick, Character.valueOf('X'), Item.silk
            });
            addRecipe(new ItemStack(Block.stairCompactCobblestone, 4), new Object[] {
                "#  ", "## ", "###", Character.valueOf('#'), Block.cobblestone
            });
            addRecipe(new ItemStack(Item.painting, 1), new Object[] {
                "###", "#X#", "###", Character.valueOf('#'), Item.stick, Character.valueOf('X'), Block.cloth
            });
            addRecipe(new ItemStack(Item.appleGold, 1), new Object[] {
                "###", "#X#", "###", Character.valueOf('#'), Block.blockGold, Character.valueOf('X'), Item.appleRed
            });
            addRecipe(new ItemStack(Block.lever, 1), new Object[] {
                "X", "#", Character.valueOf('#'), Block.cobblestone, Character.valueOf('X'), Item.stick
            });
            addRecipe(new ItemStack(Block.torchRedstoneActive, 1), new Object[] {
                "X", "#", Character.valueOf('#'), Item.stick, Character.valueOf('X'), Item.redstone
            });
            addRecipe(new ItemStack(Item.pocketSundial, 1), new Object[] {
                " # ", "#X#", " # ", Character.valueOf('#'), Item.ingotGold, Character.valueOf('X'), Item.redstone
            });
            addRecipe(new ItemStack(Item.compass, 1), new Object[] {
                " # ", "#X#", " # ", Character.valueOf('#'), Item.ingotIron, Character.valueOf('X'), Item.redstone
            });
            addRecipe(new ItemStack(Block.button, 1), new Object[] {
                "#", "#", Character.valueOf('#'), Block.stone
            });
            addRecipe(new ItemStack(Block.pressurePlateStone, 1), new Object[] {
                "###", Character.valueOf('#'), Block.stone
            });
            addRecipe(new ItemStack(Block.pressurePlatePlanks, 1), new Object[] {
                "###", Character.valueOf('#'), Block.planks
            });
            addRecipe(new ItemStack(Block.field_9265_P, 1), new Object[] {
                "###", "#X#", "#R#", Character.valueOf('#'), Block.cobblestone, Character.valueOf('X'), Item.bow, Character.valueOf('R'), Item.redstone
            });
      addRecipe(new ItemStack(Block.lightStone, 4), new Object[] {
                "###", "#X#", "###", Character.valueOf('#'), Block.field_9264_Q, Character.valueOf('X'), Block.torchWood
            });
      addRecipe(new ItemStack(Item.silk, 4), new Object[] {
                "#", Character.valueOf('#'), Block.cloth
            });
      addRecipe(new ItemStack(Block.bloodStone, 16), new Object[] {
                "###", "#X#", "###", Character.valueOf('#'), Block.cobblestone, Character.valueOf('X'), Block.pumpkinLantern
            });
      addRecipe(new ItemStack(Block.slowSand, 4), new Object[] {
                " # ", "#X#", " # ", Character.valueOf('#'), Block.sand, Character.valueOf('X'), Block.bloodStone
            });
      addRecipe(new ItemStack(Block.mobSpawner, 1), new Object[] {
                "X#X", "#X#", "X#X", Character.valueOf('#'), Block.bloodStone, Character.valueOf('X'), Item.diamond
            });
      addRecipe(new ItemStack(Item.coal, 16), new Object[] {
                "#", Character.valueOf('#'), Item.diamond
            });
      addRecipe(new ItemStack(Item.ingotIron, 1), new Object[] {
                " #", "#X", Character.valueOf('#'), Block.torchWood, Character.valueOf('X'), Block.oreIron
            });
      addRecipe(new ItemStack(Item.ingotGold, 1), new Object[] {
                " #", "#X", Character.valueOf('#'), Block.torchWood, Character.valueOf('X'), Block.oreGold
            });
            Collections.sort(recipes, new RecipeSorter(this));
            System.out.println((new StringBuilder()).append(recipes.size()).append(" recipes").toString());
        }
        void addRecipe(ItemStack itemstack, Object aobj[])
        {
            String s = "";
            int i = 0;
            int j = 0;
            int k = 0;
            if(aobj[i] instanceof String[])
            {
                String as[] = (String[])aobj[i++];
                for(int l = 0; l < as.length; l++)
                {
                    String s2 = as[l];
                    k++;
                    j = s2.length();
                    s = (new StringBuilder()).append(s).append(s2).toString();
                }
            } else
            {
                while(aobj[i] instanceof String) 
                {
                    String s1 = (String)aobj[i++];
                    k++;
                    j = s1.length();
                    s = (new StringBuilder()).append(s).append(s1).toString();
                }
            }
            HashMap hashmap = new HashMap();
            for(; i < aobj.length; i += 2)
            {
                Character character = (Character)aobj[i];
                ItemStack itemstack1 = null;
                if(aobj[i + 1] instanceof Item)
                {
                    itemstack1 = new ItemStack((Item)aobj[i + 1]);
                } else
                if(aobj[i + 1] instanceof Block)
                {
                    itemstack1 = new ItemStack((Block)aobj[i + 1], 1, -1);
                } else
                if(aobj[i + 1] instanceof ItemStack)
                {
                    itemstack1 = (ItemStack)aobj[i + 1];
                }
                hashmap.put(character, itemstack1);
            }
            ItemStack aitemstack[] = new ItemStack[j * k];
            for(int i1 = 0; i1 < j * k; i1++)
            {
                char c = s.charAt(i1);
                if(hashmap.containsKey(Character.valueOf(c)))
                {
                    aitemstack[i1] = ((ItemStack)hashmap.get(Character.valueOf(c))).copy();
                } else
                {
                    aitemstack[i1] = null;
                }
            }
            recipes.add(new ShapedRecipes(j, k, aitemstack, itemstack));
        }
        void func_21187_b(ItemStack itemstack, Object aobj[])
        {
            ArrayList arraylist = new ArrayList();
            Object aobj1[] = aobj;
            int i = aobj1.length;
            for(int j = 0; j < i; j++)
            {
                Object obj = aobj1[j];
                if(obj instanceof ItemStack)
                {
                    arraylist.add(((ItemStack)obj).copy());
                    continue;
                }
                if(obj instanceof Item)
                {
                    arraylist.add(new ItemStack((Item)obj));
                    continue;
                }
                if(obj instanceof Block)
                {
                    arraylist.add(new ItemStack((Block)obj));
                } else
                {
                    throw new RuntimeException("Invalid shapeless recipy!");
                }
            }
            recipes.add(new ShapelessRecipes(itemstack, arraylist));
        }
        public ItemStack func_21188_a(InventoryCrafting inventorycrafting)
        {
            for(int i = 0; i < recipes.size(); i++)
            {
                IRecipe irecipe = (IRecipe)recipes.get(i);
                if(irecipe.func_21135_a(inventorycrafting))
                {
                    return irecipe.func_21136_b(inventorycrafting);
                }
            }
            return null;
        }
        private static final CraftingManager instance = new CraftingManager();
        private List recipes;
    }
    
    CraftingManager.java and EntityCow.java were the only two scripts I changed.
    Can anyone help me make this a reality?
     
  2. Offline

    Mischgasm

    I'm not certain but that code looks pretty useless besides maybe a few functions. From what I've learned so far today, I think you will need to make a listener for whenever a cow dies and then when it dies execute an action. If it were me I would try and find some itemcreate command in the bukkit api to use. Doesn't help a whole lot on the actual programming side, but these should. If something looks like a command or action in minecraft, or a minecraft related thing, you can probably look it up in the bukkit api here http://javadoc.lukegb.com/Bukkit/ and figure out what it does. Also make sure you're using the eclipse editor and not netbeans for now. I find it's very useful when it corrects errors, as it can make constructors and import things for you as you need them. That should make sense as you do it to. This tutorial http://forums.bukkit.org/threads/basic-bukkit-plugin-tutorial.1339/ also helps a little bit. The biggest help is just downloading it's source though and copy pasting whatever parts of it you need.

    I think I'm going to try and start learning some crafting related stuff tomorrow. Do you have skype?
     
  3. Offline

    Snowl

    You can use blockdrops to drop bones from cows. If you want to make a plugin out of it look at BlockDropsEntityListener.java (in src)
     
  4. Offline

    fullwall

    Well, I'd guess that you'd need to edit craftbukkit.jar to call your events in the entityanimals class.
     
  5. Offline

    TheUnseenForce

    Well, I think I am a bit closer to converting it. I now have (I think) the files I need. From here, what should I do? I'm guessing that there will be a ton of other files I need to make this work... can anyone give me a setep by step process on making these all work together? I'd appreciate it a ton.

    Code:
    00001 package net.minecraft.server;
    00002
    00003 import java.util.ArrayList;
    00004 import java.util.Collections;
    00005 import java.util.HashMap;
    00006 import java.util.List;
    00007
    00008 public class CraftingManager {
    00009
    00010    private static final CraftingManager a = new CraftingManager();
    00011    private List b = new ArrayList();
    00012
    00013    public static final CraftingManager a() {
    00014        return a;
    00015    }
    00016
    00017    private CraftingManager() {
    00018        (new RecipesTools()).a(this);
    00019        (new RecipesWeapons()).a(this);
    00020        (new RecipeIngots()).a(this);
    00021        (new RecipesFood()).a(this);
    00022        (new RecipesCrafting()).a(this);
    00023        (new RecipesArmor()).a(this);
    00024        (new RecipesDyes()).a(this);
    00025        this.a(new ItemStack(Item.PAPER, 3), new Object[] { "###", Character.valueOf('#'), Item.SUGAR_CANE});
    00026        this.a(new ItemStack(Item.BOOK, 1), new Object[] { "#", "#", "#", Character.valueOf('#'), Item.PAPER});
    00027        this.a(new ItemStack(Block.FENCE, 2), new Object[] { "###", "###", Character.valueOf('#'), Item.STICK});
    00028        this.a(new ItemStack(Block.JUKEBOX, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Block.WOOD, Character.valueOf('X'), Item.DIAMOND});
    00029        this.a(new ItemStack(Block.NOTE_BLOCK, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Block.WOOD, Character.valueOf('X'), Item.REDSTONE});
    00030        this.a(new ItemStack(Block.BOOKSHELF, 1), new Object[] { "###", "XXX", "###", Character.valueOf('#'), Block.WOOD, Character.valueOf('X'), Item.BOOK});
    00031        this.a(new ItemStack(Block.SNOW_BLOCK, 1), new Object[] { "##", "##", Character.valueOf('#'), Item.SNOW_BALL});
    00032        this.a(new ItemStack(Block.CLAY, 1), new Object[] { "##", "##", Character.valueOf('#'), Item.CLAY_BALL});
    00033        this.a(new ItemStack(Block.BRICK, 1), new Object[] { "##", "##", Character.valueOf('#'), Item.CLAY_BRICK});
    00034        this.a(new ItemStack(Block.GLOWSTONE, 1), new Object[] { "###", "###", "###", Character.valueOf('#'), Item.GLOWSTONE_DUST});
    00035        this.a(new ItemStack(Block.WOOL, 1), new Object[] { "###", "###", "###", Character.valueOf('#'), Item.STRING});
    00036        this.a(new ItemStack(Block.TNT, 1), new Object[] { "X#X", "#X#", "X#X", Character.valueOf('X'), Item.SULPHUR, Character.valueOf('#'), Block.SAND});
    00037        this.a(new ItemStack(Block.STEP, 3), new Object[] { "###", Character.valueOf('#'), Block.COBBLESTONE});
    00038        this.a(new ItemStack(Block.LADDER, 1), new Object[] { "# #", "###", "# #", Character.valueOf('#'), Item.STICK});
    00039        this.a(new ItemStack(Item.WOOD_DOOR, 1), new Object[] { "##", "##", "##", Character.valueOf('#'), Block.WOOD});
    00040        this.a(new ItemStack(Item.IRON_DOOR, 1), new Object[] { "##", "##", "##", Character.valueOf('#'), Item.IRON_INGOT});
    00041        this.a(new ItemStack(Item.SIGN, 1), new Object[] { "###", "###", " X ", Character.valueOf('#'), Block.WOOD, Character.valueOf('X'), Item.STICK});
    00042        this.a(new ItemStack(Item.CAKE, 1), new Object[] { "AAA", "BEB", "CCC", Character.valueOf('A'), Item.MILK_BUCKET, Character.valueOf('B'), Item.SUGAR, Character.valueOf('C'), Item.WHEAT, Character.valueOf('E'), Item.EGG});
    00043        this.a(new ItemStack(Item.SUGAR, 1), new Object[] { "#", Character.valueOf('#'), Item.SUGAR_CANE});
    00044        this.a(new ItemStack(Block.WOOD, 4), new Object[] { "#", Character.valueOf('#'), Block.LOG});
    00045        this.a(new ItemStack(Item.STICK, 4), new Object[] { "#", "#", Character.valueOf('#'), Block.WOOD});
    00046        this.a(new ItemStack(Block.TORCH, 4), new Object[] { "X", "#", Character.valueOf('X'), Item.COAL, Character.valueOf('#'), Item.STICK});
    00047        this.a(new ItemStack(Block.TORCH, 4), new Object[] { "X", "#", Character.valueOf('X'), new ItemStack(Item.COAL, 1, 1), Character.valueOf('#'), Item.STICK});
    00048        this.a(new ItemStack(Item.BOWL, 4), new Object[] { "# #", " # ", Character.valueOf('#'), Block.WOOD});
    00049        this.a(new ItemStack(Block.RAILS, 16), new Object[] { "X X", "X#X", "X X", Character.valueOf('X'), Item.IRON_INGOT, Character.valueOf('#'), Item.STICK});
    00050        this.a(new ItemStack(Item.MINECART, 1), new Object[] { "# #", "###", Character.valueOf('#'), Item.IRON_INGOT});
    00051        this.a(new ItemStack(Block.JACK_O_LANTERN, 1), new Object[] { "A", "B", Character.valueOf('A'), Block.PUMPKIN, Character.valueOf('B'), Block.TORCH});
    00052        this.a(new ItemStack(Item.STORAGE_MINECART, 1), new Object[] { "A", "B", Character.valueOf('A'), Block.CHEST, Character.valueOf('B'), Item.MINECART});
    00053        this.a(new ItemStack(Item.POWERED_MINECART, 1), new Object[] { "A", "B", Character.valueOf('A'), Block.FURNACE, Character.valueOf('B'), Item.MINECART});
    00054        this.a(new ItemStack(Item.BOAT, 1), new Object[] { "# #", "###", Character.valueOf('#'), Block.WOOD});
    00055        this.a(new ItemStack(Item.BUCKET, 1), new Object[] { "# #", " # ", Character.valueOf('#'), Item.IRON_INGOT});
    00056        this.a(new ItemStack(Item.FLINT_AND_STEEL, 1), new Object[] { "A ", " B", Character.valueOf('A'), Item.IRON_INGOT, Character.valueOf('B'), Item.FLINT});
    00057        this.a(new ItemStack(Item.BREAD, 1), new Object[] { "###", Character.valueOf('#'), Item.WHEAT});
    00058        this.a(new ItemStack(Block.WOOD_STAIRS, 4), new Object[] { "#  ", "## ", "###", Character.valueOf('#'), Block.WOOD});
    00059        this.a(new ItemStack(Item.FISHING_ROD, 1), new Object[] { "  #", " #X", "# X", Character.valueOf('#'), Item.STICK, Character.valueOf('X'), Item.STRING});
    00060        this.a(new ItemStack(Block.COBBLESTONE_STAIRS, 4), new Object[] { "#  ", "## ", "###", Character.valueOf('#'), Block.COBBLESTONE});
    00061        this.a(new ItemStack(Item.PAINTING, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Item.STICK, Character.valueOf('X'), Block.WOOL});
    00062        this.a(new ItemStack(Item.GOLDEN_APPLE, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Block.GOLD_BLOCK, Character.valueOf('X'), Item.APPLE});
    00063        this.a(new ItemStack(Block.LEVER, 1), new Object[] { "X", "#", Character.valueOf('#'), Block.COBBLESTONE, Character.valueOf('X'), Item.STICK});
    00064        this.a(new ItemStack(Block.REDSTONE_TORCH_ON, 1), new Object[] { "X", "#", Character.valueOf('#'), Item.STICK, Character.valueOf('X'), Item.REDSTONE});
    00065        this.a(new ItemStack(Item.WATCH, 1), new Object[] { " # ", "#X#", " # ", Character.valueOf('#'), Item.GOLD_INGOT, Character.valueOf('X'), Item.REDSTONE});
    00066        this.a(new ItemStack(Item.COMPASS, 1), new Object[] { " # ", "#X#", " # ", Character.valueOf('#'), Item.IRON_INGOT, Character.valueOf('X'), Item.REDSTONE});
    00067        this.a(new ItemStack(Block.STONE_BUTTON, 1), new Object[] { "#", "#", Character.valueOf('#'), Block.STONE});
    00068        this.a(new ItemStack(Block.STONE_PLATE, 1), new Object[] { "###", Character.valueOf('#'), Block.STONE});
    00069        this.a(new ItemStack(Block.WOOD_PLATE, 1), new Object[] { "###", Character.valueOf('#'), Block.WOOD});
    00070        this.a(new ItemStack(Block.DISPENSER, 1), new Object[] { "###", "#X#", "#R#", Character.valueOf('#'), Block.COBBLESTONE, Character.valueOf('X'), Item.BOW, Character.valueOf('R'), Item.REDSTONE});
    77701        this.a(new ItemStack(Block.GLOWSTONE, 4), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Block.SANDSTONE, Character.valueOf('X'), Block.TORCH});
    77702        this.a(new ItemStack(Block.NETHERRACK, 16), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Block.COBBLESTONE, Character.valueOf('X'), Block.JACK_O_LANTERN});
    77703        this.a(new ItemStack(Block.SOUL_SAND, 4), new Object[] { " # ", "#X#", " # ", Character.valueOf('#'), Block.SAND, Character.valueOf('X'), Block.NETHERRACK});
    77704        this.a(new ItemStack(Item.STRING, 4), new Object[] { "#", Character.valueOf('#'), Block.WOOL});
    77705        this.a(new ItemStack(Item.IRON_INGOT, 1), new Object[] { " #", "#X", Character.valueOf('#'), Block.TORCH, Character.valueOf('X'), Block.IRON_ORE});
    77706        this.a(new ItemStack(Item.GOLD_INGOT, 1), new Object[] { " #", "#X", Character.valueOf('#'), Block.TORCH, Character.valueOf('X'), Block.GOLD_ORE});
    77707        this.a(new ItemStack(Item.COAL, 16), new Object[] { " #", Character.valueOf('#'), Item.DIAMOND});
    00071        Collections.sort(this.b, new RecipeSorter(this));
    00072        System.out.println(this.b.size() + " recipes");
    00073    }
    00074
    00075    void a(ItemStack itemstack, Object... aobject) {
    00076        String s = "";
    00077        int i = 0;
    00078        int j = 0;
    00079        int k = 0;
    00080
    00081        if (aobject[i] instanceof String[]) {
    00082            String[] astring = (String[]) ((String[]) aobject[i++]);
    00083
    00084            for (int l = 0; l < astring.length; ++l) {
    00085                String s1 = astring[l];
    00086
    00087                ++k;
    00088                j = s1.length();
    00089                s = s + s1;
    00090            }
    00091        } else {
    00092            while (aobject[i] instanceof String) {
    00093                String s2 = (String) aobject[i++];
    00094
    00095                ++k;
    00096                j = s2.length();
    00097                s = s + s2;
    00098            }
    00099        }
    00100
    00101        HashMap hashmap;
    00102
    00103        for (hashmap = new HashMap(); i < aobject.length; i += 2) {
    00104            Character character = (Character) aobject[i];
    00105            ItemStack itemstack1 = null;
    00106
    00107            if (aobject[i + 1] instanceof Item) {
    00108                itemstack1 = new ItemStack((Item) aobject[i + 1]);
    00109            } else if (aobject[i + 1] instanceof Block) {
    00110                itemstack1 = new ItemStack((Block) aobject[i + 1], 1, -1);
    00111            } else if (aobject[i + 1] instanceof ItemStack) {
    00112                itemstack1 = (ItemStack) aobject[i + 1];
    00113            }
    00114
    00115            hashmap.put(character, itemstack1);
    00116        }
    00117
    00118        ItemStack[] aitemstack = new ItemStack[j * k];
    00119
    00120        for (int i1 = 0; i1 < j * k; ++i1) {
    00121            char c0 = s.charAt(i1);
    00122
    00123            if (hashmap.containsKey(Character.valueOf(c0))) {
    00124                aitemstack[i1] = ((ItemStack) hashmap.get(Character.valueOf(c0))).j();
    00125            } else {
    00126                aitemstack[i1] = null;
    00127            }
    00128        }
    00129
    00130        this.b.add(new ShapedRecipes(j, k, aitemstack, itemstack));
    00131    }
    00132
    00133    void b(ItemStack itemstack, Object... aobject) {
    00134        ArrayList arraylist = new ArrayList();
    00135        Object[] aobject1 = aobject;
    00136        int i = aobject.length;
    00137
    00138        for (int j = 0; j < i; ++j) {
    00139            Object object = aobject1[j];
    00140
    00141            if (object instanceof ItemStack) {
    00142                arraylist.add(((ItemStack) object).j());
    00143            } else if (object instanceof Item) {
    00144                arraylist.add(new ItemStack((Item) object));
    00145            } else {
    00146                if (!(object instanceof Block)) {
    00147                    throw new RuntimeException("Invalid shapeless recipy!");
    00148                }
    00149
    00150                arraylist.add(new ItemStack((Block) object));
    00151            }
    00152        }
    00153
    00154        this.b.add(new ShapelessRecipes(itemstack, arraylist));
    00155    }
    00156
    00157    public ItemStack a(InventoryCrafting inventorycrafting) {
    00158        for (int i = 0; i < this.b.size(); ++i) {
    00159            CraftingRecipe craftingrecipe = (CraftingRecipe) this.b.get(i);
    00160
    00161            if (craftingrecipe.a(inventorycrafting)) {
    00162                return craftingrecipe.b(inventorycrafting);
    00163            }
    00164        }
    00165
    00166        return null;
    00167    }
    00168 }
    
    Code:
    00001 package net.minecraft.server;
    00002
    00003 public class EntityCow extends EntityAnimal {
    00004
    00005    public EntityCow(World world) {
    00006        super(world);
    00007        this.texture = "/mob/cow.png";
    00008        this.a(0.9F, 1.3F);
    00009    }
    00010
    00011    public void a(NBTTagCompound nbttagcompound) {
    00012        super.a(nbttagcompound);
    00013    }
    00014
    00015    public void b(NBTTagCompound nbttagcompound) {
    00016        super.b(nbttagcompound);
    00017    }
    00018
    00019    protected String e() {
    00020        return "mob.cow";
    00021    }
    00022
    00023    protected String f() {
    00024        return "mob.cowhurt";
    00025    }
    00026
    00027    protected String g() {
    00028        return "mob.cowhurt";
    00029    }
    00030
    00031    protected float i() {
    00032        return 0.4F;
    00033    }
    00034
    00035    protected void g_() {
    00072        int i = this.random.nextInt(3);
    00073
    00074        int j;
    00075
    00076        for (j = 0; j < i; ++j) {
    00077            this.a(Item.LEATHER.id, 1);
    00078        }
    00079
    00080        i = this.random.nextInt(3);
    00081
    00082        for (j = 0; j < i; ++j) {
    00083            this.a(Item.BONE.id, 1);
    00084        }
    00085    }
    00086 }
    00038
    00039    public boolean a(EntityHuman entityhuman) {
    00040        ItemStack itemstack = entityhuman.inventory.e();
    00041
    00042        if (itemstack != null && itemstack.id == Item.BUCKET.id) {
    00043            entityhuman.inventory.a(entityhuman.inventory.c, new ItemStack(Item.MILK_BUCKET));
    00044            return true;
    00045        } else {
    00046            return false;
    00047        }
    00048    }
    00049 }
    
     
  6. Offline

    fullwall

    Well, you have to replace the craftbukkit classes with the classes you made to replace them... then see if it works. Make sure it implements the same functions already in the craftbukkit functions though. Then you need to put in some function calls in other craftbukkit classes (event manager?) to call your new craftbukkit classes.
     
Thread Status:
Not open for further replies.

Share This Page