mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 08:24:46 +00:00
Made more adjustments to the off range of music, and made the music properly repeat. Background bard music always plays at the player.
This commit is contained in:
1 parent
2d9063cf24
commit
56bb6751b1
5 files changed
+31
-8
No files matched your search
@@ -9,7 +9,9 @@ import net.minecraft.util.ResourceLocation;
|
||||
public class MusicController {
|
||||
public static MusicController Instance;
|
||||
public ScriptClientSound sound;
|
||||
|
||||
private Entity entity;
|
||||
private int offRange;
|
||||
|
||||
public MusicController(){
|
||||
Instance = this;
|
||||
@@ -24,31 +26,37 @@ public class MusicController {
|
||||
}
|
||||
}
|
||||
|
||||
public void playStreaming(String music, Entity entity){
|
||||
public void playMusicJukebox(String music, Entity entity, int offRange){
|
||||
if (this.isPlaying(music)) {
|
||||
return;
|
||||
}
|
||||
this.stopMusic();
|
||||
|
||||
ScriptClientSound clientSound = new ScriptClientSound(music);
|
||||
clientSound.setPos((float)entity.posX, (float)entity.posY, (float)entity.posZ);
|
||||
clientSound.setVolume(4.0F);
|
||||
clientSound.setAttenuationType(ISound.AttenuationType.LINEAR);
|
||||
clientSound.setRepeat(true);
|
||||
this.sound = clientSound;
|
||||
this.entity = entity;
|
||||
this.offRange = offRange;
|
||||
|
||||
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
|
||||
soundHandler.playSound(clientSound);
|
||||
}
|
||||
|
||||
public void playMusic(String music, Entity entity) {
|
||||
public void playMusicBackground(String music, Entity entity, int offRange) {
|
||||
if (this.isPlaying(music)) {
|
||||
return;
|
||||
}
|
||||
this.stopMusic();
|
||||
|
||||
ScriptClientSound clientSound = new ScriptClientSound(music);
|
||||
clientSound.setEntity(entity);
|
||||
clientSound.setEntity(Minecraft.getMinecraft().thePlayer);
|
||||
clientSound.setRepeat(true);
|
||||
this.sound = clientSound;
|
||||
this.entity = entity;
|
||||
this.offRange = offRange;
|
||||
|
||||
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
|
||||
soundHandler.playSound(clientSound);
|
||||
@@ -74,6 +82,10 @@ public class MusicController {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
public int getOffRange() {
|
||||
return this.offRange;
|
||||
}
|
||||
|
||||
public void playSound(String music, float x, float y, float z) {
|
||||
Minecraft.getMinecraft().theWorld.playSound(x, y, z, music, 1, 1, false);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user