MaterialAPI - Create new items and blocks!

Discussion in 'Resources' started by Cybermaxke, Jan 19, 2013.

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

    Hydrosis

    I get two errors when I use this (one on startup with my plugin and one as soon as the server starts).
    Can someone help me solve these errors!
    Server Log: http://pastebin.com/T5gtaFED
    The errors at the end continuously spam until the log becomes 3 mb.

    If I forgot something, please let me know! Thanks in advance for any assistance!! :)
     
  2. Offline

    Cybermaxke

    Hydrosis
    I just need to update the TagUtils to 1.5.2
     
  3. Offline

    Hydrosis

    Alright thanks! :) I'll keep an eye on this thread for an update!

    -Edit-
    Cybermaxke
    Of course I'm not trying to rush you, but do you know when you'd finish updating the API? I can't wait to use it ^_^
     
  4. Offline

    Minnymin3

    I created my own custom item class for one of my plugins... Kinda wish I had seen this first...
    Anyways nice job!
     
  5. Offline

    Hydrosis

  6. Offline

    Minnymin3

  7. Offline

    Hydrosis

    Thanks! That code looks really helpful ^_^
     
  8. Offline

    BRampersad

    Nice API. I have a couple of questions. Are you planning on adding support for entities that spawn as a result of using the CustomItem? Example would be an arrow that spawns as a result of a Custom Bow use.
     
  9. Offline

    Cybermaxke

    Not really, but you can do it yourself. ;)
     
  10. Offline

    Hydrosis

    Wait, so is it not updated or am I just writing bad code? :/
     
  11. Offline

    Cybermaxke

    Donwload the latest build here: http://81.165.56.159:8080/
    But I didn't test them yet.
     
  12. Offline

    Hydrosis

    Thanks for the response haha! Also, that link is dead, just saying. :3

    Just wondering, where exactly are these imports coming from?

    import net.minecraft.server.v1_5_R3.*;
    and
    import org.bukkit.craftbukkit.v1_5_R3.inventory.CraftItemStack;

    I tried using minecraft_server.jar for the first one (no luck) and it can't find the second one in the beta build of cb 1.5.2 (as well as a ton of errors dealing with NBTBase lol. I'm assuming it has to do with not importing correctly).

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  13. Offline

    BRampersad

    I think the NBTBase errors are coming from a not up to date version of TagUtils as stated here: http://forums.bukkit.org/threads/materialapi-create-new-items-and-blocks.123851/page-4#post-1678025
     
  14. Offline

    Nova20012

    Cybermaxke
    Any idea when the new updated TagUtils will come out? I really want to try this API! By the way, thanks for making it so simple to use!
     
  15. Offline

    Cybermaxke

  16. Offline

    Nova20012

    Cybermaxke
    Do I put that in my ...server/plugins folder?
     
  17. Offline

    BRampersad

    Any plans to support OnItemConsumeEvent?

    Using the Phoenix example and the latest dev jar on your Jenkins repo i get the following exception:

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  18. Offline

    xxNightlordx

    Does the setDamage conflict with Mcmmo?
     
  19. Offline

    DreadKyller

    When I compile and start my server, the plugin fails to load. I'm typically good with understanding the error logs, but I can't find the source of this issue, because the error is being trown from inside your API.

    I'm having a LOT of errors, not just some, but a LOT.

    For some reason my plugin loads before the API and therefore can't utilize everything completely. Besides that however I get this error:

    Code:
    [SEVERE] Could not load 'plugins\CustomWeapons.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.NullPointerException
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:182)
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
    at org.bukkit.craftbukkit.v1_5_R3.CraftServer.loadPlugins(CraftServer.java:239)
    at org.bukkit.craftbukkit.v1_5_R3.CraftServer.<init>(CraftServer.java:217)
    at net.minecraft.server.v1_5_R3.PlayerList.<init>(PlayerList.java:55)
    at net.minecraft.server.v1_5_R3.DedicatedPlayerList.<init>(SourceFile:11)
    at net.minecraft.server.v1_5_R3.DedicatedServer.init(DedicatedServer.java:106)
    at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java:382)
    at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:573)
    Caused by: java.lang.NullPointerException
    at me.cybermaxke.materialapi.map.MapData.addMapData(MapData.java:78)
    at me.cybermaxke.materialapi.map.CustomMap.<init>(CustomMap.java:39)
    at me.cybermaxke.materialapi.map.CustomMap.<init>(CustomMap.java:48)
    at me.cybermaxke.materialapi.map.CustomMap.<init>(CustomMap.java:44)
    at org.ic3d.weapon.baseline.Weapon.<init>(Weapon.java:16)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:178)
    ... 9 more
    [MaterialAPI] Loading MaterialAPI v2.1
    [MaterialAPI] Enabling MaterialAPI v2.1
     
    [MaterialAPI] Metrics loaded!
    [MaterialAPI] The api is loaded.
    
    That is the error I keep getting, it's talking about not being able to creat the instance. I have the proper constructor you've talked about and I don't see anything wrong with the setup.

    After the server finished loading, I get one specific error that keeps appearing on a loop:

    Code:
    [SEVERE] Could not pass event ChunkUnloadEvent to MaterialAPI v2.1
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462)
    at net.minecraft.server.v1_5_R3.ChunkProviderServer.unloadChunks(ChunkProviderServer.java:292)
    at net.minecraft.server.v1_5_R3.WorldServer.doTick(WorldServer.java:190)
    at net.minecraft.server.v1_5_R3.MinecraftServer.r(MinecraftServer.java:555)
    at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:226)
    at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:477)
    at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java:410)
    at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:573)
    Caused by: java.lang.NoClassDefFoundError: net/minecraft/server/v1_5_R2/NBTBase
    at me.cybermaxke.chunkdata.ChunkDataMap.save(ChunkDataMap.java:114)
    at me.cybermaxke.chunkdata.ChunkDataListener.onChunkUnload(ChunkDataListener.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425)
    ... 10 more
    Caused by: java.lang.ClassNotFoundException: net.minecraft.server.v1_5_R2.NBTBase
    at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:70)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 17 more
    
    this error appears about 20 times a second (once per server tick)

    My code:

    Weapon.java:
    Code:
    package org.ic3d.weapon.baseline;
    import me.cybermaxke.materialapi.inventory.CustomItemStack;
    import me.cybermaxke.materialapi.map.CustomMap;
    import me.cybermaxke.materialapi.material.CustomMaterial;
    import me.cybermaxke.materialapi.recipe.CustomRecipeShaped;
    import me.cybermaxke.materialapi.recipe.RecipeData;
    import java.io.File;
    import org.bukkit.Material;
    import org.bukkit.plugin.java.JavaPlugin;
    public class Weapon extends JavaPlugin
    {
    CustomMap PICTURE = new CustomMap("doombring", new File("plugins/weapons/doombringer.png"));
     
    public static CustomMaterial DOOM_BRINGER;
     
    public void onEnable()
    {
      System.out.println();
      System.out.println("[CustomWeapons] Trying to Add \"Doom Bringer\"");
      DOOM_BRINGER = new DoomBringer(this, "doombringer", Material.DIAMOND_SWORD);
     
      CustomItemStack is = new CustomItemStack(DOOM_BRINGER);
     
      CustomRecipeShaped r = new CustomRecipeShaped(is);
        r.setShape(
            new CustomItemStack[] { new CustomItemStack(Material.OBSIDIAN) },
            new CustomItemStack[] { new CustomItemStack(Material.OBSIDIAN) },
            new CustomItemStack[] { new CustomItemStack(Material.BLAZE_ROD) });
     
        RecipeData.registerRecipe(r);
        System.out.println("[CustomWeapons] Custom Weapons has been Enabled :)");
        System.out.println();
    }
    public void onDisable()
    {
      System.out.println();
      System.out.println("[CustomWeapons] Custom Weapons has been Disabled :(");
      System.out.println();
    }
    }
    
    DoomBringer.java:
    Code:
    package org.ic3d.weapon.baseline;
    import org.bukkit.Material;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.block.BlockDamageEvent;
    import org.bukkit.event.block.BlockPlaceEvent;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerItemHeldEvent;
    import me.cybermaxke.materialapi.material.CustomMaterial;
    public class DoomBringer extends CustomMaterial
    {
     
    public DoomBringer(Weapon pl, String id, Material material)
    {
      super(id,material);
     
      this.setMap(pl.PICTURE);
      this.setName("Doom Bringer");
      this.setData((byte)0);
     
      this.setLore("A most unusual weapon", "It drains the soul");
    }
    @Override
    public void onHit(EntityDamageByEntityEvent event)
    {
      if(event.getDamager().getType() != EntityType.PLAYER)
      {
      return;
      }
      event.getEntity().setFireTicks(60);
     
      //The Doom Bringer restores half the damage it does to the
      //player holding it. This power can make the holder hungry for
      //more power, and for food.
     
      int damage = event.getDamage();
     
      Player player = (Player)event.getDamager();
     
      int health = player.getHealth() + (damage / 2);
     
      player.setHealth( health <= 20 ? health : 20 );
     
      int food = player.getFoodLevel() - (damage / 4);
      float saturation = player.getSaturation() - ((float)damage / 10);
     
      if (saturation < 0.05)
      {
      player.setFoodLevel(food >= 0 ? food : 0);
      }
      else
      {
      player.setSaturation((float) (saturation >= 0.0 ? saturation : 0.0));
      }
    }
    @Override
    public void onBlockBreak(BlockBreakEvent arg0)
    {
    }
    @Override
    public void onBlockDamage(BlockDamageEvent arg0)
    {
    }
    @Override
    public void onBlockInteract(PlayerInteractEvent arg0)
    {
    }
    @Override
    public void onBlockPlaced(BlockPlaceEvent arg0)
    {
    }
    @Override
    public void onHold(PlayerItemHeldEvent arg0)
    {
    }
    @Override
    public void onInteract(PlayerInteractEvent arg0)
    {
    }
    @Override
    public void onInteractEntity(PlayerInteractEntityEvent arg0)
    {
    }
    }
    I'm taking a guess that a bulk of this is out of date errors? because the API seems to be looking for server.v1_5_R2 while the build is server.v1_5_R3, but that still doesn't explain the first error (or maybe it does?).

    Anyways, can someone provide some feedback?

    EDIT! I downgraded to 1.5.1 R.02 which got rid of the constant errors, however the inital errors are still occuring.
     
  20. Offline

    Cybermaxke

    You can also use the TagUtils into your own plugin and add adding your own tags for the ids, so you don't need any dependency. (Also change the package for conflicts with other plugins.)
    I will update the thread for info about the tagutils.
     
  21. Offline

    jb_aero

    D: I only just started using it
     
  22. Offline

    Cybermaxke

    Last edited by a moderator: May 30, 2016
  23. Be a shame to lose this api, love the idea of being to create infinite items with ease
     
  24. Offline

    Cybermaxke

    Updates may just take a while, but I will try to find some time to keep it working.
     
  25. That would be greatly appreciated. I'm using this to create an infinite crafting plugin that allows players to craft items based on material properties.

    So far so good. Thanks mucho for this API, its has saved my a whole heap of time.
     
  26. Offline

    DreadKyller

    Cybermaxke yes, but how do I do that, since the way to load a plugin is via /reload which will also reload all the plugins, in wich case gives the same results. I could probably onEnable wait for the world to finish loading and then do all the initalizing of the map.
     
  27. Offline

    H3XCoding

    Great tutorial!
     
  28. I'm confused.
    I can't figure out how to use a map as "texture".
    Here's my code, pls help me out. I've been trying to get it working for 2 hours now, but I'm sure you guys know how it should be^^
    #
    [removed the unimportant parts of my code]

    Main class:
    Code:
    public class ThaumTools extends JavaPlugin implements Listener {
     
        public static CustomMaterial ThaumAxe;
     
        @Override
        public void onEnable() {
            getServer().getPluginManager().registerEvents(this, this);
     
            ThaumAxe = new ThaumAxe("ThaumAxe", Material.DIAMOND_AXE);
           
            CustomItemStack is1 = new CustomItemStack(ThaumAxe);
            CustomRecipeShaped r1 = new CustomRecipeShaped(is1);
            r1.setShape(
                    new CustomItemStack[]{null, new CustomItemStack(Material.DIAMOND), null},
                    new CustomItemStack[]{new CustomItemStack(Material.DIAMOND), new CustomItemStack(Material.DIAMOND_AXE), new CustomItemStack(Material.DIAMOND)},
                    new CustomItemStack[]{null});
            RecipeData.registerRecipe(r1);
        }
    }


    Weapon class:
    Code:
    public class ThaumAxe extends CustomMaterial {
     
        public ThaumTools plugin;
        CustomMap PICTURE;
     
        public ThaumAxe(String id, Material material) {
            super(id, material);
            this.PICTURE = new CustomMap("pictureId", new File("plugins/ThaumTools/axe.png"));
     
            this.setDamage(3);
            this.setName("ThaumAxe");
            this.setLore("Left-click a tree!");
        }
    }
    Thanks in advance!
     
  29. Offline

    desht

Thread Status:
Not open for further replies.

Share This Page