Posted December 9, 20186 yr Hello firstly sorry for my bad english I use translator , I have created a level and attribute mod, the level system works with the vanilla mc system when the player increases by one level he gains +1 life and an attribute point when the player increases the level attribute of life it gains 2 life in addition until the all works however I try to make it compatible with a plugin named "My items" the system of life of this plugin replaces the system of life of my mod example: Spoiler https://cdn.discordapp.com/attachments/520891777893531650/520913955661545472/Screenshot_4.png The bar of life of the player when he does not have the helmet equipped with the system of life of my mod: Spoiler https://cdn.discordapp.com/attachments/520891777893531650/520914145076445184/Screenshot_5.png The life bar of the player when he equips the helmet with stats of life and more (stats of the plugin): Spoiler https://cdn.discordapp.com/attachments/520891777893531650/520915325391339521/Screenshot_6.png as you can see the plugin life system replaces my system the player only have 15 more life , he is supposed to have 24 more life ... I have contacted the creator of the plugin to ask him the sources of his plugin for modifying the sources to add the lives of the two systems , however he explained to me that his plugin works with a library "AgarthaLib" and he told me says that there is an event named "PlayerHealthMaxChangeEvent" and that I can directly add the maximum life of my mod when the event is called however I have no idea how to do it ... Is it possible to use a Spigot library on Forge? Thank you in advance for those who can give me reasoning. Edited December 9, 20186 yr by KarmaOwner
December 9, 20186 yr Author 1 hour ago, diesieben07 said: Show how you increase the player's max health. @SubscribeEvent public void onServerTick(TickEvent.ServerTickEvent event) { World world = MinecraftServer.getServer().getEntityWorld(); for(Object obj : world.playerEntities) { EntityPlayer p = (EntityPlayer) obj; ExtendedPlayer exP = ExtendedPlayer.get(p); p.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(ExtendedPlayer.startHP + Math.abs(p.getMaxHealth() - (p.getHealth() + exP.getHP())) + exP.getHP()); p.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(p.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue() + exP.getDamage()); if(ExtendedPlayer.maxLevel == -1) { if(p.experienceLevel >= exP.getLevel() + 1) { exP.onLevelUP(Math.abs(p.experienceLevel - exP.getLevel())); p.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Felecitations vous venez d'up un level ! Votre lvl : " + EnumChatFormatting.GOLD + exP.getLevel())); } } else { if(p.experienceLevel < ExtendedPlayer.maxLevel && p.experienceLevel >= exP.getLevel() + 1) { exP.onLevelUP(Math.abs(p.experienceLevel - exP.getLevel())); p.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Felecitations vous venez d'up un level ! Votre lvl : " + EnumChatFormatting.GOLD + exP.getLevel())); } } } }
December 14, 20186 yr On 12/9/2018 at 7:42 PM, diesieben07 said: Don't modify the base value of the attribute. Instead apply an attribute modifier, like you can see in EntityLivingBase#onUpdate based on ItemStack#getAttributeModifiers. Thanks I fixed my problem thanks to you !
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.