use of net.minecraft.world.entity.LightningBolt in project MyPet by xXKeyleXx.
the class PlatformHelper method strikeLightning.
@Override
public void strikeLightning(Location loc, float distance) {
ServerLevel world = ((CraftWorld) loc.getWorld()).getHandle();
LightningBolt lightning = new LightningBolt(EntityType.LIGHTNING_BOLT, world);
lightning.setVisualOnly(true);
lightning.moveTo(loc.getX(), loc.getY(), loc.getZ(), 0.0F, 0.0F);
/*world.getCraftServer()
.getServer()
.getPlayerList()
.broadcast(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.dimension(),
new ClientboundAddEntityPacket(lightning));
world.getCraftServer()
.getServer()
.getPlayerList()
.broadcast(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.dimension(),
new ClientboundSoundPacket(SoundEvents.LIGHTNING_BOLT_THUNDER, SoundSource.WEATHER, loc.getX(), loc.getY(), loc.getZ(), distance, 1F));
*/
// Thank you wrong mappings for this workaround
DedicatedServer server = world.getCraftServer().getServer();
Method getPlayerListReflect = ReflectionUtil.getMethod(DedicatedServer.class, "getPlayerList");
try {
DedicatedPlayerList playerList = (DedicatedPlayerList) getPlayerListReflect.invoke(server, null);
playerList.broadcast(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.dimension(), new ClientboundAddEntityPacket(lightning));
playerList.broadcast(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.dimension(), new ClientboundSoundPacket(SoundEvents.LIGHTNING_BOLT_THUNDER, SoundSource.WEATHER, loc.getX(), loc.getY(), loc.getZ(), distance, 1F));
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.minecraft.world.entity.LightningBolt in project MyPet by xXKeyleXx.
the class PlatformHelper method strikeLightning.
@Override
public void strikeLightning(Location loc, float distance) {
ServerLevel world = ((CraftWorld) loc.getWorld()).getHandle();
LightningBolt lightning = new LightningBolt(EntityType.LIGHTNING_BOLT, world);
lightning.setVisualOnly(true);
lightning.moveTo(loc.getX(), loc.getY(), loc.getZ(), 0.0F, 0.0F);
world.getCraftServer().getServer().getPlayerList().broadcast(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.dimension(), new ClientboundAddEntityPacket(lightning));
world.getCraftServer().getServer().getPlayerList().broadcast(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.dimension(), new ClientboundSoundPacket(SoundEvents.LIGHTNING_BOLT_THUNDER, SoundSource.WEATHER, loc.getX(), loc.getY(), loc.getZ(), distance, 1F));
}
Aggregations