Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

adding health with attributes, and other stuff[Solved.. Finally]


Recommended Posts

wait a second, since the maxhealth attribute already has setShouldWatch I don't need to implement it? I basically but every thing that requires the playertickevent in one method, but only one of the items still seems to works, although right before I log in game, the Item the before currently was working, shows hearts until the login is complete, so basically it lags. so im still not sure how to get both items working properly, I no longer have to subscribe events, just one that does everything. here is the code :P

sorry

public static String theUUID = "1F28C409-EA90-4E54-AD57-13F3D92F68B2"; // this is supposed to be some static-for-your-modifier UUID. You decide what this String is, it must be in an UUID format tho.
public static String theName = "MySuperModifier"; // This will be the name of modifier.
public static String theName1 = "MySuperModifer1";
public static String theName2 = "MySuperModifie2"; // This will be the name of modifier.
public static String theName3 = "MySuperModifer3";
public static AttributeModifier myAttributeModifier = new AttributeModifier(UUID.fromString(theUUID), theName, 10.0D, 0); // And yes, you can put those above inside this one's declaration.
public static AttributeModifier myAttributeModifier1 = new AttributeModifier(UUID.fromString(theUUID), theName1, 20.0D, 0); // And yes, you can put those above inside this one's declaration.
public static AttributeModifier myAttributeModifier2 = new AttributeModifier(UUID.fromString(theUUID), theName2, 10.0D, 0); // And yes, you can put those above inside this one's declaration.
public static AttributeModifier myAttributeModifier3 = new AttributeModifier(UUID.fromString(theUUID), theName3, 20.0D, 0); // And yes, you can put those above inside this one's declaration.

//Now what you do in method to apply/remove:


@SubscribeEvent
public void playerTick(PlayerTickEvent event) {
	if (event.phase == Phase.END) {
		boolean hasItem = event.player.inventory
				.hasItem(ModItems.DnaPosideonInfused);
		boolean hasItem2 = event.player.inventory
				.hasItem(ModItems.DnaZeusInfused);
		if (event.player.capabilities.isCreativeMode) {
		} else {
			if (event.player.isWet()) {
				if (hasItem == true) {
					if (!event.player.worldObj.isRemote) {
						event.player.getEntityAttribute(
								SharedMonsterAttributes.maxHealth)
								.applyModifier(myAttributeModifier1);
						event.player.addPotionEffect(new PotionEffect(
								Potion.moveSpeed.id, 1, 1));
						event.player.addPotionEffect(new PotionEffect(
								Potion.waterBreathing.id, 1, 1));
						event.player.addPotionEffect(new PotionEffect(
								Potion.damageBoost.id, 3, 3));
						event.player.addPotionEffect(new PotionEffect(
								Potion.resistance.id, 1, 1));
					}
				}
			} else {

				if (hasItem == true) {
					if (!event.player.worldObj.isRemote) {
						event.player.getEntityAttribute(
								SharedMonsterAttributes.maxHealth)
								.removeModifier(myAttributeModifier1); 

						event.player.getEntityAttribute(
								SharedMonsterAttributes.maxHealth)
								.applyModifier(myAttributeModifier);
						event.player.addPotionEffect(new PotionEffect(
								Potion.damageBoost.id, 1, 1));
						event.player.addPotionEffect(new PotionEffect(
								Potion.resistance.id, 0, 0));
					}
				}
			}
		}
		if (event.player.capabilities.isCreativeMode) {
		} else {
			if (hasItem == false) {
				if (!event.player.worldObj.isRemote) {
					event.player.getEntityAttribute(
							SharedMonsterAttributes.maxHealth)
							.removeModifier(myAttributeModifier);

				}
			}

			if (event.player.isInWater() && hasItem == true) {
				if (!event.player.worldObj.isRemote) {
					event.player.addPotionEffect(new PotionEffect(
							Potion.regeneration.id, 1, 1));
				}
			}
		}
		if (event.player.capabilities.isCreativeMode) {
		} else {
			if (hasItem2 == true) {
				event.player.capabilities.allowFlying = true;
			}
			if (event.player.capabilities.isFlying) {
				if (hasItem2 == true) {
					if (!event.player.worldObj.isRemote) {
						event.player.getEntityAttribute(
								SharedMonsterAttributes.maxHealth)
								.applyModifier(myAttributeModifier3);
					}
				}
			} else {
				if (hasItem2 == true) {
					if (!event.player.worldObj.isRemote) {
						event.player.getEntityAttribute(
								SharedMonsterAttributes.maxHealth).removeModifier(myAttributeModifier3);

						event.player.getEntityAttribute(
								SharedMonsterAttributes.maxHealth).applyModifier(myAttributeModifier2);
					}
				}
			}
		}

		if (event.player.capabilities.isCreativeMode) {
		} else {
			if (hasItem2 == false) {
				if (!event.player.worldObj.isRemote) {
					event.player.getEntityAttribute(
							SharedMonsterAttributes.maxHealth).removeModifier(myAttributeModifier2); 

				}
				event.player.capabilities.allowFlying = false;
				event.player.capabilities.isFlying = false;
			}
		}
	}
}

Im serious don't look at it!!

Link to comment
Share on other sites

It's like I told you all that stuff and you only focused on fixing one thing. There is a reason why that all was written.

 

Your code does same stuff milion times, not really thing I want to look deep into. You chanve repeating chaines if statements. Unclear actions, again - repeating code.

 

Stop using events for this. This is NOT the right way to to work with custom item effects. Events are for not-your-mod-stuff.

 

As to bumps - I mean, my guesss would be at least N*12h (minimum work/sleep cycle, where N is repeating bump number, lol).

 

 

Other:

if (hasItem == true) - really? just do if (hasItem).

 

Finally to problem:

Read the damn tutorial AND Vanilla code.

You declared 4 different modifiers with different names, yet same UUID.

You need to handle each modifier on its own.

e.g: buff1 (10.0D), buff2 (20.0D), buff3 (30.0D) where each would be checked separately.

I guess (quick look) you can also have 4 modifiers using SAME name and UUID and operation, and just have different value, idk for sure tho.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

wow, im getting better at this sorta thing but my progression compared to others over the last three months does not seem to match others, although I have not met/chated with anyone with such little experience in the minecraft field/java. but thank you I cant believe it was as simple as different uuids :P yeah sorry for the inconvenience. THANKS TO ALL

Im serious don't look at it!!

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.