How to give Vanilla Mobs custom Drops

Started by DarkAssassin on

Topic category: Help with Minecraft modding (Java Edition)

Joined Sep 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to give Vanilla Mobs custom Drops
Wed, 08/21/2019 - 01:41 (edited)

So I tried a few things to get this to work but I have had no luck, I've tried Procedures and Overlays, only Procedures have seemed to succeed, but it Only does it for all mobs [Entity Dies] so It's quite useless unless I want all mobs to drop the custom loot.

I tried making an Overlay and editing the code like Nuparu00 said on this topic here -=- https://mcreator.net/comment/28477 -=- and also a small bit of info on this page aswell -=- https://mcreator.net/forum/42141/how-do-i-make-vanilla-mobs-drop-custom… -=-

I believe to have a good grip on what I need to do, for example. This is what I tried to do while following the instructions that I could see.

Below is the original code, Below that will be my edited version of the code.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

public class mcreator_test {

    public static Object instance;

    public void load(FMLInitializationEvent event) {
        MinecraftForge.EVENT_BUS.register(new GUIRenderEventClass());
    }

    public void generateNether(World world, Random random, int chunkX, int chunkZ) {
    }

    public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
    }

    public void serverLoad(FMLServerStartingEvent event) {
    }

    public void preInit(FMLPreInitializationEvent event) {
    }

    public void registerRenderers() {
    }

    public int addFuel(ItemStack fuel) {
        return 0;
    }

    public static class GUIRenderEventClass {

        @SubscribeEvent(priority = EventPriority.NORMAL)
        public void eventHandler(RenderGameOverlayEvent event) {
            if (!event.isCancelable() && event.getType() == RenderGameOverlayEvent.ElementType.HELMET) {
                int posX = (event.getResolution().getScaledWidth()) / 2;
                int posY = (event.getResolution().getScaledHeight()) / 2;
                EntityPlayer entitySP = Minecraft.getMinecraft().player;
                MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
                World world = server.getWorld(entitySP.dimension);
                EntityPlayer entity = entitySP;
                for (EntityPlayer entityMP : world.playerEntities)
                    if (entityMP.getName().equals(entitySP.getName()))
                        entity = entityMP;
                int x = (int) entity.posX;
                int y = (int) entity.posY;
                int z = (int) entity.posZ;
                if ((true)) {
                }
            }
        }
    }
}

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Now for what I was able to do with the instructions given.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

public class mcreator_test {

    public static Object instance;

    public void load(FMLInitializationEvent event) {
        MinecraftForge.EVENT_BUS.register(new GUIRenderEventClass());
    }

    public void generateNether(World world, Random random, int chunkX, int chunkZ) {
    }

    public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
    }

    public void serverLoad(FMLServerStartingEvent event) {
    }

    public void preInit(FMLPreInitializationEvent event) {
    }

    public void registerRenderers() {
    }

    public int addFuel(ItemStack fuel) {
        return 0;
    }

    public static class GUIRenderEventClass {  public void playerKilledZombie(LivingDropsEvent event)
   {
      if(event.entityLiving instanceof EntityZombie)
      {

        

        event.entityLiving.dropItem(Items.rotten_flesh, 1);

         event.entityLiving.dropItem(Items.bone, 1);
        
      }
    
}

        @SubscribeEvent(priority = EventPriority.NORMAL)
        public void eventHandler(RenderGameOverlayEvent event) {
            if (!event.isCancelable() && event.getType() == RenderGameOverlayEvent.ElementType.HELMET) {
                int posX = (event.getResolution().getScaledWidth()) / 2;
                int posY = (event.getResolution().getScaledHeight()) / 2;
                EntityPlayer entitySP = Minecraft.getMinecraft().player;
                MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
                World world = server.getWorld(entitySP.dimension);
                EntityPlayer entity = entitySP;
                for (EntityPlayer entityMP : world.playerEntities)
                    if (entityMP.getName().equals(entitySP.getName()))
                        entity = entityMP;
                int x = (int) entity.posX;
                int y = (int) entity.posY;
                int z = (int) entity.posZ;
                if ((true)) {
                }
            }
        }
    }
}

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Also yes, I have tried to use getEntityLiving() aswell.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

I also tried this but it didn't work.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

public class mcreator_test{

public static class GUIRenderEventClass
{}

public mcreator_overlayTest(){}

public Object instance;
public void load(FMLInitializationEvent event){
    MinecraftForge.EVENT_BUS.register(new GUIRenderEventClass(
    public void playerKilledZombie(LivingDropsEvent event)
   {
      if (event.entityLiving instanceof EntityZombie)
      {

        

        event.entityLiving.dropItem(Items.rotten_flesh, 1);

         event.entityLiving.dropItem(Items.bone, 1);
        
      }
    
}));
    
     
}
public void generateNether(World world, Random random, int chunkX, int chunkZ){}
public void generateSurface(World world, Random random, int chunkX, int chunkZ){}
public int addFuel(ItemStack fuel){return 0;}
public void serverLoad(FMLServerStartingEvent event){}
public void preInit(FMLPreInitializationEvent event){}
public void registerRenderers(){}
}[/spoiler]

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

When I run save and build on any of these, it always comes up as a error.

I'm not too sure what I am doing wrong, Any help would be Appreciated.

 

(Note: If you do happen to know how to do this, could you please provide a 'Before and After' image of the code so it is easier to follow along, thank you.)

(Note: I am also using version 1.8.0 of MCreator)

Edited by DarkAssassin on Wed, 08/21/2019 - 01:41
Joined Sep 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Just another note, when I do…
Sun, 09/23/2018 - 20:23

Just another note, when I do run this, I get this in the Console:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

:clean
:deobfCompileDummyTask
:deobfProvidedDummyTask
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
C:\Pylo\MCreator180\forge\build\sources\main\java\mod\mcreator\mcreator_test.java:48: error: cannot find symbol
  public void playerKilledZombie(LivingDropsEvent event)
                                                   ^
  symbol:  class LivingDropsEvent
  location: class GUIRenderEventClass
1 error
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 13.135 secs
C:\Pylo\MCreator180\forge>
Task completed with return code 0 in 13657 milliseconds

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

From what I can get is that 'LivingDropsEvent' no longer works, I have tried to change it to other things close to it like 'DropsEvent' and 'DropEvent' but it still seems not to work.

Hope this is helpful