Skip to content

Commit

Permalink
Simplify pet dismounting
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Aug 23, 2024
1 parent 22ec6b9 commit 40dc0f3
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 40 deletions.
12 changes: 3 additions & 9 deletions src/main/java/drzhark/mocreatures/MoCTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -1225,10 +1225,10 @@ public static void dismountPassengerFromEntity(Entity passenger, Entity entity,
if (!force && (passenger == null || entity == null || passenger.getRidingEntity() == null)) {
return;
}
if (force || (passenger instanceof EntityLivingBase && entity.isSneaking())) {
System.out.println("Forcing dismount from " + entity + " for passenger " + passenger);
passenger.dismountRidingEntity();
if (force || entity.isSneaking() || passenger.isInWater()) {
if (force) MoCreatures.LOGGER.info("Forcing dismount from " + entity + " for passenger " + passenger);
passenger.setPositionAndUpdate(entity.posX, entity.posY + 1D, entity.posZ);
passenger.dismountRidingEntity();
MoCTools.playCustomSound(passenger, SoundEvents.ENTITY_CHICKEN_EGG);
if (entity instanceof EntityPlayer) {
NBTTagCompound tag = entity.getEntityData();
Expand All @@ -1240,12 +1240,6 @@ public static void dismountPassengerFromEntity(Entity passenger, Entity entity,
}
}

public static void dismountSneakingPlayer(Entity entity) {
// Entity is riding the player.
if (!entity.isRiding()) return;
dismountPassengerFromEntity(entity, entity.getRidingEntity(), false);
}

public static boolean isInsideOfMaterial(Material material, Entity entity) {
double d = entity.posY + entity.getEyeHeight();
int i = MathHelper.floor(entity.posX);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public void onLivingUpdate() {
this.randomAttributesUpdated = true;
}

if (this.canRidePlayer() && this.isRiding()) MoCTools.dismountSneakingPlayer(this);
if (this.canRidePlayer() && this.isRiding()) MoCTools.dismountPassengerFromEntity(this, this.getRidingEntity(), false);
super.onLivingUpdate();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void onUpdate() {
}
}
}
if (this.isRiding()) MoCTools.dismountSneakingPlayer(this);
if (this.isRiding()) MoCTools.dismountPassengerFromEntity(this, this.getRidingEntity(), false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void onUpdate() {
setUsedLitter(false);
this.litterTime = 0;
}
if (this.isRiding()) MoCTools.dismountSneakingPlayer(this);
if (this.isRiding()) MoCTools.dismountPassengerFromEntity(this, this.getRidingEntity(), false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,20 +502,6 @@ public void setGestationTime(int time) {
gestationtime = time;
}

@Override
public boolean startRidingPlayer(EntityPlayer player) {
if (MoCTools.getEntityRidingPlayer(player) != null) {
return false; // Something is already riding this player.
}
boolean ret = super.startRiding(player);
if (ret) {
NBTTagCompound tag = player.getEntityData();
tag.setUniqueId("MOCEntity_Riding_Player", this.getUniqueID());
return true;
}
return false;
}

@Override
public boolean canRidePlayer() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,20 +505,6 @@ public int getGestationTime() {
return gestationtime;
}

@Override
public boolean startRidingPlayer(EntityPlayer player) {
if (MoCTools.getEntityRidingPlayer(player) != null) {
return false; // Something is already riding this player.
}
boolean ret = super.startRiding(player);
if (ret) {
NBTTagCompound tag = player.getEntityData();
tag.setUniqueId("MOCEntity_Riding_Player", this.getUniqueID());
return true;
}
return false;
}

@Override
public boolean canRidePlayer() {
return false;
Expand Down

0 comments on commit 40dc0f3

Please sign in to comment.