Search in sources :

Example 1 with CustomizableSCTE

use of org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE in project SecurityCraft by Geforce132.

the class BlockLaser method onEntityCollidedWithBlock.

/**
 * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
 */
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {
    if (!par1World.isRemote && par5Entity instanceof EntityLivingBase && !HelpfulMethods.doesMobHavePotionEffect((EntityLivingBase) par5Entity, Potion.invisibility)) {
        for (int i = 1; i <= mod_SecurityCraft.configHandler.laserBlockRange; i++) {
            Block id = par1World.getBlock(par2 + i, par3, par4);
            if (id == mod_SecurityCraft.LaserBlock) {
                if (((CustomizableSCTE) par1World.getTileEntity(par2 + i, par3, par4)).hasModule(EnumCustomModules.WHITELIST) && HelpfulMethods.getPlayersFromModule(par1World, par2 + i, par3, par4, EnumCustomModules.WHITELIST).contains(((EntityLivingBase) par5Entity).getCommandSenderName())) {
                    return;
                }
                // par1World.setBlock(par2 + i, par3, par4, mod_SecurityCraft.LaserBlock, 2, 3); //TODO
                par1World.setBlockMetadataWithNotify(par2 + i, par3, par4, 2, 3);
                par1World.notifyBlocksOfNeighborChange(par2 + i, par3, par4, mod_SecurityCraft.LaserBlock);
                par1World.scheduleBlockUpdate(par2 + i, par3, par4, mod_SecurityCraft.LaserBlock, 50);
                par1World.notifyBlocksOfNeighborChange(par2 + i, par3, par4, mod_SecurityCraft.LaserBlock);
                if (par1World.getTileEntity(par2 + i, par3, par4) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2 + i, par3, par4)).hasModule(EnumCustomModules.HARMING)) {
                    float f = ((EntityLivingBase) par5Entity).getHealth();
                    ((EntityLivingBase) par5Entity).attackEntityFrom(DamageSource.generic, 10F);
                // ((EntityLivingBase) par5Entity).setHealth(f - 0.5F);
                }
            } else {
                continue;
            }
        }
        for (int i = 0; i <= mod_SecurityCraft.configHandler.laserBlockRange; i++) {
            Block id = par1World.getBlock(par2 - i, par3, par4);
            if (id == mod_SecurityCraft.LaserBlock) {
                if (((CustomizableSCTE) par1World.getTileEntity(par2 - i, par3, par4)).hasModule(EnumCustomModules.WHITELIST) && HelpfulMethods.getPlayersFromModule(par1World, par2 - i, par3, par4, EnumCustomModules.WHITELIST).contains(((EntityLivingBase) par5Entity).getCommandSenderName())) {
                    return;
                }
                // par1World.setBlock(par2 - i, par3, par4, mod_SecurityCraft.LaserBlock, 2, 3);
                par1World.setBlockMetadataWithNotify(par2 - i, par3, par4, 2, 3);
                par1World.notifyBlocksOfNeighborChange(par2 - i, par3, par4, mod_SecurityCraft.LaserBlock);
                par1World.scheduleBlockUpdate(par2 - i, par3, par4, mod_SecurityCraft.LaserBlock, 50);
                par1World.notifyBlocksOfNeighborChange(par2 - i, par3, par4, mod_SecurityCraft.LaserBlock);
                if (par1World.getTileEntity(par2 - i, par3, par4) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2 - i, par3, par4)).hasModule(EnumCustomModules.HARMING)) {
                    float f = ((EntityLivingBase) par5Entity).getHealth();
                    ((EntityLivingBase) par5Entity).attackEntityFrom(DamageSource.generic, 10F);
                // ((EntityLivingBase) par5Entity).setHealth(f - 0.5F);
                }
            } else {
                continue;
            }
        }
        for (int i = 0; i <= mod_SecurityCraft.configHandler.laserBlockRange; i++) {
            Block id = par1World.getBlock(par2, par3, par4 + i);
            if (id == mod_SecurityCraft.LaserBlock) {
                if (((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4 + i)).hasModule(EnumCustomModules.WHITELIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4 + i, EnumCustomModules.WHITELIST).contains(((EntityLivingBase) par5Entity).getCommandSenderName())) {
                    return;
                }
                // par1World.setBlock(par2, par3, par4 + i, mod_SecurityCraft.LaserBlock, 2, 3);
                par1World.setBlockMetadataWithNotify(par2, par3, par4 + i, 2, 3);
                par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + i, mod_SecurityCraft.LaserBlock);
                par1World.scheduleBlockUpdate(par2, par3, par4 + i, mod_SecurityCraft.LaserBlock, 50);
                par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + i, mod_SecurityCraft.LaserBlock);
                if (par1World.getTileEntity(par2, par3, par4 + i) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4 + i)).hasModule(EnumCustomModules.HARMING)) {
                    float f = ((EntityLivingBase) par5Entity).getHealth();
                    ((EntityLivingBase) par5Entity).attackEntityFrom(DamageSource.generic, 10F);
                // ((EntityLivingBase) par5Entity).setHealth(f - 0.5F);
                }
            } else {
                continue;
            }
        }
        for (int i = 0; i <= mod_SecurityCraft.configHandler.laserBlockRange; i++) {
            Block id = par1World.getBlock(par2, par3, par4 - i);
            if (id == mod_SecurityCraft.LaserBlock) {
                if (((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4 - i)).hasModule(EnumCustomModules.WHITELIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4 - i, EnumCustomModules.WHITELIST).contains(((EntityLivingBase) par5Entity).getCommandSenderName())) {
                    return;
                }
                // par1World.setBlock(par2, par3, par4 - i, mod_SecurityCraft.LaserBlock, 2, 3);
                par1World.setBlockMetadataWithNotify(par2, par3, par4 - i, 2, 3);
                par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - i, mod_SecurityCraft.LaserBlock);
                par1World.scheduleBlockUpdate(par2, par3, par4 - i, mod_SecurityCraft.LaserBlock, 50);
                par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - i, mod_SecurityCraft.LaserBlock);
                if (par1World.getTileEntity(par2, par3, par4 - i) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4 - i)).hasModule(EnumCustomModules.HARMING)) {
                    float f = ((EntityLivingBase) par5Entity).getHealth();
                    ((EntityLivingBase) par5Entity).attackEntityFrom(DamageSource.generic, 10F);
                // ((EntityLivingBase) par5Entity).setHealth(f - 0.5F);
                }
            } else {
                continue;
            }
        }
        for (int i = 0; i <= mod_SecurityCraft.configHandler.laserBlockRange; i++) {
            Block id = par1World.getBlock(par2, par3 + i, par4);
            if (id == mod_SecurityCraft.LaserBlock) {
                if (((CustomizableSCTE) par1World.getTileEntity(par2, par3 + i, par4)).hasModule(EnumCustomModules.WHITELIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3 + i, par4, EnumCustomModules.WHITELIST).contains(((EntityLivingBase) par5Entity).getCommandSenderName())) {
                    return;
                }
                // par1World.setBlock(par2, par3 + i, par4, mod_SecurityCraft.LaserBlock, 2, 3);
                par1World.setBlockMetadataWithNotify(par2, par3 + i, par4, 2, 3);
                par1World.notifyBlocksOfNeighborChange(par2, par3 + i, par4, mod_SecurityCraft.LaserBlock);
                par1World.scheduleBlockUpdate(par2, par3 + i, par4, mod_SecurityCraft.LaserBlock, 50);
                par1World.notifyBlocksOfNeighborChange(par2, par3 + i, par4, mod_SecurityCraft.LaserBlock);
                if (par1World.getTileEntity(par2, par3 + i, par4) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2, par3 + i, par4)).hasModule(EnumCustomModules.HARMING)) {
                    float f = ((EntityLivingBase) par5Entity).getHealth();
                    ((EntityLivingBase) par5Entity).attackEntityFrom(DamageSource.generic, 10F);
                // ((EntityLivingBase) par5Entity).setHealth(f - 0.5F);
                }
            } else {
                continue;
            }
        }
        for (int i = 0; i <= mod_SecurityCraft.configHandler.laserBlockRange; i++) {
            Block id = par1World.getBlock(par2, par3 - i, par4);
            if (id == mod_SecurityCraft.LaserBlock) {
                if (((CustomizableSCTE) par1World.getTileEntity(par2, par3 - i, par4)).hasModule(EnumCustomModules.WHITELIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3 - i, par4, EnumCustomModules.WHITELIST).contains(((EntityLivingBase) par5Entity).getCommandSenderName())) {
                    return;
                }
                // par1World.setBlock(par2, par3 - i, par4, mod_SecurityCraft.LaserBlock, 2, 3);
                par1World.setBlockMetadataWithNotify(par2, par3 - i, par4, 2, 3);
                par1World.notifyBlocksOfNeighborChange(par2, par3 - i, par4, mod_SecurityCraft.LaserBlock);
                par1World.scheduleBlockUpdate(par2, par3 - i, par4, mod_SecurityCraft.LaserBlock, 50);
                par1World.notifyBlocksOfNeighborChange(par2, par3 - i, par4, mod_SecurityCraft.LaserBlock);
                if (par1World.getTileEntity(par2, par3 - i, par4) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2, par3 - i, par4)).hasModule(EnumCustomModules.HARMING)) {
                    float f = ((EntityLivingBase) par5Entity).getHealth();
                    ((EntityLivingBase) par5Entity).attackEntityFrom(DamageSource.generic, 10F);
                // ((EntityLivingBase) par5Entity).setHealth(f - 0.5F);
                }
            } else {
                continue;
            }
        }
    }
}
Also used : CustomizableSCTE(org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Block(net.minecraft.block.Block)

Example 2 with CustomizableSCTE

use of org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE in project SecurityCraft by Geforce132.

the class HelpfulMethods method getPlayersFromModule.

public static List<String> getPlayersFromModule(World par1World, int par2, int par3, int par4, EnumCustomModules module) {
    List<String> list = new ArrayList<String>();
    CustomizableSCTE te = (CustomizableSCTE) par1World.getTileEntity(par2, par3, par4);
    if (te.hasModule(module)) {
        ItemStack item = te.getModule(module);
        for (int i = 1; i <= 10; i++) {
            if (item.stackTagCompound != null && item.stackTagCompound.getString("Player" + i) != null && !item.stackTagCompound.getString("Player" + i).isEmpty()) {
                list.add(item.stackTagCompound.getString("Player" + i));
            }
        }
    }
    return list;
}
Also used : CustomizableSCTE(org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 3 with CustomizableSCTE

use of org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE in project SecurityCraft by Geforce132.

the class ForgeEventHandler method onBlockBroken.

@SubscribeEvent
public void onBlockBroken(BreakEvent event) {
    if (!event.world.isRemote) {
        if (event.world.getTileEntity(event.x, event.y, event.z) != null && event.world.getTileEntity(event.x, event.y, event.z) instanceof CustomizableSCTE) {
            for (int i = 0; i < ((CustomizableSCTE) event.world.getTileEntity(event.x, event.y, event.z)).getNumberOfCustomizableOptions(); i++) {
                if (((CustomizableSCTE) event.world.getTileEntity(event.x, event.y, event.z)).itemStacks[i] != null) {
                    EntityItem item = new EntityItem(event.world, (double) event.x, (double) event.y, (double) event.z, ((CustomizableSCTE) event.world.getTileEntity(event.x, event.y, event.z)).itemStacks[i]);
                    event.world.spawnEntityInWorld(item);
                }
            }
        }
    }
}
Also used : CustomizableSCTE(org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 4 with CustomizableSCTE

use of org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE in project SecurityCraft by Geforce132.

the class HelpfulMethods method checkForModule.

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) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName())) {
            HelpfulMethods.sendMessageToPlayer(par5EntityPlayer, "You have been whitelisted on this keypad.", EnumChatFormatting.GREEN);
            new ScheduleUpdate(par1World, 3, par2, par3, par4);
            return true;
        }
        if (module == EnumCustomModules.BLACKLIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.BLACKLIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.BLACKLIST).contains(par5EntityPlayer.getCommandSenderName())) {
            HelpfulMethods.sendMessageToPlayer(par5EntityPlayer, "You have been blacklisted on this keypad.", EnumChatFormatting.RED);
            return true;
        }
    } else if (te instanceof TileEntityKeycardReader) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName())) {
            HelpfulMethods.sendMessageToPlayer(par5EntityPlayer, "You have been whitelisted on this reader.", EnumChatFormatting.GREEN);
            ((TileEntityKeycardReader) te).setIsProvidingPower(true);
            new ScheduleKeycardUpdate(3, par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4));
            par1World.notifyBlocksOfNeighborChange(par2, par3, par4, par1World.getBlock(par2, par3, par4));
            return true;
        }
        if (module == EnumCustomModules.BLACKLIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.BLACKLIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.BLACKLIST).contains(par5EntityPlayer.getCommandSenderName())) {
            HelpfulMethods.sendMessageToPlayer(par5EntityPlayer, "You have been blacklisted on this reader.", EnumChatFormatting.RED);
            return true;
        }
    } else if (te instanceof TileEntityRetinalScanner) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName())) {
            return true;
        }
    } else if (te instanceof TileEntityInventoryScanner) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName())) {
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CustomizableSCTE(org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE) TileEntityRetinalScanner(org.freeforums.geforce.securitycraft.tileentity.TileEntityRetinalScanner) ScheduleUpdate(org.freeforums.geforce.securitycraft.timers.ScheduleUpdate) TileEntityInventoryScanner(org.freeforums.geforce.securitycraft.tileentity.TileEntityInventoryScanner) ScheduleKeycardUpdate(org.freeforums.geforce.securitycraft.timers.ScheduleKeycardUpdate) TileEntityKeycardReader(org.freeforums.geforce.securitycraft.tileentity.TileEntityKeycardReader) TileEntityKeypad(org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypad)

Example 5 with CustomizableSCTE

use of org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE in project SecurityCraft by Geforce132.

the class BlockPortableRadar method addEffectsToPlayers.

public void addEffectsToPlayers(World par1World, int par2, int par3, int par4) {
    if (par1World.isRemote) {
        return;
    } else {
        // double d0 = (double)(5 * 10);
        double d0 = (double) (mod_SecurityCraft.configHandler.portableRadarSearchRadius);
        AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox((double) par2, (double) par3, (double) par4, (double) (par2 + 1), (double) (par3 + 1), (double) (par4 + 1)).expand(d0, d0, d0);
        axisalignedbb.maxY = (double) par1World.getHeight();
        List list = par1World.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
        Iterator iterator = list.iterator();
        EntityPlayer entityplayer;
        if (list.isEmpty()) {
            if (par1World.getTileEntity(par2, par3, par4) != null && par1World.getTileEntity(par2, par3, par4) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.REDSTONE) && par1World.getBlockMetadata(par2, par3, par4) == 1) {
                this.togglePowerOutput(par1World, par2, par3, par4, false);
                return;
            }
        }
        while (iterator.hasNext()) {
            EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getUsername());
            entityplayer = (EntityPlayer) iterator.next();
            if (this.isOwnerOnline(((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getUsername())) {
                if (!((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).isEmped()) {
                    HelpfulMethods.sendMessageToPlayer(entityplayermp, ((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).hasCustomName() ? (EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET + " is near your portable radar named " + EnumChatFormatting.ITALIC + ((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getCustomName() + EnumChatFormatting.RESET + ".") : (EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET + " is near a portable radar (at X: " + par2 + " Y:" + par3 + " Z:" + par4 + ")."), null);
                } else {
                    HelpfulMethods.sendMessageToPlayer(entityplayermp, "xxxxxxxxxx", EnumChatFormatting.OBFUSCATED);
                }
            }
            if (par1World.getTileEntity(par2, par3, par4) != null && par1World.getTileEntity(par2, par3, par4) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.REDSTONE)) {
                this.togglePowerOutput(par1World, par2, par3, par4, true);
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) CustomizableSCTE(org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE) TileEntityPortableRadar(org.freeforums.geforce.securitycraft.tileentity.TileEntityPortableRadar) Iterator(java.util.Iterator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) List(java.util.List) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Aggregations

CustomizableSCTE (org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE)5 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Block (net.minecraft.block.Block)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)1 TileEntityInventoryScanner (org.freeforums.geforce.securitycraft.tileentity.TileEntityInventoryScanner)1 TileEntityKeycardReader (org.freeforums.geforce.securitycraft.tileentity.TileEntityKeycardReader)1 TileEntityKeypad (org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypad)1 TileEntityPortableRadar (org.freeforums.geforce.securitycraft.tileentity.TileEntityPortableRadar)1 TileEntityRetinalScanner (org.freeforums.geforce.securitycraft.tileentity.TileEntityRetinalScanner)1 ScheduleKeycardUpdate (org.freeforums.geforce.securitycraft.timers.ScheduleKeycardUpdate)1 ScheduleUpdate (org.freeforums.geforce.securitycraft.timers.ScheduleUpdate)1