Skip to content

Commit

Permalink
Merge pull request #119 from ACGaming/118-kitty-pickup-while-holding-…
Browse files Browse the repository at this point in the history
…item

Bugfix - `Kitty` could only be picked up with empty hand
  • Loading branch information
demonlexe authored Jan 5, 2024
2 parents c4ac146 + 6ca11dd commit 9eab853
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/main/java/drzhark/mocreatures/MoCTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,9 @@ public static void dismountPassengerFromEntity(Entity passenger, Entity entity,
if (entity instanceof EntityPlayer) {
NBTTagCompound tag = entity.getEntityData();
tag.setUniqueId("MOCEntity_Riding_Player", entity.getUniqueID()); // set to self, because cannot set to null.
if (IMoCEntity.class.isAssignableFrom(passenger.getClass())) {
((IMoCEntity)passenger).onStopRidingPlayer();
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/drzhark/mocreatures/entity/IMoCEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,7 @@ public interface IMoCEntity {
String getClazzString();
boolean startRidingPlayer(EntityPlayer player);

void onStopRidingPlayer();

boolean canRidePlayer();
}
Original file line number Diff line number Diff line change
Expand Up @@ -542,4 +542,9 @@ public boolean startRidingPlayer(EntityPlayer player) {
}
return false;
}

@Override
public void onStopRidingPlayer() {
// Called when an Entity is dismounted from riding on the Player's head.
}
}
5 changes: 5 additions & 0 deletions src/main/java/drzhark/mocreatures/entity/MoCEntityAnimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,11 @@ public boolean startRidingPlayer(EntityPlayer player) {
return false;
}

@Override
public void onStopRidingPlayer() {
// Called when an Entity is dismounted from riding on the Player's head.
}

@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 @@ -1043,4 +1043,9 @@ public boolean startRidingPlayer(EntityPlayer player) {
}
return false;
}

@Override
public void onStopRidingPlayer() {
// Called when an Entity is dismounted from riding on the Player's head.
}
}
5 changes: 5 additions & 0 deletions src/main/java/drzhark/mocreatures/entity/MoCEntityMob.java
Original file line number Diff line number Diff line change
Expand Up @@ -517,4 +517,9 @@ public boolean startRidingPlayer(EntityPlayer player) {
}
return false;
}

@Override
public void onStopRidingPlayer() {
// Called when an Entity is dismounted from riding on the Player's head.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -486,16 +486,14 @@ public boolean processInteract(EntityPlayer player, EnumHand hand) {
setAttackTarget(null);
return true;
}
if (stack.isEmpty() && getKittyState() > 2 && pickable()) {
// Can be picked up, then pick it up
if (getKittyState() > 2 && pickable()) {
if (this.startRidingPlayer(player)) {
changeKittyState(15);
}
return true;
}
if (stack.isEmpty() && getKittyState() == 15) {
changeKittyState(7);
return true;
}
// Roped and not on player
if (getKittyState() == 14 && this.getRidingEntity() != null) {
changeKittyState(7);
return true;
Expand All @@ -508,6 +506,13 @@ public boolean isMovementCeased() {
return getIsSitting() || getKittyState() == 6 || (getKittyState() == 16 && getOnTree()) || getKittyState() == 12 || getKittyState() == 17 || getKittyState() == 14 || getKittyState() == 20 || getKittyState() == 23;
}


// Called when an Entity is dismounted from riding on the Player's head.
@Override
public void onStopRidingPlayer() {
// Stopped riding player, reset state to Idle.
changeKittyState(7);
}
@Override
public boolean isOnLadder() {
return this.isBesideClimbableBlock();
Expand Down

0 comments on commit 9eab853

Please sign in to comment.