use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ItemKeyPanel 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) == mod_SecurityCraft.frame) {
Owner owner = ((IOwnable) par3World.getTileEntity(pos)).getOwner();
EnumFacing enumfacing = (EnumFacing) par3World.getBlockState(pos).getValue(BlockKeypad.FACING);
par3World.setBlockState(pos, mod_SecurityCraft.keypad.getDefaultState().withProperty(BlockKeypad.FACING, enumfacing).withProperty(BlockKeypad.POWERED, false));
((IOwnable) par3World.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
par1ItemStack.stackSize -= 1;
}
return true;
}
return false;
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class GuiSCManual method drawScreen.
@Override
public void drawScreen(int par1, int par2, float par3) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
if (update) {
updateRecipeAndIcons();
update = false;
}
if (this.currentPage == -1) {
this.mc.getTextureManager().bindTexture(infoBookTitlePage);
} else {
if (this.recipe != null)
this.mc.getTextureManager().bindTexture(infoBookTexture);
else
this.mc.getTextureManager().bindTexture(infoBookTextureSpecial);
}
this.drawTexturedModalRect(k, 5, 0, 0, 256, 250);
if (this.currentPage > -1) {
this.fontRendererObj.drawString(I18n.translateToLocal(mod_SecurityCraft.instance.manualPages.get(currentPage).getItem().getUnlocalizedName() + ".name"), k + 39, 27, 0, false);
this.fontRendererObj.drawSplitString(mod_SecurityCraft.instance.manualPages.get(currentPage).getHelpInfo(), k + 18, 45, 225, 0);
} else {
this.fontRendererObj.drawString(I18n.translateToLocal("gui.scManual.intro.1"), k + 39, 27, 0, false);
this.fontRendererObj.drawString(I18n.translateToLocal("gui.scManual.intro.2"), k + 60, 159, 0, false);
if (I18n.canTranslate("gui.scManual.author")) {
this.fontRendererObj.drawString(I18n.translateToLocal("gui.scManual.author"), k + 65, 170, 0, false);
}
}
for (int i = 0; i < this.buttonList.size(); i++) {
this.buttonList.get(i).drawButton(this.mc, par1, par2);
}
if (this.currentPage > -1) {
Item item = mod_SecurityCraft.instance.manualPages.get(currentPage).getItem();
GuiUtils.drawItemStackToGui(mc, item, k + 19, 22, !(mod_SecurityCraft.instance.manualPages.get(currentPage).getItem() instanceof ItemBlock));
this.mc.getTextureManager().bindTexture(infoBookIcons);
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 (itemBlock != null) {
if (itemBlock instanceof IExplosive) {
this.drawTexturedModalRect(k + 107, 117, 54, 1, 18, 18);
}
if (te != null) {
if (te instanceof IOwnable) {
this.drawTexturedModalRect(k + 29, 118, 1, 1, 16, 16);
}
if (te instanceof IPasswordProtected) {
this.drawTexturedModalRect(k + 55, 118, 18, 1, 17, 16);
}
if (te instanceof TileEntitySCTE && ((TileEntitySCTE) te).isActivatedByView()) {
this.drawTexturedModalRect(k + 81, 118, 36, 1, 17, 16);
}
if (te instanceof CustomizableSCTE) {
this.drawTexturedModalRect(k + 213, 118, 72, 1, 16, 16);
}
}
}
if (recipe != null) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (((i * 3) + j) >= recipe.length) {
break;
}
if (this.recipe[(i * 3) + j] == null) {
continue;
}
if (this.recipe[(i * 3) + j].getItem() instanceof ItemBlock) {
GuiUtils.drawItemStackToGui(mc, Block.getBlockFromItem(this.recipe[(i * 3) + j].getItem()), (k + 100) + (j * 20), 144 + (i * 20), !(this.recipe[(i * 3) + j].getItem() instanceof ItemBlock));
} else {
GuiUtils.drawItemStackToGui(mc, this.recipe[(i * 3) + j].getItem(), this.recipe[(i * 3) + j].getItemDamage(), (k + 100) + (j * 20), 144 + (i * 20), !(this.recipe[(i * 3) + j].getItem() instanceof ItemBlock));
}
}
}
}
for (CustomHoverChecker chc : hoverCheckers) {
if (chc != null && chc.checkHover(par1, par2)) {
if (chc.getName() != null)
drawHoveringText(mc.fontRendererObj.listFormattedStringToWidth(chc.getName(), 250), par1, par2, mc.fontRendererObj);
}
}
}
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class WailaDataProvider method getWailaBody.
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> tipList, IWailaDataAccessor iDataAccessor, IWailaConfigHandler iConfigHandler) {
if (iDataAccessor.getBlock() instanceof ICustomWailaDisplay && !((ICustomWailaDisplay) iDataAccessor.getBlock()).shouldShowSCInfo(iDataAccessor.getWorld(), iDataAccessor.getBlockState(), iDataAccessor.getPosition()))
return tipList;
if (iConfigHandler.getConfig("securitycraft.showowner") && iDataAccessor.getTileEntity() instanceof IOwnable) {
tipList.add(I18n.translateToLocal("waila.owner") + " " + ((IOwnable) iDataAccessor.getTileEntity()).getOwner().getName());
}
if (iConfigHandler.getConfig("securitycraft.showmodules") && iDataAccessor.getTileEntity() instanceof CustomizableSCTE && ((CustomizableSCTE) iDataAccessor.getTileEntity()).getOwner().isOwner(iDataAccessor.getPlayer())) {
if (!((CustomizableSCTE) iDataAccessor.getTileEntity()).getModules().isEmpty()) {
tipList.add(I18n.translateToLocal("waila.equipped"));
}
for (EnumCustomModules module : ((CustomizableSCTE) iDataAccessor.getTileEntity()).getModules()) {
tipList.add("- " + module.getName());
}
}
if (iConfigHandler.getConfig("securitycraft.showpasswords") && iDataAccessor.getTileEntity() instanceof IPasswordProtected && !(iDataAccessor.getTileEntity() instanceof TileEntityKeycardReader) && ((IOwnable) iDataAccessor.getTileEntity()).getOwner().isOwner(iDataAccessor.getPlayer())) {
String password = ((IPasswordProtected) iDataAccessor.getTileEntity()).getPassword();
tipList.add(I18n.translateToLocal("waila.password") + " " + (password != null && !password.isEmpty() ? password : I18n.translateToLocal("waila.password.notSet")));
}
if (iConfigHandler.getConfig("securitycraft.showcustomname") && iDataAccessor.getTileEntity() instanceof INameable && ((INameable) iDataAccessor.getTileEntity()).canBeNamed()) {
String name = ((INameable) iDataAccessor.getTileEntity()).getCustomName();
tipList.add(I18n.translateToLocal("waila.customName") + " " + (((INameable) iDataAccessor.getTileEntity()).hasCustomName() ? name : I18n.translateToLocal("waila.customName.notSet")));
}
return tipList;
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ItemBlockReinforcedSlabs 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;
}
use of net.geforcemods.securitycraft.api.IOwnable in project SecurityCraft by Geforce132.
the class ForgeEventHandler method onRightClickBlock.
@SubscribeEvent
public void onRightClickBlock(RightClickBlock event) {
if (!event.getEntityPlayer().worldObj.isRemote) {
World world = event.getEntityPlayer().worldObj;
TileEntity tileEntity = event.getEntityPlayer().worldObj.getTileEntity(event.getPos());
Block block = event.getEntityPlayer().worldObj.getBlockState(event.getPos()).getBlock();
if (PlayerUtils.isHoldingItem(event.getEntityPlayer(), mod_SecurityCraft.codebreaker) && handleCodebreaking(event)) {
event.setCanceled(true);
return;
}
if (tileEntity != null && tileEntity instanceof CustomizableSCTE && PlayerUtils.isHoldingItem(event.getEntityPlayer(), mod_SecurityCraft.universalBlockModifier)) {
event.setCanceled(true);
if (!((IOwnable) tileEntity).getOwner().isOwner(event.getEntityPlayer())) {
PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), I18n.translateToLocal("item.universalBlockModifier.name"), I18n.translateToLocal("messages.notOwned").replace("#", ((TileEntityOwnable) tileEntity).getOwner().getName()), TextFormatting.RED);
return;
}
event.getEntityPlayer().openGui(mod_SecurityCraft.instance, GuiHandler.CUSTOMIZE_BLOCK, world, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
return;
}
if (tileEntity instanceof INameable && ((INameable) tileEntity).canBeNamed() && PlayerUtils.isHoldingItem(event.getEntityPlayer(), Items.NAME_TAG) && event.getEntityPlayer().inventory.getCurrentItem().hasDisplayName()) {
event.setCanceled(true);
for (String character : new String[] { "(", ")" }) {
if (event.getEntityPlayer().inventory.getCurrentItem().getDisplayName().contains(character)) {
PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), "Naming", I18n.translateToLocal("messages.naming.error").replace("#n", event.getEntityPlayer().inventory.getCurrentItem().getDisplayName()).replace("#c", character), TextFormatting.RED);
return;
}
}
if (((INameable) tileEntity).getCustomName().matches(event.getEntityPlayer().inventory.getCurrentItem().getDisplayName())) {
PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), "Naming", I18n.translateToLocal("messages.naming.alreadyMatches").replace("#n", ((INameable) tileEntity).getCustomName()), TextFormatting.RED);
return;
}
event.getEntityPlayer().inventory.getCurrentItem().stackSize--;
((INameable) tileEntity).setCustomName(event.getEntityPlayer().inventory.getCurrentItem().getDisplayName());
return;
}
if (tileEntity != null && isOwnableBlock(block, tileEntity) && PlayerUtils.isHoldingItem(event.getEntityPlayer(), mod_SecurityCraft.universalBlockRemover)) {
event.setCanceled(true);
if (!((IOwnable) tileEntity).getOwner().isOwner(event.getEntityPlayer())) {
PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), I18n.translateToLocal("item.universalBlockRemover.name"), I18n.translateToLocal("messages.notOwned").replace("#", ((TileEntityOwnable) tileEntity).getOwner().getName()), TextFormatting.RED);
return;
}
if (block == mod_SecurityCraft.laserBlock) {
world.destroyBlock(event.getPos(), true);
BlockLaserBlock.destroyAdjacentLasers(event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
event.getEntityPlayer().inventory.getCurrentItem().damageItem(1, event.getEntityPlayer());
} else {
world.destroyBlock(event.getPos(), true);
world.removeTileEntity(event.getPos());
event.getEntityPlayer().inventory.getCurrentItem().damageItem(1, event.getEntityPlayer());
}
}
}
}
Aggregations