use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class BlockClaymore method activateMine.
public void activateMine(World world, int par2, int par3, int par4) {
if (!world.isRemote) {
Owner owner = ((IOwnable) world.getTileEntity(par2, par3, par4)).getOwner();
world.setBlock(par2, par3, par4, mod_SecurityCraft.claymoreActive);
((IOwnable) world.getTileEntity(par2, par3, par4)).setOwner(owner.getUUID(), owner.getName());
}
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class BlockCageTrap method onEntityCollidedWithBlock.
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {
if (par1World.isRemote) {
return;
} else {
if (par5Entity instanceof EntityPlayer && !deactivated) {
IOwnable originalTrap = (IOwnable) par1World.getTileEntity(par2, par3, par4);
if (originalTrap.getOwner().isOwner((EntityPlayer) par5Entity))
return;
par1World.setBlock(par2, par3, par4, mod_SecurityCraft.deactivatedCageTrap);
par1World.setBlock(par2, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars);
par1World.setBlock(par2 + 1, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars);
par1World.setBlock(par2 - 1, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars);
par1World.setBlock(par2, par3 + 4, par4 + 1, mod_SecurityCraft.unbreakableIronBars);
par1World.setBlock(par2, par3 + 4, par4 - 1, mod_SecurityCraft.unbreakableIronBars);
BlockUtils.setBlockInBox(par1World, par2, par3, par4, mod_SecurityCraft.unbreakableIronBars);
setTileEntities(par1World, par2, par3, par4, originalTrap.getOwner().getUUID(), originalTrap.getOwner().getName());
par1World.playSoundAtEntity(par5Entity, "random.anvil_use", 3.0F, 1.0F);
MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText("[" + EnumChatFormatting.BLACK + StatCollector.translateToLocal("tile.cageTrap.name") + EnumChatFormatting.RESET + "] " + StatCollector.translateToLocal("messages.cageTrap.captured").replace("#player", ((EntityPlayer) par5Entity).getCommandSenderName()).replace("#location", Utils.getFormattedCoordinates(par2, par3, par4))));
}
}
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ItemAdminTool method onItemUse.
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
if (!par3World.isRemote) {
if (par3World.getTileEntity(par4, par5, par6) != null) {
TileEntity te = par3World.getTileEntity(par4, par5, par6);
boolean hasInfo = false;
if (te instanceof IOwnable) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), StatCollector.translateToLocal("messages.adminTool.owner.name").replace("#", (((IOwnable) te).getOwner().getName() == null ? "????" : ((IOwnable) te).getOwner().getName())), EnumChatFormatting.DARK_PURPLE);
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), StatCollector.translateToLocal("messages.adminTool.owner.uuid").replace("#", (((IOwnable) te).getOwner().getUUID() == null ? "????" : ((IOwnable) te).getOwner().getUUID())), EnumChatFormatting.DARK_PURPLE);
hasInfo = true;
}
if (te instanceof IPasswordProtected) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), StatCollector.translateToLocal("messages.adminTool.password").replace("#", (((IPasswordProtected) te).getPassword() == null ? "????" : ((IPasswordProtected) te).getPassword())), EnumChatFormatting.DARK_PURPLE);
hasInfo = true;
}
if (te instanceof CustomizableSCTE) {
List<EnumCustomModules> modules = ((CustomizableSCTE) te).getModules();
if (!modules.isEmpty()) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), StatCollector.translateToLocal("messages.adminTool.equippedModules"), EnumChatFormatting.DARK_PURPLE);
for (EnumCustomModules module : modules) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), "-" + module.getName(), EnumChatFormatting.DARK_PURPLE);
}
hasInfo = true;
}
}
if (!hasInfo) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), StatCollector.translateToLocal("messages.adminTool.noInfo"), EnumChatFormatting.DARK_PURPLE);
}
return false;
}
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), StatCollector.translateToLocal("messages.adminTool.noInfo"), EnumChatFormatting.DARK_PURPLE);
}
return false;
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ItemBlockReinforcedSlabs method onItemUse.
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
if (this.isNotSlab) {
return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
} else if (par1ItemStack.stackSize == 0) {
return false;
} else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) {
return false;
} else {
Block block = par3World.getBlock(par4, par5, par6);
int i1 = par3World.getBlockMetadata(par4, par5, par6);
int j1 = i1 & 7;
boolean flag = (i1 & 8) != 0;
Owner owner = null;
if (par3World.getTileEntity(par4, par5, par6) instanceof IOwnable) {
owner = ((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner();
if (!((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner().isOwner(par2EntityPlayer)) {
if (!par3World.isRemote) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("messages.reinforcedSlab"), StatCollector.translateToLocal("messages.reinforcedSlab.cannotDoubleSlab"), EnumChatFormatting.RED);
}
return false;
}
}
if ((par7 == 1 && !flag || par7 == 0 && flag) && isBlock(block) && j1 == par1ItemStack.getItemDamage()) {
if (par3World.checkNoEntityCollision(this.getBlockVariant(i1).getCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.setBlock(par4, par5, par6, this.getBlockVariant(block, i1), (block == mod_SecurityCraft.reinforcedStoneSlabs && i1 == 2 ? 2 : j1), 3)) {
par3World.playSoundEffect(par4 + 0.5F, par5 + 0.5F, par6 + 0.5F, this.getBlockVariant(block, i1).stepSound.func_150496_b(), (this.getBlockVariant(block, i1).stepSound.getVolume() + 1.0F) / 2.0F, this.getBlockVariant(block, i1).stepSound.getPitch() * 0.8F);
--par1ItemStack.stackSize;
if (owner != null) {
((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner().set(owner);
}
}
return true;
} else {
return this.func_150946_a(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7) ? true : super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
}
}
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ItemCameraMonitor method onItemUse.
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
if (!par3World.isRemote) {
//When the mod is using the LookingGlass system.
if (mod_SecurityCraft.instance.useLookingGlass()) {
if (par3World.getBlock(par4, par5, par6) instanceof BlockSecurityCamera) {
if (!((TileEntitySecurityCamera) par3World.getTileEntity(par4, par5, par6)).getOwner().isOwner(par2EntityPlayer)) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.cameraMonitor.name"), StatCollector.translateToLocal("messages.cameraMonitor.cannotView"), EnumChatFormatting.RED);
return false;
}
if (par1ItemStack.getTagCompound() == null) {
par1ItemStack.setTagCompound(new NBTTagCompound());
}
CameraView view = new CameraView(par4, par5, par6, par2EntityPlayer.dimension);
if (isCameraAdded(par1ItemStack.getTagCompound(), view)) {
par1ItemStack.getTagCompound().removeTag(getTagNameFromPosition(par1ItemStack.getTagCompound(), view));
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.cameraMonitor.name"), StatCollector.translateToLocal("messages.cameraMonitor.unbound").replace("#", Utils.getFormattedCoordinates(view.x, view.y, view.z)), EnumChatFormatting.RED);
return true;
}
par1ItemStack.getTagCompound().setString("Camera1", view.toNBTString());
mod_SecurityCraft.network.sendTo(new PacketCCreateLGView(view.x, view.y, view.z, view.dimension), (EntityPlayerMP) par2EntityPlayer);
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.cameraMonitor.name"), StatCollector.translateToLocal("messages.cameraMonitor.bound").replace("#", Utils.getFormattedCoordinates(view.x, view.y, view.z)), EnumChatFormatting.GREEN);
return true;
} else if (par3World.getBlock(par4, par5, par6) == mod_SecurityCraft.frame) {
if (!par1ItemStack.hasTagCompound() || !hasCameraAdded(par1ItemStack.getTagCompound()))
return false;
CameraView view = getCameraView(par1ItemStack.getTagCompound());
if (view == null)
return true;
((TileEntityFrame) par3World.getTileEntity(par4, par5, par6)).setCameraLocation(view.x, view.y, view.z, view.dimension);
mod_SecurityCraft.network.sendToAll(new PacketCSetCameraLocation(par4, par5, par6, view.x, view.y, view.z, view.dimension));
par1ItemStack.stackSize--;
return true;
} else {
if (!par1ItemStack.hasTagCompound() || !hasCameraAdded(par1ItemStack.getTagCompound()))
return false;
CameraView view = getCameraView(par1ItemStack.getTagCompound());
if (view == null)
return true;
if (!(par3World.getBlock(view.x, view.y, view.z) instanceof BlockSecurityCamera)) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.cameraMonitor.name"), StatCollector.translateToLocal("messages.cameraMonitor.noCamera").replace("#", Utils.getFormattedCoordinates(view.x, view.y, view.z)), EnumChatFormatting.RED);
return false;
}
if (mod_SecurityCraft.instance.useLookingGlass()) {
mod_SecurityCraft.network.sendTo(new PacketCCreateLGView(view.x, view.y, view.z, view.dimension), (EntityPlayerMP) par2EntityPlayer);
} else {
par2EntityPlayer.openGui(mod_SecurityCraft.instance, GuiHandler.CAMERA_MONITOR_GUI_ID, par3World, par4, par5, par6);
}
return false;
}
} else {
//When the mod is using the built-in mounting system.
if (par3World.getBlock(par4, par5, par6) == mod_SecurityCraft.securityCamera) {
if (!((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner().isOwner(par2EntityPlayer)) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.cameraMonitor.name"), StatCollector.translateToLocal("messages.cameraMonitor.cannotView"), EnumChatFormatting.RED);
return true;
}
if (par2EntityPlayer.getCurrentEquippedItem().getTagCompound() == null) {
par2EntityPlayer.getCurrentEquippedItem().setTagCompound(new NBTTagCompound());
}
CameraView view = new CameraView(par4, par5, par6, par2EntityPlayer.dimension);
if (isCameraAdded(par2EntityPlayer.getCurrentEquippedItem().getTagCompound(), view)) {
par2EntityPlayer.getCurrentEquippedItem().getTagCompound().removeTag(getTagNameFromPosition(par2EntityPlayer.getCurrentEquippedItem().getTagCompound(), view));
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.cameraMonitor.name"), StatCollector.translateToLocal("messages.cameraMonitor.unbound").replace("#", Utils.getFormattedCoordinates(par4, par5, par6)), EnumChatFormatting.RED);
return true;
}
for (int i = 1; i <= 30; i++) {
if (!par2EntityPlayer.getCurrentEquippedItem().getTagCompound().hasKey("Camera" + i)) {
par2EntityPlayer.getCurrentEquippedItem().getTagCompound().setString("Camera" + i, view.toNBTString());
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.cameraMonitor.name"), StatCollector.translateToLocal("messages.cameraMonitor.bound").replace("#", Utils.getFormattedCoordinates(par4, par5, par6)), EnumChatFormatting.GREEN);
break;
}
}
mod_SecurityCraft.network.sendTo(new PacketCUpdateNBTTag(par1ItemStack), (EntityPlayerMP) par2EntityPlayer);
return true;
}
}
}
return true;
}
Aggregations