Topic category: Help with Minecraft modding (Java Edition)
Help Please It is annoying
CODE:
package net.mcreator.liveagain;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.World;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityLiving;
@Elementsliveagain.ModElement.Tag
public class MCreatorA extends Elementsliveagain.ModElement {
public MCreatorA(Elementsliveagain instance) {
super(instance, 5);
}
public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
}
@SubscribeEvent
public void onPlayerHurt(LivingHurtEvent event) {
if (event.entityLiving instanceof EntityPlayer && event.entityLiving.getHealth()-event.ammount <=0) {
System.out.println("The Player " + event.entityLiving.getEntityName() + " died.");
event.setCanceled(true);
}
};
@Override
public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(this);
}
}
Console:
C:\Users\micel\.mcreator\Workspace\new\build\sources\main\java\net\mcreator\liveagain\MCreatorA.java:29: error: entityLiving has private access in LivingEvent
if (event.entityLiving instanceof EntityPlayer && event.entityLiving.getHealth()-event.ammount <=0) {
^
C:\Users\micel\.mcreator\Workspace\new\build\sources\main\java\net\mcreator\liveagain\MCreatorA.java:29: error: entityLiving has private access in LivingEvent
if (event.entityLiving instanceof EntityPlayer && event.entityLiving.getHealth()-event.ammount <=0) {
^
C:\Users\micel\.mcreator\Workspace\new\build\sources\main\java\net\mcreator\liveagain\MCreatorA.java:29: error: cannot find symbol
if (event.entityLiving instanceof EntityPlayer && event.entityLiving.getHealth()-event.ammount <=0) {
^
symbol: variable ammount
location: variable event of type LivingHurtEvent
C:\Users\micel\.mcreator\Workspace\new\build\sources\main\java\net\mcreator\liveagain\MCreatorA.java:33: error: entityLiving has private access in LivingEvent
System.out.println("The Player " + event.entityLiving.getEntityName() + " died.");
^
C:\Users\micel\.mcreator\Workspace\new\build\sources\main\java\net\mcreator\liveagain\MCreatorA.java:33: error: cannot find symbol
System.out.println("The Player " + event.entityLiving.getEntityName() + " died.");
^
symbol: method getEntityName()
location: variable entityLiving of type EntityLivingBase
5 errors
: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. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
5 actionable tasks: 4 executed, 1 up-to-date
BUILD FAILED
Task completed in 1747 milliseconds
It seems you copied some code for different Minecraft version