majesity
Members-
Posts
19 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
majesity's Achievements
Tree Puncher (2/8)
1
Reputation
-
Hi all, for my mod I am making a spider that shoots poisonous projectiles at the player (called a crawler) and I want to make a custom projectile for this. I have made the projectile entity class and I know that I need to make the rendering class, but before I do that I need to make a custom EntityType in order to even create the projectile entity in the world. Here is my projectile class: public class CrawlerVenomEntity extends AbstractCrawlerVenomEntity { public int explosionPower = 0; public double explosionRadius = 2.0; public CrawlerVenomEntity(EntityType<CrawlerVenomEntity> type, World worldIn) { super(type, worldIn); } @OnlyIn(Dist.CLIENT) public CrawlerVenomEntity(EntityType<? extends CrawlerVenomEntity> type, World worldIn, double x, double y, double z, double accelX, double accelY, double accelZ) { super(type, x, y, z, accelX, accelY, accelZ, worldIn); this.setVelocity(accelX, accelY, accelZ); } /** * Called when this EntityFireball hits a block or entity. */ protected void onImpact(RayTraceResult result) { super.onImpact(result); if (!this.world.isRemote) { boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this.func_234616_v_()); this.world.playSound(this.getPosX(),this.getPosY(),this.getPosZ(), SoundEvents.ENTITY_SPIDER_AMBIENT, SoundCategory.HOSTILE,1.0F,1.0F,true); World world = this.getEntityWorld(); world.addParticle(ParticleTypes.ITEM_SLIME,this.getPosX(),this.getPosY()+0.5,this.getPosZ(),0,1,0); world.addParticle(ParticleTypes.ITEM_SLIME,this.getPosX(),this.getPosY()+1.5,this.getPosZ(),0,1,0); world.addParticle(ParticleTypes.ITEM_SLIME,this.getPosX(),this.getPosY()+1.0,this.getPosZ(),0,1,0); // this.world.createExplosion((Entity)null, this.getPosX(), this.getPosY(), this.getPosZ(), (float)this.explosionPower, flag, flag ? Explosion.Mode.DESTROY : Explosion.Mode.NONE); Vector3d victor = result.getHitVec(); AxisAlignedBB aabb = new AxisAlignedBB(this.getPosX()-explosionRadius,this.getPosY()-explosionRadius,this.getPosZ()-explosionRadius, this.getPosX()+explosionRadius,this.getPosY()+explosionRadius,this.getPosZ()+explosionRadius); for(LivingEntity e:this.world.getEntitiesWithinAABB(LivingEntity.class,aabb)) { e.attackEntityFrom(DamageSource.MAGIC,5); e.addPotionEffect(new EffectInstance(Effects.POISON,80,1)); } this.remove(); } } /** * Called when the arrow hits an entity */ protected void onEntityHit(EntityRayTraceResult p_213868_1_) { super.onEntityHit(p_213868_1_); if (!this.world.isRemote) { Entity entity = p_213868_1_.getEntity(); Entity entity1 = this.func_234616_v_(); entity.attackEntityFrom(DamageSource.MAGIC, 6.0F); if (entity1 instanceof LivingEntity) { this.applyEnchantments((LivingEntity)entity1, entity); } } } public void writeAdditional(CompoundNBT compound) { super.writeAdditional(compound); compound.putInt("ExplosionPower", this.explosionPower); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readAdditional(CompoundNBT compound) { super.readAdditional(compound); if (compound.contains("ExplosionPower", 99)) { this.explosionPower = compound.getInt("ExplosionPower"); } } protected ItemStack getStack() { return new ItemStack(Items.SLIME_BALL); } @OnlyIn(Dist.CLIENT) public ItemStack getItem() { ItemStack itemstack = this.getStack(); return itemstack.isEmpty() ? new ItemStack(Items.SLIME_BALL) : itemstack; } } Here is the AbstractCrawlerVenomEntity class: @OnlyIn( value = Dist.CLIENT, _interface = IRendersAsItem.class ) public abstract class AbstractCrawlerVenomEntity extends DamagingProjectileEntity implements IRendersAsItem { private static final DataParameter<ItemStack> STACK = EntityDataManager.createKey(net.minecraft.entity.projectile.AbstractFireballEntity.class, DataSerializers.ITEMSTACK); public AbstractCrawlerVenomEntity(EntityType<? extends AbstractCrawlerVenomEntity> p_i50166_1_, World p_i50166_2_) { super(p_i50166_1_, p_i50166_2_); } public AbstractCrawlerVenomEntity(EntityType<? extends AbstractCrawlerVenomEntity> p_i50167_1_, double p_i50167_2_, double p_i50167_4_, double p_i50167_6_, double p_i50167_8_, double p_i50167_10_, double p_i50167_12_, World p_i50167_14_) { super(p_i50167_1_, p_i50167_2_, p_i50167_4_, p_i50167_6_, p_i50167_8_, p_i50167_10_, p_i50167_12_, p_i50167_14_); } public void setStack(ItemStack p_213898_1_) { if (p_213898_1_.getItem() != Items.FIRE_CHARGE || p_213898_1_.hasTag()) { this.getDataManager().set(STACK, Util.make(p_213898_1_.copy(), (p_213897_0_) -> { p_213897_0_.setCount(1); })); } } protected ItemStack getStack() { return this.getDataManager().get(STACK); } @OnlyIn(Dist.CLIENT) public ItemStack getItem() { ItemStack itemstack = this.getStack(); return itemstack.isEmpty() ? new ItemStack(Items.FIRE_CHARGE) : itemstack; } protected void registerData() { this.getDataManager().register(STACK, ItemStack.EMPTY); } public void writeAdditional(CompoundNBT compound) { super.writeAdditional(compound); ItemStack itemstack = this.getStack(); if (!itemstack.isEmpty()) { compound.put("Item", itemstack.write(new CompoundNBT())); } } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readAdditional(CompoundNBT compound) { super.readAdditional(compound); ItemStack itemstack = ItemStack.read(compound.getCompound("Item")); this.setStack(itemstack); } } And I am trying to create an EntityType for this class so I can spawn it in by doing the following in my EntityTypesInit: public class ModEntityTypes { public static DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, MajCraft.MOD_ID); // All my other Entity Types here // Projectile Entity Types public static final RegistryObject<EntityType<CrawlerVenomEntity>> CRAWLER_VENOM = ENTITY_TYPES.register("crawler_venom", () -> EntityType.Builder.create(CrawlerVenomEntity::new, EntityClassification.MISC) .size(1.0f,0.5f) .build(new ResourceLocation(MajCraft.MOD_ID, "crawler_venom").toString()) ); } But for some reason it does not like the CrawlerVenomEntity::new and I do not know why... I've played around with changing the data types of the parameters. To spawn in the entity I want to do something like this: CrawlerVenomEntity test = new CrawlerVenomEntity(ModEntityTypes.CRAWLER_VENOM,worldIn,playerIn.getPosX()+playerIn.getForward().getX(),playerIn.getPosY()+1.25,playerIn.getPosZ()+playerIn.getForward().getZ(),playerIn.getForward().getX(),playerIn.getForward().getY(),playerIn.getForward().getZ()) Why isn't this working? Thank you for your time!
-
But how would I make one in this scenario? And what specified Type would it need to return? I have tried a boatload of things including making blank constructors that assign default values, but none have worked. Could you point me in the right direction? Thank you for helping me on this.
-
I didn't figure it out, my current solution is to make the recipe for my item take 100000 ticks to complete so players can theoretically never smelt it from a vanilla furnace, then in my custom furnace I check for the item and set the smelting time to 100. I don't like it because it means that it consumes the item if a player puts it in the vanilla furnace instead of just having it not smelt, but it works and I can't figure anything else out.
-
ok so I got as far as this: public static final DeferredRegister<IRecipeSerializer<?>> RECIPES = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, MajCraft.MOD_ID); public static final RegistryObject<ObsidianForgeRecipeSerializer<ObsidianForgeRecipe>> OBSIDIAN_FORGE_RECIPES = RECIPES.register("obsidian_forge", ObsidianForgeRecipeSerializer); What do I need to put in place of ObsidianForgeRecipeSerializer. I know it needs to be a Supplier, but how to I make one for the ObsidianForgeRecipeSerializer? Is it a lambda expression?
-
Would that be through a DeferredRegistry? This is as far as I got but I don't know what value to assign it to: @ObjectHolder(MajCraft.MOD_ID) public class ModRecipeSerializers { public static final ObsidianForgeRecipeSerializer<ObsidianForgeRecipe> OBSIDIAN_FORGE = null; } or do I do it like I do with all my other stuff in the mod with Deferred Registries like for example my items: public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MajCraft.MOD_ID); public void init() { ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); } I looked into the ForgeRegistries and it has ForgeRegistries.RECIPE_SERIALIZERS... is this it? Where can I look to learn how to do this? Sorry if this is a noob question.
-
Hi all! For my mod I have a custom furnace called the Obsidian Forge which is used to smelt higher tier ores that can't be smelted in a regular furnace. However, I'm having trouble with making custom recipe JSONs to be used for the forge. I made an ObsidianForgeRecipe class and an ObsidianForgeRecipeSerializer class and they both have no errors when I load up a world, but it says '[Render thread/WARN] [minecraft/ClientRecipeBook]: Unknown recipe category: minecraft:obsidian_forge/majcraft:obsidian_forge' which means that my custom recipe type must not have been properly registered, but how do I do that? Here is my Obsidian Forge class: public class ObsidianForgeRecipe implements IRecipe<RecipeWrapper> { public static final IRecipeType<ObsidianForgeRecipe> obsidian_forge = IRecipeType.register("obsidian_forge"); private final IRecipeType<?> type; private final ResourceLocation id; final String group; final Ingredient ingredient; final ItemStack result; final int cookTime; public ObsidianForgeRecipe(ResourceLocation resourceLocation, String group, Ingredient ingredient, ItemStack result, int cookTime) { type = obsidian_forge; id = resourceLocation; this.group = group; this.ingredient = ingredient; this.result = result; this.cookTime = cookTime; } @Override public boolean matches(RecipeWrapper inv, World worldIn) { return this.ingredient.test(inv.getStackInSlot(0)); } @Override public ItemStack getCraftingResult(RecipeWrapper inv) { return this.result.copy(); } @Override public boolean canFit(int width, int height) { return true; } @Override public ItemStack getRecipeOutput() { return result; } @Override public ResourceLocation getId() { return id; } @Override public IRecipeSerializer<?> getSerializer() { return ModRecipeSerializers.OBSIDIAN_FORGE; } @Override public IRecipeType<?> getType() { return type; } @Override public NonNullList<Ingredient> getIngredients() { NonNullList<Ingredient> nonnulllist = NonNullList.create(); nonnulllist.add(this.ingredient); return nonnulllist; } @Override public ItemStack getIcon() { return new ItemStack(ModBlocks.OBSIDIAN_FORGE.get()); } public int getCookTime() { return cookTime; } } and here is my ObsidianForgeRecipeSerializer class: public class ObsidianForgeRecipeSerializer<T extends ObsidianForgeRecipe> extends net.minecraftforge.registries.ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<T> { private final ObsidianForgeRecipeSerializer.IFactory<T> factory; public ObsidianForgeRecipeSerializer(ObsidianForgeRecipeSerializer.IFactory<T> factory) { this.factory = factory; } @Override @Nonnull public T read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json) { // group String groupString = JSONUtils.getString(json, "group", ""); // ingredient JsonElement ingredientJSON = JSONUtils.isJsonArray(json, "ingredient") ? JSONUtils.getJsonArray(json, "ingredient") : JSONUtils.getJsonObject(json, "ingredient"); Ingredient ingredient = Ingredient.deserialize(ingredientJSON); // result ItemStack resultItemStack; if (!json.has("result")) { resultItemStack = ItemStack.EMPTY; } else if (json.get("result").isJsonObject()) { resultItemStack = ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(json, "result")); } else { String resultString = JSONUtils.getString(json, "result"); ResourceLocation resultRS = new ResourceLocation(resultString); resultItemStack = new ItemStack(ForgeRegistries.ITEMS.getValue(resultRS)); } // cookTime int cookTime = JSONUtils.getInt(json, "furnaceTime", 200); return this.factory.create(recipeId, groupString, ingredient, resultItemStack, cookTime); } @Nullable @Override public T read(@Nonnull ResourceLocation recipeId, PacketBuffer buffer) { // group String groupString = buffer.readString(32767); // ingredient Ingredient ingredient = Ingredient.read(buffer); // result ItemStack itemstack = buffer.readItemStack(); // cookTime int cookTime = buffer.readVarInt(); return this.factory.create(recipeId, groupString, ingredient, itemstack, cookTime); } @Override public void write(PacketBuffer buffer, T recipe) { // group buffer.writeString(recipe.group); // ingredient recipe.ingredient.write(buffer); // result buffer.writeItemStack(recipe.result); // cookTime buffer.writeVarInt(recipe.cookTime); } public interface IFactory<T extends ObsidianForgeRecipe> { T create(ResourceLocation resourceLocation, String group, Ingredient ingredient, ItemStack result, int cookTime); } } link to my github: https://github.com/majesityreal/MajCraft Thank you for your time and help!
-
Hello all, for my mod I want to have an ore that is smelt-able when you throw it into the end gateway so I have set up a simple item toss event with ray tracing. The tracing works with any block that I'm looking at but for some reason it doesn't even fire for the end gateway (it doesn't recognize it as a block even) Here is my code: @SubscribeEvent public static void onItemDrop(ItemTossEvent event) { if(event.getEntityItem().getItem().getItem().equals(ModItems.FIN_ORE_ITEM.get().getItem())) { PlayerEntity player = event.getPlayer(); Vector3d eyePos = player.getEyePosition(1.0F); BlockRayTraceResult result = player.getEntityWorld().rayTraceBlocks(new RayTraceContext(eyePos, player.getLookVec().mul(5,5,5).add(eyePos), RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player)); if(result.getType() == RayTraceResult.Type.BLOCK) { MajCraft.LOGGER.info("result location: " + result.getPos().toString()); if(player.getEntityWorld().getBlockState(result.getPos()).equals(Blocks.END_GATEWAY.getDefaultState())) { MajCraft.LOGGER.info("Yes it is the end gateway!"); } if(player.getEntityWorld().getBlockState(result.getPos()).equals(Blocks.END_STONE.getDefaultState())) { MajCraft.LOGGER.info("it is end stone"); } } } } When I look at end stone, the log will print the location of the end stone say "it is end stone" (as expected). However, when I look at the end portal gate, it doesn't even print a "result location: " which means it doesn't recognize it as a block. What's even weirder is when I look at a block through the end gateway, it will print out the result location of that block (not the gateway). How can I make sure the player is looking at the end gateway so I can 'smelt' the ore when they throw it in? Thank you!
-
[Solved] [1.16.1] Trouble with Capabilities and LazyOptionals
majesity replied to majesity's topic in Modder Support
Yes! This worked! Thank you so much. I can't express how grateful I am, I've spent nearly three days trying to figure out this issue and it finally works. Thank you. -
[Solved] [1.16.1] Trouble with Capabilities and LazyOptionals
majesity replied to majesity's topic in Modder Support
I just edited the post, I have late night foggy brain I was being stupid. I just put my project into a repository, here: https://github.com/majesityreal/MajCraft -
[Solved] [1.16.1] Trouble with Capabilities and LazyOptionals
majesity replied to majesity's topic in Modder Support
My capability is registered properly. I'm still getting the same error: Here is how I registered my capability in my main mod class (called MajCraft): private void setup(final FMLCommonSetupEvent event) { CapabilityManager.INSTANCE.register(IPlayerData.class, new PlayerDataStorage(), PlayerDataFactory::new); } -
[Solved] [1.16.1] Trouble with Capabilities and LazyOptionals
majesity replied to majesity's topic in Modder Support
@SubscribeEvent // LivingEntity#func_233480_cy_() --> LivingEntity#getPosition() public static void onJump(LivingEvent.LivingJumpEvent event) { if(event.getEntityLiving() instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity)event.getEntityLiving(); IPlayerData data = player.getCapability(PlayerDataProvider.capability).orElse(null); data.setHealth(1.0F); MajCraft.LOGGER.info("amount of health " + data.getHealth()); } } All I did was cast it. -
[Solved] [1.16.1] Trouble with Capabilities and LazyOptionals
majesity replied to majesity's topic in Modder Support
I casted it to a PlayerEntity after checking and I still got the same error. -
[Solved] [1.16.1] Trouble with Capabilities and LazyOptionals
majesity replied to majesity's topic in Modder Support
Oh wow I can't believe I forgot to check that *facepalms*. I fixed that and the world launches fine, but the moment I jump it crashes. Here is the error: [19:51:49] [Render thread/ERROR] [ne.mi.ev.EventBus/EVENTBUS]: Exception caught during firing event: null Index: 1 Listeners: 0: NORMAL 1: ASM: class com.majesity.majcraft.events.ModClientEvents onJump(Lnet/minecraftforge/event/entity/living/LivingEvent$LivingJumpEvent;)V java.lang.NullPointerException at com.majesity.majcraft.events.ModClientEvents.onJump(ModClientEvents.java:30) at net.minecraftforge.eventbus.ASMEventHandler_2_ModClientEvents_onJump_LivingJumpEvent.invoke(.dynamic) at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) at net.minecraftforge.common.ForgeHooks.onLivingJump(ForgeHooks.java:412) at net.minecraft.entity.LivingEntity.jump(LivingEntity.java:2010) at net.minecraft.entity.player.PlayerEntity.jump(PlayerEntity.java:1410) at net.minecraft.entity.LivingEntity.livingTick(LivingEntity.java:2575) at net.minecraft.entity.player.PlayerEntity.livingTick(PlayerEntity.java:510) at net.minecraft.client.entity.player.ClientPlayerEntity.livingTick(ClientPlayerEntity.java:834) at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2300) at net.minecraft.entity.player.PlayerEntity.tick(PlayerEntity.java:226) at net.minecraft.client.entity.player.ClientPlayerEntity.tick(ClientPlayerEntity.java:198) at net.minecraft.client.world.ClientWorld.updateEntity(ClientWorld.java:197) at net.minecraft.world.World.guardEntityTick(World.java:637) at net.minecraft.client.world.ClientWorld.tickEntities(ClientWorld.java:166) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1508) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:958) at net.minecraft.client.Minecraft.run(Minecraft.java:586) at net.minecraft.client.main.Main.main(Main.java:184) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) The onJump line 30 is: data.setHealth(1.0F); which is just after I successfully create the data object right here (this is line 29): IPlayerData data = player.getCapability(PlayerDataProvider.capability).orElse(null); What went wrong this time? -
[Solved] [1.16.1] Trouble with Capabilities and LazyOptionals
majesity replied to majesity's topic in Modder Support
?????? I don't know where it went wrong -
[Solved] [1.16.1] Trouble with Capabilities and LazyOptionals
majesity replied to majesity's topic in Modder Support
Ok so I have completely changed around everything. I found another Forge topic and they had their Capabilities set up way more organized, so I mimicked theirs. I have the following: Interface: public interface IPlayerData { float getHealth(); void setHealth(float amount); int getStrength(); int getDexterity(); int getIntelligence(); void setStrength(int amount); void setDexterity(int amount); void setIntelligence(int amount); void addStrength(int amount); void addDexterity(int amount); void addIntelligence(int amount); } Factory: public class PlayerDataFactory implements IPlayerData{ private float health; private int strength; private int dexterity; private int intelligence; public PlayerDataFactory() { } @Override public float getHealth() { return health; } @Override public void setHealth(float amount) { this.health = amount; } @Override public int getStrength() { return strength; } @Override public int getDexterity() { return dexterity; } @Override public int getIntelligence() { return intelligence; } @Override public void setStrength(int amount) { this.strength = amount; } @Override public void setDexterity(int amount) { this.dexterity = amount; } @Override public void setIntelligence(int amount) { this.intelligence = amount; } @Override public void addStrength(int amount) { this.strength += amount; } @Override public void addDexterity(int amount) { this.dexterity += amount; } @Override public void addIntelligence(int amount) { this.intelligence += amount; } } Provider: public class PlayerDataProvider implements ICapabilitySerializable<INBT> { @CapabilityInject(IPlayerData.class) public static Capability<IPlayerData> capability = null; private LazyOptional<IPlayerData> instance = LazyOptional.of(capability::getDefaultInstance); @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { return cap == capability ? instance.cast() : LazyOptional.empty(); } @Override public INBT serializeNBT() { return capability.getStorage().writeNBT(capability, this.instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null); } @Override public void deserializeNBT(INBT nbt) { capability.getStorage().readNBT(capability, this.instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null, nbt); } } Storage: public class PlayerDataStorage implements Capability.IStorage<IPlayerData> { @Nullable @Override public INBT writeNBT(Capability<IPlayerData> capability, IPlayerData instance, Direction side) { CompoundNBT tag = new CompoundNBT(); tag.putFloat("Health", instance.getHealth()); tag.putInt("Strength", instance.getStrength()); tag.putInt("Dexterity", instance.getDexterity()); tag.putInt("Intelligence", instance.getIntelligence()); return tag; } @Override public void readNBT(Capability<IPlayerData> capability, IPlayerData instance, Direction side, INBT nbt) { CompoundNBT tag = (CompoundNBT) nbt; instance.setHealth(tag.getFloat("Health")); instance.setStrength(tag.getInt("Strength")); instance.setDexterity(tag.getInt("Dexterity")); instance.setIntelligence(tag.getInt("Intelligence")); } } @Mod @Mod.EventBusSubscriber(modid = MajCraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class CapabilityHandler { public static final ResourceLocation PLAYER_DATA = new ResourceLocation(MajCraft.MOD_ID, "playerdata"); @SubscribeEvent public void attachCapability(AttachCapabilitiesEvent<Entity> event) { if(!(event.getObject() instanceof PlayerEntity)) { return; } event.addCapability(PLAYER_DATA, new PlayerDataProvider()); } } and finally the place where I am trying to retrieve it (using the LivingJumpEvent just to test it😞 @Mod.EventBusSubscriber(modid = MajCraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class ModClientEvents { @SubscribeEvent public static void onJump(LivingEvent.LivingJumpEvent event) { LivingEntity player = event.getEntityLiving(); IPlayerData data = player.getCapability(PlayerDataProvider.capability).orElseThrow(IllegalStateException::new); data.setHealth(1.0F); MajCraft.LOGGER.info("amount of health " + data.getHealth()); } } The game starts fine but the moment I load a world, it crashes with the following error: [19:27:59] [Server thread/ERROR] [ne.mi.ev.EventBus/EVENTBUS]: Exception caught during firing event: null Index: 1 Listeners: 0: NORMAL 1: ASM: class com.majesity.majcraft.events.ModClientEvents onJump(Lnet/minecraftforge/event/entity/living/LivingEvent$LivingJumpEvent;)V java.lang.IllegalStateException at net.minecraftforge.common.util.LazyOptional.orElseThrow(LazyOptional.java:261) at com.majesity.majcraft.events.ModClientEvents.onJump(ModClientEvents.java:26) at net.minecraftforge.eventbus.ASMEventHandler_2_ModClientEvents_onJump_LivingJumpEvent.invoke(.dynamic) at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) at net.minecraftforge.common.ForgeHooks.onLivingJump(ForgeHooks.java:412) at net.minecraft.entity.LivingEntity.jump(LivingEntity.java:2010) at net.minecraft.entity.LivingEntity.livingTick(LivingEntity.java:2575) at net.minecraft.entity.MobEntity.livingTick(MobEntity.java:536) at net.minecraft.entity.monster.MonsterEntity.livingTick(MonsterEntity.java:42) at net.minecraft.entity.monster.ZombieEntity.livingTick(ZombieEntity.java:245) at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2300) at net.minecraft.entity.MobEntity.tick(MobEntity.java:336) at net.minecraft.entity.monster.ZombieEntity.tick(ZombieEntity.java:216) at net.minecraft.world.server.ServerWorld.updateEntity(ServerWorld.java:616) at net.minecraft.world.World.guardEntityTick(World.java:637) at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:400) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:889) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:825) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:87) at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:665) at net.minecraft.server.MinecraftServer.lambda$func_240784_a_$0(MinecraftServer.java:231) at java.lang.Thread.run(Thread.java:748) [19:27:59] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception net.minecraft.crash.ReportedException: Ticking entity at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:893) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:825) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:87) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:665) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.lambda$func_240784_a_$0(MinecraftServer.java:231) ~[?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:748) [?:1.8.0_251] {} Caused by: java.lang.IllegalStateException at net.minecraftforge.common.util.LazyOptional.orElseThrow(LazyOptional.java:261) ~[forge-1.16.1-32.0.63_mapped_snapshot_20200707-1.16.1-recomp.jar:?] {re:classloading} at com.majesity.majcraft.events.ModClientEvents.onJump(ModClientEvents.java:26) ~[main/:?] {re:classloading} at net.minecraftforge.eventbus.ASMEventHandler_2_ModClientEvents_onJump_LivingJumpEvent.invoke(.dynamic) ~[?:?] {} at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80) ~[eventbus-2.2.0-service.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) ~[eventbus-2.2.0-service.jar:?] {} at net.minecraftforge.common.ForgeHooks.onLivingJump(ForgeHooks.java:412) ~[?:?] {re:classloading} at net.minecraft.entity.LivingEntity.jump(LivingEntity.java:2010) ~[?:?] {re:classloading} at net.minecraft.entity.LivingEntity.livingTick(LivingEntity.java:2575) ~[?:?] {re:classloading} at net.minecraft.entity.MobEntity.livingTick(MobEntity.java:536) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.monster.MonsterEntity.livingTick(MonsterEntity.java:42) ~[?:?] {re:classloading} at net.minecraft.entity.monster.ZombieEntity.livingTick(ZombieEntity.java:245) ~[?:?] {re:classloading} at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2300) ~[?:?] {re:classloading} at net.minecraft.entity.MobEntity.tick(MobEntity.java:336) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.monster.ZombieEntity.tick(ZombieEntity.java:216) ~[?:?] {re:classloading} at net.minecraft.world.server.ServerWorld.updateEntity(ServerWorld.java:616) ~[?:?] {re:classloading} at net.minecraft.world.World.guardEntityTick(World.java:637) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:400) ~[?:?] {re:classloading} at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:889) ~[?:?] {re:classloading,pl:accesstransformer:B} ... 5 more AL lib: (EE) alc_cleanup: 1 device not closed Process finished with exit code -1 onJump line 26 is: IPlayerData data = player.getCapability(PlayerDataProvider.capability).orElseThrow(IllegalStateException::new); So, the error is in getting the actual capability. I don't know why it has a null value. I have put a lot of effort into this and to no avail... please somebody tell me what I am doing wrong! Thank you for your time