use of com.cjm721.overloaded.tile.functional.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);
}
use of com.cjm721.overloaded.tile.functional.TilePlayerInterface in project Overloaded by CJ-MC-Mods.
the class BlockPlayerInterface method use.
@Override
@Nonnull
public ActionResultType use(@Nonnull BlockState state, World world, @Nonnull BlockPos pos, @Nonnull PlayerEntity player, @Nonnull Hand hand, @Nonnull BlockRayTraceResult rayTraceResult) {
if (!world.isClientSide && hand == Hand.MAIN_HAND) {
TileEntity te = world.getBlockEntity(pos);
if (te instanceof TilePlayerInterface) {
UUID placer = ((TilePlayerInterface) te).getPlacer();
if (placer == null) {
player.sendMessage(new StringTextComponent("Not bound to anyone..... ghosts placed this."), player.getUUID());
} else {
String username = UsernameCache.getLastKnownUsername(placer);
player.sendMessage(new StringTextComponent("Bound to player: " + (username == null ? placer.toString() : username)), player.getUUID());
}
}
return ActionResultType.SUCCESS;
}
return super.use(state, world, pos, player, hand, rayTraceResult);
}
Aggregations