Jump to content

Need help by experienced people


KarmaOwner

Recommended Posts

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:

 

 

The bar of life of the player when he does not have the helmet equipped with the system of life of my mod:

 

 

The life bar of the player when he equips the helmet with stats of life and more (stats of the plugin):

 

 

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 by KarmaOwner
Link to comment
Share on other sites

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()));
			    	}
			    }
		   }
	   }

 

 

Link to comment
Share on other sites

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 !

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.