Skip to content

Commit

Permalink
1.8-PRE-3 pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
retrooper committed Feb 7, 2021
1 parent bacc1cd commit 6221ff0
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package io.github.retrooper.packetevents.packetwrappers.play.out.namedsoundeffect;

import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
import io.github.retrooper.packetevents.packetwrappers.SendableWrapper;
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
import io.github.retrooper.packetevents.utils.reflection.Reflection;
import io.github.retrooper.packetevents.utils.server.ServerVersion;

//TODO test
class WrappedPacketOutNamedSoundEffect extends WrappedPacket implements SendableWrapper {
class WrappedPacketOutNamedSoundEffect extends WrappedPacket {
private static boolean soundEffectVarExists;

public WrappedPacketOutNamedSoundEffect(NMSPacket packet) {
super(packet);
}
Expand All @@ -19,19 +19,13 @@ protected void load() {
soundEffectVarExists = Reflection.getField(packet.getClass(), NMSUtils.soundEffectClass, 0) != null;
}

@Override
public Object asNMSPacket() {
return null;
}

public String getSoundEffectName() {
if (soundEffectVarExists) {
Object soundEffect = readObject(0, NMSUtils.soundEffectClass);
WrappedPacket soundEffectWrapper = new WrappedPacket(new NMSPacket(soundEffect));
Object minecraftKey = soundEffectWrapper.readObject(0, NMSUtils.minecraftKeyClass);
return NMSUtils.getStringFromMinecraftKey(minecraftKey);
}
else {
} else {
return readString(0);
}
}
Expand All @@ -49,15 +43,14 @@ public double getEffectPositionZ() {
}

//Might be more than 1.0 on some older versions
public float getVolume(){
public float getVolume() {
return readFloat(0);
}

public float getPitch() {
if (version.isOlderThan(ServerVersion.v_1_10)) {
return readInt(1);
}
else {
} else {
return readFloat(1);
}
}
Expand Down

0 comments on commit 6221ff0

Please sign in to comment.