Search in sources :

Example 1 with TilePlayerInterface

use of com.cjm721.overloaded.block.tile.TilePlayerInterface in project Overloaded by CJ-MC-Mods.

the class BlockPlayerInterface method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote && hand == EnumHand.MAIN_HAND) {
        TileEntity te = worldIn.getTileEntity(pos);
        if (te instanceof TilePlayerInterface) {
            UUID placer = ((TilePlayerInterface) te).getPlacer();
            GameProfile profile = worldIn.getMinecraftServer().getPlayerProfileCache().getProfileByUUID(placer);
            if (profile == null) {
                playerIn.sendMessage(new TextComponentString(String.format("Bound to offline player: %s", placer.toString())));
            } else {
                playerIn.sendMessage(new TextComponentString("Bound to player: " + profile.getName()));
            }
        }
    }
    return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TilePlayerInterface(com.cjm721.overloaded.block.tile.TilePlayerInterface) GameProfile(com.mojang.authlib.GameProfile) UUID(java.util.UUID) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

TilePlayerInterface (com.cjm721.overloaded.block.tile.TilePlayerInterface)1 GameProfile (com.mojang.authlib.GameProfile)1 UUID (java.util.UUID)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TextComponentString (net.minecraft.util.text.TextComponentString)1