Added a new function to allow control over whether an entity is dismounted when the entity it is riding goes under water

This commit is contained in:
MrMasochism 2013-08-01 08:02:19 +12:00
parent 6397939c9e
commit 9564575d77
2 changed files with 20 additions and 1 deletions

View File

@ -155,7 +155,7 @@
}
public boolean func_96091_a(Explosion par1Explosion, World par2World, int par3, int par4, int par5, int par6, float par7)
@@ -2426,4 +2496,160 @@
@@ -2426,4 +2496,170 @@
{
return this.getEntityName();
}
@ -314,5 +314,15 @@
+ public boolean canRiderInteract()
+ {
+ return false;
+ }
+
+ /**
+ * If the rider should be dismounted from the entity when the entity goes under water
+ *
+ * @param rider The entity that is riding
+ * @return if the entity should be dismounted when under water
+ */
+ public boolean shouldDismountInWater(Entity rider){
+ return this instanceof EntityLivingBase;
+ }
}

View File

@ -20,6 +20,15 @@
public abstract class EntityLivingBase extends Entity
{
@@ -299,7 +302,7 @@
this.extinguish();
- if (!this.worldObj.isRemote && this.isRiding() && this.ridingEntity instanceof EntityLivingBase)
+ if (!this.worldObj.isRemote && this.isRiding() && ridingEntity!=null && ridingEntity.shouldDismountInWater(this))
{
this.mountEntity((Entity)null);
}
@@ -446,6 +449,7 @@
{
this.entityLivingToAttack = par1EntityLivingBase;