use of net.geforcemods.securitycraft.tileentity.TileEntityKeypad 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.tileentity.TileEntityKeypad in project SecurityCraft by Geforce132.
the class BlockKeypad method getDisguisedBlockState.
public IBlockState getDisguisedBlockState(IBlockAccess world, BlockPos pos) {
if (world.getTileEntity(pos) instanceof TileEntityKeypad) {
TileEntityKeypad te = (TileEntityKeypad) world.getTileEntity(pos);
ItemStack module = te.hasModule(EnumCustomModules.DISGUISE) ? te.getModule(EnumCustomModules.DISGUISE) : null;
if (module != null && !((ItemModule) module.getItem()).getBlockAddons(module.getTagCompound()).isEmpty()) {
ItemStack disguisedStack = ((ItemModule) module.getItem()).getAddons(module.getTagCompound()).get(0);
Block block = Block.getBlockFromItem(disguisedStack.getItem());
boolean hasMeta = disguisedStack.getHasSubtypes();
IBlockState disguisedModel = block.getStateFromMeta(hasMeta ? disguisedStack.getItemDamage() : getMetaFromState(world.getBlockState(pos)));
if (block != this) {
return block.getActualState(disguisedModel, world, pos);
}
}
}
return null;
}
use of net.geforcemods.securitycraft.tileentity.TileEntityKeypad in project SecurityCraft by Geforce132.
the class BlockKeypad method getDisguisedStack.
public ItemStack getDisguisedStack(IBlockAccess world, BlockPos pos) {
if (world.getTileEntity(pos) instanceof TileEntityKeypad) {
TileEntityKeypad te = (TileEntityKeypad) world.getTileEntity(pos);
ItemStack stack = te.hasModule(EnumCustomModules.DISGUISE) ? te.getModule(EnumCustomModules.DISGUISE) : null;
if (stack != null && !((ItemModule) stack.getItem()).getBlockAddons(stack.getTagCompound()).isEmpty()) {
ItemStack disguisedStack = ((ItemModule) stack.getItem()).getAddons(stack.getTagCompound()).get(0);
if (Block.getBlockFromItem(disguisedStack.getItem()) != this) {
return disguisedStack;
}
}
}
return null;
}
use of net.geforcemods.securitycraft.tileentity.TileEntityKeypad in project SecurityCraft by Geforce132.
the class BlockUtils method setBlockProperty.
public static void setBlockProperty(World par1World, BlockPos pos, PropertyBool property, boolean value, boolean retainOldTileEntity) {
if (retainOldTileEntity) {
ItemStack[] modules = null;
ItemStack[] inventory = null;
int[] times = new int[4];
String password = "";
Owner owner = null;
int cooldown = -1;
if (par1World.getTileEntity(pos) instanceof CustomizableSCTE) {
modules = ((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks;
}
if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
inventory = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks;
times[0] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime;
times[1] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime;
times[2] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime;
times[3] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime;
}
if (par1World.getTileEntity(pos) instanceof TileEntityOwnable && ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner() != null) {
owner = ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner();
}
if (par1World.getTileEntity(pos) instanceof TileEntityKeypad && ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword() != null) {
password = ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword();
}
if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace && ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword() != null) {
password = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword();
}
if (par1World.getTileEntity(pos) instanceof TileEntityKeypadChest && ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword() != null) {
password = ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword();
}
if (par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown() != 0) {
cooldown = ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown();
}
TileEntity tileEntity = par1World.getTileEntity(pos);
par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
par1World.setTileEntity(pos, tileEntity);
if (modules != null) {
((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks = modules;
}
if (inventory != null && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks = inventory;
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime = times[0];
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime = times[1];
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime = times[2];
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime = times[3];
}
if (owner != null) {
((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner().set(owner);
}
if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypad) {
((TileEntityKeypad) par1World.getTileEntity(pos)).setPassword(password);
}
if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).setPassword(password);
}
if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadChest) {
((TileEntityKeypadChest) par1World.getTileEntity(pos)).setPassword(password);
}
if (cooldown != -1 && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar) {
((TileEntityPortableRadar) par1World.getTileEntity(pos)).setAttackCooldown(cooldown);
}
} else {
par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
}
}
use of net.geforcemods.securitycraft.tileentity.TileEntityKeypad in project SecurityCraft by Geforce132.
the class BlockKeypad method getIcon.
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess access, int x, int y, int z, int side) {
int meta = access.getBlockMetadata(x, y, z);
TileEntityKeypad tileEntity = ((TileEntityKeypad) access.getTileEntity(x, y, z));
boolean isDisguised = tileEntity.hasModule(EnumCustomModules.DISGUISE);
if (isDisguised && !tileEntity.getAddonsFromModule(EnumCustomModules.DISGUISE).isEmpty()) {
List<ItemStack> stacks = tileEntity.getAddonsFromModule(EnumCustomModules.DISGUISE);
if (stacks.size() != 0) {
ItemStack stack = stacks.get(0);
Block disguisedAs = Block.getBlockFromItem(stack.getItem());
return stack.getHasSubtypes() ? disguisedAs.getIcon(side, stack.getItemDamage()) : disguisedAs.getIcon(side, meta);
}
}
if (meta > 6 && meta < 11) {
return side == 1 ? this.keypadIconTop : (side == 0 ? this.keypadIconTop : (side != (meta - 5) ? this.blockIcon : this.keypadIconFrontActive));
} else {
return side == 1 ? this.keypadIconTop : (side == 0 ? this.keypadIconTop : (side != meta ? this.blockIcon : this.keypadIconFront));
}
}
Aggregations