Skip to content

Commit

Permalink
Merge pull request #111 from demonlexe/19-mouse-hotfix
Browse files Browse the repository at this point in the history
hotfix for dismounting riding mouse, which isn't `Tameable`
  • Loading branch information
demonlexe authored Jan 4, 2024
2 parents dd31c5a + b58924a commit 386ea80
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
4 changes: 4 additions & 0 deletions src/main/java/drzhark/mocreatures/entity/IMoCEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package drzhark.mocreatures.entity;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;

import java.util.UUID;
Expand Down Expand Up @@ -95,4 +96,7 @@ public interface IMoCEntity {
boolean getIsFlying();

String getClazzString();
boolean startRidingPlayer(EntityPlayer player);

boolean canRidePlayer();
}
14 changes: 14 additions & 0 deletions src/main/java/drzhark/mocreatures/entity/MoCEntityAnimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,20 @@ public boolean getIsGhost() {
return false;
}

@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 void setLeashHolder(Entity entityIn, boolean sendAttachNotification) {
if (this.getIsTamed() && entityIn instanceof EntityPlayer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ public interface IMoCTameable extends IMoCEntity {

int getGestationTime();

boolean startRidingPlayer(EntityPlayer player);

boolean canRidePlayer();

void setGestationTime(int time);

}
Original file line number Diff line number Diff line change
Expand Up @@ -543,18 +543,4 @@ public int getGestationTime() {
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;
}
}
5 changes: 3 additions & 2 deletions src/main/java/drzhark/mocreatures/event/MoCEventHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.google.common.primitives.Ints;
import drzhark.mocreatures.MoCConstants;
import drzhark.mocreatures.MoCTools;
import drzhark.mocreatures.entity.IMoCEntity;
import drzhark.mocreatures.entity.MoCEntityAnimal;
import drzhark.mocreatures.entity.MoCEntityData;
import drzhark.mocreatures.entity.tameable.MoCPetMapData;
Expand Down Expand Up @@ -127,8 +128,8 @@ public void onPlayerLogout(PlayerEvent.PlayerLoggedOutEvent event) {
Entity entityRidingPlayer = MoCTools.getEntityRidingPlayer(player);
if (entityRidingPlayer != null) {
// System.out.println("PLAYER LEFT THE GAME carrying entity: "+entityRidingPlayer);
if (IMoCTameable.class.isAssignableFrom(entityRidingPlayer.getClass())) {
IMoCTameable mocEntity = (IMoCTameable) entityRidingPlayer;
if (IMoCEntity.class.isAssignableFrom(entityRidingPlayer.getClass())) {
IMoCEntity mocEntity = (IMoCEntity) entityRidingPlayer;
if (mocEntity.canRidePlayer()) MoCTools.dismountPassengerFromEntity(entityRidingPlayer, player, true);
}
}
Expand Down

0 comments on commit 386ea80

Please sign in to comment.