use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.
the class EntitySecurityCamera method emitLight.
public void emitLight() {
Block block = this.worldObj.getBlock((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ));
if (block instanceof BlockSecurityCamera) {
this.toggleLightCooldown = 30;
int meta = this.worldObj.getBlockMetadata((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ));
ItemStack[] modules = null;
if (!((CustomizableSCTE) this.worldObj.getTileEntity((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ))).getModules().isEmpty()) {
modules = ((CustomizableSCTE) this.worldObj.getTileEntity((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ))).itemStacks;
}
if (block == mod_SecurityCraft.securityCamera) {
mod_SecurityCraft.network.sendToServer(new PacketSetBlockAndMetadata((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ), "securitycraft:securityCameraLit", meta));
mod_SecurityCraft.network.sendToServer(new PacketSSetOwner((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ), ((IOwnable) this.worldObj.getTileEntity((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ))).getOwner().getUUID(), ((IOwnable) this.worldObj.getTileEntity((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ))).getOwner().getName()));
if (modules != null) {
mod_SecurityCraft.network.sendToServer(new PacketSAddModules((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ), modules));
}
}
}
}
use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.
the class BlockPortableRadar method searchForPlayers.
public static void searchForPlayers(World par1World, int par2, int par3, int par4, double searchRadius) {
if (!par1World.isRemote) {
double d0 = (searchRadius);
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(par2, par3, par4, par2 + 1, par3 + 1, par4 + 1).expand(d0, d0, d0);
axisalignedbb.maxY = 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) {
togglePowerOutput(par1World, par2, par3, par4, false);
return;
}
}
while (iterator.hasNext()) {
EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager().func_152612_a(((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getOwner().getName());
entityplayer = (EntityPlayer) iterator.next();
if (par1World.getTileEntity(par2, par3, par4) == null || !(par1World.getTileEntity(par2, par3, par4) instanceof CustomizableSCTE)) {
continue;
}
if (((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(entityplayermp.getCommandSenderName().toLowerCase())) {
continue;
}
if (PlayerUtils.isPlayerOnline(((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getOwner().getName())) {
if (!((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).shouldSendMessage(entityplayer)) {
continue;
}
PlayerUtils.sendMessageToPlayer(entityplayermp, StatCollector.translateToLocal("tile.portableRadar.name"), ((INameable) par1World.getTileEntity(par2, par3, par4)).hasCustomName() ? (StatCollector.translateToLocal("messages.portableRadar.withName").replace("#p", EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET).replace("#n", EnumChatFormatting.ITALIC + ((INameable) par1World.getTileEntity(par2, par3, par4)).getCustomName() + EnumChatFormatting.RESET)) : (StatCollector.translateToLocal("messages.portableRadar.withoutName").replace("#p", EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET).replace("#l", Utils.getFormattedCoordinates(par2, par3, par4))), EnumChatFormatting.BLUE);
((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).setSentMessage();
}
if (par1World.getTileEntity(par2, par3, par4) != null && par1World.getTileEntity(par2, par3, par4) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.REDSTONE)) {
togglePowerOutput(par1World, par2, par3, par4, true);
}
}
}
}
use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.
the class ModuleUtils method getPlayersFromModule.
/**
* Gets the players added to customizable modules (such as the Whitelist Module.) <p>
*
* Args: world, x, y, z, moduleType.
*/
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).toLowerCase());
}
}
}
return list;
}
use of net.geforcemods.securitycraft.api.CustomizableSCTE 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;
}
use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.
the class BlockPortableRadar method searchForPlayers.
public static void searchForPlayers(World par1World, BlockPos pos, IBlockState state) {
if (!par1World.isRemote) {
double d0 = (mod_SecurityCraft.configHandler.portableRadarSearchRadius);
AxisAlignedBB axisalignedbb = BlockUtils.fromBounds(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1).expand(d0, d0, d0).addCoord(0.0D, par1World.getHeight(), 0.0D);
List<?> list = par1World.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
Iterator<?> iterator = list.iterator();
EntityPlayer entityplayer;
if (list.isEmpty()) {
if (par1World.getTileEntity(pos) != null && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(pos)).hasModule(EnumCustomModules.REDSTONE) && state.getValue(POWERED).booleanValue()) {
togglePowerOutput(par1World, pos, false);
return;
}
}
if (!((CustomizableSCTE) par1World.getTileEntity(pos)).hasModule(EnumCustomModules.REDSTONE)) {
togglePowerOutput(par1World, pos, false);
}
while (iterator.hasNext()) {
EntityPlayerMP entityplayermp = par1World.getMinecraftServer().getPlayerList().getPlayerByUsername(((TileEntityPortableRadar) par1World.getTileEntity(pos)).getOwner().getName());
entityplayer = (EntityPlayer) iterator.next();
if (entityplayermp != null && ((CustomizableSCTE) par1World.getTileEntity(pos)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, pos, EnumCustomModules.WHITELIST).contains(entityplayermp.getName().toLowerCase())) {
continue;
}
if (PlayerUtils.isPlayerOnline(((TileEntityPortableRadar) par1World.getTileEntity(pos)).getOwner().getName())) {
if (!((TileEntityPortableRadar) par1World.getTileEntity(pos)).shouldSendMessage(entityplayer)) {
continue;
}
PlayerUtils.sendMessageToPlayer(entityplayermp, I18n.translateToLocal("tile.portableRadar.name"), ((INameable) par1World.getTileEntity(pos)).hasCustomName() ? (I18n.translateToLocal("messages.portableRadar.withName").replace("#p", TextFormatting.ITALIC + entityplayer.getName() + TextFormatting.RESET).replace("#n", TextFormatting.ITALIC + ((INameable) par1World.getTileEntity(pos)).getCustomName() + TextFormatting.RESET)) : (I18n.translateToLocal("messages.portableRadar.withoutName").replace("#p", TextFormatting.ITALIC + entityplayer.getName() + TextFormatting.RESET).replace("#l", Utils.getFormattedCoordinates(pos))), TextFormatting.BLUE);
((TileEntityPortableRadar) par1World.getTileEntity(pos)).setSentMessage();
}
if (par1World.getTileEntity(pos) != null && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(pos)).hasModule(EnumCustomModules.REDSTONE)) {
togglePowerOutput(par1World, pos, true);
}
}
}
}
Aggregations