Make an EntityPlayer version of onWornTick()
msrEagle opened this issue · 5 comments
As a suggestion, could you consider making a version of onWornTick() that respects EntityPlayer as opposed to the current EntityLivingBase. This would be especially useful to increase the players capabilities using things such as the speedOnGround variable, the speedInAir variable and to test to see if the player is blocking, without needing to add potion effects.
What you're supposed to do is the following:
@Override
public void onWornTick(ItemStack itemstack, EntityLivingBase entity) {
// Just in case Azanor wants Baubles to be available to mobs,
// you should check if the EntityLivingBase is an EntityPlayer.
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer)entity;
// Do something with the player here.
}
}
You should've looked up what "casting" actually means in Java.
Apologies if I'm asking alot of questions, I've never really used an API other than Forge of course, but replacing "EntityLivingBase" with "EntityPlayer" in the onWornTick variable just tells me to implement onWornTick with "EntityLivingBase" instead.
eg.
@OverRide
public void onWornTick(ItemStack itemstack, EntityLivingBase player)
{ }
works fine, but if I changed it to
@OverRide
public void onWornTick(ItemStack itemstack, EntityPlayer player)
{ }
it would claim I am not using onWornTick. Would you mind providing a quick example of what you meant?
Aha, cheers.
-----Original Message-----
From: "copygirl" [email protected]
Sent: 09/05/2014 17:34
To: "Azanor/Baubles" [email protected]
Cc: "GustoniaEagle" [email protected]
Subject: Re: [Baubles] Make an EntityPlayer version of onWornTick() (#21)
What you're supposed to do is the following:
@OverRide
public void onWornTick(ItemStack itemstack, EntityLivingBase entity) {
// Just in case Azanor wants Baubles to be available to mobs,
// you should check if the EntityLivingBase is an EntityPlayer.
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer)entity;
// Do something with the player here.
}
}
You should've looked up what "casting" actually means in Java.
—
Reply to this email directly or view it on GitHub.