Search in sources :

Example 1 with TileEntityInventoryScanner

use of net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner in project SecurityCraft by Geforce132.

the class ModuleUtils method checkForModule.

/**
 * A large block of code that checks if the TileEntity at the specified coordinates has the given module inserted, and what should happen if it does. <p>
 *
 * Args: world, x, y, z, player, moduleType.
 */
public static boolean checkForModule(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, EnumCustomModules module) {
    TileEntity te = par1World.getTileEntity(par2, par3, par4);
    if (te == null || !(te instanceof CustomizableSCTE))
        return false;
    if (te instanceof TileEntityKeypad) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            PlayerUtils.sendMessageToPlayer(par5EntityPlayer, StatCollector.translateToLocal("tile.keypad.name"), StatCollector.translateToLocal("messages.module.whitelisted"), EnumChatFormatting.GREEN);
            BlockKeypad.activate(par1World, par2, par3, par4);
            return true;
        }
        if (module == EnumCustomModules.BLACKLIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.BLACKLIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.BLACKLIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            PlayerUtils.sendMessageToPlayer(par5EntityPlayer, StatCollector.translateToLocal("tile.keypad.name"), StatCollector.translateToLocal("messages.module.blacklisted"), EnumChatFormatting.RED);
            return true;
        }
    } else if (te instanceof TileEntityKeycardReader) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            PlayerUtils.sendMessageToPlayer(par5EntityPlayer, StatCollector.translateToLocal("tile.keycardReader.name"), StatCollector.translateToLocal("messages.module.whitelisted"), EnumChatFormatting.GREEN);
            BlockKeycardReader.activate(par1World, par2, par3, par4);
            return true;
        }
        if (module == EnumCustomModules.BLACKLIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.BLACKLIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.BLACKLIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            PlayerUtils.sendMessageToPlayer(par5EntityPlayer, StatCollector.translateToLocal("tile.keycardReader.name"), StatCollector.translateToLocal("messages.module.blacklisted"), EnumChatFormatting.RED);
            return true;
        }
    } else if (te instanceof TileEntityRetinalScanner) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase()))
            return true;
    } else if (te instanceof TileEntityInventoryScanner)
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase()))
            return true;
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) TileEntityRetinalScanner(net.geforcemods.securitycraft.tileentity.TileEntityRetinalScanner) TileEntityInventoryScanner(net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner) TileEntityKeycardReader(net.geforcemods.securitycraft.tileentity.TileEntityKeycardReader) TileEntityKeypad(net.geforcemods.securitycraft.tileentity.TileEntityKeypad)

Example 2 with TileEntityInventoryScanner

use of net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner in project SecurityCraft by Geforce132.

the class BlockInventoryScanner method checkAndPlaceAppropriately.

private void checkAndPlaceAppropriately(World par1World, int par2, int par3, int par4) {
    TileEntityInventoryScanner connectedScanner = getConnectedInventoryScanner(par1World, par2, par3, par4);
    if (connectedScanner == null)
        return;
    if (par1World.getBlockMetadata(par2, par3, par4) == 4) {
        for (int j = 1; j < Math.abs(par2 - connectedScanner.xCoord); j++) {
            par1World.setBlock(par2 - j, par3, par4, SCContent.inventoryScannerField, 1, 3);
        }
    } else if (par1World.getBlockMetadata(par2, par3, par4) == 5) {
        for (int j = 1; j < Math.abs(par2 - connectedScanner.xCoord); j++) {
            par1World.setBlock(par2 + j, par3, par4, SCContent.inventoryScannerField, 1, 3);
        }
    } else if (par1World.getBlockMetadata(par2, par3, par4) == 2) {
        for (int j = 1; j < Math.abs(par4 - connectedScanner.zCoord); j++) {
            par1World.setBlock(par2, par3, par4 - j, SCContent.inventoryScannerField, 2, 3);
        }
    } else if (par1World.getBlockMetadata(par2, par3, par4) == 3) {
        for (int j = 1; j < Math.abs(par4 - connectedScanner.zCoord); j++) {
            par1World.setBlock(par2, par3, par4 + j, SCContent.inventoryScannerField, 2, 3);
        }
    }
    CustomizableSCTE.link((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4), connectedScanner);
}
Also used : TileEntityInventoryScanner(net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner)

Example 3 with TileEntityInventoryScanner

use of net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner in project SecurityCraft by Geforce132.

the class Utils method setISinTEAppropriately.

public static void setISinTEAppropriately(World par1World, BlockPos pos, NonNullList<ItemStack> contents, String type) {
    TileEntityInventoryScanner connectedScanner = BlockInventoryScanner.getConnectedInventoryScanner(par1World, pos);
    connectedScanner.setContents(contents);
    connectedScanner.setType(type);
}
Also used : TileEntityInventoryScanner(net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner)

Example 4 with TileEntityInventoryScanner

use of net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner in project SecurityCraft by Geforce132.

the class BlockInventoryScanner method checkAndPlaceAppropriately.

private void checkAndPlaceAppropriately(World par1World, BlockPos pos) {
    TileEntityInventoryScanner connectedScanner = getConnectedInventoryScanner(par1World, pos);
    if (connectedScanner == null)
        return;
    if ((EnumFacing) par1World.getBlockState(pos).getValue(FACING) == EnumFacing.WEST) {
        for (int i = 1; i < Math.abs(pos.getX() - connectedScanner.getPos().getX()); i++) {
            par1World.setBlockState(pos.west(i), SCContent.inventoryScannerField.getDefaultState().withProperty(FACING, EnumFacing.WEST));
        }
    } else if ((EnumFacing) par1World.getBlockState(pos).getValue(FACING) == EnumFacing.EAST) {
        for (int i = 1; i < Math.abs(pos.getX() - connectedScanner.getPos().getX()); i++) {
            par1World.setBlockState(pos.east(i), SCContent.inventoryScannerField.getDefaultState().withProperty(FACING, EnumFacing.EAST));
        }
    } else if ((EnumFacing) par1World.getBlockState(pos).getValue(FACING) == EnumFacing.NORTH) {
        for (int i = 1; i < Math.abs(pos.getZ() - connectedScanner.getPos().getZ()); i++) {
            par1World.setBlockState(pos.north(i), SCContent.inventoryScannerField.getDefaultState().withProperty(FACING, EnumFacing.NORTH));
        }
    } else if ((EnumFacing) par1World.getBlockState(pos).getValue(FACING) == EnumFacing.SOUTH) {
        for (int i = 1; i < Math.abs(pos.getZ() - connectedScanner.getPos().getZ()); i++) {
            par1World.setBlockState(pos.south(i), SCContent.inventoryScannerField.getDefaultState().withProperty(FACING, EnumFacing.SOUTH));
        }
    }
    CustomizableSCTE.link((CustomizableSCTE) par1World.getTileEntity(pos), connectedScanner);
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) TileEntityInventoryScanner(net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner)

Example 5 with TileEntityInventoryScanner

use of net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner in project SecurityCraft by Geforce132.

the class BlockInventoryScanner method breakBlock.

@Override
public void breakBlock(World par1World, BlockPos pos, IBlockState state) {
    if (par1World.isRemote)
        return;
    TileEntityInventoryScanner connectedScanner = null;
    for (int i = 1; i <= SecurityCraft.config.inventoryScannerRange; i++) {
        if (BlockUtils.getBlock(par1World, pos.west(i)) == SCContent.inventoryScanner) {
            for (int j = 1; j < i; j++) {
                if (BlockUtils.getBlock(par1World, pos.west(j)) == SCContent.inventoryScannerField)
                    par1World.destroyBlock(pos.west(j), false);
            }
            connectedScanner = (TileEntityInventoryScanner) par1World.getTileEntity(pos.west(i));
            break;
        }
    }
    for (int i = 1; i <= SecurityCraft.config.inventoryScannerRange; i++) {
        if (BlockUtils.getBlock(par1World, pos.east(i)) == SCContent.inventoryScanner) {
            for (int j = 1; j < i; j++) {
                if (BlockUtils.getBlock(par1World, pos.east(j)) == SCContent.inventoryScannerField)
                    par1World.destroyBlock(pos.east(j), false);
            }
            connectedScanner = (TileEntityInventoryScanner) par1World.getTileEntity(pos.east(i));
            break;
        }
    }
    for (int i = 1; i <= SecurityCraft.config.inventoryScannerRange; i++) {
        if (BlockUtils.getBlock(par1World, pos.north(i)) == SCContent.inventoryScanner) {
            for (int j = 1; j < i; j++) {
                if (BlockUtils.getBlock(par1World, pos.north(j)) == SCContent.inventoryScannerField)
                    par1World.destroyBlock(pos.north(j), false);
            }
            connectedScanner = (TileEntityInventoryScanner) par1World.getTileEntity(pos.north(i));
            break;
        }
    }
    for (int i = 1; i <= SecurityCraft.config.inventoryScannerRange; i++) {
        if (BlockUtils.getBlock(par1World, pos.south(i)) == SCContent.inventoryScanner) {
            for (int j = 1; j < i; j++) {
                if (BlockUtils.getBlock(par1World, pos.south(j)) == SCContent.inventoryScannerField)
                    par1World.destroyBlock(pos.south(j), false);
            }
            connectedScanner = (TileEntityInventoryScanner) par1World.getTileEntity(pos.south(i));
            break;
        }
    }
    for (int i = 0; i < ((TileEntityInventoryScanner) par1World.getTileEntity(pos)).getContents().length; i++) {
        if (((TileEntityInventoryScanner) par1World.getTileEntity(pos)).getContents()[i] != null)
            par1World.spawnEntityInWorld(new EntityItem(par1World, pos.getX(), pos.getY(), pos.getZ(), ((TileEntityInventoryScanner) par1World.getTileEntity(pos)).getContents()[i]));
    }
    if (connectedScanner != null) {
        for (int i = 0; i < connectedScanner.getContents().length; i++) {
            connectedScanner.getContents()[i] = null;
        }
    }
    super.breakBlock(par1World, pos, state);
}
Also used : TileEntityInventoryScanner(net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

TileEntityInventoryScanner (net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner)9 EntityItem (net.minecraft.entity.item.EntityItem)2 CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)1 TileEntityKeycardReader (net.geforcemods.securitycraft.tileentity.TileEntityKeycardReader)1 TileEntityKeypad (net.geforcemods.securitycraft.tileentity.TileEntityKeypad)1 TileEntityRetinalScanner (net.geforcemods.securitycraft.tileentity.TileEntityRetinalScanner)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1