use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ItemKeyPanel method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote) {
if (BlockUtils.getBlock(worldIn, pos) == mod_SecurityCraft.frame) {
Owner owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
EnumFacing enumfacing = worldIn.getBlockState(pos).getValue(BlockKeypad.FACING);
worldIn.setBlockState(pos, mod_SecurityCraft.keypad.getDefaultState().withProperty(BlockKeypad.FACING, enumfacing).withProperty(BlockKeypad.POWERED, false));
((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
stack.stackSize -= 1;
}
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ItemMineRemoteAccessTool method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote) {
if (BlockUtils.getBlock(worldIn, pos) instanceof IExplosive) {
if (!isMineAdded(stack, worldIn, pos)) {
int availSlot = this.getNextAvaliableSlot(stack);
if (availSlot == 0) {
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.remoteAccessMine.name"), I18n.translateToLocal("messages.mrat.noSlots"), TextFormatting.RED);
return EnumActionResult.FAIL;
}
if (worldIn.getTileEntity(pos) instanceof IOwnable && !((IOwnable) worldIn.getTileEntity(pos)).getOwner().isOwner(playerIn)) {
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.remoteAccessMine.name"), I18n.translateToLocal("messages.mrat.cantBind"), TextFormatting.RED);
return EnumActionResult.FAIL;
}
if (stack.getTagCompound() == null) {
stack.setTagCompound(new NBTTagCompound());
}
stack.getTagCompound().setIntArray(("mine" + availSlot), new int[] { BlockUtils.fromPos(pos)[0], BlockUtils.fromPos(pos)[1], BlockUtils.fromPos(pos)[2] });
mod_SecurityCraft.network.sendTo(new PacketCUpdateNBTTag(stack), (EntityPlayerMP) playerIn);
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.remoteAccessMine.name"), I18n.translateToLocal("messages.mrat.bound").replace("#", Utils.getFormattedCoordinates(pos)), TextFormatting.GREEN);
} else {
this.removeTagFromItemAndUpdate(stack, pos, playerIn);
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.remoteAccessMine.name"), I18n.translateToLocal("messages.mrat.unbound").replace("#", Utils.getFormattedCoordinates(pos)), TextFormatting.RED);
}
} else {
playerIn.openGui(mod_SecurityCraft.instance, GuiHandler.MRAT_MENU_ID, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ);
}
}
return EnumActionResult.SUCCESS;
}
Aggregations