Skip to content

Commit

Permalink
Fix game crash when a chunk with a playing player/radio is unloaded
Browse files Browse the repository at this point in the history
#11
  • Loading branch information
NicholasFeldman committed Sep 5, 2016
1 parent f12abf5 commit b887de1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,12 @@ public void run(){
if(tileEntity != null && tileEntity instanceof IRecordWireHome) entry.getValue().getCurrentSong().playRadius = ((IRecordWireHome) tileEntity).getSongRadius();
float dist = (float) Math.abs(Math.sqrt(Math.pow(player.posX - entry.getValue().getCurrentSong().x, 2) + Math.pow(player.posY - entry.getValue().getCurrentSong().y, 2) + Math.pow(player.posZ - entry.getValue().getCurrentSong().z, 2)));
IRecordWireHome wireHome = (IRecordWireHome) tileEntity;
for(RecordConnection rc : wireHome.getConnections()){
float d = (float) Math.abs(Math.sqrt(Math.pow(player.posX - rc.x2, 2) + Math.pow(player.posY - rc.y2, 2) + Math.pow(player.posZ - rc.z2, 2)));
if(d < dist){
dist = d;
if (wireHome != null) {
for (RecordConnection rc : wireHome.getConnections()) {
float d = (float) Math.abs(Math.sqrt(Math.pow(player.posX - rc.x2, 2) + Math.pow(player.posY - rc.y2, 2) + Math.pow(player.posZ - rc.z2, 2)));
if (d < dist) {
dist = d;
}
}
}
if(dist > entry.getValue().getCurrentSong().playRadius + 10F) entry.getValue().getCurrentSong().volume.setValue(-80F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ else if(openAmount > 0F)
}
}

@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);

Expand All @@ -142,6 +143,7 @@ public void readFromNBT(NBTTagCompound compound) {
playRadius = compound.getFloat("playRadius");
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);

Expand Down

0 comments on commit b887de1

Please sign in to comment.