use of net.geforcemods.securitycraft.misc.CameraView 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) == SCContent.securityCamera) {
if (!((IOwnable) worldIn.getTileEntity(pos)).getOwner().isOwner(playerIn)) {
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.cameraMonitor.name"), ClientUtils.localize("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, ClientUtils.localize("item.cameraMonitor.name"), ClientUtils.localize("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, ClientUtils.localize("item.cameraMonitor.name"), ClientUtils.localize("messages.cameraMonitor.bound").replace("#", Utils.getFormattedCoordinates(pos)), TextFormatting.GREEN);
break;
}
SecurityCraft.network.sendTo(new PacketCUpdateNBTTag(stack), (EntityPlayerMP) playerIn);
return EnumActionResult.SUCCESS;
}
} else if (worldIn.isRemote && BlockUtils.getBlock(worldIn, pos) != SCContent.securityCamera) {
if (playerIn.getRidingEntity() != null && playerIn.getRidingEntity() instanceof EntitySecurityCamera)
return EnumActionResult.SUCCESS;
if (stack.getTagCompound() == null || stack.getTagCompound().hasNoTags()) {
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.cameraMonitor.name"), ClientUtils.localize("messages.cameraMonitor.rightclickToView"), TextFormatting.RED);
return EnumActionResult.SUCCESS;
}
playerIn.openGui(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.misc.CameraView in project SecurityCraft by Geforce132.
the class ItemCameraMonitorRenderer method renderItem.
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
if (type == ItemRenderType.FIRST_PERSON_MAP) {
// Draw the base monitor texture.
((TextureManager) data[1]).bindTexture(new ResourceLocation("securitycraft:textures/gui/camera/cameraBackground.png"));
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(0 - 7, 128 + 7, 0.0D, 0.0D, 1.0D);
tessellator.addVertexWithUV(128 + 7, 128 + 7, 0.0D, 1.0D, 1.0D);
tessellator.addVertexWithUV(128 + 7, 0 - 7, 0.0D, 1.0D, 0.0D);
tessellator.addVertexWithUV(0 - 7, 0 - 7, 0.0D, 0.0D, 0.0D);
tessellator.draw();
if (item != null && item.getItem() instanceof ItemCameraMonitor && ((ItemCameraMonitor) item.getItem()).hasCameraAdded(item.getTagCompound())) {
CameraView view = ((ItemCameraMonitor) item.getItem()).getCameraView(item.getTagCompound());
if (SecurityCraft.instance.hasViewForCoords(view.toNBTString())) {
IWorldView worldView = SecurityCraft.instance.getViewFromCoords(view.toNBTString()).getView();
if (worldView.isReady() && worldView.getTexture() != 0) {
// Bind the IWorldView texture then draw it.
GL11.glDisable(3008);
GL11.glDisable(2896);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, worldView.getTexture());
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(128 + 7, 0 - 7, 0.0D, 0.0D, 1.0D);
tessellator.addVertexWithUV(0 - 7, 0 - 7, 0.0D, -1.0D, 1.0D);
tessellator.addVertexWithUV(0 - 7, 128 + 7, 0.0D, -1.0D, 0.0D);
tessellator.addVertexWithUV(128 + 7, 128 + 7, 0.0D, 0.0D, 0.0D);
tessellator.draw();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
GL11.glEnable(3008);
GL11.glEnable(2896);
//
}
// Update the camera.
worldView.markDirty();
}
}
}
}
use of net.geforcemods.securitycraft.misc.CameraView in project SecurityCraft by Geforce132.
the class ItemCameraMonitor method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(hand);
if (!worldIn.isRemote) {
if (BlockUtils.getBlock(worldIn, pos) == SCContent.securityCamera) {
if (!((IOwnable) worldIn.getTileEntity(pos)).getOwner().isOwner(playerIn)) {
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.cameraMonitor.name"), ClientUtils.localize("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, ClientUtils.localize("item.cameraMonitor.name"), ClientUtils.localize("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, ClientUtils.localize("item.cameraMonitor.name"), ClientUtils.localize("messages.cameraMonitor.bound").replace("#", Utils.getFormattedCoordinates(pos)), TextFormatting.GREEN);
break;
}
SecurityCraft.network.sendTo(new PacketCUpdateNBTTag(stack), (EntityPlayerMP) playerIn);
return EnumActionResult.SUCCESS;
}
} else if (worldIn.isRemote && BlockUtils.getBlock(worldIn, pos) != SCContent.securityCamera) {
if (playerIn.getRidingEntity() != null && playerIn.getRidingEntity() instanceof EntitySecurityCamera)
return EnumActionResult.SUCCESS;
if (stack.getTagCompound() == null || stack.getTagCompound().hasNoTags()) {
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.cameraMonitor.name"), ClientUtils.localize("messages.cameraMonitor.rightclickToView"), TextFormatting.RED);
return EnumActionResult.SUCCESS;
}
playerIn.openGui(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.misc.CameraView 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.misc.CameraView in project SecurityCraft by Geforce132.
the class GuiCameraMonitor method actionPerformed.
@Override
protected void actionPerformed(GuiButton guibutton) {
if (guibutton.id == -1)
mc.displayGuiScreen(new GuiCameraMonitor(playerInventory, cameraMonitor, nbtTag, page - 1));
else if (guibutton.id == 0)
mc.displayGuiScreen(new GuiCameraMonitor(playerInventory, cameraMonitor, nbtTag, page + 1));
else if (guibutton.id < 11) {
int camID = guibutton.id + ((page - 1) * 10);
CameraView view = (cameraMonitor.getCameraPositions(nbtTag).get(camID - 1));
if (BlockUtils.getBlock(Minecraft.getMinecraft().theWorld, view.getLocation()) == SCContent.securityCamera) {
((BlockSecurityCamera) BlockUtils.getBlock(Minecraft.getMinecraft().theWorld, view.getLocation())).mountCamera(Minecraft.getMinecraft().theWorld, view.x, view.y, view.z, camID, Minecraft.getMinecraft().thePlayer);
SecurityCraft.network.sendToServer(new PacketSMountCamera(view.x, view.y, view.z, camID));
Minecraft.getMinecraft().thePlayer.closeScreen();
} else
guibutton.enabled = false;
} else {
int camID = (guibutton.id - 10) + ((page - 1) * 10);
SecurityCraft.network.sendToServer(new PacketSRemoveCameraTag(playerInventory.getCurrentItem(), camID));
nbtTag.removeTag(ItemCameraMonitor.getTagNameFromPosition(nbtTag, cameraMonitor.getCameraPositions(nbtTag).get(camID - 1)));
guibutton.enabled = false;
cameraButtons[(camID - 1) % 10].enabled = false;
}
}
Aggregations