use of net.minecraft.network.play.server.SPacketWorldBorder in project SpongeCommon by SpongePowered.
the class MixinEntityPlayerMP method setWorldBorder.
@Override
public void setWorldBorder(@Nullable WorldBorder border, Cause cause) {
if (this.worldBorder == border) {
// do not fire an event since nothing would have changed
return;
}
if (!SpongeImpl.postEvent(SpongeEventFactory.createChangeWorldBorderEventTargetPlayer(cause, Optional.ofNullable(this.worldBorder), Optional.ofNullable(border), this))) {
if (this.worldBorder != null) {
// is the world border about to be unset?
// remove the listener, if so
((net.minecraft.world.border.WorldBorder) this.worldBorder).listeners.remove(this.borderListener);
}
this.worldBorder = border;
if (this.worldBorder != null) {
((net.minecraft.world.border.WorldBorder) this.worldBorder).addListener(this.borderListener);
this.connection.sendPacket(new SPacketWorldBorder((net.minecraft.world.border.WorldBorder) this.worldBorder, SPacketWorldBorder.Action.INITIALIZE));
} else {
// unset the border if null
this.connection.sendPacket(new SPacketWorldBorder(this.world.getWorldBorder(), SPacketWorldBorder.Action.INITIALIZE));
}
}
}
Aggregations