(Just so you know I'm kinda new to coding and I'm using MCreator. So don't criticize me in a bad way)
I want to create a mod where I make mobs kill each other. So I'm creating class files that adds code to the source class files of minecraft. (Example: A class file named Zombie,which makes zombies attack skeletons, adds code to EntityZombie, the original Zombie code.) The problem is that I'm not sure if the code structure is right, and I don't know where to put this line of code <FMLCommonHandler.instance().bus().register(new Zombie());>
Here's the code
package mod.mcreator;
public class Zombie {
@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent e) {}
@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event)
{
if (event.entity instanceof EntityLiving) doTaskStuff((EntityLiving) event.entity, event);
}
private void doTaskStuff(EntityLiving e, Event ev)
{
if (e instanceof EntiyZombie)
{
((EntityZombie) e).targetTasks.addTask(2, new EntityAINearestAttackableTarget( e, EntitySkeleton.class, 0, true));
}
}
Okay, I'm not gonna criticize you badly but here's the thing, you are not gonna achieve the result you want with MCreator (trust me, I've tried it before, it's not very good for making mods). So here's the thing, if you wanna make a mod, you should start with the basics and learn how to code. I have been learning how to code for the past 5 years and now I'm golden (now it shouldn't take you that long, at least a few months, maybe longer). I can link you some places to learn programming to start with. It's Java. Secondly, if you want to achieve your mod result, you should open a new dev environment and create a basic mod set up (there are tons of tutorials out there, including mine) and to make the entities attack each other, you gotta add in an AI called EntityAIAttackNearest and put in the parameters this and EntitySkeleton.class, for your EnttiyZombie. Likewise, do the same for the others and put in the necessary entities in the second parameter for their respective entity classes you are creating. If you have any questions relating to modding, don't hesitate to ask, but make sure to google first because some might have asked before (just a little tip).
Rollback Post to RevisionRollBack
If you would like to get a hold of me somehow, then my discord is @Alex Couch#5275.
Also, if you want help with a specific block of code, put it on pastebin and provide a link. Its not as hard as it sounds, and it preserves the formatting of the code, which REALLY REALLY helps hunt down bugs. just google pastebin, there's a big "new paste" button at the top, the rest is largely self explanatory.
(Just so you know I'm kinda new to coding and I'm using MCreator. So don't criticize me in a bad way)
I want to create a mod where I make mobs kill each other. So I'm creating class files that adds code to the source class files of minecraft. (Example: A class file named Zombie,which makes zombies attack skeletons, adds code to EntityZombie, the original Zombie code.) The problem is that I'm not sure if the code structure is right, and I don't know where to put this line of code <FMLCommonHandler.instance().bus().register(new Zombie());>
Here's the code
package mod.mcreator;
public class Zombie {
@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent e) {}
FMLCommonHandler.instance().bus().register(new Zombie());
@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event)
{
if (event.entity instanceof EntityLiving) doTaskStuff((EntityLiving) event.entity, event);
}
private void doTaskStuff(EntityLiving e, Event ev)
{
if (e instanceof EntiyZombie)
{
((EntityZombie) e).targetTasks.addTask(2, new EntityAINearestAttackableTarget( e, EntitySkeleton.class, 0, true));
}
}
}
Someone please help.
Okay, I'm not gonna criticize you badly but here's the thing, you are not gonna achieve the result you want with MCreator (trust me, I've tried it before, it's not very good for making mods). So here's the thing, if you wanna make a mod, you should start with the basics and learn how to code. I have been learning how to code for the past 5 years and now I'm golden (now it shouldn't take you that long, at least a few months, maybe longer). I can link you some places to learn programming to start with. It's Java. Secondly, if you want to achieve your mod result, you should open a new dev environment and create a basic mod set up (there are tons of tutorials out there, including mine) and to make the entities attack each other, you gotta add in an AI called EntityAIAttackNearest and put in the parameters this and EntitySkeleton.class, for your EnttiyZombie. Likewise, do the same for the others and put in the necessary entities in the second parameter for their respective entity classes you are creating. If you have any questions relating to modding, don't hesitate to ask, but make sure to google first because some might have asked before (just a little tip).
If you would like to get a hold of me somehow, then my discord is @Alex Couch#5275.
Also, if you want help with a specific block of code, put it on pastebin and provide a link. Its not as hard as it sounds, and it preserves the formatting of the code, which REALLY REALLY helps hunt down bugs. just google pastebin, there's a big "new paste" button at the top, the rest is largely self explanatory.
My first mod =D