Skip to content

Commit

Permalink
Fix entity morphs not making voice/footstep sounds when switching dim…
Browse files Browse the repository at this point in the history
…ensions
  • Loading branch information
asanetargoss committed Dec 18, 2017
1 parent 5d68c51 commit 6ad448c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/mchorse/metamorph/api/MorphHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;

Expand Down Expand Up @@ -246,6 +247,20 @@ public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event)
}
}
}

/**
* Make sure the player dimension and morph dimension are synced
*/
@SubscribeEvent
public void onPlayerChangeDimension(PlayerChangedDimensionEvent event)
{
IMorphing capability = Morphing.get(event.player);

if (capability != null && capability.getCurrentMorph() != null)
{
capability.getCurrentMorph().onChangeDimension(event.player, event.fromDim, event.toDim);
}
}

/**
* Run future tasks on both client and server.
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/mchorse/metamorph/api/morphs/AbstractMorph.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ public void playStepSound(EntityLivingBase target)
e.printStackTrace();
}
}

/**
* Called when the player just changed dimensions
*/
public void onChangeDimension(EntityPlayer player, int oldDim, int currentDim) { }

/**
* Check either if given object is the same as this morph
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/mchorse/metamorph/api/morphs/EntityMorph.java
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,15 @@ public void playStepSound(EntityLivingBase target)
e.printStackTrace();
}
}

@Override
public void onChangeDimension(EntityPlayer player, int oldDim, int currentDim)
{
if (this.entity != null)
{
this.entity.worldObj = player.worldObj;
}
}

@Override
public void toNBT(NBTTagCompound tag)
Expand Down

0 comments on commit 6ad448c

Please sign in to comment.