Skip to content

Commit

Permalink
Add seed parameter to play_sound()
Browse files Browse the repository at this point in the history
  • Loading branch information
PseudoKnight committed Nov 11, 2024
1 parent de5e661 commit d06e57b
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 157 deletions.
18 changes: 4 additions & 14 deletions src/main/java/com/laytonsmith/abstraction/MCPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,13 @@ public interface MCPlayer extends MCCommandSender, MCHumanEntity, MCOfflinePlaye

void playNote(MCLocation loc, MCInstrument instrument, MCNote note);

void playSound(MCLocation l, MCSound sound, float volume, float pitch);
void playSound(MCLocation l, MCSound sound, MCSoundCategory category, float volume, float pitch, Long seed);

void playSound(MCLocation l, String sound, float volume, float pitch);
void playSound(MCEntity ent, MCSound sound, MCSoundCategory category, float volume, float pitch, Long seed);

void playSound(MCLocation l, MCSound sound, MCSoundCategory category, float volume, float pitch);
void playSound(MCLocation l, String sound, MCSoundCategory category, float volume, float pitch, Long seed);

void playSound(MCEntity ent, MCSound sound, MCSoundCategory category, float volume, float pitch);

void playSound(MCLocation l, String sound, MCSoundCategory category, float volume, float pitch);

void playSound(MCEntity ent, String sound, float volume, float pitch);

void playSound(MCEntity ent, String sound, MCSoundCategory category, float volume, float pitch);

void stopSound(MCSound sound);

void stopSound(String sound);
void playSound(MCEntity ent, String sound, MCSoundCategory category, float volume, float pitch, Long seed);

void stopSound(MCSound sound, MCSoundCategory category);

Expand Down
12 changes: 4 additions & 8 deletions src/main/java/com/laytonsmith/abstraction/MCWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,13 @@ public interface MCWorld extends MCMetadatable {

void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, Object data);

void playSound(MCLocation l, MCSound sound, float volume, float pitch);
void playSound(MCLocation l, MCSound sound, MCSoundCategory category, float volume, float pitch, Long seed);

void playSound(MCLocation l, String sound, float volume, float pitch);
void playSound(MCEntity ent, MCSound sound, MCSoundCategory category, float volume, float pitch, Long seed);

void playSound(MCLocation l, MCSound sound, MCSoundCategory category, float volume, float pitch);
void playSound(MCEntity ent, String sound, MCSoundCategory category, float volume, float pitch, Long seed);

void playSound(MCEntity ent, MCSound sound, MCSoundCategory category, float volume, float pitch);

void playSound(MCEntity ent, String sound, MCSoundCategory category, float volume, float pitch);

void playSound(MCLocation l, String sound, MCSoundCategory category, float volume, float pitch);
void playSound(MCLocation l, String sound, MCSoundCategory category, float volume, float pitch, Long seed);

MCItem dropItemNaturally(MCLocation l, MCItemStack is);

Expand Down
64 changes: 34 additions & 30 deletions src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,51 +308,55 @@ public void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX
}

@Override
public void playSound(MCLocation l, MCSound sound, float volume, float pitch) {
w.playSound(((BukkitMCLocation) l).asLocation(),
((BukkitMCSound) sound).getConcrete(), volume, pitch);
}

@Override
public void playSound(MCLocation l, String sound, float volume, float pitch) {
w.playSound((Location) l.getHandle(), sound, volume, pitch);
}

@Override
public void playSound(MCLocation l, MCSound sound, MCSoundCategory category, float volume, float pitch) {
if(category == null) {
w.playSound((Location) l.getHandle(), ((BukkitMCSound) sound).getConcrete(),
SoundCategory.MASTER, volume, pitch);
public void playSound(MCLocation l, MCSound sound, MCSoundCategory category, float volume, float pitch, Long seed) {
SoundCategory cat = BukkitMCSoundCategory.getConvertor().getConcreteEnum(category);
if(cat == null) {
cat = SoundCategory.MASTER;
}
if(seed == null) {
w.playSound((Location) l.getHandle(), ((BukkitMCSound) sound).getConcrete(), cat, volume, pitch);
} else {
w.playSound((Location) l.getHandle(), ((BukkitMCSound) sound).getConcrete(),
BukkitMCSoundCategory.getConvertor().getConcreteEnum(category), volume, pitch);
w.playSound((Location) l.getHandle(), ((BukkitMCSound) sound).getConcrete(), cat, volume, pitch, seed);
}
}

@Override
public void playSound(MCEntity ent, MCSound sound, MCSoundCategory category, float volume, float pitch) {
if(category == null) {
w.playSound((Entity) ent.getHandle(), ((BukkitMCSound) sound).getConcrete(),
SoundCategory.MASTER, volume, pitch);
public void playSound(MCEntity ent, MCSound sound, MCSoundCategory category, float volume, float pitch, Long seed) {
SoundCategory cat = BukkitMCSoundCategory.getConvertor().getConcreteEnum(category);
if(cat == null) {
cat = SoundCategory.MASTER;
}
if(seed == null) {
w.playSound((Entity) ent.getHandle(), ((BukkitMCSound) sound).getConcrete(), cat, volume, pitch);
} else {
w.playSound((Entity) ent.getHandle(), ((BukkitMCSound) sound).getConcrete(),
BukkitMCSoundCategory.getConvertor().getConcreteEnum(category), volume, pitch);
w.playSound((Entity) ent.getHandle(), ((BukkitMCSound) sound).getConcrete(), cat, volume, pitch, seed);
}
}

@Override
public void playSound(MCEntity ent, String sound, MCSoundCategory category, float volume, float pitch) {
if(category == null) {
w.playSound((Entity) ent.getHandle(), sound, SoundCategory.MASTER, volume, pitch);
public void playSound(MCEntity ent, String sound, MCSoundCategory category, float volume, float pitch, Long seed) {
SoundCategory cat = BukkitMCSoundCategory.getConvertor().getConcreteEnum(category);
if(cat == null) {
cat = SoundCategory.MASTER;
}
if(seed == null) {
w.playSound((Entity) ent.getHandle(), sound, cat, volume, pitch);
} else {
w.playSound((Entity) ent.getHandle(), sound, BukkitMCSoundCategory.getConvertor().getConcreteEnum(category), volume, pitch);
w.playSound((Entity) ent.getHandle(), sound, cat, volume, pitch, seed);
}
}

@Override
public void playSound(MCLocation l, String sound, MCSoundCategory category, float volume, float pitch) {
w.playSound((Location) l.getHandle(), sound,
BukkitMCSoundCategory.getConvertor().getConcreteEnum(category), volume, pitch);
public void playSound(MCLocation l, String sound, MCSoundCategory category, float volume, float pitch, Long seed) {
SoundCategory cat = BukkitMCSoundCategory.getConvertor().getConcreteEnum(category);
if(cat == null) {
cat = SoundCategory.MASTER;
}
if(seed == null) {
w.playSound((Location) l.getHandle(), sound, cat, volume, pitch);
} else {
w.playSound((Location) l.getHandle(), sound, cat, volume, pitch, seed);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,63 +600,55 @@ public void playNote(MCLocation loc, MCInstrument instrument, MCNote note) {
}

@Override
public void playSound(MCLocation l, MCSound sound, float volume, float pitch) {
p.playSound(((BukkitMCLocation) l).asLocation(),
((BukkitMCSound) sound).getConcrete(), volume, pitch);
}

@Override
public void playSound(MCLocation l, String sound, float volume, float pitch) {
p.playSound(((BukkitMCLocation) l).asLocation(), sound, volume, pitch);
}

@Override
public void playSound(MCLocation l, MCSound sound, MCSoundCategory category, float volume, float pitch) {
if(category == null) {
p.playSound((Location) l.getHandle(), ((BukkitMCSound) sound).getConcrete(),
SoundCategory.MASTER, volume, pitch);
public void playSound(MCLocation l, MCSound sound, MCSoundCategory category, float volume, float pitch, Long seed) {
SoundCategory cat = BukkitMCSoundCategory.getConvertor().getConcreteEnum(category);
if(cat == null) {
cat = SoundCategory.MASTER;
}
if(seed == null) {
p.playSound((Location) l.getHandle(), ((BukkitMCSound) sound).getConcrete(), cat, volume, pitch);
} else {
p.playSound((Location) l.getHandle(), ((BukkitMCSound) sound).getConcrete(),
BukkitMCSoundCategory.getConvertor().getConcreteEnum(category), volume, pitch);
p.playSound((Location) l.getHandle(), ((BukkitMCSound) sound).getConcrete(), cat, volume, pitch, seed);
}
}

@Override
public void playSound(MCEntity ent, MCSound sound, MCSoundCategory category, float volume, float pitch) {
public void playSound(MCEntity ent, MCSound sound, MCSoundCategory category, float volume, float pitch, Long seed) {
SoundCategory cat = BukkitMCSoundCategory.getConvertor().getConcreteEnum(category);
if(cat == null) {
cat = SoundCategory.MASTER;
}
if(category == null) {
p.playSound((Entity) ent.getHandle(), ((BukkitMCSound) sound).getConcrete(),
SoundCategory.MASTER, volume, pitch);
p.playSound((Entity) ent.getHandle(), ((BukkitMCSound) sound).getConcrete(), cat, volume, pitch);
} else {
p.playSound((Entity) ent.getHandle(), ((BukkitMCSound) sound).getConcrete(),
BukkitMCSoundCategory.getConvertor().getConcreteEnum(category), volume, pitch);
p.playSound((Entity) ent.getHandle(), ((BukkitMCSound) sound).getConcrete(), cat, volume, pitch, seed);
}
}

@Override
public void playSound(MCLocation l, String sound, MCSoundCategory category, float volume, float pitch) {
p.playSound((Location) l.getHandle(), sound,
BukkitMCSoundCategory.getConvertor().getConcreteEnum(category), volume, pitch);
}

@Override
public void playSound(MCEntity ent, String sound, MCSoundCategory category, float volume, float pitch) {
p.playSound(((Entity) ent.getHandle()), sound,
BukkitMCSoundCategory.getConvertor().getConcreteEnum(category), volume, pitch);
}

@Override
public void playSound(MCEntity ent, String sound, float volume, float pitch) {
p.playSound(((Entity) ent.getHandle()), sound, volume, pitch);
}

@Override
public void stopSound(MCSound sound) {
p.stopSound(((BukkitMCSound) sound).getConcrete());
public void playSound(MCLocation l, String sound, MCSoundCategory category, float volume, float pitch, Long seed) {
SoundCategory cat = BukkitMCSoundCategory.getConvertor().getConcreteEnum(category);
if(cat == null) {
cat = SoundCategory.MASTER;
}
if(seed == null) {
p.playSound((Location) l.getHandle(), sound, cat, volume, pitch);
} else {
p.playSound((Location) l.getHandle(), sound, cat, volume, pitch, seed);
}
}

@Override
public void stopSound(String sound) {
p.stopSound(sound);
public void playSound(MCEntity ent, String sound, MCSoundCategory category, float volume, float pitch, Long seed) {
SoundCategory cat = BukkitMCSoundCategory.getConvertor().getConcreteEnum(category);
if(cat == null) {
cat = SoundCategory.MASTER;
}
if(seed == null) {
p.playSound((Entity) ent.getHandle(), sound, cat, volume, pitch);
} else {
p.playSound((Entity) ent.getHandle(), sound, cat, volume, pitch, seed);
}
}

@Override
Expand Down
Loading

0 comments on commit d06e57b

Please sign in to comment.