use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ForgeEventHandler method handleOwnableTEs.
private void handleOwnableTEs(PlaceEvent event) {
if (event.getWorld().getTileEntity(event.getPos()) instanceof IOwnable) {
String name = event.getPlayer().getName();
String uuid = event.getPlayer().getGameProfile().getId().toString();
((IOwnable) event.getWorld().getTileEntity(event.getPos())).getOwner().set(uuid, name);
}
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ItemCameraMonitor 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.securityCamera) {
if (!((IOwnable) worldIn.getTileEntity(pos)).getOwner().isOwner(playerIn)) {
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.cameraMonitor.name"), I18n.translateToLocal("messages.cameraMonitor.cannotView"), TextFormatting.RED);
return EnumActionResult.SUCCESS;
}
if (playerIn.inventory.getCurrentItem().getTagCompound() == null) {
playerIn.inventory.getCurrentItem().setTagCompound(new NBTTagCompound());
}
CameraView view = new CameraView(pos, playerIn.dimension);
if (isCameraAdded(playerIn.inventory.getCurrentItem().getTagCompound(), view)) {
playerIn.inventory.getCurrentItem().getTagCompound().removeTag(getTagNameFromPosition(playerIn.inventory.getCurrentItem().getTagCompound(), view));
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.cameraMonitor.name"), I18n.translateToLocal("messages.cameraMonitor.unbound").replace("#", Utils.getFormattedCoordinates(pos)), TextFormatting.RED);
return EnumActionResult.SUCCESS;
}
for (int i = 1; i <= 30; i++) {
if (!playerIn.inventory.getCurrentItem().getTagCompound().hasKey("Camera" + i)) {
playerIn.inventory.getCurrentItem().getTagCompound().setString("Camera" + i, view.toNBTString());
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.cameraMonitor.name"), I18n.translateToLocal("messages.cameraMonitor.bound").replace("#", Utils.getFormattedCoordinates(pos)), TextFormatting.GREEN);
break;
}
}
mod_SecurityCraft.network.sendTo(new PacketCUpdateNBTTag(stack), (EntityPlayerMP) playerIn);
return EnumActionResult.SUCCESS;
}
} else if (worldIn.isRemote && BlockUtils.getBlock(worldIn, pos) != mod_SecurityCraft.securityCamera) {
if (playerIn.getRidingEntity() != null && playerIn.getRidingEntity() instanceof EntitySecurityCamera)
return EnumActionResult.SUCCESS;
if (stack.getTagCompound() == null || stack.getTagCompound().hasNoTags()) {
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.cameraMonitor.name"), I18n.translateToLocal("messages.cameraMonitor.rightclickToView"), TextFormatting.RED);
return EnumActionResult.SUCCESS;
}
playerIn.openGui(mod_SecurityCraft.instance, GuiHandler.CAMERA_MONITOR_GUI_ID, worldIn, pos.getX(), pos.getY(), pos.getZ());
return EnumActionResult.SUCCESS;
}
return EnumActionResult.SUCCESS;
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ItemUniversalOwnerChanger method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
TileEntity te = world.getTileEntity(pos);
String newOwner = stack.getDisplayName();
if (!world.isRemote) {
if (!stack.hasDisplayName()) {
PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("item.universalOwnerChanger.name"), I18n.translateToLocal("messages.universalOwnerChanger.noName"), TextFormatting.RED);
return EnumActionResult.FAIL;
}
if (!(te instanceof IOwnable)) {
PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("item.universalOwnerChanger.name"), I18n.translateToLocal("messages.universalOwnerChanger.cantChange"), TextFormatting.RED);
return EnumActionResult.FAIL;
}
if (!((IOwnable) te).getOwner().isOwner(player)) {
PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("item.universalOwnerChanger.name"), I18n.translateToLocal("messages.universalOwnerChanger.notOwned"), TextFormatting.RED);
return EnumActionResult.FAIL;
}
if (BlockUtils.getBlock(world, pos) instanceof BlockReinforcedDoor) {
if (BlockUtils.getBlock(world, pos.up()) instanceof BlockReinforcedDoor)
((IOwnable) world.getTileEntity(pos.up())).getOwner().set(PlayerUtils.isPlayerOnline(newOwner) ? PlayerUtils.getPlayerFromName(newOwner).getUniqueID().toString() : "ownerUUID", newOwner);
else
((IOwnable) world.getTileEntity(pos.up())).getOwner().set(PlayerUtils.isPlayerOnline(newOwner) ? PlayerUtils.getPlayerFromName(newOwner).getUniqueID().toString() : "ownerUUID", newOwner);
}
if (te instanceof IOwnable)
((IOwnable) te).getOwner().set(PlayerUtils.isPlayerOnline(newOwner) ? PlayerUtils.getPlayerFromName(newOwner).getUniqueID().toString() : "ownerUUID", newOwner);
world.getMinecraftServer().getPlayerList().sendPacketToAllPlayers(te.getUpdatePacket());
PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("item.universalOwnerChanger.name"), I18n.translateToLocal("messages.universalOwnerChanger.changed").replace("#", newOwner), TextFormatting.GREEN);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ItemAdminTool 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 (worldIn.getTileEntity(pos) != null) {
TileEntity te = worldIn.getTileEntity(pos);
boolean hasInfo = false;
if (te instanceof IOwnable) {
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.adminTool.name"), I18n.translateToLocal("messages.adminTool.owner.name").replace("#", (((IOwnable) te).getOwner().getName() == null ? "????" : ((IOwnable) te).getOwner().getName())), TextFormatting.DARK_PURPLE);
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.adminTool.name"), I18n.translateToLocal("messages.adminTool.owner.uuid").replace("#", (((IOwnable) te).getOwner().getUUID() == null ? "????" : ((IOwnable) te).getOwner().getUUID())), TextFormatting.DARK_PURPLE);
hasInfo = true;
}
if (te instanceof IPasswordProtected) {
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.adminTool.name"), I18n.translateToLocal("messages.adminTool.password").replace("#", (((IPasswordProtected) te).getPassword() == null ? "????" : ((IPasswordProtected) te).getPassword())), TextFormatting.DARK_PURPLE);
hasInfo = true;
}
if (te instanceof CustomizableSCTE) {
List<EnumCustomModules> modules = ((CustomizableSCTE) te).getModules();
if (!modules.isEmpty()) {
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.adminTool.name"), I18n.translateToLocal("messages.adminTool.equippedModules"), TextFormatting.DARK_PURPLE);
for (EnumCustomModules module : modules) {
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.adminTool.name"), "-" + module.getName(), TextFormatting.DARK_PURPLE);
}
hasInfo = true;
}
}
if (!hasInfo) {
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.adminTool.name"), I18n.translateToLocal("messages.adminTool.noInfo"), TextFormatting.DARK_PURPLE);
}
return EnumActionResult.FAIL;
}
PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.adminTool.name"), I18n.translateToLocal("messages.adminTool.noInfo"), TextFormatting.DARK_PURPLE);
}
return EnumActionResult.FAIL;
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ItemBlockReinforcedWoodSlabs method tryPlace.
private boolean tryPlace(ItemStack stack, World worldIn, EntityPlayer player, BlockPos pos, Object variantInStack) {
IBlockState iblockstate = worldIn.getBlockState(pos);
Owner owner = null;
if (worldIn.getTileEntity(pos) instanceof IOwnable) {
owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
}
if (iblockstate.getBlock() == this.singleSlab) {
Comparable<?> comparable = iblockstate.getValue(this.singleSlab.getVariantProperty());
if (comparable == variantInStack) {
IBlockState iblockstate1 = this.makeState(this.singleSlab.getVariantProperty(), comparable);
if (worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(iblockstate1, worldIn, pos)) && worldIn.setBlockState(pos, iblockstate1, 3)) {
worldIn.playSound(player, pos, this.doubleSlab.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (this.doubleSlab.getSoundType().getVolume() + 1.0F) / 2.0F, this.doubleSlab.getSoundType().getPitch() * 0.8F);
--stack.stackSize;
if (owner != null) {
((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
}
}
return true;
}
}
return false;
}
Aggregations