Search in sources :

Example 1 with SPacketSignEditorOpen

use of net.minecraft.network.play.server.SPacketSignEditorOpen in project Almura by AlmuraDev.

the class SignEditFeature method interact.

@Listener
public void interact(final InteractBlockEvent.Secondary.MainHand event, @Root final Player player) {
    if (!(player instanceof EntityPlayerMP) || !player.require(Keys.IS_SNEAKING)) {
        return;
    }
    final BlockSnapshot snapshot = event.getTargetBlock();
    final BlockType type = snapshot.getState().getType();
    if (type == BlockTypes.STANDING_SIGN || type == BlockTypes.WALL_SIGN) {
        snapshot.getLocation().flatMap(Location::getTileEntity).ifPresent((be) -> {
            if (be instanceof TileEntitySign) {
                ((EntityPlayerMP) player).connection.sendPacket(new SPacketSignEditorOpen(VecHelper.toBlockPos(snapshot.getPosition())));
            }
        });
    }
}
Also used : TileEntitySign(net.minecraft.tileentity.TileEntitySign) SPacketSignEditorOpen(net.minecraft.network.play.server.SPacketSignEditorOpen) BlockType(org.spongepowered.api.block.BlockType) BlockSnapshot(org.spongepowered.api.block.BlockSnapshot) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Listener(org.spongepowered.api.event.Listener)

Aggregations

EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 SPacketSignEditorOpen (net.minecraft.network.play.server.SPacketSignEditorOpen)1 TileEntitySign (net.minecraft.tileentity.TileEntitySign)1 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)1 BlockType (org.spongepowered.api.block.BlockType)1 Listener (org.spongepowered.api.event.Listener)1