Search in sources :

Example 16 with BlockPos

use of net.minecraft.core.BlockPos in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method showBlockAction.

@Override
public void showBlockAction(Player player, Location location, int action, int state) {
    BlockPos position = new BlockPos(location.getX(), location.getY(), location.getZ());
    Block block = ((CraftWorld) location.getWorld()).getHandle().getBlockState(position).getBlock();
    send(player, new ClientboundBlockEventPacket(position, block, action, state));
}
Also used : FakeBlock(com.denizenscript.denizen.utilities.blocks.FakeBlock) Block(net.minecraft.world.level.block.Block) BlockPos(net.minecraft.core.BlockPos) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 17 with BlockPos

use of net.minecraft.core.BlockPos 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 18 with BlockPos

use of net.minecraft.core.BlockPos in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method showTileEntityData.

@Override
public void showTileEntityData(Player player, Location location, int action, CompoundTag compoundTag) {
    BlockPos position = new BlockPos(location.getX(), location.getY(), location.getZ());
    send(player, new ClientboundBlockEntityDataPacket(position, action, ((CompoundTagImpl) compoundTag).toNMSTag()));
}
Also used : BlockPos(net.minecraft.core.BlockPos) CompoundTagImpl(com.denizenscript.denizen.nms.v1_17.impl.jnbt.CompoundTagImpl)

Example 19 with BlockPos

use of net.minecraft.core.BlockPos in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method showBlockCrack.

@Override
public void showBlockCrack(Player player, int id, Location location, int progress) {
    BlockPos position = new BlockPos(location.getX(), location.getY(), location.getZ());
    send(player, new ClientboundBlockDestructionPacket(id, position, progress));
}
Also used : BlockPos(net.minecraft.core.BlockPos)

Example 20 with BlockPos

use of net.minecraft.core.BlockPos in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method showTileEntityData.

@Override
public void showTileEntityData(Player player, Location location, int action, CompoundTag compoundTag) {
    BlockPos position = new BlockPos(location.getX(), location.getY(), location.getZ());
    try {
        ClientboundBlockEntityDataPacket packet = (ClientboundBlockEntityDataPacket) BLOCK_ENTITY_DATA_PACKET_CONSTRUCTOR.invoke(position, action, ((CompoundTagImpl) compoundTag).toNMSTag());
        send(player, packet);
    } catch (Throwable ex) {
        Debug.echoError(ex);
    }
}
Also used : BlockPos(net.minecraft.core.BlockPos) CompoundTagImpl(com.denizenscript.denizen.nms.v1_18.impl.jnbt.CompoundTagImpl)

Aggregations

BlockPos (net.minecraft.core.BlockPos)54 BlockState (net.minecraft.world.level.block.state.BlockState)10 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)8 LevelChunk (net.minecraft.world.level.chunk.LevelChunk)8 Level (net.minecraft.world.level.Level)7 Direction (net.minecraft.core.Direction)6 Vec3 (net.minecraft.world.phys.Vec3)6 Nonnull (javax.annotation.Nonnull)5 ResourceLocation (net.minecraft.resources.ResourceLocation)5 ItemStack (net.minecraft.world.item.ItemStack)5 LocationTag (com.denizenscript.denizen.objects.LocationTag)4 ChunkCoordinate (com.denizenscript.denizen.utilities.blocks.ChunkCoordinate)4 FakeBlock (com.denizenscript.denizen.utilities.blocks.FakeBlock)4 Nullable (javax.annotation.Nullable)3 GameTest (net.minecraft.gametest.framework.GameTest)3 ChunkPos (net.minecraft.world.level.ChunkPos)3 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)3 BlockLight (com.denizenscript.denizen.nms.abstracts.BlockLight)2 CompoundTagBuilder (com.denizenscript.denizen.nms.util.jnbt.CompoundTagBuilder)2 MaterialTag (com.denizenscript.denizen.objects.MaterialTag)2