use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class BlockMine 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.mine);
((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 ItemUniversalOwnerChanger method onItemUse.
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, 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, StatCollector.translateToLocal("item.universalOwnerChanger.name"), StatCollector.translateToLocal("messages.universalOwnerChanger.noName"), EnumChatFormatting.RED);
return false;
}
if (!(te instanceof IOwnable)) {
PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("item.universalOwnerChanger.name"), StatCollector.translateToLocal("messages.universalOwnerChanger.cantChange"), EnumChatFormatting.RED);
return false;
}
if (!((IOwnable) te).getOwner().isOwner(player)) {
PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("item.universalOwnerChanger.name"), StatCollector.translateToLocal("messages.universalOwnerChanger.notOwned"), EnumChatFormatting.RED);
return false;
}
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);
MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(te.getDescriptionPacket());
PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("item.universalOwnerChanger.name"), StatCollector.translateToLocal("messages.universalOwnerChanger.changed").replace("#", newOwner), EnumChatFormatting.GREEN);
return true;
}
return false;
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ItemMineRemoteAccessTool method onItemUse.
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing par5EnumFacing, float hitX, float hitY, float hitZ) {
if (!par3World.isRemote) {
if (BlockUtils.getBlock(par3World, pos) instanceof IExplosive) {
if (!isMineAdded(par1ItemStack, par3World, pos)) {
int availSlot = this.getNextAvaliableSlot(par1ItemStack);
if (availSlot == 0) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.remoteAccessMine.name"), StatCollector.translateToLocal("messages.mrat.noSlots"), EnumChatFormatting.RED);
return false;
}
if (par3World.getTileEntity(pos) instanceof IOwnable && !((IOwnable) par3World.getTileEntity(pos)).getOwner().isOwner(par2EntityPlayer)) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.remoteAccessMine.name"), StatCollector.translateToLocal("messages.mrat.cantBind"), EnumChatFormatting.RED);
return false;
}
if (par1ItemStack.getTagCompound() == null) {
par1ItemStack.setTagCompound(new NBTTagCompound());
}
par1ItemStack.getTagCompound().setIntArray(("mine" + availSlot), new int[] { BlockUtils.fromPos(pos)[0], BlockUtils.fromPos(pos)[1], BlockUtils.fromPos(pos)[2] });
mod_SecurityCraft.network.sendTo(new PacketCUpdateNBTTag(par1ItemStack), (EntityPlayerMP) par2EntityPlayer);
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.remoteAccessMine.name"), StatCollector.translateToLocal("messages.mrat.bound").replace("#", Utils.getFormattedCoordinates(pos)), EnumChatFormatting.GREEN);
} else {
this.removeTagFromItemAndUpdate(par1ItemStack, pos, par2EntityPlayer);
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.remoteAccessMine.name"), StatCollector.translateToLocal("messages.mrat.unbound").replace("#", Utils.getFormattedCoordinates(pos)), EnumChatFormatting.RED);
}
} else {
par2EntityPlayer.openGui(mod_SecurityCraft.instance, GuiHandler.MRAT_MENU_ID, par3World, (int) par2EntityPlayer.posX, (int) par2EntityPlayer.posY, (int) par2EntityPlayer.posZ);
}
}
return true;
}
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, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
if (!par3World.isRemote) {
if (BlockUtils.getBlock(par3World, pos) == mod_SecurityCraft.securityCamera) {
if (!((IOwnable) par3World.getTileEntity(pos)).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(pos, 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(pos)), 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(pos)), EnumChatFormatting.GREEN);
break;
}
}
mod_SecurityCraft.network.sendTo(new PacketCUpdateNBTTag(par1ItemStack), (EntityPlayerMP) par2EntityPlayer);
return true;
}
} else if (par3World.isRemote && BlockUtils.getBlock(par3World, pos) != mod_SecurityCraft.securityCamera) {
if (par2EntityPlayer.ridingEntity != null && par2EntityPlayer.ridingEntity instanceof EntitySecurityCamera)
return true;
if (par1ItemStack.getTagCompound() == null || par1ItemStack.getTagCompound().hasNoTags()) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.cameraMonitor.name"), StatCollector.translateToLocal("messages.cameraMonitor.rightclickToView"), EnumChatFormatting.RED);
return true;
}
par2EntityPlayer.openGui(mod_SecurityCraft.instance, GuiHandler.CAMERA_MONITOR_GUI_ID, par3World, pos.getX(), pos.getY(), pos.getZ());
return true;
}
return true;
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class GuiSCManual method updateRecipeAndIcons.
private void updateRecipeAndIcons() {
if (this.currentPage < 0) {
recipe = null;
this.hoverCheckers.clear();
return;
}
this.hoverCheckers.clear();
if (mod_SecurityCraft.instance.manualPages.get(currentPage).hasCustomRecipe()) {
this.recipe = mod_SecurityCraft.instance.manualPages.get(currentPage).getRecipe();
} else {
for (Object object : CraftingManager.getInstance().getRecipeList()) {
if (object instanceof ShapedRecipes) {
ShapedRecipes recipe = (ShapedRecipes) object;
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == mod_SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
this.recipe = recipe.recipeItems;
break;
}
} else if (object instanceof ShapelessRecipes) {
ShapelessRecipes recipe = (ShapelessRecipes) object;
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == mod_SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
this.recipe = this.toItemStackArray(recipe.recipeItems);
break;
}
}
this.recipe = null;
}
}
if (recipe != null) {
outer: for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if ((i * 3) + j == recipe.length)
break outer;
if (recipe[(i * 3) + j] != null)
hoverCheckers.add(new CustomHoverChecker(144 + (i * 20), 144 + (i * 20) + 16, (k + 100) + (j * 20), (k + 100) + (j * 20) + 16, 20, recipe[(i * 3) + j].getDisplayName()));
}
}
} else {
String name = mod_SecurityCraft.instance.manualPages.get(currentPage).getItemName();
//make first character lower case and remove spaces
name = name.substring(0, 1).toLowerCase() + name.substring(1, name.length()).replace(" ", "");
hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, I18n.translateToLocal("gui.scManual.recipe." + name)));
}
Item item = mod_SecurityCraft.instance.manualPages.get(currentPage).getItem();
TileEntity te = ((item instanceof ItemBlock && ((ItemBlock) item).getBlock() instanceof ITileEntityProvider) ? ((ITileEntityProvider) ((ItemBlock) item).getBlock()).createNewTileEntity(Minecraft.getMinecraft().theWorld, 0) : null);
Block itemBlock = ((item instanceof ItemBlock) ? ((ItemBlock) item).getBlock() : null);
if (te != null) {
if (te instanceof IOwnable) {
this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 29, (k + 29) + 16, 20, I18n.translateToLocal("gui.scManual.ownableBlock")));
}
if (te instanceof IPasswordProtected) {
this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 55, (k + 55) + 16, 20, I18n.translateToLocal("gui.scManual.passwordProtectedBlock")));
}
if (te instanceof TileEntitySCTE && ((TileEntitySCTE) te).isActivatedByView()) {
this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 81, (k + 81) + 16, 20, I18n.translateToLocal("gui.scManual.viewActivatedBlock")));
}
if (itemBlock instanceof IExplosive) {
this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 107, (k + 107) + 16, 20, I18n.translateToLocal("gui.scManual.explosiveBlock")));
}
if (te instanceof CustomizableSCTE) {
this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 213, (k + 213) + 16, 20, I18n.translateToLocal("gui.scManual.customizableBlock")));
}
}
}
Aggregations