diff --git a/src/main/java/com/flansmod/common/driveables/EntitySeat.java b/src/main/java/com/flansmod/common/driveables/EntitySeat.java index 72a14428f..2cabc2114 100644 --- a/src/main/java/com/flansmod/common/driveables/EntitySeat.java +++ b/src/main/java/com/flansmod/common/driveables/EntitySeat.java @@ -6,8 +6,8 @@ import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemLead; @@ -743,27 +743,24 @@ public boolean processInitialInteract(EntityPlayer entityplayer, return true; if(currentItem.getItem() instanceof ItemLead) { - if(getControllingPassenger() != null && getControllingPassenger() instanceof EntityLiving && - !(getControllingPassenger() instanceof EntityPlayer)) + if(getControllingPassenger() instanceof EntityAnimal) { - EntityLiving mob = (EntityLiving)getControllingPassenger(); - mob.dismountRidingEntity(); - mob.setLeashHolder(entityplayer, true); + // Minecraft will handle dismounting the mob return true; } + double checkRange = 10; - List nearbyMobs = world.getEntitiesWithinAABB(EntityLiving.class, + List nearbyAnimals = world.getEntitiesWithinAABB(EntityAnimal.class, new AxisAlignedBB(posX - checkRange, posY - checkRange, posZ - checkRange, posX + checkRange, posY + checkRange, posZ + checkRange)); - for(Object obj : nearbyMobs) + for(EntityAnimal animal : nearbyAnimals) { - EntityLiving entity = (EntityLiving)obj; - if(entity.getLeashed() && entity.getLeashHolder() == entityplayer) + if(animal.getLeashed() && animal.getLeashHolder() == entityplayer) { - if(entity.startRiding(this)) + if(animal.startRiding(this)) { - looking.setAngles(-entity.rotationYaw, entity.rotationPitch, 0F); - entity.clearLeashed(true, !entityplayer.capabilities.isCreativeMode); + looking.setAngles(-animal.rotationYaw, animal.rotationPitch, 0F); + animal.clearLeashed(true, !entityplayer.capabilities.isCreativeMode); } else {