Skip to content

Commit

Permalink
Fix #1027
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLane committed Mar 25, 2019
1 parent 51bca3b commit 20d46ff
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/main/java/com/flansmod/common/driveables/EntitySeat.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import io.netty.buffer.ByteBuf;
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;
Expand Down Expand Up @@ -735,27 +735,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<EntityAnimal> 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
{
Expand Down

0 comments on commit 20d46ff

Please sign in to comment.