Search in sources :

Example 1 with DenizenNetworkManagerImpl

use of com.denizenscript.denizen.nms.v1_16.impl.network.handlers.DenizenNetworkManagerImpl in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method showSignEditor.

@Override
public boolean showSignEditor(Player player, Location location) {
    if (location == null) {
        LocationTag fakeSign = new LocationTag(player.getLocation());
        fakeSign.setY(0);
        FakeBlock.showFakeBlockTo(Collections.singletonList(new PlayerTag(player)), fakeSign, new MaterialTag(org.bukkit.Material.OAK_WALL_SIGN), new DurationTag(1), true);
        BlockPos pos = new BlockPos(fakeSign.getX(), 0, fakeSign.getZ());
        ((DenizenNetworkManagerImpl) ((CraftPlayer) player).getHandle().connection.connection).packetListener.fakeSignExpected = pos;
        send(player, new ClientboundOpenSignEditorPacket(pos));
        return true;
    }
    BlockEntity tileEntity = ((CraftWorld) location.getWorld()).getHandle().getTileEntity(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), true);
    if (tileEntity instanceof SignBlockEntity) {
        SignBlockEntity sign = (SignBlockEntity) tileEntity;
        // Prevent client crashing by sending current state of the sign
        send(player, sign.getUpdatePacket());
        sign.isEditable = true;
        sign.setAllowedPlayerEditor(player.getUniqueId());
        send(player, new ClientboundOpenSignEditorPacket(sign.getBlockPos()));
        return true;
    } else {
        return false;
    }
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) MaterialTag(com.denizenscript.denizen.objects.MaterialTag) SignBlockEntity(net.minecraft.world.level.block.entity.SignBlockEntity) PlayerTag(com.denizenscript.denizen.objects.PlayerTag) BlockPos(net.minecraft.core.BlockPos) DenizenNetworkManagerImpl(com.denizenscript.denizen.nms.v1_17.impl.network.handlers.DenizenNetworkManagerImpl) DurationTag(com.denizenscript.denizencore.objects.core.DurationTag) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) SignBlockEntity(net.minecraft.world.level.block.entity.SignBlockEntity)

Example 2 with DenizenNetworkManagerImpl

use of com.denizenscript.denizen.nms.v1_16.impl.network.handlers.DenizenNetworkManagerImpl in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method showSignEditor.

@Override
public boolean showSignEditor(Player player, Location location) {
    if (location == null) {
        LocationTag fakeSign = new LocationTag(player.getLocation());
        fakeSign.setY(0);
        FakeBlock.showFakeBlockTo(Collections.singletonList(new PlayerTag(player)), fakeSign, new MaterialTag(org.bukkit.Material.OAK_WALL_SIGN), new DurationTag(1), true);
        BlockPos pos = new BlockPos(fakeSign.getX(), 0, fakeSign.getZ());
        ((DenizenNetworkManagerImpl) ((CraftPlayer) player).getHandle().connection.connection).packetListener.fakeSignExpected = pos;
        send(player, new ClientboundOpenSignEditorPacket(pos));
        return true;
    }
    BlockEntity tileEntity = ((CraftWorld) location.getWorld()).getHandle().getBlockEntity(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), true);
    if (tileEntity instanceof SignBlockEntity) {
        SignBlockEntity sign = (SignBlockEntity) tileEntity;
        // Prevent client crashing by sending current state of the sign
        send(player, sign.getUpdatePacket());
        sign.isEditable = true;
        sign.setAllowedPlayerEditor(player.getUniqueId());
        send(player, new ClientboundOpenSignEditorPacket(sign.getBlockPos()));
        return true;
    } else {
        return false;
    }
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) MaterialTag(com.denizenscript.denizen.objects.MaterialTag) SignBlockEntity(net.minecraft.world.level.block.entity.SignBlockEntity) PlayerTag(com.denizenscript.denizen.objects.PlayerTag) BlockPos(net.minecraft.core.BlockPos) DenizenNetworkManagerImpl(com.denizenscript.denizen.nms.v1_18.impl.network.handlers.DenizenNetworkManagerImpl) DurationTag(com.denizenscript.denizencore.objects.core.DurationTag) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) SignBlockEntity(net.minecraft.world.level.block.entity.SignBlockEntity)

Example 3 with DenizenNetworkManagerImpl

use of com.denizenscript.denizen.nms.v1_16.impl.network.handlers.DenizenNetworkManagerImpl in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method showSignEditor.

@Override
public boolean showSignEditor(Player player, Location location) {
    if (location == null) {
        LocationTag fakeSign = new LocationTag(player.getLocation());
        fakeSign.setY(0);
        FakeBlock.showFakeBlockTo(Collections.singletonList(new PlayerTag(player)), fakeSign, new MaterialTag(org.bukkit.Material.OAK_WALL_SIGN), new DurationTag(1), true);
        BlockPosition pos = new BlockPosition(fakeSign.getX(), 0, fakeSign.getZ());
        ((DenizenNetworkManagerImpl) ((CraftPlayer) player).getHandle().playerConnection.networkManager).packetListener.fakeSignExpected = pos;
        sendPacket(player, new PacketPlayOutOpenSignEditor(pos));
        return true;
    }
    TileEntity tileEntity = ((CraftWorld) location.getWorld()).getHandle().getTileEntity(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
    if (tileEntity instanceof TileEntitySign) {
        TileEntitySign sign = (TileEntitySign) tileEntity;
        // Prevent client crashing by sending current state of the sign
        sendPacket(player, sign.getUpdatePacket());
        sign.isEditable = true;
        sign.a((EntityHuman) ((CraftPlayer) player).getHandle());
        sendPacket(player, new PacketPlayOutOpenSignEditor(sign.getPosition()));
        return true;
    } else {
        return false;
    }
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) MaterialTag(com.denizenscript.denizen.objects.MaterialTag) PlayerTag(com.denizenscript.denizen.objects.PlayerTag) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) DenizenNetworkManagerImpl(com.denizenscript.denizen.nms.v1_16.impl.network.handlers.DenizenNetworkManagerImpl) DurationTag(com.denizenscript.denizencore.objects.core.DurationTag)

Aggregations

LocationTag (com.denizenscript.denizen.objects.LocationTag)3 MaterialTag (com.denizenscript.denizen.objects.MaterialTag)3 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)3 DurationTag (com.denizenscript.denizencore.objects.core.DurationTag)3 BlockPos (net.minecraft.core.BlockPos)2 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)2 SignBlockEntity (net.minecraft.world.level.block.entity.SignBlockEntity)2 DenizenNetworkManagerImpl (com.denizenscript.denizen.nms.v1_16.impl.network.handlers.DenizenNetworkManagerImpl)1 DenizenNetworkManagerImpl (com.denizenscript.denizen.nms.v1_17.impl.network.handlers.DenizenNetworkManagerImpl)1 DenizenNetworkManagerImpl (com.denizenscript.denizen.nms.v1_18.impl.network.handlers.DenizenNetworkManagerImpl)1 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)1