Topic category: Advanced modding
I know MCreator has a built in event where "entity dies" however, my problem is that I only want it to trigger a procedure when the PLAYER kills an entity. I've tested the entity dies, and if other mobs kill each other or another player kills an entity it counts for all players and still triggers the procedure.
I tried messing with some code, however mine doesn't work and keeps coming up with errors.
@SubscribeEvent
public void kill(LivingDeathEvent event) {
if (event.source.getSourceOfDamage() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) source.getSourceOfDamage();
int i = (int) entity.posX;
int j = (int) entity.posY;
int k = (int) entity.posZ;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = server.worlds[0];
java.util.HashMap<String, Object> dependencies = new java.util.HashMap<>();
dependencies.put("x", i);
dependencies.put("y", j);
dependencies.put("z", k);
dependencies.put("world", world);
dependencies.put("entity", entity);
this.executeProcedure(dependencies);
}
}
And here is the errors from the console:
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_testproc1.java:43: error: source has private access in LivingDeathEvent
if (event.source.getSourceOfDamage() instanceof EntityPlayer) {
^
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_testproc1.java:43: error: cannot find symbol
if (event.source.getSourceOfDamage() instanceof EntityPlayer) {
^
symbol: method getSourceOfDamage()
location: variable source of type DamageSource
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_testproc1.java:44: error: cannot find symbol
EntityPlayer player = (EntityPlayer) source.getSourceOfDamage();
^
symbol: variable source
location: class mcreator_testproc1
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_testproc1.java:45: error: cannot find symbol
int i = (int) entity.posX;
^
symbol: variable entity
location: class mcreator_testproc1
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_testproc1.java:46: error: cannot find symbol
int j = (int) entity.posY;
^
symbol: variable entity
location: class mcreator_testproc1
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_testproc1.java:47: error: cannot find symbol
int k = (int) entity.posZ;
^
symbol: variable entity
location: class mcreator_testproc1
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_testproc1.java:55: error: cannot find symbol
dependencies.put("entity", entity);
^
symbol: variable entity
location: class mcreator_testproc1
7 errors
:compileJava FAILED
FAILURE: Build failed with an exception.
I would like to know this as well. What died and who killed it?