-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/attribute
- Loading branch information
Showing
11 changed files
with
176 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...main/java/io/github/sculkpowered/server/protocol/packet/play/sound/EntitySoundEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.github.sculkpowered.server.protocol.packet.play.sound; | ||
|
||
import io.github.sculkpowered.server.protocol.Buffer; | ||
import io.github.sculkpowered.server.protocol.packet.Packet; | ||
import net.kyori.adventure.sound.Sound; | ||
|
||
public final class EntitySoundEffect implements Packet { | ||
|
||
private final Sound sound; | ||
private final int entityId; | ||
|
||
public EntitySoundEffect(final Sound sound, final int entityId) { | ||
this.sound = sound; | ||
this.entityId = entityId; | ||
} | ||
|
||
@Override | ||
public void encode(Buffer buf) { | ||
buf | ||
.writeByte((byte) 0) | ||
.writeString(this.sound.name().asString()) | ||
.writeBoolean(false) | ||
.writeVarInt(0) | ||
.writeVarInt(this.entityId) | ||
.writeFloat(this.sound.volume()) | ||
.writeFloat(this.sound.pitch()) | ||
.writeLong(this.sound.seed().orElse(0)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "EntitySoundEffect{" + | ||
"sound=" + this.sound + | ||
", entityId=" + this.entityId + | ||
'}'; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...r/src/main/java/io/github/sculkpowered/server/protocol/packet/play/sound/SoundEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.github.sculkpowered.server.protocol.packet.play.sound; | ||
|
||
import io.github.sculkpowered.server.protocol.Buffer; | ||
import io.github.sculkpowered.server.protocol.packet.Packet; | ||
import net.kyori.adventure.sound.Sound; | ||
|
||
public final class SoundEffect implements Packet { | ||
|
||
private final Sound sound; | ||
private final int x; | ||
private final int y; | ||
private final int z; | ||
|
||
public SoundEffect(final Sound sound, final int x, final int y, final int z) { | ||
this.sound = sound; | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
} | ||
|
||
@Override | ||
public void encode(Buffer buf) { | ||
buf.writeByte((byte) 0) | ||
.writeString(this.sound.name().asString()) | ||
.writeBoolean(false) | ||
.writeVarInt(this.sound.source().ordinal()) | ||
.writeInt(this.x) | ||
.writeInt(this.y) | ||
.writeInt(this.z) | ||
.writeFloat(this.sound.volume()) | ||
.writeFloat(this.sound.pitch()) | ||
.writeLong(this.sound.seed().orElse(0)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SoundEffect{" + | ||
"sound=" + this.sound + | ||
", x=" + this.x + | ||
", y=" + this.y + | ||
", z=" + this.z + | ||
'}'; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
server/src/main/java/io/github/sculkpowered/server/protocol/packet/play/sound/StopSound.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.github.sculkpowered.server.protocol.packet.play.sound; | ||
|
||
import io.github.sculkpowered.server.protocol.Buffer; | ||
import io.github.sculkpowered.server.protocol.packet.Packet; | ||
import java.util.Objects; | ||
import net.kyori.adventure.sound.SoundStop; | ||
|
||
public final class StopSound implements Packet { | ||
|
||
private final SoundStop stop; | ||
|
||
public StopSound(SoundStop stop) { | ||
this.stop = stop; | ||
} | ||
|
||
@Override | ||
public void encode(Buffer buf) { | ||
if (this.stop == SoundStop.all()) { | ||
buf.writeByte((byte) 0); | ||
return; | ||
} | ||
var flags = (byte) 0; | ||
if (this.stop.source() != null) { | ||
flags |= 1; | ||
} | ||
if (this.stop.sound() != null) { | ||
flags |= 2; | ||
} | ||
buf.writeByte(flags); | ||
if (this.stop.source() != null) { | ||
buf.writeVarInt(Objects.requireNonNull(this.stop.source()).ordinal()); | ||
} | ||
if (this.stop.sound() != null) { | ||
buf.writeString(Objects.requireNonNull(this.stop.sound()).asString()); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "StopSound{" + | ||
"stop=" + this.stop + | ||
'}'; | ||
} | ||
} |