Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update WrapperPlayServerExplosion to 1.21 #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.WrappedParticle;
import org.bukkit.Sound;

public class WrapperPlayServerExplosion extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.EXPLOSION;
Expand Down Expand Up @@ -127,8 +130,8 @@ public List<BlockPosition> getRecords() {
* Notes: this is the count, not the size. The size is 3 times this value.
*
* @return The current Record count
* @deprecated Misspelled.
* @see #getRecords()
* @deprecated Misspelled.
*/
@Deprecated
public List<BlockPosition> getRecors() {
Expand All @@ -144,28 +147,201 @@ public void setRecords(List<BlockPosition> value) {
handle.getBlockPositionCollectionModifier().write(0, value);
}

/**
* Retrieve the X velocity of the player being pushed by the explosion.
*
* @return The current X velocity.
*/
public float getPlayerVelocityX() {
return handle.getFloat().read(1);
}

/**
* Set the X velocity of the player being pushed by the explosion.
*
* @param value - new X velocity.
*/
public void setPlayerVelocityX(float value) {
handle.getFloat().write(1, value);
}

/**
* Retrieve the Y velocity of the player being pushed by the explosion.
*
* @return The current Y velocity.
*/
public float getPlayerVelocityY() {
return handle.getFloat().read(2);
}

/**
* Set the Y velocity of the player being pushed by the explosion.
*
* @param value - new Y velocity.
*/
public void setPlayerVelocityY(float value) {
handle.getFloat().write(2, value);
}

/**
* Retrieve the Z velocity of the player being pushed by the explosion.
*
* @return The current Z velocity.
*/
public float getPlayerVelocityZ() {
return handle.getFloat().read(3);
}

/**
* Set the Z velocity of the player being pushed by the explosion.
*
* @param value - new Z velocity.
*/
public void setPlayerVelocityZ(float value) {
handle.getFloat().write(3, value);
}

/**
* Retrieve the small explosion particle ID.
* <p>
* This is for Minecraft R1.20+
*
* @return The current small explosion particle ID.
*/
public EnumWrappers.Particle getSmallExplosionParticleId() {
return handle.getParticles().read(8);
}

/**
* Set the small explosion particle ID.
* <p>
* This is for Minecraft R1.20+
*
* @param value - new small explosion particle ID.
*/
public void setSmallExplosionParticleId(EnumWrappers.Particle value) {
handle.getParticles().write(8, value);
}

/**
* Retrieve the small explosion particle data.
* <p>
* This is for Minecraft R1.20+
*
* @return The current small explosion particle data.
*/
public WrappedParticle<?> getSmallExplosionParticle() {
return handle.getNewParticles().read(0);
}

/**
* Set the small explosion particle data.
* <p>
* This is for Minecraft R1.20+
*
* @param value - new small explosion particle data.
*/
public void setSmallExplosionParticle(WrappedParticle<?> value) {
handle.getNewParticles().write(0, value);
}

/**
* Retrieve the large explosion particle ID.
* <p>
* This is for Minecraft R1.20+
*
* @return The current large explosion particle ID.
*/
public EnumWrappers.Particle getLargeExplosionParticleId() {
return handle.getParticles().read(9);
}

/**
* Set the large explosion particle ID.
* <p>
* This is for Minecraft R1.20+
*
* @param value - new large explosion particle ID.
*/
public void setLargeExplosionParticleId(EnumWrappers.Particle value) {
handle.getParticles().write(9, value);
}

/**
* Retrieve the large explosion particle data.
* <p>
* This is for Minecraft R1.20+
*
* @return The current large explosion particle data.
*/
public WrappedParticle<?> getLargeExplosionParticle() {
return handle.getNewParticles().read(1);
}

/**
* Set the large explosion particle data.
* <p>
* This is for Minecraft R1.20+
*
* @param value - new large explosion particle data.
*/
public void setLargeExplosionParticle(WrappedParticle<?> value) {
handle.getNewParticles().write(1, value);
}

/**
* Retrieve the sound effect of the explosion.
* <p>
* This is for Minecraft R1.20+
*
* @return The current sound effect.
*/
public Sound getSound() {
return handle.getSoundEffects().read(0);
}

/**
* Set the sound effect of the explosion.
* <p>
* This is for Minecraft R1.20+
*
* @param value - new sound effect.
*/
public void setSound(Sound value) {
handle.getSoundEffects().write(0, value);
}

/**
* Set the block interaction type.
* <p>
* This is for Minecraft R1.20+
*
* @param value - new block interaction effect.
* @throws IllegalArgumentException when the provided value is not of {@link net.minecraft.world.level.Explosion$Effect}
* @throws ClassNotFoundException when called with an incompatible Minecraft version
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public void setBlockInteraction(Enum<?> value) throws ClassNotFoundException {
Class<?> enumClass = Class.forName("net.minecraft.world.level.Explosion$Effect");
if (!enumClass.isInstance(value)) {
throw new IllegalArgumentException("Invalid enum type: " + value.getDeclaringClass().getName()
+ ". Required type: net.minecraft.world.level.Explosion$Effect");
}
handle.getEnumModifier((Class<Enum>) enumClass, 10).write(0, value);
}


/**
* Retrieve the block interaction type.
* <p>
* This is for Minecraft R1.20+
*
* @return The current block interaction effect.
* @throws ClassNotFoundException when called with an incompatible Minecraft version
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public Enum<?> getBlockInteraction() throws ClassNotFoundException {
Class<?> enumClass = Class.forName("net.minecraft.world.level.Explosion$Effect");
return (Enum<?>) handle.getEnumModifier((Class<Enum>) enumClass, 10).read(0);
}
}