use of net.geforcemods.securitycraft.network.packets.PacketCCreateLGView in project SecurityCraft by Geforce132.
the class ItemCameraMonitor method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
if (!par2World.isRemote) {
if (!par1ItemStack.hasTagCompound() || !hasCameraAdded(par1ItemStack.getTagCompound())) {
PlayerUtils.sendMessageToPlayer(par3EntityPlayer, StatCollector.translateToLocal("item.cameraMonitor.name"), StatCollector.translateToLocal("messages.cameraMonitor.rightclickToView"), EnumChatFormatting.RED);
return par1ItemStack;
}
if (SecurityCraft.instance.useLookingGlass()) {
CameraView view = getCameraView(par1ItemStack.getTagCompound());
if (!(par2World.getBlock(view.x, view.y, view.z) instanceof BlockSecurityCamera)) {
PlayerUtils.sendMessageToPlayer(par3EntityPlayer, StatCollector.translateToLocal("item.cameraMonitor.name"), StatCollector.translateToLocal("messages.cameraMonitor.noCamera").replace("#", Utils.getFormattedCoordinates(view.x, view.y, view.z)), EnumChatFormatting.RED);
return par1ItemStack;
}
SecurityCraft.network.sendTo(new PacketCCreateLGView(view.x, view.y, view.z, view.dimension), (EntityPlayerMP) par3EntityPlayer);
} else
par3EntityPlayer.openGui(SecurityCraft.instance, GuiHandler.CAMERA_MONITOR_GUI_ID, par2World, (int) par3EntityPlayer.posX, (int) par3EntityPlayer.posY, (int) par3EntityPlayer.posZ);
}
return par1ItemStack;
}
use of net.geforcemods.securitycraft.network.packets.PacketCCreateLGView in project SecurityCraft by Geforce132.
the class ItemCameraMonitor method onItemUse.
@Override
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 (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());
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) == SCContent.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);
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 (SecurityCraft.instance.useLookingGlass())
SecurityCraft.network.sendTo(new PacketCCreateLGView(view.x, view.y, view.z, view.dimension), (EntityPlayerMP) par2EntityPlayer);
else
par2EntityPlayer.openGui(SecurityCraft.instance, GuiHandler.CAMERA_MONITOR_GUI_ID, par3World, par4, par5, par6);
return false;
}
} else if (par3World.getBlock(par4, par5, par6) == SCContent.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;
}
SecurityCraft.network.sendTo(new PacketCUpdateNBTTag(par1ItemStack), (EntityPlayerMP) par2EntityPlayer);
return true;
}
return true;
}
Aggregations