|
5 | 5 | import io.netty.buffer.ByteBuf;
|
6 | 6 | import net.minecraft.client.Minecraft;
|
7 | 7 | import net.minecraft.entity.Entity;
|
8 |
| -import net.minecraft.entity.EntityLiving; |
9 | 8 | import net.minecraft.entity.EntityLivingBase;
|
| 9 | +import net.minecraft.entity.passive.EntityAnimal; |
10 | 10 | import net.minecraft.entity.player.EntityPlayer;
|
11 | 11 | import net.minecraft.entity.player.EntityPlayerMP;
|
12 | 12 | import net.minecraft.item.ItemLead;
|
@@ -735,27 +735,24 @@ public boolean processInitialInteract(EntityPlayer entityplayer,
|
735 | 735 | return true;
|
736 | 736 | if(currentItem.getItem() instanceof ItemLead)
|
737 | 737 | {
|
738 |
| - if(getControllingPassenger() != null && getControllingPassenger() instanceof EntityLiving && |
739 |
| - !(getControllingPassenger() instanceof EntityPlayer)) |
| 738 | + if(getControllingPassenger() instanceof EntityAnimal) |
740 | 739 | {
|
741 |
| - EntityLiving mob = (EntityLiving)getControllingPassenger(); |
742 |
| - mob.dismountRidingEntity(); |
743 |
| - mob.setLeashHolder(entityplayer, true); |
| 740 | + // Minecraft will handle dismounting the mob |
744 | 741 | return true;
|
745 | 742 | }
|
| 743 | + |
746 | 744 | double checkRange = 10;
|
747 |
| - List nearbyMobs = world.getEntitiesWithinAABB(EntityLiving.class, |
| 745 | + List<EntityAnimal> nearbyAnimals = world.getEntitiesWithinAABB(EntityAnimal.class, |
748 | 746 | new AxisAlignedBB(posX - checkRange, posY - checkRange, posZ - checkRange, posX + checkRange,
|
749 | 747 | posY + checkRange, posZ + checkRange));
|
750 |
| - for(Object obj : nearbyMobs) |
| 748 | + for(EntityAnimal animal : nearbyAnimals) |
751 | 749 | {
|
752 |
| - EntityLiving entity = (EntityLiving)obj; |
753 |
| - if(entity.getLeashed() && entity.getLeashHolder() == entityplayer) |
| 750 | + if(animal.getLeashed() && animal.getLeashHolder() == entityplayer) |
754 | 751 | {
|
755 |
| - if(entity.startRiding(this)) |
| 752 | + if(animal.startRiding(this)) |
756 | 753 | {
|
757 |
| - looking.setAngles(-entity.rotationYaw, entity.rotationPitch, 0F); |
758 |
| - entity.clearLeashed(true, !entityplayer.capabilities.isCreativeMode); |
| 754 | + looking.setAngles(-animal.rotationYaw, animal.rotationPitch, 0F); |
| 755 | + animal.clearLeashed(true, !entityplayer.capabilities.isCreativeMode); |
759 | 756 | }
|
760 | 757 | else
|
761 | 758 | {
|
|
0 commit comments