use of net.minecraft.core.particles.ParticleOptions in project Denizen-For-Bukkit by DenizenScript.
the class DenizenNetworkManagerImpl method processParticlesForPacket.
public boolean processParticlesForPacket(Packet<?> packet) {
if (HideParticles.hidden.isEmpty()) {
return false;
}
try {
if (packet instanceof ClientboundLevelParticlesPacket) {
HashSet<Particle> hidden = HideParticles.hidden.get(player.getUUID());
if (hidden == null) {
return false;
}
ParticleOptions particle = ((ClientboundLevelParticlesPacket) packet).getParticle();
Particle bukkitParticle = CraftParticle.toBukkit(particle);
if (hidden.contains(bukkitParticle)) {
return true;
}
return false;
}
} catch (Throwable ex) {
Debug.echoError(ex);
}
return false;
}
use of net.minecraft.core.particles.ParticleOptions in project Denizen-For-Bukkit by DenizenScript.
the class DenizenNetworkManagerImpl method processParticlesForPacket.
public boolean processParticlesForPacket(Packet<?> packet) {
if (HideParticles.hidden.isEmpty()) {
return false;
}
try {
if (packet instanceof ClientboundLevelParticlesPacket) {
HashSet<Particle> hidden = HideParticles.hidden.get(player.getUUID());
if (hidden == null) {
return false;
}
ParticleOptions particle = ((ClientboundLevelParticlesPacket) packet).getParticle();
Particle bukkitParticle = CraftParticle.toBukkit(particle);
if (hidden.contains(bukkitParticle)) {
return true;
}
return false;
}
} catch (Throwable ex) {
Debug.echoError(ex);
}
return false;
}
use of net.minecraft.core.particles.ParticleOptions in project MyPet by xXKeyleXx.
the class PlatformHelper method playParticleEffect.
/**
* @param location the {@link Location} around which players must be to see the effect
* @param effectName list of effects: https://gist.github.com/riking/5759002
* @param offsetX the amount to be randomly offset by in the X axis
* @param offsetY the amount to be randomly offset by in the Y axis
* @param offsetZ the amount to be randomly offset by in the Z axis
* @param speed the speed of the particles
* @param count the number of particles
* @param radius the radius around the location
*/
@Override
public void playParticleEffect(Location location, String effectName, float offsetX, float offsetY, float offsetZ, float speed, int count, int radius, de.Keyle.MyPet.api.compat.Compat<Object> data) {
ParticleType effect = Registry.PARTICLE_TYPE.get(new ResourceLocation(effectName));
Validate.notNull(location, "Location cannot be null");
Validate.notNull(effect, "Effect cannot be null");
Validate.notNull(location.getWorld(), "World cannot be null");
ParticleOptions particle = null;
if (effect.getDeserializer() != null && data != null) {
try {
particle = effect.getDeserializer().fromCommand(effect, new StringReader(" " + data.get().toString()));
} catch (CommandSyntaxException e) {
e.printStackTrace();
}
} else if (effect instanceof SimpleParticleType) {
particle = (SimpleParticleType) effect;
}
if (particle == null) {
return;
}
ClientboundLevelParticlesPacket packet = new ClientboundLevelParticlesPacket(particle, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count);
radius = radius * radius;
for (Player player : location.getWorld().getPlayers()) {
if ((int) MyPetApi.getPlatformHelper().distanceSquared(player.getLocation(), location) <= radius) {
((CraftPlayer) player).getHandle().connection.send(packet);
}
}
}
use of net.minecraft.core.particles.ParticleOptions in project MyPet by xXKeyleXx.
the class PlatformHelper method playParticleEffect.
/**
* @param location the {@link Location} around which players must be to see the effect
* @param effectName list of effects: https://gist.github.com/riking/5759002
* @param offsetX the amount to be randomly offset by in the X axis
* @param offsetY the amount to be randomly offset by in the Y axis
* @param offsetZ the amount to be randomly offset by in the Z axis
* @param speed the speed of the particles
* @param count the number of particles
* @param radius the radius around the location
*/
@Override
public void playParticleEffect(Player player, Location location, String effectName, float offsetX, float offsetY, float offsetZ, float speed, int count, int radius, de.Keyle.MyPet.api.compat.Compat<Object> data) {
ParticleType effect = Registry.PARTICLE_TYPE.get(new ResourceLocation(effectName));
Validate.notNull(location, "Location cannot be null");
Validate.notNull(effect, "Effect cannot be null");
Validate.notNull(location.getWorld(), "World cannot be null");
ParticleOptions particle = null;
if (effect.getDeserializer() != null && data != null) {
try {
particle = effect.getDeserializer().fromCommand(effect, new StringReader(" " + data.get().toString()));
} catch (CommandSyntaxException e) {
e.printStackTrace();
}
} else if (effect instanceof SimpleParticleType) {
particle = (SimpleParticleType) effect;
}
if (particle == null) {
return;
}
ClientboundLevelParticlesPacket packet = new ClientboundLevelParticlesPacket(particle, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count);
if (MyPetApi.getPlatformHelper().distanceSquared(player.getLocation(), location) <= radius) {
((CraftPlayer) player).getHandle().connection.send(packet);
}
}
use of net.minecraft.core.particles.ParticleOptions in project MyPet by xXKeyleXx.
the class PlatformHelper method playParticleEffect.
/**
* @param location the {@link Location} around which players must be to see the effect
* @param effectName list of effects: https://gist.github.com/riking/5759002
* @param offsetX the amount to be randomly offset by in the X axis
* @param offsetY the amount to be randomly offset by in the Y axis
* @param offsetZ the amount to be randomly offset by in the Z axis
* @param speed the speed of the particles
* @param count the number of particles
* @param radius the radius around the location
*/
@Override
public void playParticleEffect(Player player, Location location, String effectName, float offsetX, float offsetY, float offsetZ, float speed, int count, int radius, de.Keyle.MyPet.api.compat.Compat<Object> data) {
ParticleType effect = Registry.PARTICLE_TYPE.get(new ResourceLocation(effectName));
Validate.notNull(location, "Location cannot be null");
Validate.notNull(effect, "Effect cannot be null");
Validate.notNull(location.getWorld(), "World cannot be null");
ParticleOptions particle = null;
if (effect.getDeserializer() != null && data != null) {
try {
particle = effect.getDeserializer().fromCommand(effect, new StringReader(" " + data.get().toString()));
} catch (CommandSyntaxException e) {
e.printStackTrace();
}
} else if (effect instanceof SimpleParticleType) {
particle = (SimpleParticleType) effect;
}
if (particle == null) {
return;
}
ClientboundLevelParticlesPacket packet = new ClientboundLevelParticlesPacket(particle, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count);
if (MyPetApi.getPlatformHelper().distanceSquared(player.getLocation(), location) <= radius) {
((CraftPlayer) player).getHandle().connection.send(packet);
}
}
Aggregations