1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-09-28 15:08:47 +00:00

Adds pocket computer light support to Speaker

This makes use of new pocket computer light access peripherals have and adds said functionality to speaker. If noisy pocket has made sound the pocket computer light will turn dark blue for a second.
This commit is contained in:
Wojbie 2017-05-28 15:53:37 +02:00
parent 54d202cf6b
commit 225ec594e7
2 changed files with 7 additions and 0 deletions

View File

@ -55,6 +55,11 @@ public class SpeakerPeripheral implements IPeripheral {
return m_speaker.getPos();
}
public synchronized boolean madeSound()
{
return (m_clock - m_lastPlayTime <= 20) ;
}
/* IPeripheral implementation */
@Override

View File

@ -11,6 +11,7 @@ import dan200.computercraft.api.pocket.IPocketAccess;
import dan200.computercraft.api.pocket.IPocketUpgrade;
import dan200.computercraft.shared.peripheral.PeripheralType;
import dan200.computercraft.shared.peripheral.common.PeripheralItemFactory;
import dan200.computercraft.shared.util.Colour;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
@ -74,6 +75,7 @@ public class PocketSpeaker implements IPocketUpgrade
speaker.setLocation( entity.getEntityWorld(), entity.posX, entity.posY, entity.posZ );
}
speaker.update();
access.setLight( speaker.madeSound() ? 0x3320fc : -1 );
}
}