id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
2,700
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/JobDetails.java
JobDetails.getCounterValueAsLong
Long getCounterValueAsLong(final CounterMap counters, final String counterGroupName, final String counterName) { Counter c1 = counters.getCounter(counterGroupName, counterName); if (c1 != null) { return c1.getValue(); } else { return 0L; } }
java
Long getCounterValueAsLong(final CounterMap counters, final String counterGroupName, final String counterName) { Counter c1 = counters.getCounter(counterGroupName, counterName); if (c1 != null) { return c1.getValue(); } else { return 0L; } }
[ "Long", "getCounterValueAsLong", "(", "final", "CounterMap", "counters", ",", "final", "String", "counterGroupName", ",", "final", "String", "counterName", ")", "{", "Counter", "c1", "=", "counters", ".", "getCounter", "(", "counterGroupName", ",", "counterName", ...
return a value for that counters from the NavigableMap as a Long @param key @param infoValues @return counter value as Long or 0L
[ "return", "a", "value", "for", "that", "counters", "from", "the", "NavigableMap", "as", "a", "Long" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/JobDetails.java#L424-L432
2,701
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/JobDetails.java
JobDetails.getHadoopVersionFromResult
private HadoopVersion getHadoopVersionFromResult(final JobHistoryKeys key, final NavigableMap<byte[], byte[]> infoValues) { byte[] value = infoValues.get(JobHistoryKeys.KEYS_TO_BYTES.get(key)); if (value != null) { String hv = Bytes.toString(value); // could throw an NPE or IllegalArgumentException return HadoopVersion.valueOf(hv); } else { // default is hadoop 1 return HadoopVersion.ONE; } }
java
private HadoopVersion getHadoopVersionFromResult(final JobHistoryKeys key, final NavigableMap<byte[], byte[]> infoValues) { byte[] value = infoValues.get(JobHistoryKeys.KEYS_TO_BYTES.get(key)); if (value != null) { String hv = Bytes.toString(value); // could throw an NPE or IllegalArgumentException return HadoopVersion.valueOf(hv); } else { // default is hadoop 1 return HadoopVersion.ONE; } }
[ "private", "HadoopVersion", "getHadoopVersionFromResult", "(", "final", "JobHistoryKeys", "key", ",", "final", "NavigableMap", "<", "byte", "[", "]", ",", "byte", "[", "]", ">", "infoValues", ")", "{", "byte", "[", "]", "value", "=", "infoValues", ".", "get"...
return an enum value from the NavigableMap for hadoop version @param key @param infoValues @return value as a enum or default of hadoop ONE
[ "return", "an", "enum", "value", "from", "the", "NavigableMap", "for", "hadoop", "version" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/JobDetails.java#L440-L451
2,702
twitter/hraven
hraven-etl/src/main/java/com/twitter/hraven/mapreduce/JobFileRawLoaderMapper.java
JobFileRawLoaderMapper.readJobFile
private byte[] readJobFile(FileStatus fileStatus) throws IOException { byte[] rawBytes = null; FSDataInputStream fsdis = null; try { long fileLength = fileStatus.getLen(); int fileLengthInt = (int) fileLength; rawBytes = new byte[fileLengthInt]; fsdis = hdfs.open(fileStatus.getPath()); IOUtils.readFully(fsdis, rawBytes, 0, fileLengthInt); } finally { IOUtils.closeStream(fsdis); } return rawBytes; }
java
private byte[] readJobFile(FileStatus fileStatus) throws IOException { byte[] rawBytes = null; FSDataInputStream fsdis = null; try { long fileLength = fileStatus.getLen(); int fileLengthInt = (int) fileLength; rawBytes = new byte[fileLengthInt]; fsdis = hdfs.open(fileStatus.getPath()); IOUtils.readFully(fsdis, rawBytes, 0, fileLengthInt); } finally { IOUtils.closeStream(fsdis); } return rawBytes; }
[ "private", "byte", "[", "]", "readJobFile", "(", "FileStatus", "fileStatus", ")", "throws", "IOException", "{", "byte", "[", "]", "rawBytes", "=", "null", ";", "FSDataInputStream", "fsdis", "=", "null", ";", "try", "{", "long", "fileLength", "=", "fileStatus...
Get the raw bytes and the last modification millis for this JobFile @return the contents of the job file. @throws IOException when bad things happen during reading
[ "Get", "the", "raw", "bytes", "and", "the", "last", "modification", "millis", "for", "this", "JobFile" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-etl/src/main/java/com/twitter/hraven/mapreduce/JobFileRawLoaderMapper.java#L220-L233
2,703
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/util/StringUtil.java
StringUtil.cleanseToken
public static String cleanseToken(String token) { if (token == null || token.length() == 0) { return token; }; String cleansed = token.replaceAll(SPACE, UNDERSCORE); cleansed = cleansed.replaceAll(Constants.SEP, UNDERSCORE); return cleansed; }
java
public static String cleanseToken(String token) { if (token == null || token.length() == 0) { return token; }; String cleansed = token.replaceAll(SPACE, UNDERSCORE); cleansed = cleansed.replaceAll(Constants.SEP, UNDERSCORE); return cleansed; }
[ "public", "static", "String", "cleanseToken", "(", "String", "token", ")", "{", "if", "(", "token", "==", "null", "||", "token", ".", "length", "(", ")", "==", "0", ")", "{", "return", "token", ";", "}", ";", "String", "cleansed", "=", "token", ".", ...
Takes a string token to be used as a key or qualifier and cleanses out reserved tokens. This operation is not symetrical. Logic is to replace all spaces and exclamation points with underscores. @param token token to cleanse. @return
[ "Takes", "a", "string", "token", "to", "be", "used", "as", "a", "key", "or", "qualifier", "and", "cleanses", "out", "reserved", "tokens", ".", "This", "operation", "is", "not", "symetrical", ".", "Logic", "is", "to", "replace", "all", "spaces", "and", "e...
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/util/StringUtil.java#L40-L47
2,704
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/util/StringUtil.java
StringUtil.buildParam
public static String buildParam(String paramName, List<String> paramArgs) throws IOException { StringBuilder sb = new StringBuilder(); for (String arg : paramArgs) { if (sb.length() > 0) { sb.append("&"); } sb.append(paramName).append("=").append(URLEncoder.encode(arg, "UTF-8")); } return sb.toString(); }
java
public static String buildParam(String paramName, List<String> paramArgs) throws IOException { StringBuilder sb = new StringBuilder(); for (String arg : paramArgs) { if (sb.length() > 0) { sb.append("&"); } sb.append(paramName).append("=").append(URLEncoder.encode(arg, "UTF-8")); } return sb.toString(); }
[ "public", "static", "String", "buildParam", "(", "String", "paramName", ",", "List", "<", "String", ">", "paramArgs", ")", "throws", "IOException", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "arg", ":", "p...
builds up a String with the parameters for the filtering of fields @param paramName @param paramArgs @return String @throws IOException
[ "builds", "up", "a", "String", "with", "the", "parameters", "for", "the", "filtering", "of", "fields" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/util/StringUtil.java#L56-L66
2,705
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/util/ByteArrayWrapper.java
ByteArrayWrapper.seek
public synchronized void seek(long position) throws IOException { if (position < 0 || position >= count) { throw new IOException("cannot seek position " + position + " as it is out of bounds"); } pos = (int) position; }
java
public synchronized void seek(long position) throws IOException { if (position < 0 || position >= count) { throw new IOException("cannot seek position " + position + " as it is out of bounds"); } pos = (int) position; }
[ "public", "synchronized", "void", "seek", "(", "long", "position", ")", "throws", "IOException", "{", "if", "(", "position", "<", "0", "||", "position", ">=", "count", ")", "{", "throw", "new", "IOException", "(", "\"cannot seek position \"", "+", "position", ...
Seeks and sets position to the specified value. @throws IOException if position is negative or exceeds the buffer size {@inheritDoc}
[ "Seeks", "and", "sets", "position", "to", "the", "specified", "value", "." ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/util/ByteArrayWrapper.java#L49-L54
2,706
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/JobDescFactoryBase.java
JobDescFactoryBase.create
protected JobDesc create(QualifiedJobId qualifiedJobId, Configuration jobConf, String appId, String version, Framework framework, long submitTimeMillis) { if (null == qualifiedJobId) { throw new IllegalArgumentException( "Cannot create a JobKey from a null qualifiedJobId."); } // get the user name from the job conf String userName = HadoopConfUtil.getUserNameInConf(jobConf); return new JobDesc(qualifiedJobId, userName, appId, version, submitTimeMillis, framework); }
java
protected JobDesc create(QualifiedJobId qualifiedJobId, Configuration jobConf, String appId, String version, Framework framework, long submitTimeMillis) { if (null == qualifiedJobId) { throw new IllegalArgumentException( "Cannot create a JobKey from a null qualifiedJobId."); } // get the user name from the job conf String userName = HadoopConfUtil.getUserNameInConf(jobConf); return new JobDesc(qualifiedJobId, userName, appId, version, submitTimeMillis, framework); }
[ "protected", "JobDesc", "create", "(", "QualifiedJobId", "qualifiedJobId", ",", "Configuration", "jobConf", ",", "String", "appId", ",", "String", "version", ",", "Framework", "framework", ",", "long", "submitTimeMillis", ")", "{", "if", "(", "null", "==", "qual...
Factory method to be used by subclasses. @param qualifiedJobId Identifying the cluster and the jobId. Cannot be null; @param jobConf the Job configuration of the job @param appId The thing that identifies an application, such as Pig script identifier, or Scalding identifier. @param version @param framework used to launch the map-reduce job. @param submitTimeMillis Identifying one single run of a version of an app. @return a JobKey with the given parameters and the userName added.
[ "Factory", "method", "to", "be", "used", "by", "subclasses", "." ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/JobDescFactoryBase.java#L63-L76
2,707
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/JobDescFactoryBase.java
JobDescFactoryBase.cleanAppId
protected String cleanAppId(String appId) { return (appId != null) ? StringUtil.cleanseToken(appId) : Constants.UNKNOWN; }
java
protected String cleanAppId(String appId) { return (appId != null) ? StringUtil.cleanseToken(appId) : Constants.UNKNOWN; }
[ "protected", "String", "cleanAppId", "(", "String", "appId", ")", "{", "return", "(", "appId", "!=", "null", ")", "?", "StringUtil", ".", "cleanseToken", "(", "appId", ")", ":", "Constants", ".", "UNKNOWN", ";", "}" ]
Given a potential value for appId, return a string that is safe to use in the jobKey @param appId possibly null value. @return non-null value stripped of separators that are used in the jobKey.
[ "Given", "a", "potential", "value", "for", "appId", "return", "a", "string", "that", "is", "safe", "to", "use", "in", "the", "jobKey" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/JobDescFactoryBase.java#L120-L122
2,708
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/HdfsStats.java
HdfsStats.populate
public void populate(Result result) { // process path-level stats and properties NavigableMap<byte[], byte[]> infoValues = result.getFamilyMap(HdfsConstants.DISK_INFO_FAM_BYTES); this.fileCount += ByteUtil.getValueAsLong(HdfsConstants.FILE_COUNT_COLUMN_BYTES, infoValues); this.dirCount += ByteUtil.getValueAsLong(HdfsConstants.DIR_COUNT_COLUMN_BYTES, infoValues); this.spaceConsumed += ByteUtil.getValueAsLong(HdfsConstants.SPACE_CONSUMED_COLUMN_BYTES, infoValues); this.accessCountTotal += ByteUtil.getValueAsLong(HdfsConstants.ACCESS_COUNT_TOTAL_COLUMN_BYTES, infoValues); this.owner = ByteUtil.getValueAsString(HdfsConstants.OWNER_COLUMN_BYTES, infoValues); this.quota += ByteUtil.getValueAsLong(HdfsConstants.QUOTA_COLUMN_BYTES, infoValues); this.spaceQuota += ByteUtil.getValueAsLong(HdfsConstants.SPACE_QUOTA_COLUMN_BYTES, infoValues); this.tmpFileCount += ByteUtil.getValueAsLong(HdfsConstants.TMP_FILE_COUNT_COLUMN_BYTES, infoValues); this.tmpSpaceConsumed += ByteUtil.getValueAsLong(HdfsConstants.TMP_SPACE_CONSUMED_COLUMN_BYTES, infoValues); this.trashFileCount += ByteUtil.getValueAsLong(HdfsConstants.TRASH_FILE_COUNT_COLUMN_BYTES, infoValues); this.trashSpaceConsumed += ByteUtil.getValueAsLong(HdfsConstants.TRASH_SPACE_CONSUMED_COLUMN_BYTES, infoValues); this.accessCost += ByteUtil.getValueAsDouble(HdfsConstants.ACCESS_COST_COLUMN_BYTES, infoValues); this.storageCost += ByteUtil.getValueAsDouble(HdfsConstants.STORAGE_COST_COLUMN_BYTES, infoValues); this.hdfsCost = calculateHDFSCost(); }
java
public void populate(Result result) { // process path-level stats and properties NavigableMap<byte[], byte[]> infoValues = result.getFamilyMap(HdfsConstants.DISK_INFO_FAM_BYTES); this.fileCount += ByteUtil.getValueAsLong(HdfsConstants.FILE_COUNT_COLUMN_BYTES, infoValues); this.dirCount += ByteUtil.getValueAsLong(HdfsConstants.DIR_COUNT_COLUMN_BYTES, infoValues); this.spaceConsumed += ByteUtil.getValueAsLong(HdfsConstants.SPACE_CONSUMED_COLUMN_BYTES, infoValues); this.accessCountTotal += ByteUtil.getValueAsLong(HdfsConstants.ACCESS_COUNT_TOTAL_COLUMN_BYTES, infoValues); this.owner = ByteUtil.getValueAsString(HdfsConstants.OWNER_COLUMN_BYTES, infoValues); this.quota += ByteUtil.getValueAsLong(HdfsConstants.QUOTA_COLUMN_BYTES, infoValues); this.spaceQuota += ByteUtil.getValueAsLong(HdfsConstants.SPACE_QUOTA_COLUMN_BYTES, infoValues); this.tmpFileCount += ByteUtil.getValueAsLong(HdfsConstants.TMP_FILE_COUNT_COLUMN_BYTES, infoValues); this.tmpSpaceConsumed += ByteUtil.getValueAsLong(HdfsConstants.TMP_SPACE_CONSUMED_COLUMN_BYTES, infoValues); this.trashFileCount += ByteUtil.getValueAsLong(HdfsConstants.TRASH_FILE_COUNT_COLUMN_BYTES, infoValues); this.trashSpaceConsumed += ByteUtil.getValueAsLong(HdfsConstants.TRASH_SPACE_CONSUMED_COLUMN_BYTES, infoValues); this.accessCost += ByteUtil.getValueAsDouble(HdfsConstants.ACCESS_COST_COLUMN_BYTES, infoValues); this.storageCost += ByteUtil.getValueAsDouble(HdfsConstants.STORAGE_COST_COLUMN_BYTES, infoValues); this.hdfsCost = calculateHDFSCost(); }
[ "public", "void", "populate", "(", "Result", "result", ")", "{", "// process path-level stats and properties", "NavigableMap", "<", "byte", "[", "]", ",", "byte", "[", "]", ">", "infoValues", "=", "result", ".", "getFamilyMap", "(", "HdfsConstants", ".", "DISK_I...
populates the hdfs stats by looking through the hbase result @param result
[ "populates", "the", "hdfs", "stats", "by", "looking", "through", "the", "hbase", "result" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/HdfsStats.java#L251-L273
2,709
twitter/hraven
hraven-etl/src/main/java/com/twitter/hraven/etl/FileLister.java
FileLister.traverseDirs
private static void traverseDirs(List<FileStatus> fileStatusesList, FileSystem hdfs, Path inputPath, JobFileModifiedRangePathFilter jobFileModifiedRangePathFilter) throws IOException { // get all the files and dirs in the current dir FileStatus allFiles[] = hdfs.listStatus(inputPath); for (FileStatus aFile: allFiles) { if (aFile.isDir()) { //recurse here traverseDirs(fileStatusesList, hdfs, aFile.getPath(), jobFileModifiedRangePathFilter); } else { // check if the pathFilter is accepted for this file if (jobFileModifiedRangePathFilter.accept(aFile.getPath())) { fileStatusesList.add(aFile); } } } }
java
private static void traverseDirs(List<FileStatus> fileStatusesList, FileSystem hdfs, Path inputPath, JobFileModifiedRangePathFilter jobFileModifiedRangePathFilter) throws IOException { // get all the files and dirs in the current dir FileStatus allFiles[] = hdfs.listStatus(inputPath); for (FileStatus aFile: allFiles) { if (aFile.isDir()) { //recurse here traverseDirs(fileStatusesList, hdfs, aFile.getPath(), jobFileModifiedRangePathFilter); } else { // check if the pathFilter is accepted for this file if (jobFileModifiedRangePathFilter.accept(aFile.getPath())) { fileStatusesList.add(aFile); } } } }
[ "private", "static", "void", "traverseDirs", "(", "List", "<", "FileStatus", ">", "fileStatusesList", ",", "FileSystem", "hdfs", ",", "Path", "inputPath", ",", "JobFileModifiedRangePathFilter", "jobFileModifiedRangePathFilter", ")", "throws", "IOException", "{", "// get...
Recursively traverses the dirs to get the list of files for a given path filtered as per the input path range filter
[ "Recursively", "traverses", "the", "dirs", "to", "get", "the", "list", "of", "files", "for", "a", "given", "path", "filtered", "as", "per", "the", "input", "path", "range", "filter" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-etl/src/main/java/com/twitter/hraven/etl/FileLister.java#L53-L71
2,710
twitter/hraven
hraven-etl/src/main/java/com/twitter/hraven/etl/FileLister.java
FileLister.listFiles
public static FileStatus[] listFiles (boolean recurse, FileSystem hdfs, Path inputPath, JobFileModifiedRangePathFilter jobFileModifiedRangePathFilter) throws IOException { if (recurse) { List<FileStatus> fileStatusesList = new ArrayList<FileStatus>(); traverseDirs(fileStatusesList, hdfs, inputPath, jobFileModifiedRangePathFilter); FileStatus[] fileStatuses = (FileStatus[]) fileStatusesList.toArray( new FileStatus[fileStatusesList.size()]); return fileStatuses; } else { return hdfs.listStatus(inputPath, jobFileModifiedRangePathFilter); } }
java
public static FileStatus[] listFiles (boolean recurse, FileSystem hdfs, Path inputPath, JobFileModifiedRangePathFilter jobFileModifiedRangePathFilter) throws IOException { if (recurse) { List<FileStatus> fileStatusesList = new ArrayList<FileStatus>(); traverseDirs(fileStatusesList, hdfs, inputPath, jobFileModifiedRangePathFilter); FileStatus[] fileStatuses = (FileStatus[]) fileStatusesList.toArray( new FileStatus[fileStatusesList.size()]); return fileStatuses; } else { return hdfs.listStatus(inputPath, jobFileModifiedRangePathFilter); } }
[ "public", "static", "FileStatus", "[", "]", "listFiles", "(", "boolean", "recurse", ",", "FileSystem", "hdfs", ",", "Path", "inputPath", ",", "JobFileModifiedRangePathFilter", "jobFileModifiedRangePathFilter", ")", "throws", "IOException", "{", "if", "(", "recurse", ...
Gets the list of files for a given path filtered as per the input path range filter Can go into directories recursively @param recurse - whether or not to traverse recursively @param hdfs - the file system @param inputPath - the path to traverse for getting the list of files @param jobFileModifiedRangePathFilter - the filter to include/exclude certain files @return array of file status. @throws IOException
[ "Gets", "the", "list", "of", "files", "for", "a", "given", "path", "filtered", "as", "per", "the", "input", "path", "range", "filter", "Can", "go", "into", "directories", "recursively" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-etl/src/main/java/com/twitter/hraven/etl/FileLister.java#L85-L98
2,711
twitter/hraven
hraven-etl/src/main/java/com/twitter/hraven/etl/FileLister.java
FileLister.getJobIdFromPath
static String getJobIdFromPath(Path aPath) { String fileName = aPath.getName(); JobFile jf = new JobFile(fileName); String jobId = jf.getJobid(); if(jobId == null) { throw new ProcessingException("job id is null for " + aPath.toUri()); } return jobId; }
java
static String getJobIdFromPath(Path aPath) { String fileName = aPath.getName(); JobFile jf = new JobFile(fileName); String jobId = jf.getJobid(); if(jobId == null) { throw new ProcessingException("job id is null for " + aPath.toUri()); } return jobId; }
[ "static", "String", "getJobIdFromPath", "(", "Path", "aPath", ")", "{", "String", "fileName", "=", "aPath", ".", "getName", "(", ")", ";", "JobFile", "jf", "=", "new", "JobFile", "(", "fileName", ")", ";", "String", "jobId", "=", "jf", ".", "getJobid", ...
extracts the job id from a Path @param input Path @return job id as string
[ "extracts", "the", "job", "id", "from", "a", "Path" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-etl/src/main/java/com/twitter/hraven/etl/FileLister.java#L194-L202
2,712
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/JobDescFactory.java
JobDescFactory.getFrameworkSpecificJobDescFactory
public static JobDescFactoryBase getFrameworkSpecificJobDescFactory(Configuration jobConf) { Framework framework = getFramework(jobConf); switch (framework) { case PIG: return PIG_JOB_DESC_FACTORY; case SCALDING: return SCALDING_JOB_DESC_FACTORY; default: return MR_JOB_DESC_FACTORY; } }
java
public static JobDescFactoryBase getFrameworkSpecificJobDescFactory(Configuration jobConf) { Framework framework = getFramework(jobConf); switch (framework) { case PIG: return PIG_JOB_DESC_FACTORY; case SCALDING: return SCALDING_JOB_DESC_FACTORY; default: return MR_JOB_DESC_FACTORY; } }
[ "public", "static", "JobDescFactoryBase", "getFrameworkSpecificJobDescFactory", "(", "Configuration", "jobConf", ")", "{", "Framework", "framework", "=", "getFramework", "(", "jobConf", ")", ";", "switch", "(", "framework", ")", "{", "case", "PIG", ":", "return", ...
get framework specific JobDescFactory based on configuration @param jobConf configuration of the job @return framework specific JobDescFactory
[ "get", "framework", "specific", "JobDescFactory", "based", "on", "configuration" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/JobDescFactory.java#L38-L49
2,713
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/JobDescFactory.java
JobDescFactory.getCluster
public static String getCluster(Configuration jobConf) { String jobtracker = jobConf.get(RESOURCE_MANAGER_KEY); if (jobtracker == null) { jobtracker = jobConf.get(JOBTRACKER_KEY); } String cluster = null; if (jobtracker != null) { // strip any port number int portIdx = jobtracker.indexOf(':'); if (portIdx > -1) { jobtracker = jobtracker.substring(0, portIdx); } // An ExceptionInInitializerError may be thrown to indicate that an exception occurred during // evaluation of Cluster class' static initialization cluster = Cluster.getIdentifier(jobtracker); } return cluster; }
java
public static String getCluster(Configuration jobConf) { String jobtracker = jobConf.get(RESOURCE_MANAGER_KEY); if (jobtracker == null) { jobtracker = jobConf.get(JOBTRACKER_KEY); } String cluster = null; if (jobtracker != null) { // strip any port number int portIdx = jobtracker.indexOf(':'); if (portIdx > -1) { jobtracker = jobtracker.substring(0, portIdx); } // An ExceptionInInitializerError may be thrown to indicate that an exception occurred during // evaluation of Cluster class' static initialization cluster = Cluster.getIdentifier(jobtracker); } return cluster; }
[ "public", "static", "String", "getCluster", "(", "Configuration", "jobConf", ")", "{", "String", "jobtracker", "=", "jobConf", ".", "get", "(", "RESOURCE_MANAGER_KEY", ")", ";", "if", "(", "jobtracker", "==", "null", ")", "{", "jobtracker", "=", "jobConf", "...
Returns the cluster that a give job was run on by mapping the jobtracker hostname to an identifier. @param jobConf @return
[ "Returns", "the", "cluster", "that", "a", "give", "job", "was", "run", "on", "by", "mapping", "the", "jobtracker", "hostname", "to", "an", "identifier", "." ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/JobDescFactory.java#L91-L108
2,714
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/ScaldingJobDescFactory.java
ScaldingJobDescFactory.stripAppId
String stripAppId(String origId) { if (origId == null || origId.isEmpty()) { return ""; } Matcher m = stripBracketsPattern.matcher(origId); String cleanedAppId = m.replaceAll(""); Matcher tailMatcher = stripSequencePattern.matcher(cleanedAppId); if (tailMatcher.matches()) { cleanedAppId = tailMatcher.group(1); } return cleanedAppId; }
java
String stripAppId(String origId) { if (origId == null || origId.isEmpty()) { return ""; } Matcher m = stripBracketsPattern.matcher(origId); String cleanedAppId = m.replaceAll(""); Matcher tailMatcher = stripSequencePattern.matcher(cleanedAppId); if (tailMatcher.matches()) { cleanedAppId = tailMatcher.group(1); } return cleanedAppId; }
[ "String", "stripAppId", "(", "String", "origId", ")", "{", "if", "(", "origId", "==", "null", "||", "origId", ".", "isEmpty", "(", ")", ")", "{", "return", "\"\"", ";", "}", "Matcher", "m", "=", "stripBracketsPattern", ".", "matcher", "(", "origId", ")...
Strips out metadata in brackets to get a clean app name. There are multiple job name formats used by various frameworks. This method attempts to normalize these job names into a somewhat human readable appId format.
[ "Strips", "out", "metadata", "in", "brackets", "to", "get", "a", "clean", "app", "name", ".", "There", "are", "multiple", "job", "name", "formats", "used", "by", "various", "frameworks", ".", "This", "method", "attempts", "to", "normalize", "these", "job", ...
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/ScaldingJobDescFactory.java#L69-L80
2,715
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/ScaldingJobDescFactory.java
ScaldingJobDescFactory.getFlowSubmitTimeMillis
static long getFlowSubmitTimeMillis(Configuration jobConf, long submitTimeMillis) { // TODO: Do some parsing / hacking on this. // Grab the year/month component and add part of the flowId turned into long // kind of a thing. long cascadingSubmitTimeMillis = jobConf.getLong( Constants.CASCADING_RUN_CONF_KEY, 0); if (cascadingSubmitTimeMillis == 0) { // Convert hex encoded flow ID (128-bit MD5 hash) into long as a substitute String flowId = jobConf.get(Constants.CASCADING_FLOW_ID_CONF_KEY); if (flowId != null && !flowId.isEmpty()) { if (flowId.length() > 16) { flowId = flowId.substring(0, 16); } try { long tmpFlow = Long.parseLong(flowId, 16); // need to prevent the computed run ID from showing up in the future, // so we don't "mask" jobs later submitted with the correct property // make this show up within the job submit month long monthStart = DateUtil.getMonthStart(submitTimeMillis); // this still allows these jobs to show up in the "future", but at least // constrains to current month cascadingSubmitTimeMillis = monthStart + (tmpFlow % DateUtil.MONTH_IN_MILLIS); } catch (NumberFormatException nfe) { // fall back to the job submit time cascadingSubmitTimeMillis = submitTimeMillis; } } else { // fall back to the job submit time cascadingSubmitTimeMillis = submitTimeMillis; } } return cascadingSubmitTimeMillis; }
java
static long getFlowSubmitTimeMillis(Configuration jobConf, long submitTimeMillis) { // TODO: Do some parsing / hacking on this. // Grab the year/month component and add part of the flowId turned into long // kind of a thing. long cascadingSubmitTimeMillis = jobConf.getLong( Constants.CASCADING_RUN_CONF_KEY, 0); if (cascadingSubmitTimeMillis == 0) { // Convert hex encoded flow ID (128-bit MD5 hash) into long as a substitute String flowId = jobConf.get(Constants.CASCADING_FLOW_ID_CONF_KEY); if (flowId != null && !flowId.isEmpty()) { if (flowId.length() > 16) { flowId = flowId.substring(0, 16); } try { long tmpFlow = Long.parseLong(flowId, 16); // need to prevent the computed run ID from showing up in the future, // so we don't "mask" jobs later submitted with the correct property // make this show up within the job submit month long monthStart = DateUtil.getMonthStart(submitTimeMillis); // this still allows these jobs to show up in the "future", but at least // constrains to current month cascadingSubmitTimeMillis = monthStart + (tmpFlow % DateUtil.MONTH_IN_MILLIS); } catch (NumberFormatException nfe) { // fall back to the job submit time cascadingSubmitTimeMillis = submitTimeMillis; } } else { // fall back to the job submit time cascadingSubmitTimeMillis = submitTimeMillis; } } return cascadingSubmitTimeMillis; }
[ "static", "long", "getFlowSubmitTimeMillis", "(", "Configuration", "jobConf", ",", "long", "submitTimeMillis", ")", "{", "// TODO: Do some parsing / hacking on this.", "// Grab the year/month component and add part of the flowId turned into long", "// kind of a thing.", "long", "cascad...
Returns the flow submit time for this job or a computed substitute that will at least be consistent for all jobs in a flow. The time is computed according to: <ol> <li>use "scalding.flow.submitted.timestamp" if present</li> <li>otherwise use "cascading.flow.id" as a substitute</li> </ol> @param jobConf The job configuration @param submitTimeMillis of a individual job in the flow @return when the entire flow started, or else at least something that binds all jobs in a flow together.
[ "Returns", "the", "flow", "submit", "time", "for", "this", "job", "or", "a", "computed", "substitute", "that", "will", "at", "least", "be", "consistent", "for", "all", "jobs", "in", "a", "flow", "." ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/ScaldingJobDescFactory.java#L99-L136
2,716
twitter/hraven
hraven-etl/src/main/java/com/twitter/hraven/etl/ProcessRecordService.java
ProcessRecordService.createFromResults
private List<ProcessRecord> createFromResults(ResultScanner scanner, int maxCount) { // Defensive coding if ((maxCount <= 0) || (scanner == null)) { return new ArrayList<ProcessRecord>(0); } List<ProcessRecord> records = new ArrayList<ProcessRecord>(); for (Result result : scanner) { byte[] row = result.getRow(); ProcessRecordKey key = keyConv.fromBytes(row); KeyValue keyValue = result.getColumnLatest(Constants.INFO_FAM_BYTES, Constants.MIN_MOD_TIME_MILLIS_COLUMN_BYTES); long minModificationTimeMillis = Bytes.toLong(keyValue.getValue()); keyValue = result.getColumnLatest(Constants.INFO_FAM_BYTES, Constants.PROCESSED_JOB_FILES_COLUMN_BYTES); int processedJobFiles = Bytes.toInt(keyValue.getValue()); keyValue = result.getColumnLatest(Constants.INFO_FAM_BYTES, Constants.PROCESS_FILE_COLUMN_BYTES); String processingDirectory = Bytes.toString(keyValue.getValue()); keyValue = result.getColumnLatest(Constants.INFO_FAM_BYTES, Constants.PROCESSING_STATE_COLUMN_BYTES); ProcessState processState = ProcessState.getProcessState(Bytes.toInt(keyValue.getValue())); keyValue = result.getColumnLatest(Constants.INFO_FAM_BYTES, Constants.MIN_JOB_ID_COLUMN_BYTES); String minJobId = null; if (keyValue != null) { minJobId = Bytes.toString(keyValue.getValue()); } keyValue = result.getColumnLatest(Constants.INFO_FAM_BYTES, Constants.MAX_JOB_ID_COLUMN_BYTES); String maxJobId = null; if (keyValue != null) { maxJobId = Bytes.toString(keyValue.getValue()); } ProcessRecord processRecord = new ProcessRecord(key.getCluster(), processState, minModificationTimeMillis, key.getTimestamp(), processedJobFiles, processingDirectory, minJobId, maxJobId); records.add(processRecord); // Check if we retrieved enough records. if (records.size() >= maxCount) { break; } } LOG.info("Returning " + records.size() + " process records"); return records; }
java
private List<ProcessRecord> createFromResults(ResultScanner scanner, int maxCount) { // Defensive coding if ((maxCount <= 0) || (scanner == null)) { return new ArrayList<ProcessRecord>(0); } List<ProcessRecord> records = new ArrayList<ProcessRecord>(); for (Result result : scanner) { byte[] row = result.getRow(); ProcessRecordKey key = keyConv.fromBytes(row); KeyValue keyValue = result.getColumnLatest(Constants.INFO_FAM_BYTES, Constants.MIN_MOD_TIME_MILLIS_COLUMN_BYTES); long minModificationTimeMillis = Bytes.toLong(keyValue.getValue()); keyValue = result.getColumnLatest(Constants.INFO_FAM_BYTES, Constants.PROCESSED_JOB_FILES_COLUMN_BYTES); int processedJobFiles = Bytes.toInt(keyValue.getValue()); keyValue = result.getColumnLatest(Constants.INFO_FAM_BYTES, Constants.PROCESS_FILE_COLUMN_BYTES); String processingDirectory = Bytes.toString(keyValue.getValue()); keyValue = result.getColumnLatest(Constants.INFO_FAM_BYTES, Constants.PROCESSING_STATE_COLUMN_BYTES); ProcessState processState = ProcessState.getProcessState(Bytes.toInt(keyValue.getValue())); keyValue = result.getColumnLatest(Constants.INFO_FAM_BYTES, Constants.MIN_JOB_ID_COLUMN_BYTES); String minJobId = null; if (keyValue != null) { minJobId = Bytes.toString(keyValue.getValue()); } keyValue = result.getColumnLatest(Constants.INFO_FAM_BYTES, Constants.MAX_JOB_ID_COLUMN_BYTES); String maxJobId = null; if (keyValue != null) { maxJobId = Bytes.toString(keyValue.getValue()); } ProcessRecord processRecord = new ProcessRecord(key.getCluster(), processState, minModificationTimeMillis, key.getTimestamp(), processedJobFiles, processingDirectory, minJobId, maxJobId); records.add(processRecord); // Check if we retrieved enough records. if (records.size() >= maxCount) { break; } } LOG.info("Returning " + records.size() + " process records"); return records; }
[ "private", "List", "<", "ProcessRecord", ">", "createFromResults", "(", "ResultScanner", "scanner", ",", "int", "maxCount", ")", "{", "// Defensive coding", "if", "(", "(", "maxCount", "<=", "0", ")", "||", "(", "scanner", "==", "null", ")", ")", "{", "ret...
Transform results pulled from a scanner and turn into a list of ProcessRecords. @param scanner used to pull the results from, in the order determined by the scanner. @param maxCount maximum number of results to return. @return
[ "Transform", "results", "pulled", "from", "a", "scanner", "and", "turn", "into", "a", "list", "of", "ProcessRecords", "." ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-etl/src/main/java/com/twitter/hraven/etl/ProcessRecordService.java#L294-L351
2,717
twitter/hraven
hraven-etl/src/main/java/com/twitter/hraven/etl/ProcessRecordService.java
ProcessRecordService.setProcessState
public ProcessRecord setProcessState(ProcessRecord processRecord, ProcessState newState) throws IOException { Put put = new Put(keyConv.toBytes(processRecord.getKey())); put.addColumn(Constants.INFO_FAM_BYTES, Constants.PROCESSING_STATE_COLUMN_BYTES, Bytes.toBytes(newState.getCode())); Table processRecordTable = null; try { processRecordTable = hbaseConnection .getTable(TableName.valueOf(Constants.JOB_FILE_PROCESS_TABLE)); processRecordTable.put(put); } finally { if (processRecordTable != null) { processRecordTable.close(); } } ProcessRecord updatedProcessRecord = new ProcessRecord( processRecord.getCluster(), newState, processRecord.getMinModificationTimeMillis(), processRecord.getMaxModificationTimeMillis(), processRecord.getProcessedJobFiles(), processRecord.getProcessFile(), processRecord.getMinJobId(), processRecord.getMaxJobId()); return updatedProcessRecord; }
java
public ProcessRecord setProcessState(ProcessRecord processRecord, ProcessState newState) throws IOException { Put put = new Put(keyConv.toBytes(processRecord.getKey())); put.addColumn(Constants.INFO_FAM_BYTES, Constants.PROCESSING_STATE_COLUMN_BYTES, Bytes.toBytes(newState.getCode())); Table processRecordTable = null; try { processRecordTable = hbaseConnection .getTable(TableName.valueOf(Constants.JOB_FILE_PROCESS_TABLE)); processRecordTable.put(put); } finally { if (processRecordTable != null) { processRecordTable.close(); } } ProcessRecord updatedProcessRecord = new ProcessRecord( processRecord.getCluster(), newState, processRecord.getMinModificationTimeMillis(), processRecord.getMaxModificationTimeMillis(), processRecord.getProcessedJobFiles(), processRecord.getProcessFile(), processRecord.getMinJobId(), processRecord.getMaxJobId()); return updatedProcessRecord; }
[ "public", "ProcessRecord", "setProcessState", "(", "ProcessRecord", "processRecord", ",", "ProcessState", "newState", ")", "throws", "IOException", "{", "Put", "put", "=", "new", "Put", "(", "keyConv", ".", "toBytes", "(", "processRecord", ".", "getKey", "(", ")...
Set the process state for a given processRecord. @param processRecord for which to update the state @param newState the new state to set in HBase. @return a new ProcessRecord with the new state. @throws IOException
[ "Set", "the", "process", "state", "for", "a", "given", "processRecord", "." ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-etl/src/main/java/com/twitter/hraven/etl/ProcessRecordService.java#L361-L385
2,718
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/Flow.java
Flow.compareTo
@Override public int compareTo(Flow otherFlow) { if (otherFlow == null) { return -1; } return new CompareToBuilder().append(this.key, otherFlow.getFlowKey()) .toComparison(); }
java
@Override public int compareTo(Flow otherFlow) { if (otherFlow == null) { return -1; } return new CompareToBuilder().append(this.key, otherFlow.getFlowKey()) .toComparison(); }
[ "@", "Override", "public", "int", "compareTo", "(", "Flow", "otherFlow", ")", "{", "if", "(", "otherFlow", "==", "null", ")", "{", "return", "-", "1", ";", "}", "return", "new", "CompareToBuilder", "(", ")", ".", "append", "(", "this", ".", "key", ",...
Compares two Flow objects on the basis of their FlowKeys @param otherFlow @return 0 if the FlowKeys are equal, 1 if this FlowKey greater than other FlowKey, -1 if this FlowKey is less than other FlowKey
[ "Compares", "two", "Flow", "objects", "on", "the", "basis", "of", "their", "FlowKeys" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/Flow.java#L204-L211
2,719
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java
AppSummaryService.getNewApps
public List<AppSummary> getNewApps(JobHistoryService jhs, String cluster, String user, long startTime, long endTime, int limit) throws IOException { byte[] startRow = null; if (StringUtils.isNotBlank(user)) { startRow = ByteUtil.join(Constants.SEP_BYTES, Bytes.toBytes(cluster), Bytes.toBytes(user)); } else { startRow = ByteUtil.join(Constants.SEP_BYTES, Bytes.toBytes(cluster)); } LOG.info( "Reading app version rows start at " + Bytes.toStringBinary(startRow)); Scan scan = new Scan(); // start scanning app version table at cluster!user! scan.setStartRow(startRow); // require that all results match this flow prefix FilterList filters = new FilterList(FilterList.Operator.MUST_PASS_ALL); filters.addFilter(new WhileMatchFilter(new PrefixFilter(startRow))); scan.setFilter(filters); List<AppKey> newAppsKeys = new ArrayList<AppKey>(); try { newAppsKeys = createNewAppKeysFromResults(scan, startTime, endTime, limit); } catch (IOException e) { LOG.error( "Caught exception while trying to scan, returning empty list of flows: " + e.toString()); } List<AppSummary> newApps = new ArrayList<AppSummary>(); for (AppKey ak : newAppsKeys) { AppSummary anApp = new AppSummary(ak); List<Flow> flows = jhs.getFlowSeries(ak.getCluster(), ak.getUserName(), ak.getAppId(), null, Boolean.FALSE, startTime, endTime, Integer.MAX_VALUE); for (Flow f : flows) { anApp.addFlow(f); } newApps.add(anApp); } return newApps; }
java
public List<AppSummary> getNewApps(JobHistoryService jhs, String cluster, String user, long startTime, long endTime, int limit) throws IOException { byte[] startRow = null; if (StringUtils.isNotBlank(user)) { startRow = ByteUtil.join(Constants.SEP_BYTES, Bytes.toBytes(cluster), Bytes.toBytes(user)); } else { startRow = ByteUtil.join(Constants.SEP_BYTES, Bytes.toBytes(cluster)); } LOG.info( "Reading app version rows start at " + Bytes.toStringBinary(startRow)); Scan scan = new Scan(); // start scanning app version table at cluster!user! scan.setStartRow(startRow); // require that all results match this flow prefix FilterList filters = new FilterList(FilterList.Operator.MUST_PASS_ALL); filters.addFilter(new WhileMatchFilter(new PrefixFilter(startRow))); scan.setFilter(filters); List<AppKey> newAppsKeys = new ArrayList<AppKey>(); try { newAppsKeys = createNewAppKeysFromResults(scan, startTime, endTime, limit); } catch (IOException e) { LOG.error( "Caught exception while trying to scan, returning empty list of flows: " + e.toString()); } List<AppSummary> newApps = new ArrayList<AppSummary>(); for (AppKey ak : newAppsKeys) { AppSummary anApp = new AppSummary(ak); List<Flow> flows = jhs.getFlowSeries(ak.getCluster(), ak.getUserName(), ak.getAppId(), null, Boolean.FALSE, startTime, endTime, Integer.MAX_VALUE); for (Flow f : flows) { anApp.addFlow(f); } newApps.add(anApp); } return newApps; }
[ "public", "List", "<", "AppSummary", ">", "getNewApps", "(", "JobHistoryService", "jhs", ",", "String", "cluster", ",", "String", "user", ",", "long", "startTime", ",", "long", "endTime", ",", "int", "limit", ")", "throws", "IOException", "{", "byte", "[", ...
scans the app version table to look for jobs that showed up in the given time range creates the flow key that maps to these apps @param cluster @param user @param startTime @param endTime @param limit @return list of flow keys @throws IOException @throws ProcessingException
[ "scans", "the", "app", "version", "table", "to", "look", "for", "jobs", "that", "showed", "up", "in", "the", "given", "time", "range", "creates", "the", "flow", "key", "that", "maps", "to", "these", "apps" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java#L96-L139
2,720
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java
AppSummaryService.createNewAppKeysFromResults
public List<AppKey> createNewAppKeysFromResults(Scan scan, long startTime, long endTime, int maxCount) throws IOException { ResultScanner scanner = null; List<AppKey> newAppsKeys = new ArrayList<AppKey>(); Table versionsTable = null; try { Stopwatch timer = new Stopwatch().start(); int rowCount = 0; long colCount = 0; long resultSize = 0; versionsTable = hbaseConnection .getTable(TableName.valueOf(Constants.HISTORY_APP_VERSION_TABLE)); scanner = versionsTable.getScanner(scan); for (Result result : scanner) { if (result != null && !result.isEmpty()) { rowCount++; colCount += result.size(); // TODO dogpiledays resultSize += result.getWritableSize(); AppKey appKey = getNewAppKeyFromResult(result, startTime, endTime); if (appKey != null) { newAppsKeys.add(appKey); } if (newAppsKeys.size() >= maxCount) { break; } } } timer.stop(); LOG.info(" Fetched from hbase " + rowCount + " rows, " + colCount + " columns, " + resultSize + " bytes ( " + resultSize / (1024 * 1024) + ") MB, in total time of " + timer); } finally { if (scanner != null) { scanner.close(); } if (versionsTable != null) { versionsTable.close(); } } return newAppsKeys; }
java
public List<AppKey> createNewAppKeysFromResults(Scan scan, long startTime, long endTime, int maxCount) throws IOException { ResultScanner scanner = null; List<AppKey> newAppsKeys = new ArrayList<AppKey>(); Table versionsTable = null; try { Stopwatch timer = new Stopwatch().start(); int rowCount = 0; long colCount = 0; long resultSize = 0; versionsTable = hbaseConnection .getTable(TableName.valueOf(Constants.HISTORY_APP_VERSION_TABLE)); scanner = versionsTable.getScanner(scan); for (Result result : scanner) { if (result != null && !result.isEmpty()) { rowCount++; colCount += result.size(); // TODO dogpiledays resultSize += result.getWritableSize(); AppKey appKey = getNewAppKeyFromResult(result, startTime, endTime); if (appKey != null) { newAppsKeys.add(appKey); } if (newAppsKeys.size() >= maxCount) { break; } } } timer.stop(); LOG.info(" Fetched from hbase " + rowCount + " rows, " + colCount + " columns, " + resultSize + " bytes ( " + resultSize / (1024 * 1024) + ") MB, in total time of " + timer); } finally { if (scanner != null) { scanner.close(); } if (versionsTable != null) { versionsTable.close(); } } return newAppsKeys; }
[ "public", "List", "<", "AppKey", ">", "createNewAppKeysFromResults", "(", "Scan", "scan", ",", "long", "startTime", ",", "long", "endTime", ",", "int", "maxCount", ")", "throws", "IOException", "{", "ResultScanner", "scanner", "=", "null", ";", "List", "<", ...
creates a list of appkeys from the hbase scan @param scan @param startTime @param endTime @param maxCount @return list of flow keys @throws IOException
[ "creates", "a", "list", "of", "appkeys", "from", "the", "hbase", "scan" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java#L150-L191
2,721
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java
AppSummaryService.getNewAppKeyFromResult
private AppKey getNewAppKeyFromResult(Result result, long startTime, long endTime) throws IOException { byte[] rowKey = result.getRow(); byte[][] keyComponents = ByteUtil.split(rowKey, Constants.SEP_BYTES); String cluster = Bytes.toString(keyComponents[0]); String user = Bytes.toString(keyComponents[1]); String appId = Bytes.toString(keyComponents[2]); NavigableMap<byte[], byte[]> valueMap = result.getFamilyMap(Constants.INFO_FAM_BYTES); long runId = Long.MAX_VALUE; for (Map.Entry<byte[], byte[]> entry : valueMap.entrySet()) { long tsl = Bytes.toLong(entry.getValue()); // get the earliest runid, which indicates the first time this app ran if (tsl < runId) { runId = tsl; } } if ((runId >= startTime) && (runId <= endTime)) { AppKey ak = new AppKey(cluster, user, appId); return ak; } return null; }
java
private AppKey getNewAppKeyFromResult(Result result, long startTime, long endTime) throws IOException { byte[] rowKey = result.getRow(); byte[][] keyComponents = ByteUtil.split(rowKey, Constants.SEP_BYTES); String cluster = Bytes.toString(keyComponents[0]); String user = Bytes.toString(keyComponents[1]); String appId = Bytes.toString(keyComponents[2]); NavigableMap<byte[], byte[]> valueMap = result.getFamilyMap(Constants.INFO_FAM_BYTES); long runId = Long.MAX_VALUE; for (Map.Entry<byte[], byte[]> entry : valueMap.entrySet()) { long tsl = Bytes.toLong(entry.getValue()); // get the earliest runid, which indicates the first time this app ran if (tsl < runId) { runId = tsl; } } if ((runId >= startTime) && (runId <= endTime)) { AppKey ak = new AppKey(cluster, user, appId); return ak; } return null; }
[ "private", "AppKey", "getNewAppKeyFromResult", "(", "Result", "result", ",", "long", "startTime", ",", "long", "endTime", ")", "throws", "IOException", "{", "byte", "[", "]", "rowKey", "=", "result", ".", "getRow", "(", ")", ";", "byte", "[", "]", "[", "...
constructs App key from the result set based on cluster, user, appId picks those results that satisfy the time range criteria @param result @param startTime @param endTime @return flow key @throws IOException
[ "constructs", "App", "key", "from", "the", "result", "set", "based", "on", "cluster", "user", "appId", "picks", "those", "results", "that", "satisfy", "the", "time", "range", "criteria" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java#L202-L226
2,722
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java
AppSummaryService.aggregateJobDetails
public boolean aggregateJobDetails(JobDetails jobDetails, AggregationConstants.AGGREGATION_TYPE aggType) { Table aggTable = null; try { switch (aggType) { case DAILY: aggTable = hbaseConnection .getTable(TableName.valueOf(AggregationConstants.AGG_DAILY_TABLE)); break; case WEEKLY: aggTable = hbaseConnection .getTable(TableName.valueOf(AggregationConstants.AGG_WEEKLY_TABLE)); ; break; default: LOG.error("Unknown aggregation type : " + aggType); return false; } // create row key JobKey jobKey = jobDetails.getJobKey(); AppAggregationKey appAggKey = new AppAggregationKey(jobKey.getCluster(), jobKey.getUserName(), jobKey.getAppId(), getTimestamp(jobKey.getRunId(), aggType)); LOG.info("Aggregating " + aggType + " stats for " + jobKey.toString()); Increment aggIncrement = incrementAppSummary(appAggKey, jobDetails); aggTable.increment(aggIncrement); boolean status = updateMoreAggInfo(aggTable, appAggKey, jobDetails); return status; } /* * try to catch all exceptions so that processing is unaffected by * aggregation errors this can be turned off in the future when we determine * aggregation to be a mandatory part of Processing Step */ catch (Exception e) { LOG.error("Caught exception while attempting to aggregate for " + aggType + " table ", e); return false; } finally { if (aggTable != null) { try { aggTable.close(); } catch (IOException e) { LOG.error("Caught exception while attempting to close table ", e); } } } }
java
public boolean aggregateJobDetails(JobDetails jobDetails, AggregationConstants.AGGREGATION_TYPE aggType) { Table aggTable = null; try { switch (aggType) { case DAILY: aggTable = hbaseConnection .getTable(TableName.valueOf(AggregationConstants.AGG_DAILY_TABLE)); break; case WEEKLY: aggTable = hbaseConnection .getTable(TableName.valueOf(AggregationConstants.AGG_WEEKLY_TABLE)); ; break; default: LOG.error("Unknown aggregation type : " + aggType); return false; } // create row key JobKey jobKey = jobDetails.getJobKey(); AppAggregationKey appAggKey = new AppAggregationKey(jobKey.getCluster(), jobKey.getUserName(), jobKey.getAppId(), getTimestamp(jobKey.getRunId(), aggType)); LOG.info("Aggregating " + aggType + " stats for " + jobKey.toString()); Increment aggIncrement = incrementAppSummary(appAggKey, jobDetails); aggTable.increment(aggIncrement); boolean status = updateMoreAggInfo(aggTable, appAggKey, jobDetails); return status; } /* * try to catch all exceptions so that processing is unaffected by * aggregation errors this can be turned off in the future when we determine * aggregation to be a mandatory part of Processing Step */ catch (Exception e) { LOG.error("Caught exception while attempting to aggregate for " + aggType + " table ", e); return false; } finally { if (aggTable != null) { try { aggTable.close(); } catch (IOException e) { LOG.error("Caught exception while attempting to close table ", e); } } } }
[ "public", "boolean", "aggregateJobDetails", "(", "JobDetails", "jobDetails", ",", "AggregationConstants", ".", "AGGREGATION_TYPE", "aggType", ")", "{", "Table", "aggTable", "=", "null", ";", "try", "{", "switch", "(", "aggType", ")", "{", "case", "DAILY", ":", ...
creates a list of puts that aggregate the job details and stores in daily or weekly aggregation table @param {@link JobDetails}
[ "creates", "a", "list", "of", "puts", "that", "aggregate", "the", "job", "details", "and", "stores", "in", "daily", "or", "weekly", "aggregation", "table" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java#L233-L281
2,723
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java
AppSummaryService.getNumberRunsScratch
long getNumberRunsScratch(Map<byte[], byte[]> rawFamily) { long numberRuns = 0L; if (rawFamily != null) { numberRuns = rawFamily.size(); } if (numberRuns == 0L) { LOG.error("Number of runs in scratch column family can't be 0," + " if processing within TTL"); throw new ProcessingException("Number of runs is 0"); } return numberRuns; }
java
long getNumberRunsScratch(Map<byte[], byte[]> rawFamily) { long numberRuns = 0L; if (rawFamily != null) { numberRuns = rawFamily.size(); } if (numberRuns == 0L) { LOG.error("Number of runs in scratch column family can't be 0," + " if processing within TTL"); throw new ProcessingException("Number of runs is 0"); } return numberRuns; }
[ "long", "getNumberRunsScratch", "(", "Map", "<", "byte", "[", "]", ",", "byte", "[", "]", ">", "rawFamily", ")", "{", "long", "numberRuns", "=", "0L", ";", "if", "(", "rawFamily", "!=", "null", ")", "{", "numberRuns", "=", "rawFamily", ".", "size", "...
interprets the number of runs based on number of columns in raw col family @param {@link Result} @return number of runs
[ "interprets", "the", "number", "of", "runs", "based", "on", "number", "of", "columns", "in", "raw", "col", "family" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java#L288-L299
2,724
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java
AppSummaryService.incrementAppSummary
private Increment incrementAppSummary(AppAggregationKey appAggKey, JobDetails jobDetails) { Increment aggIncrement = new Increment(aggConv.toBytes(appAggKey)); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.TOTAL_MAPS_BYTES, jobDetails.getTotalMaps()); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.TOTAL_REDUCES_BYTES, jobDetails.getTotalReduces()); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.MEGABYTEMILLIS_BYTES, jobDetails.getMegabyteMillis()); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.SLOTS_MILLIS_MAPS_BYTES, jobDetails.getMapSlotMillis()); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.SLOTS_MILLIS_REDUCES_BYTES, jobDetails.getReduceSlotMillis()); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.SLOTS_MILLIS_REDUCES_BYTES, jobDetails.getReduceSlotMillis()); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.TOTAL_JOBS_BYTES, 1L); byte[] numberRowsCol = Bytes.toBytes(jobDetails.getJobKey().getRunId()); aggIncrement.addColumn(AggregationConstants.SCRATCH_FAM_BYTES, numberRowsCol, 1L); return aggIncrement; }
java
private Increment incrementAppSummary(AppAggregationKey appAggKey, JobDetails jobDetails) { Increment aggIncrement = new Increment(aggConv.toBytes(appAggKey)); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.TOTAL_MAPS_BYTES, jobDetails.getTotalMaps()); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.TOTAL_REDUCES_BYTES, jobDetails.getTotalReduces()); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.MEGABYTEMILLIS_BYTES, jobDetails.getMegabyteMillis()); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.SLOTS_MILLIS_MAPS_BYTES, jobDetails.getMapSlotMillis()); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.SLOTS_MILLIS_REDUCES_BYTES, jobDetails.getReduceSlotMillis()); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.SLOTS_MILLIS_REDUCES_BYTES, jobDetails.getReduceSlotMillis()); aggIncrement.addColumn(Constants.INFO_FAM_BYTES, AggregationConstants.TOTAL_JOBS_BYTES, 1L); byte[] numberRowsCol = Bytes.toBytes(jobDetails.getJobKey().getRunId()); aggIncrement.addColumn(AggregationConstants.SCRATCH_FAM_BYTES, numberRowsCol, 1L); return aggIncrement; }
[ "private", "Increment", "incrementAppSummary", "(", "AppAggregationKey", "appAggKey", ",", "JobDetails", "jobDetails", ")", "{", "Increment", "aggIncrement", "=", "new", "Increment", "(", "aggConv", ".", "toBytes", "(", "appAggKey", ")", ")", ";", "aggIncrement", ...
creates an Increment to aggregate job details @param {@link AppAggregationKey} @param {@link JobDetails} @return {@link Increment}
[ "creates", "an", "Increment", "to", "aggregate", "job", "details" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java#L332-L359
2,725
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java
AppSummaryService.updateQueue
boolean updateQueue(AppAggregationKey appAggKey, Table aggTable, JobDetails jobDetails) throws IOException { byte[] rowKey = aggConv.toBytes(appAggKey); Get g = new Get(rowKey); g.addColumn(AggregationConstants.INFO_FAM_BYTES, AggregationConstants.HRAVEN_QUEUE_BYTES); Result r = aggTable.get(g); Cell existingQueuesCell = r.getColumnLatestCell(AggregationConstants.INFO_FAM_BYTES, AggregationConstants.HRAVEN_QUEUE_BYTES); String existingQueues = null; byte[] existingQueuesBytes = null; if (existingQueuesCell != null) { existingQueues = Bytes.toString(CellUtil.cloneValue(existingQueuesCell)); existingQueuesBytes = Bytes.toBytes(existingQueues); } // get details for the queue list to be inserted String insertQueues = createQueueListValue(jobDetails, existingQueues); // if existing and to be inserted queue lists are different, then // execute check and put if (insertQueues.equalsIgnoreCase(existingQueues)) { if (LOG.isTraceEnabled()) { LOG.trace("Queue already present in aggregation for this app " + existingQueues + " " + insertQueues); } return true; } else { return executeCheckAndPut(aggTable, rowKey, existingQueuesBytes, Bytes.toBytes(insertQueues), AggregationConstants.INFO_FAM_BYTES, AggregationConstants.HRAVEN_QUEUE_BYTES); } }
java
boolean updateQueue(AppAggregationKey appAggKey, Table aggTable, JobDetails jobDetails) throws IOException { byte[] rowKey = aggConv.toBytes(appAggKey); Get g = new Get(rowKey); g.addColumn(AggregationConstants.INFO_FAM_BYTES, AggregationConstants.HRAVEN_QUEUE_BYTES); Result r = aggTable.get(g); Cell existingQueuesCell = r.getColumnLatestCell(AggregationConstants.INFO_FAM_BYTES, AggregationConstants.HRAVEN_QUEUE_BYTES); String existingQueues = null; byte[] existingQueuesBytes = null; if (existingQueuesCell != null) { existingQueues = Bytes.toString(CellUtil.cloneValue(existingQueuesCell)); existingQueuesBytes = Bytes.toBytes(existingQueues); } // get details for the queue list to be inserted String insertQueues = createQueueListValue(jobDetails, existingQueues); // if existing and to be inserted queue lists are different, then // execute check and put if (insertQueues.equalsIgnoreCase(existingQueues)) { if (LOG.isTraceEnabled()) { LOG.trace("Queue already present in aggregation for this app " + existingQueues + " " + insertQueues); } return true; } else { return executeCheckAndPut(aggTable, rowKey, existingQueuesBytes, Bytes.toBytes(insertQueues), AggregationConstants.INFO_FAM_BYTES, AggregationConstants.HRAVEN_QUEUE_BYTES); } }
[ "boolean", "updateQueue", "(", "AppAggregationKey", "appAggKey", ",", "Table", "aggTable", ",", "JobDetails", "jobDetails", ")", "throws", "IOException", "{", "byte", "[", "]", "rowKey", "=", "aggConv", ".", "toBytes", "(", "appAggKey", ")", ";", "Get", "g", ...
updates the queue list for this app aggregation @throws IOException
[ "updates", "the", "queue", "list", "for", "this", "app", "aggregation" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java#L464-L499
2,726
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java
AppSummaryService.executeCheckAndPut
boolean executeCheckAndPut(Table aggTable, byte[] rowKey, byte[] existingValueBytes, byte[] newValueBytes, byte[] famBytes, byte[] colBytes) throws IOException { Put put = new Put(rowKey); put.addColumn(famBytes, colBytes, newValueBytes); boolean statusCheckAndPut = aggTable.checkAndPut(rowKey, famBytes, colBytes, existingValueBytes, put); return statusCheckAndPut; }
java
boolean executeCheckAndPut(Table aggTable, byte[] rowKey, byte[] existingValueBytes, byte[] newValueBytes, byte[] famBytes, byte[] colBytes) throws IOException { Put put = new Put(rowKey); put.addColumn(famBytes, colBytes, newValueBytes); boolean statusCheckAndPut = aggTable.checkAndPut(rowKey, famBytes, colBytes, existingValueBytes, put); return statusCheckAndPut; }
[ "boolean", "executeCheckAndPut", "(", "Table", "aggTable", ",", "byte", "[", "]", "rowKey", ",", "byte", "[", "]", "existingValueBytes", ",", "byte", "[", "]", "newValueBytes", ",", "byte", "[", "]", "famBytes", ",", "byte", "[", "]", "colBytes", ")", "t...
method to execute an hbase checkAndPut operation @return whether or not the check and put was successful after retries @throws IOException
[ "method", "to", "execute", "an", "hbase", "checkAndPut", "operation" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java#L506-L517
2,727
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java
AppSummaryService.incrNumberRuns
boolean incrNumberRuns(List<Cell> column, Table aggTable, AppAggregationKey appAggKey) throws IOException { /* * check if this is the very first insert for numbers for this app in that * case, there will no existing column/value for number of run in info col * family null signifies non existence of the column for {@link * Table.checkAndPut} */ long expectedValueBeforePut = 0L; if (column.size() > 0) { try { expectedValueBeforePut = Bytes.toLong(column.get(0).getValue()); } catch (NumberFormatException e) { LOG.error( "Could not read existing value for number of runs during aggregation" + appAggKey.toString()); return false; } } byte[] rowKey = aggConv.toBytes(appAggKey); long insertValue = 1L; byte[] expectedValueBeforePutBytes = null; if (expectedValueBeforePut != 0L) { insertValue = 1 + expectedValueBeforePut; expectedValueBeforePutBytes = Bytes.toBytes(expectedValueBeforePut); } byte[] insertValueBytes = Bytes.toBytes(insertValue); if (LOG.isTraceEnabled()) { LOG.trace(" before statusCheckAndPut " + insertValue + " " + expectedValueBeforePut); } return executeCheckAndPut(aggTable, rowKey, expectedValueBeforePutBytes, insertValueBytes, AggregationConstants.INFO_FAM_BYTES, AggregationConstants.NUMBER_RUNS_BYTES); }
java
boolean incrNumberRuns(List<Cell> column, Table aggTable, AppAggregationKey appAggKey) throws IOException { /* * check if this is the very first insert for numbers for this app in that * case, there will no existing column/value for number of run in info col * family null signifies non existence of the column for {@link * Table.checkAndPut} */ long expectedValueBeforePut = 0L; if (column.size() > 0) { try { expectedValueBeforePut = Bytes.toLong(column.get(0).getValue()); } catch (NumberFormatException e) { LOG.error( "Could not read existing value for number of runs during aggregation" + appAggKey.toString()); return false; } } byte[] rowKey = aggConv.toBytes(appAggKey); long insertValue = 1L; byte[] expectedValueBeforePutBytes = null; if (expectedValueBeforePut != 0L) { insertValue = 1 + expectedValueBeforePut; expectedValueBeforePutBytes = Bytes.toBytes(expectedValueBeforePut); } byte[] insertValueBytes = Bytes.toBytes(insertValue); if (LOG.isTraceEnabled()) { LOG.trace(" before statusCheckAndPut " + insertValue + " " + expectedValueBeforePut); } return executeCheckAndPut(aggTable, rowKey, expectedValueBeforePutBytes, insertValueBytes, AggregationConstants.INFO_FAM_BYTES, AggregationConstants.NUMBER_RUNS_BYTES); }
[ "boolean", "incrNumberRuns", "(", "List", "<", "Cell", ">", "column", ",", "Table", "aggTable", ",", "AppAggregationKey", "appAggKey", ")", "throws", "IOException", "{", "/*\n * check if this is the very first insert for numbers for this app in that\n * case, there will n...
checks and increments the number of runs for this app aggregation. no need to retry, since another map task may have updated it in the mean time @throws IOException
[ "checks", "and", "increments", "the", "number", "of", "runs", "for", "this", "app", "aggregation", ".", "no", "need", "to", "retry", "since", "another", "map", "task", "may", "have", "updated", "it", "in", "the", "mean", "time" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java#L567-L605
2,728
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/Cluster.java
Cluster.loadHadoopClustersProps
static void loadHadoopClustersProps(String filename) { // read the property file // populate the map Properties prop = new Properties(); if (StringUtils.isBlank(filename)) { filename = Constants.HRAVEN_CLUSTER_PROPERTIES_FILENAME; } try { //TODO : property file to be moved out from resources into config dir InputStream inp = Cluster.class.getResourceAsStream("/" + filename); if (inp == null) { LOG.error(filename + " for mapping clusters to cluster identifiers in hRaven does not exist"); return; } prop.load(inp); Set<String> hostnames = prop.stringPropertyNames(); for (String h : hostnames) { CLUSTERS_BY_HOST.put(h, prop.getProperty(h)); } } catch (IOException e) { // An ExceptionInInitializerError will be thrown to indicate that an // exception occurred during evaluation of a static initializer or the // initializer for a static variable. throw new ExceptionInInitializerError(" Could not load properties file " + filename + " for mapping clusters to cluster identifiers in hRaven"); } }
java
static void loadHadoopClustersProps(String filename) { // read the property file // populate the map Properties prop = new Properties(); if (StringUtils.isBlank(filename)) { filename = Constants.HRAVEN_CLUSTER_PROPERTIES_FILENAME; } try { //TODO : property file to be moved out from resources into config dir InputStream inp = Cluster.class.getResourceAsStream("/" + filename); if (inp == null) { LOG.error(filename + " for mapping clusters to cluster identifiers in hRaven does not exist"); return; } prop.load(inp); Set<String> hostnames = prop.stringPropertyNames(); for (String h : hostnames) { CLUSTERS_BY_HOST.put(h, prop.getProperty(h)); } } catch (IOException e) { // An ExceptionInInitializerError will be thrown to indicate that an // exception occurred during evaluation of a static initializer or the // initializer for a static variable. throw new ExceptionInInitializerError(" Could not load properties file " + filename + " for mapping clusters to cluster identifiers in hRaven"); } }
[ "static", "void", "loadHadoopClustersProps", "(", "String", "filename", ")", "{", "// read the property file", "// populate the map", "Properties", "prop", "=", "new", "Properties", "(", ")", ";", "if", "(", "StringUtils", ".", "isBlank", "(", "filename", ")", ")"...
testing with different properties file names
[ "testing", "with", "different", "properties", "file", "names" ]
e35996b6e2f016bcd18db0bad320be7c93d95208
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/Cluster.java#L43-L70
2,729
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/model/loader/AnimationImporter.java
AnimationImporter.load
public void load(ResourceLocation resourceLocation) { IResource res = Silenced.get(() -> Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation)); if (res == null) return; GsonBuilder gsonBuilder = new GsonBuilder(); //we don't want GSON to create a new AnimationImporte but use this current one gsonBuilder.registerTypeAdapter(AnimationImporter.class, (InstanceCreator<AnimationImporter>) type -> this); //no builtin way to dezerialize multimaps gsonBuilder.registerTypeAdapter(Multimap.class, (JsonDeserializer<Multimap<String, Anim>>) this::deserializeAnim); Gson gson = gsonBuilder.create(); try (Reader reader = new InputStreamReader(res.getInputStream(), "UTF-8")) { JsonReader jsonReader = new JsonReader(reader); jsonReader.setLenient(true); gson.fromJson(jsonReader, AnimationImporter.class); } catch (Exception e) { MalisisCore.log.error("Failed to read {}", resourceLocation, e); } }
java
public void load(ResourceLocation resourceLocation) { IResource res = Silenced.get(() -> Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation)); if (res == null) return; GsonBuilder gsonBuilder = new GsonBuilder(); //we don't want GSON to create a new AnimationImporte but use this current one gsonBuilder.registerTypeAdapter(AnimationImporter.class, (InstanceCreator<AnimationImporter>) type -> this); //no builtin way to dezerialize multimaps gsonBuilder.registerTypeAdapter(Multimap.class, (JsonDeserializer<Multimap<String, Anim>>) this::deserializeAnim); Gson gson = gsonBuilder.create(); try (Reader reader = new InputStreamReader(res.getInputStream(), "UTF-8")) { JsonReader jsonReader = new JsonReader(reader); jsonReader.setLenient(true); gson.fromJson(jsonReader, AnimationImporter.class); } catch (Exception e) { MalisisCore.log.error("Failed to read {}", resourceLocation, e); } }
[ "public", "void", "load", "(", "ResourceLocation", "resourceLocation", ")", "{", "IResource", "res", "=", "Silenced", ".", "get", "(", "(", ")", "->", "Minecraft", ".", "getMinecraft", "(", ")", ".", "getResourceManager", "(", ")", ".", "getResource", "(", ...
Loads and reads the JSON. @param resourceLocation the resource location
[ "Loads", "and", "reads", "the", "JSON", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/model/loader/AnimationImporter.java#L134-L157
2,730
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/model/loader/AnimationImporter.java
AnimationImporter.deserializeAnim
public Multimap<String, Anim> deserializeAnim(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { Multimap<String, Anim> anims = ArrayListMultimap.create(); JsonObject obj = json.getAsJsonObject(); TypeToken<ArrayList<Anim>> token = new TypeToken<ArrayList<Anim>>() { }; for (Entry<String, JsonElement> entry : obj.entrySet()) anims.putAll(entry.getKey(), context.deserialize(entry.getValue(), token.getType())); return anims; }
java
public Multimap<String, Anim> deserializeAnim(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { Multimap<String, Anim> anims = ArrayListMultimap.create(); JsonObject obj = json.getAsJsonObject(); TypeToken<ArrayList<Anim>> token = new TypeToken<ArrayList<Anim>>() { }; for (Entry<String, JsonElement> entry : obj.entrySet()) anims.putAll(entry.getKey(), context.deserialize(entry.getValue(), token.getType())); return anims; }
[ "public", "Multimap", "<", "String", ",", "Anim", ">", "deserializeAnim", "(", "JsonElement", "json", ",", "Type", "typeOfT", ",", "JsonDeserializationContext", "context", ")", "throws", "JsonParseException", "{", "Multimap", "<", "String", ",", "Anim", ">", "an...
Deserialize "anims" multimap. @param json the json @param typeOfT the type of t @param context the context @return the multimap @throws JsonParseException the json parse exception
[ "Deserialize", "anims", "multimap", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/model/loader/AnimationImporter.java#L182-L194
2,731
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/component/UIComponent.java
UIComponent.onButtonPress
public boolean onButtonPress(MouseButton button) { if (!isEnabled()) return false; return parent != null ? parent.onButtonPress(button) : false; }
java
public boolean onButtonPress(MouseButton button) { if (!isEnabled()) return false; return parent != null ? parent.onButtonPress(button) : false; }
[ "public", "boolean", "onButtonPress", "(", "MouseButton", "button", ")", "{", "if", "(", "!", "isEnabled", "(", ")", ")", "return", "false", ";", "return", "parent", "!=", "null", "?", "parent", ".", "onButtonPress", "(", "button", ")", ":", "false", ";"...
On button press. @param button the button @return true, if successful
[ "On", "button", "press", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/component/UIComponent.java#L569-L575
2,732
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/component/UIComponent.java
UIComponent.onButtonRelease
public boolean onButtonRelease(MouseButton button) { if (!isEnabled()) return false; return parent != null ? parent.onButtonRelease(button) : false; }
java
public boolean onButtonRelease(MouseButton button) { if (!isEnabled()) return false; return parent != null ? parent.onButtonRelease(button) : false; }
[ "public", "boolean", "onButtonRelease", "(", "MouseButton", "button", ")", "{", "if", "(", "!", "isEnabled", "(", ")", ")", "return", "false", ";", "return", "parent", "!=", "null", "?", "parent", ".", "onButtonRelease", "(", "button", ")", ":", "false", ...
On button release. @param button the button @return true, if successful
[ "On", "button", "release", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/component/UIComponent.java#L583-L589
2,733
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/component/UIComponent.java
UIComponent.onDoubleClick
public boolean onDoubleClick(MouseButton button) { if (!isEnabled()) return false; return parent != null ? parent.onDoubleClick(button) : false; }
java
public boolean onDoubleClick(MouseButton button) { if (!isEnabled()) return false; return parent != null ? parent.onDoubleClick(button) : false; }
[ "public", "boolean", "onDoubleClick", "(", "MouseButton", "button", ")", "{", "if", "(", "!", "isEnabled", "(", ")", ")", "return", "false", ";", "return", "parent", "!=", "null", "?", "parent", ".", "onDoubleClick", "(", "button", ")", ":", "false", ";"...
On double click. @param button the button @return true, if successful
[ "On", "double", "click", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/component/UIComponent.java#L623-L629
2,734
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/component/UIComponent.java
UIComponent.onDrag
public boolean onDrag(MouseButton button) { if (!isEnabled()) return false; return parent != null ? parent.onDrag(button) : false; }
java
public boolean onDrag(MouseButton button) { if (!isEnabled()) return false; return parent != null ? parent.onDrag(button) : false; }
[ "public", "boolean", "onDrag", "(", "MouseButton", "button", ")", "{", "if", "(", "!", "isEnabled", "(", ")", ")", "return", "false", ";", "return", "parent", "!=", "null", "?", "parent", ".", "onDrag", "(", "button", ")", ":", "false", ";", "}" ]
On drag. @param button the button @return true, if successful
[ "On", "drag", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/component/UIComponent.java#L637-L643
2,735
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/component/UIComponent.java
UIComponent.onScrollWheel
public boolean onScrollWheel(int delta) { if (!isEnabled()) return false; for (IControlComponent c : controlComponents) if (c.onScrollWheel(delta)) return true; return parent != null && !(this instanceof IControlComponent) ? parent.onScrollWheel(delta) : false; }
java
public boolean onScrollWheel(int delta) { if (!isEnabled()) return false; for (IControlComponent c : controlComponents) if (c.onScrollWheel(delta)) return true; return parent != null && !(this instanceof IControlComponent) ? parent.onScrollWheel(delta) : false; }
[ "public", "boolean", "onScrollWheel", "(", "int", "delta", ")", "{", "if", "(", "!", "isEnabled", "(", ")", ")", "return", "false", ";", "for", "(", "IControlComponent", "c", ":", "controlComponents", ")", "if", "(", "c", ".", "onScrollWheel", "(", "delt...
On scroll wheel. @param delta the delta @return true, if successful
[ "On", "scroll", "wheel", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/component/UIComponent.java#L651-L661
2,736
Ordinastie/MalisisCore
src/main/java/net/malisis/core/MalisisCommand.java
MalisisCommand.execute
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] params) throws CommandException { if (params.length == 0) throw new WrongUsageException("malisiscore.commands.usage"); if (!parameters.contains(params[0])) throw new WrongUsageException("malisiscore.commands.usage"); switch (params[0]) { case "config": configCommand(sender, params); break; case "version": IMalisisMod mod = null; if (params.length == 1) mod = MalisisCore.instance; else { mod = MalisisCore.getMod(params[1]); if (mod == null) MalisisCore.message("malisiscore.commands.modnotfound", params[1]); } if (mod != null) MalisisCore.message("malisiscore.commands.modversion", mod.getName(), mod.getVersion()); break; case "debug": debugCommand(sender, params); break; default: MalisisCore.message("Not yet implemented"); break; } }
java
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] params) throws CommandException { if (params.length == 0) throw new WrongUsageException("malisiscore.commands.usage"); if (!parameters.contains(params[0])) throw new WrongUsageException("malisiscore.commands.usage"); switch (params[0]) { case "config": configCommand(sender, params); break; case "version": IMalisisMod mod = null; if (params.length == 1) mod = MalisisCore.instance; else { mod = MalisisCore.getMod(params[1]); if (mod == null) MalisisCore.message("malisiscore.commands.modnotfound", params[1]); } if (mod != null) MalisisCore.message("malisiscore.commands.modversion", mod.getName(), mod.getVersion()); break; case "debug": debugCommand(sender, params); break; default: MalisisCore.message("Not yet implemented"); break; } }
[ "@", "Override", "public", "void", "execute", "(", "MinecraftServer", "server", ",", "ICommandSender", "sender", ",", "String", "[", "]", "params", ")", "throws", "CommandException", "{", "if", "(", "params", ".", "length", "==", "0", ")", "throw", "new", ...
Processes the command. @param sender the sender @param params the params
[ "Processes", "the", "command", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/MalisisCommand.java#L105-L142
2,737
Ordinastie/MalisisCore
src/main/java/net/malisis/core/asm/AsmUtils.java
AsmUtils.findMethod
public static MethodNode findMethod(ClassNode clazz, String name) { for (MethodNode method : clazz.methods) { if (method.name.equals(name)) { return method; } } return null; }
java
public static MethodNode findMethod(ClassNode clazz, String name) { for (MethodNode method : clazz.methods) { if (method.name.equals(name)) { return method; } } return null; }
[ "public", "static", "MethodNode", "findMethod", "(", "ClassNode", "clazz", ",", "String", "name", ")", "{", "for", "(", "MethodNode", "method", ":", "clazz", ".", "methods", ")", "{", "if", "(", "method", ".", "name", ".", "equals", "(", "name", ")", "...
Finds the method with the given name. If multiple methods with the same name exist, the first one will be returned @param clazz the class @param name the method name to search for @return the first method with the given name or null if no such method is found
[ "Finds", "the", "method", "with", "the", "given", "name", ".", "If", "multiple", "methods", "with", "the", "same", "name", "exist", "the", "first", "one", "will", "be", "returned" ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/asm/AsmUtils.java#L63-L73
2,738
Ordinastie/MalisisCore
src/main/java/net/malisis/core/asm/AsmUtils.java
AsmUtils.findInstruction
public static AbstractInsnNode findInstruction(MethodNode method, InsnList matches, int index) { AbstractInsnNode node = method.instructions.get(index); AbstractInsnNode match = matches.getFirst(); while (node != null) { if (insnEqual(node, match)) { AbstractInsnNode m = match.getNext(); AbstractInsnNode n = node.getNext(); while (m != null && n != null && insnEqual(m, n)) { m = m.getNext(); n = n.getNext(); } if (m == null) return node; } node = node.getNext(); } return null; }
java
public static AbstractInsnNode findInstruction(MethodNode method, InsnList matches, int index) { AbstractInsnNode node = method.instructions.get(index); AbstractInsnNode match = matches.getFirst(); while (node != null) { if (insnEqual(node, match)) { AbstractInsnNode m = match.getNext(); AbstractInsnNode n = node.getNext(); while (m != null && n != null && insnEqual(m, n)) { m = m.getNext(); n = n.getNext(); } if (m == null) return node; } node = node.getNext(); } return null; }
[ "public", "static", "AbstractInsnNode", "findInstruction", "(", "MethodNode", "method", ",", "InsnList", "matches", ",", "int", "index", ")", "{", "AbstractInsnNode", "node", "=", "method", ".", "instructions", ".", "get", "(", "index", ")", ";", "AbstractInsnNo...
Finds instruction a specific instruction list inside a method, starting from the specified index. @param method the method @param matches the matches @param index the index @return the abstract insn node
[ "Finds", "instruction", "a", "specific", "instruction", "list", "inside", "a", "method", "starting", "from", "the", "specified", "index", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/asm/AsmUtils.java#L116-L138
2,739
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/MBlockPos.java
MBlockPos.add
public MBlockPos add(int x, int y, int z) { return new MBlockPos(this.getX() + x, this.getY() + y, this.getZ() + z); }
java
public MBlockPos add(int x, int y, int z) { return new MBlockPos(this.getX() + x, this.getY() + y, this.getZ() + z); }
[ "public", "MBlockPos", "add", "(", "int", "x", ",", "int", "y", ",", "int", "z", ")", "{", "return", "new", "MBlockPos", "(", "this", ".", "getX", "(", ")", "+", "x", ",", "this", ".", "getY", "(", ")", "+", "y", ",", "this", ".", "getZ", "("...
Add the given coordinates to the coordinates of this BlockPos @param x X coordinate @param y Y coordinate @param z Z coordinate
[ "Add", "the", "given", "coordinates", "to", "the", "coordinates", "of", "this", "BlockPos" ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/MBlockPos.java#L111-L114
2,740
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/MBlockPos.java
MBlockPos.offset
public MBlockPos offset(EnumFacing facing, int n) { return new MBlockPos( this.getX() + facing.getFrontOffsetX() * n, this.getY() + facing.getFrontOffsetY() * n, this.getZ() + facing.getFrontOffsetZ() * n); }
java
public MBlockPos offset(EnumFacing facing, int n) { return new MBlockPos( this.getX() + facing.getFrontOffsetX() * n, this.getY() + facing.getFrontOffsetY() * n, this.getZ() + facing.getFrontOffsetZ() * n); }
[ "public", "MBlockPos", "offset", "(", "EnumFacing", "facing", ",", "int", "n", ")", "{", "return", "new", "MBlockPos", "(", "this", ".", "getX", "(", ")", "+", "facing", ".", "getFrontOffsetX", "(", ")", "*", "n", ",", "this", ".", "getY", "(", ")", ...
Offsets this BlockPos n blocks in the given direction @param facing The direction of the offset @param n The number of blocks to offset by
[ "Offsets", "this", "BlockPos", "n", "blocks", "in", "the", "given", "direction" ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/MBlockPos.java#L240-L245
2,741
Ordinastie/MalisisCore
src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java
MalisisInventoryContainer.setPickedItemStack
public void setPickedItemStack(ItemStack itemStack) { pickedItemStack = checkNotNull(itemStack); owner.inventory.setItemStack(itemStack); }
java
public void setPickedItemStack(ItemStack itemStack) { pickedItemStack = checkNotNull(itemStack); owner.inventory.setItemStack(itemStack); }
[ "public", "void", "setPickedItemStack", "(", "ItemStack", "itemStack", ")", "{", "pickedItemStack", "=", "checkNotNull", "(", "itemStack", ")", ";", "owner", ".", "inventory", ".", "setItemStack", "(", "itemStack", ")", ";", "}" ]
Sets the currently picked itemStack. Update player inventory. @param itemStack the new picked item stack
[ "Sets", "the", "currently", "picked", "itemStack", ".", "Update", "player", "inventory", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L224-L228
2,742
Ordinastie/MalisisCore
src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java
MalisisInventoryContainer.shouldEndDrag
public boolean shouldEndDrag(int button) { if (!isDraggingItemStack()) return false; if (dragType == DRAG_TYPE_ONE || dragType == DRAG_TYPE_SPREAD) return dragType == button && draggedSlots.size() > 1; return dragType == DRAG_TYPE_PICKUP; }
java
public boolean shouldEndDrag(int button) { if (!isDraggingItemStack()) return false; if (dragType == DRAG_TYPE_ONE || dragType == DRAG_TYPE_SPREAD) return dragType == button && draggedSlots.size() > 1; return dragType == DRAG_TYPE_PICKUP; }
[ "public", "boolean", "shouldEndDrag", "(", "int", "button", ")", "{", "if", "(", "!", "isDraggingItemStack", "(", ")", ")", "return", "false", ";", "if", "(", "dragType", "==", "DRAG_TYPE_ONE", "||", "dragType", "==", "DRAG_TYPE_SPREAD", ")", "return", "drag...
Checks if the dragging should end based on the mouse button clicked. @param button the button @return true, if dragging should end
[ "Checks", "if", "the", "dragging", "should", "end", "based", "on", "the", "mouse", "button", "clicked", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L256-L265
2,743
Ordinastie/MalisisCore
src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java
MalisisInventoryContainer.shouldResetDrag
public boolean shouldResetDrag(int button) { if (!isDraggingItemStack()) return false; if (dragType == DRAG_TYPE_SPREAD) return button == 1 && draggedSlots.size() > 1; if (dragType == DRAG_TYPE_ONE) return button == 0 && draggedSlots.size() > 1; return dragType != DRAG_TYPE_PICKUP; }
java
public boolean shouldResetDrag(int button) { if (!isDraggingItemStack()) return false; if (dragType == DRAG_TYPE_SPREAD) return button == 1 && draggedSlots.size() > 1; if (dragType == DRAG_TYPE_ONE) return button == 0 && draggedSlots.size() > 1; return dragType != DRAG_TYPE_PICKUP; }
[ "public", "boolean", "shouldResetDrag", "(", "int", "button", ")", "{", "if", "(", "!", "isDraggingItemStack", "(", ")", ")", "return", "false", ";", "if", "(", "dragType", "==", "DRAG_TYPE_SPREAD", ")", "return", "button", "==", "1", "&&", "draggedSlots", ...
Checks if the dragging should be reset based on the mouse button clicked. @param button the button @return true, if dragging should reset
[ "Checks", "if", "the", "dragging", "should", "be", "reset", "based", "on", "the", "mouse", "button", "clicked", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L273-L284
2,744
Ordinastie/MalisisCore
src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java
MalisisInventoryContainer.detectAndSendChanges
@Override public void detectAndSendChanges() { playerInventoryCache.sendChanges(); inventoryCaches.values().forEach(InventoryCache::sendChanges); //picked itemStack pickedItemStackCache.update(); if (pickedItemStackCache.hasChanged()) UpdateInventorySlotsMessage.updatePickedItemStack(pickedItemStackCache.get(), (EntityPlayerMP) owner, windowId); }
java
@Override public void detectAndSendChanges() { playerInventoryCache.sendChanges(); inventoryCaches.values().forEach(InventoryCache::sendChanges); //picked itemStack pickedItemStackCache.update(); if (pickedItemStackCache.hasChanged()) UpdateInventorySlotsMessage.updatePickedItemStack(pickedItemStackCache.get(), (EntityPlayerMP) owner, windowId); }
[ "@", "Override", "public", "void", "detectAndSendChanges", "(", ")", "{", "playerInventoryCache", ".", "sendChanges", "(", ")", ";", "inventoryCaches", ".", "values", "(", ")", ".", "forEach", "(", "InventoryCache", "::", "sendChanges", ")", ";", "//picked itemS...
Sends all changes for base inventory, player's inventory, picked up itemStack and dragged itemStacks.
[ "Sends", "all", "changes", "for", "base", "inventory", "player", "s", "inventory", "picked", "up", "itemStack", "and", "dragged", "itemStacks", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L310-L320
2,745
Ordinastie/MalisisCore
src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java
MalisisInventoryContainer.handleDropPickedStack
private ItemStack handleDropPickedStack(boolean fullStack) { ItemUtils.ItemStackSplitter iss = new ItemUtils.ItemStackSplitter(pickedItemStack); iss.split(fullStack ? ItemUtils.FULL_STACK : 1); owner.dropItem(iss.split, true); setPickedItemStack(iss.source); return iss.source; }
java
private ItemStack handleDropPickedStack(boolean fullStack) { ItemUtils.ItemStackSplitter iss = new ItemUtils.ItemStackSplitter(pickedItemStack); iss.split(fullStack ? ItemUtils.FULL_STACK : 1); owner.dropItem(iss.split, true); setPickedItemStack(iss.source); return iss.source; }
[ "private", "ItemStack", "handleDropPickedStack", "(", "boolean", "fullStack", ")", "{", "ItemUtils", ".", "ItemStackSplitter", "iss", "=", "new", "ItemUtils", ".", "ItemStackSplitter", "(", "pickedItemStack", ")", ";", "iss", ".", "split", "(", "fullStack", "?", ...
Drops one or the full itemStack currently picked up. @param fullStack the full stack @return the item stack
[ "Drops", "one", "or", "the", "full", "itemStack", "currently", "picked", "up", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L441-L450
2,746
Ordinastie/MalisisCore
src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java
MalisisInventoryContainer.handleNormalClick
private ItemStack handleNormalClick(MalisisSlot slot, boolean fullStack) { if (!getPickedItemStack().isEmpty() && !slot.isItemValid(pickedItemStack)) return getPickedItemStack(); // already picked up an itemStack, insert/swap itemStack if (!getPickedItemStack().isEmpty()) { if (slot.isState(PLAYER_INSERT | PLAYER_EXTRACT)) setPickedItemStack(slot.insert(pickedItemStack, fullStack ? ItemUtils.FULL_STACK : 1, true)); } // pick itemStack in slot else if (slot.isState(PLAYER_EXTRACT)) setPickedItemStack(slot.extract(fullStack ? ItemUtils.FULL_STACK : ItemUtils.HALF_STACK)); return getPickedItemStack(); }
java
private ItemStack handleNormalClick(MalisisSlot slot, boolean fullStack) { if (!getPickedItemStack().isEmpty() && !slot.isItemValid(pickedItemStack)) return getPickedItemStack(); // already picked up an itemStack, insert/swap itemStack if (!getPickedItemStack().isEmpty()) { if (slot.isState(PLAYER_INSERT | PLAYER_EXTRACT)) setPickedItemStack(slot.insert(pickedItemStack, fullStack ? ItemUtils.FULL_STACK : 1, true)); } // pick itemStack in slot else if (slot.isState(PLAYER_EXTRACT)) setPickedItemStack(slot.extract(fullStack ? ItemUtils.FULL_STACK : ItemUtils.HALF_STACK)); return getPickedItemStack(); }
[ "private", "ItemStack", "handleNormalClick", "(", "MalisisSlot", "slot", ",", "boolean", "fullStack", ")", "{", "if", "(", "!", "getPickedItemStack", "(", ")", ".", "isEmpty", "(", ")", "&&", "!", "slot", ".", "isItemValid", "(", "pickedItemStack", ")", ")",...
Handles the normal left or right click. @param slot the slot @param fullStack the full stack @return the item stack
[ "Handles", "the", "normal", "left", "or", "right", "click", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L459-L475
2,747
Ordinastie/MalisisCore
src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java
MalisisInventoryContainer.handleShiftClick
private ItemStack handleShiftClick(MalisisInventory inventory, MalisisSlot slot) { ItemStack itemStack = transferSlotOutOfInventory(inventory, slot); //replace what's left of the item back into the slot slot.setItemStack(itemStack); slot.onSlotChanged(); return itemStack; }
java
private ItemStack handleShiftClick(MalisisInventory inventory, MalisisSlot slot) { ItemStack itemStack = transferSlotOutOfInventory(inventory, slot); //replace what's left of the item back into the slot slot.setItemStack(itemStack); slot.onSlotChanged(); return itemStack; }
[ "private", "ItemStack", "handleShiftClick", "(", "MalisisInventory", "inventory", ",", "MalisisSlot", "slot", ")", "{", "ItemStack", "itemStack", "=", "transferSlotOutOfInventory", "(", "inventory", ",", "slot", ")", ";", "//replace what's left of the item back into the slo...
Handles shift clicking a slot. @param inventoryId the inventory id @param slot the slot @return the item stack
[ "Handles", "shift", "clicking", "a", "slot", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L484-L492
2,748
Ordinastie/MalisisCore
src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java
MalisisInventoryContainer.handleHotbar
private ItemStack handleHotbar(MalisisInventory inventory, MalisisSlot hoveredSlot, int num) { MalisisSlot hotbarSlot = getPlayerInventory().getSlot(num); // slot from player's inventory, swap itemStacks if (inventory == getPlayerInventory() || hoveredSlot.getItemStack().isEmpty()) { if (hoveredSlot.isState(PLAYER_INSERT)) { ItemStack dest = hotbarSlot.extract(ItemUtils.FULL_STACK); ItemStack src = hoveredSlot.extract(ItemUtils.FULL_STACK); dest = hoveredSlot.insert(dest); //couldn't fit all into the slot, put back what's left in hotbar if (!dest.isEmpty()) { hotbarSlot.insert(dest); //src should be empty but better safe than sorry inventory.transferInto(src); } else src = hotbarSlot.insert(src); } } // merge itemStack in slot into hotbar. If already holding an itemStack, move elsewhere inside player inventory else { if (hoveredSlot.isState(PLAYER_EXTRACT)) { ItemStack dest = hoveredSlot.extract(ItemUtils.FULL_STACK); ItemStack left = hotbarSlot.insert(dest, ItemUtils.FULL_STACK, true); getPlayerInventory().transferInto(left, false); } } return hotbarSlot.getItemStack(); }
java
private ItemStack handleHotbar(MalisisInventory inventory, MalisisSlot hoveredSlot, int num) { MalisisSlot hotbarSlot = getPlayerInventory().getSlot(num); // slot from player's inventory, swap itemStacks if (inventory == getPlayerInventory() || hoveredSlot.getItemStack().isEmpty()) { if (hoveredSlot.isState(PLAYER_INSERT)) { ItemStack dest = hotbarSlot.extract(ItemUtils.FULL_STACK); ItemStack src = hoveredSlot.extract(ItemUtils.FULL_STACK); dest = hoveredSlot.insert(dest); //couldn't fit all into the slot, put back what's left in hotbar if (!dest.isEmpty()) { hotbarSlot.insert(dest); //src should be empty but better safe than sorry inventory.transferInto(src); } else src = hotbarSlot.insert(src); } } // merge itemStack in slot into hotbar. If already holding an itemStack, move elsewhere inside player inventory else { if (hoveredSlot.isState(PLAYER_EXTRACT)) { ItemStack dest = hoveredSlot.extract(ItemUtils.FULL_STACK); ItemStack left = hotbarSlot.insert(dest, ItemUtils.FULL_STACK, true); getPlayerInventory().transferInto(left, false); } } return hotbarSlot.getItemStack(); }
[ "private", "ItemStack", "handleHotbar", "(", "MalisisInventory", "inventory", ",", "MalisisSlot", "hoveredSlot", ",", "int", "num", ")", "{", "MalisisSlot", "hotbarSlot", "=", "getPlayerInventory", "(", ")", ".", "getSlot", "(", "num", ")", ";", "// slot from play...
Handles player pressing 1-9 key while hovering a slot. @param hoveredSlot hoveredSlot @param num the num @return the item stack
[ "Handles", "player", "pressing", "1", "-", "9", "key", "while", "hovering", "a", "slot", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L534-L570
2,749
Ordinastie/MalisisCore
src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java
MalisisInventoryContainer.handleDropSlot
private ItemStack handleDropSlot(MalisisSlot hoveredSlot, boolean fullStack) { ItemStack itemStack = hoveredSlot.getItemStack(); if (itemStack.isEmpty() || !hoveredSlot.isState(PLAYER_EXTRACT)) return itemStack; ItemUtils.ItemStackSplitter iss = new ItemUtils.ItemStackSplitter(hoveredSlot.getItemStack()); iss.split(fullStack ? ItemUtils.FULL_STACK : 1); hoveredSlot.setItemStack(iss.source); //if (slot.hasChanged()) hoveredSlot.onSlotChanged(); owner.dropItem(iss.split, true); if (iss.amount != 0) hoveredSlot.onPickupFromSlot(owner, iss.split); return iss.split; }
java
private ItemStack handleDropSlot(MalisisSlot hoveredSlot, boolean fullStack) { ItemStack itemStack = hoveredSlot.getItemStack(); if (itemStack.isEmpty() || !hoveredSlot.isState(PLAYER_EXTRACT)) return itemStack; ItemUtils.ItemStackSplitter iss = new ItemUtils.ItemStackSplitter(hoveredSlot.getItemStack()); iss.split(fullStack ? ItemUtils.FULL_STACK : 1); hoveredSlot.setItemStack(iss.source); //if (slot.hasChanged()) hoveredSlot.onSlotChanged(); owner.dropItem(iss.split, true); if (iss.amount != 0) hoveredSlot.onPickupFromSlot(owner, iss.split); return iss.split; }
[ "private", "ItemStack", "handleDropSlot", "(", "MalisisSlot", "hoveredSlot", ",", "boolean", "fullStack", ")", "{", "ItemStack", "itemStack", "=", "hoveredSlot", ".", "getItemStack", "(", ")", ";", "if", "(", "itemStack", ".", "isEmpty", "(", ")", "||", "!", ...
Drops itemStack from hovering slot. @param hoveredSlot the slot @param fullStack the full stack @return the item stack
[ "Drops", "itemStack", "from", "hovering", "slot", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L579-L597
2,750
Ordinastie/MalisisCore
src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java
MalisisInventoryContainer.handleDoubleClick
private ItemStack handleDoubleClick(MalisisInventory inventory, MalisisSlot slot, boolean shiftClick) { if (!inventory.state.is(PLAYER_EXTRACT)) return ItemStack.EMPTY; // normal double click, go through all hovered slot inventory to merge the slots with the currently picked one if (!shiftClick && !pickedItemStack.isEmpty()) { for (int i = 0; i < 2; i++) { for (MalisisInventory inv : getInventories()) if (inv.pullItemStacks(pickedItemStack, i == 0)) break; if (pickedItemStack.getCount() < pickedItemStack.getMaxStackSize()) getPlayerInventory().pullItemStacks(pickedItemStack, i == 0); } setPickedItemStack(pickedItemStack); } // shift double click, go through all hovered slot's inventory to transfer matching itemStack to the other inventory else if (!lastShiftClicked.isEmpty()) { //transfer all matching itemStack into other inventories if (inventory == getPlayerInventory()) { } for (MalisisSlot s : inventory.getNonEmptySlots()) { ItemStack itemStack = s.getItemStack(); if (s.isState(PLAYER_EXTRACT) && ItemUtils.areItemStacksStackable(itemStack, lastShiftClicked)) { itemStack = transferSlotOutOfInventory(inventory, s); //replace what's left of the item back into the slot slot.setItemStack(itemStack); slot.onSlotChanged(); //itemStack is not empty, inventory is full, no need to keep looping the slots if (!itemStack.isEmpty()) return itemStack; } } } lastShiftClicked = ItemStack.EMPTY; return ItemStack.EMPTY; }
java
private ItemStack handleDoubleClick(MalisisInventory inventory, MalisisSlot slot, boolean shiftClick) { if (!inventory.state.is(PLAYER_EXTRACT)) return ItemStack.EMPTY; // normal double click, go through all hovered slot inventory to merge the slots with the currently picked one if (!shiftClick && !pickedItemStack.isEmpty()) { for (int i = 0; i < 2; i++) { for (MalisisInventory inv : getInventories()) if (inv.pullItemStacks(pickedItemStack, i == 0)) break; if (pickedItemStack.getCount() < pickedItemStack.getMaxStackSize()) getPlayerInventory().pullItemStacks(pickedItemStack, i == 0); } setPickedItemStack(pickedItemStack); } // shift double click, go through all hovered slot's inventory to transfer matching itemStack to the other inventory else if (!lastShiftClicked.isEmpty()) { //transfer all matching itemStack into other inventories if (inventory == getPlayerInventory()) { } for (MalisisSlot s : inventory.getNonEmptySlots()) { ItemStack itemStack = s.getItemStack(); if (s.isState(PLAYER_EXTRACT) && ItemUtils.areItemStacksStackable(itemStack, lastShiftClicked)) { itemStack = transferSlotOutOfInventory(inventory, s); //replace what's left of the item back into the slot slot.setItemStack(itemStack); slot.onSlotChanged(); //itemStack is not empty, inventory is full, no need to keep looping the slots if (!itemStack.isEmpty()) return itemStack; } } } lastShiftClicked = ItemStack.EMPTY; return ItemStack.EMPTY; }
[ "private", "ItemStack", "handleDoubleClick", "(", "MalisisInventory", "inventory", ",", "MalisisSlot", "slot", ",", "boolean", "shiftClick", ")", "{", "if", "(", "!", "inventory", ".", "state", ".", "is", "(", "PLAYER_EXTRACT", ")", ")", "return", "ItemStack", ...
Handle double clicking on a slot. @param inventoryId the inventory id @param slot the slot @param shiftClick the shift click @return the item stack
[ "Handle", "double", "clicking", "on", "a", "slot", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L607-L653
2,751
Ordinastie/MalisisCore
src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java
MalisisInventoryContainer.handlePickBlock
private ItemStack handlePickBlock(MalisisSlot slot) { if (slot.getItemStack().isEmpty() || !pickedItemStack.isEmpty()) return ItemStack.EMPTY; ItemStack itemStack = ItemUtils.copy(slot.getItemStack()); itemStack.setCount(itemStack.getMaxStackSize()); setPickedItemStack(itemStack); return itemStack; }
java
private ItemStack handlePickBlock(MalisisSlot slot) { if (slot.getItemStack().isEmpty() || !pickedItemStack.isEmpty()) return ItemStack.EMPTY; ItemStack itemStack = ItemUtils.copy(slot.getItemStack()); itemStack.setCount(itemStack.getMaxStackSize()); setPickedItemStack(itemStack); return itemStack; }
[ "private", "ItemStack", "handlePickBlock", "(", "MalisisSlot", "slot", ")", "{", "if", "(", "slot", ".", "getItemStack", "(", ")", ".", "isEmpty", "(", ")", "||", "!", "pickedItemStack", ".", "isEmpty", "(", ")", ")", "return", "ItemStack", ".", "EMPTY", ...
Picks up the itemStack in the slot. @param slot the slot @return the item stack
[ "Picks", "up", "the", "itemStack", "in", "the", "slot", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L661-L671
2,752
Ordinastie/MalisisCore
src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java
MalisisInventoryContainer.resetDrag
@Override protected void resetDrag() { if (!isDraggingItemStack()) return; //if (!pickedItemStack.isEmpty()) pickedItemStack = draggedItemStack.copy(); draggedSlots.forEach(s -> s.setDraggedItemStack(ItemStack.EMPTY)); draggedSlots.clear(); draggedItemStack = null; dragType = -1; }
java
@Override protected void resetDrag() { if (!isDraggingItemStack()) return; //if (!pickedItemStack.isEmpty()) pickedItemStack = draggedItemStack.copy(); draggedSlots.forEach(s -> s.setDraggedItemStack(ItemStack.EMPTY)); draggedSlots.clear(); draggedItemStack = null; dragType = -1; }
[ "@", "Override", "protected", "void", "resetDrag", "(", ")", "{", "if", "(", "!", "isDraggingItemStack", "(", ")", ")", "return", ";", "//if (!pickedItemStack.isEmpty())", "pickedItemStack", "=", "draggedItemStack", ".", "copy", "(", ")", ";", "draggedSlots", "....
Resets the dragging state.
[ "Resets", "the", "dragging", "state", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L810-L824
2,753
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/font/MalisisFont.java
MalisisFont.getStringWidth
public float getStringWidth(String text, FontOptions options) { if (StringUtils.isEmpty(text)) return 0; StringWalker walker = new StringWalker(text, options); walker.walkToEnd(); return walker.width(); }
java
public float getStringWidth(String text, FontOptions options) { if (StringUtils.isEmpty(text)) return 0; StringWalker walker = new StringWalker(text, options); walker.walkToEnd(); return walker.width(); }
[ "public", "float", "getStringWidth", "(", "String", "text", ",", "FontOptions", "options", ")", "{", "if", "(", "StringUtils", ".", "isEmpty", "(", "text", ")", ")", "return", "0", ";", "StringWalker", "walker", "=", "new", "StringWalker", "(", "text", ","...
Gets the rendering width of the text. @param text the text @param options the options @return the string width
[ "Gets", "the", "rendering", "width", "of", "the", "text", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/font/MalisisFont.java#L457-L465
2,754
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/font/MalisisFont.java
MalisisFont.getStringHeight
public float getStringHeight(String text, FontOptions options) { StringWalker walker = new StringWalker(text, options); walker.walkToEnd(); return walker.lineHeight(); }
java
public float getStringHeight(String text, FontOptions options) { StringWalker walker = new StringWalker(text, options); walker.walkToEnd(); return walker.lineHeight(); }
[ "public", "float", "getStringHeight", "(", "String", "text", ",", "FontOptions", "options", ")", "{", "StringWalker", "walker", "=", "new", "StringWalker", "(", "text", ",", "options", ")", ";", "walker", ".", "walkToEnd", "(", ")", ";", "return", "walker", ...
Gets the rendering height of strings. @return the string height
[ "Gets", "the", "rendering", "height", "of", "strings", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/font/MalisisFont.java#L472-L477
2,755
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/font/MalisisFont.java
MalisisFont.getMaxStringWidth
public float getMaxStringWidth(List<String> strings, FontOptions options) { float width = 0; for (String str : strings) width = Math.max(width, getStringWidth(str, options)); return width; } /** * Gets the rendering width of a character. * * @param c the c * @param options the options * @return the char width */ public float getCharWidth(char c, FontOptions options) { if (c == '\r' || c == '\n') return 0; if (c == '\t') return getCharWidth(' ', options) * 4; return getCharData(c).getCharWidth() / fontGeneratorOptions.fontSize * (options != null ? options.getFontScale() : 1) * 9; }
java
public float getMaxStringWidth(List<String> strings, FontOptions options) { float width = 0; for (String str : strings) width = Math.max(width, getStringWidth(str, options)); return width; } /** * Gets the rendering width of a character. * * @param c the c * @param options the options * @return the char width */ public float getCharWidth(char c, FontOptions options) { if (c == '\r' || c == '\n') return 0; if (c == '\t') return getCharWidth(' ', options) * 4; return getCharData(c).getCharWidth() / fontGeneratorOptions.fontSize * (options != null ? options.getFontScale() : 1) * 9; }
[ "public", "float", "getMaxStringWidth", "(", "List", "<", "String", ">", "strings", ",", "FontOptions", "options", ")", "{", "float", "width", "=", "0", ";", "for", "(", "String", "str", ":", "strings", ")", "width", "=", "Math", ".", "max", "(", "widt...
Gets max rendering width of an array of string. @param strings the strings @param options the options @return the max string width
[ "Gets", "max", "rendering", "width", "of", "an", "array", "of", "string", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/font/MalisisFont.java#L508-L531
2,756
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/font/MalisisFont.java
MalisisFont.getCharHeight
public float getCharHeight(char c, FontOptions options) { return getCharData(c).getCharHeight() / fontGeneratorOptions.fontSize * (options != null ? options.getFontScale() : 1) * 9; }
java
public float getCharHeight(char c, FontOptions options) { return getCharData(c).getCharHeight() / fontGeneratorOptions.fontSize * (options != null ? options.getFontScale() : 1) * 9; }
[ "public", "float", "getCharHeight", "(", "char", "c", ",", "FontOptions", "options", ")", "{", "return", "getCharData", "(", "c", ")", ".", "getCharHeight", "(", ")", "/", "fontGeneratorOptions", ".", "fontSize", "*", "(", "options", "!=", "null", "?", "op...
Gets the rendering height of a character. @param c the c @param options the options @return the char height
[ "Gets", "the", "rendering", "height", "of", "a", "character", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/font/MalisisFont.java#L540-L543
2,757
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/font/MalisisFont.java
MalisisFont.getCharPosition
public float getCharPosition(String str, FontOptions options, int position, int charOffset) { if (StringUtils.isEmpty(str)) return 0; str = processString(str, options); //float fx = position / (fro != null ? fro.fontScale : 1); //factor the position instead of the char widths StringWalker walker = new StringWalker(str, options); //walker.startIndex(charOffset); walker.skipChars(true); return 0;//walker.walkToCoord(position); }
java
public float getCharPosition(String str, FontOptions options, int position, int charOffset) { if (StringUtils.isEmpty(str)) return 0; str = processString(str, options); //float fx = position / (fro != null ? fro.fontScale : 1); //factor the position instead of the char widths StringWalker walker = new StringWalker(str, options); //walker.startIndex(charOffset); walker.skipChars(true); return 0;//walker.walkToCoord(position); }
[ "public", "float", "getCharPosition", "(", "String", "str", ",", "FontOptions", "options", ",", "int", "position", ",", "int", "charOffset", ")", "{", "if", "(", "StringUtils", ".", "isEmpty", "(", "str", ")", ")", "return", "0", ";", "str", "=", "proces...
Determines the character for a given X coordinate. @param str the str @param options the options @param position the position @param charOffset the char offset @return position
[ "Determines", "the", "character", "for", "a", "given", "X", "coordinate", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/font/MalisisFont.java#L554-L566
2,758
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/text/GuiText.java
GuiText.setFontOptions
public void setFontOptions(FontOptions fontOptions) { checkNotNull(fontOptions); buildLines = this.fontOptions.isBold() != fontOptions.isBold() || this.fontOptions.getFontScale() != fontOptions.getFontScale(); this.fontOptions = fontOptions; }
java
public void setFontOptions(FontOptions fontOptions) { checkNotNull(fontOptions); buildLines = this.fontOptions.isBold() != fontOptions.isBold() || this.fontOptions.getFontScale() != fontOptions.getFontScale(); this.fontOptions = fontOptions; }
[ "public", "void", "setFontOptions", "(", "FontOptions", "fontOptions", ")", "{", "checkNotNull", "(", "fontOptions", ")", ";", "buildLines", "=", "this", ".", "fontOptions", ".", "isBold", "(", ")", "!=", "fontOptions", ".", "isBold", "(", ")", "||", "this",...
Sets the font options to use to render. @param fontOptions the new font options
[ "Sets", "the", "font", "options", "to", "use", "to", "render", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/text/GuiText.java#L298-L303
2,759
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/text/GuiText.java
GuiText.resolveParameter
private String resolveParameter(String key) { ICachedData<?> o = parameters.get(key); if (o == null) //not actual parameter : translate it return translated ? I18n.format(key) : key; return Objects.toString(o.get()).replace("$", "\\$"); }
java
private String resolveParameter(String key) { ICachedData<?> o = parameters.get(key); if (o == null) //not actual parameter : translate it return translated ? I18n.format(key) : key; return Objects.toString(o.get()).replace("$", "\\$"); }
[ "private", "String", "resolveParameter", "(", "String", "key", ")", "{", "ICachedData", "<", "?", ">", "o", "=", "parameters", ".", "get", "(", "key", ")", ";", "if", "(", "o", "==", "null", ")", "//not actual parameter : translate it", "return", "translated...
Resolve parameter values to use in the text. @param key the key @return the string
[ "Resolve", "parameter", "values", "to", "use", "in", "the", "text", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/text/GuiText.java#L311-L317
2,760
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/text/GuiText.java
GuiText.hasParametersChanged
private boolean hasParametersChanged() { boolean changed = false; for (ICachedData<?> data : parameters.values()) { data.update(); if (data.hasChanged()) changed |= true; //can't return early, we need to call update on each data } return changed; }
java
private boolean hasParametersChanged() { boolean changed = false; for (ICachedData<?> data : parameters.values()) { data.update(); if (data.hasChanged()) changed |= true; //can't return early, we need to call update on each data } return changed; }
[ "private", "boolean", "hasParametersChanged", "(", ")", "{", "boolean", "changed", "=", "false", ";", "for", "(", "ICachedData", "<", "?", ">", "data", ":", "parameters", ".", "values", "(", ")", ")", "{", "data", ".", "update", "(", ")", ";", "if", ...
Checks whether any parameter has changed. @return true, if successful
[ "Checks", "whether", "any", "parameter", "has", "changed", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/text/GuiText.java#L324-L334
2,761
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/text/GuiText.java
GuiText.applyParameters
public String applyParameters(String str) { Matcher matcher = pattern.matcher(str); StringBuffer sb = new StringBuffer(); while (matcher.find()) matcher.appendReplacement(sb, resolveParameter(matcher.group("key"))); matcher.appendTail(sb); str = sb.toString(); return translated ? I18n.format(str) : str; }
java
public String applyParameters(String str) { Matcher matcher = pattern.matcher(str); StringBuffer sb = new StringBuffer(); while (matcher.find()) matcher.appendReplacement(sb, resolveParameter(matcher.group("key"))); matcher.appendTail(sb); str = sb.toString(); return translated ? I18n.format(str) : str; }
[ "public", "String", "applyParameters", "(", "String", "str", ")", "{", "Matcher", "matcher", "=", "pattern", ".", "matcher", "(", "str", ")", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "while", "(", "matcher", ".", "find", "(",...
Applies parameters to the text. @param str the str @return the string
[ "Applies", "parameters", "to", "the", "text", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/text/GuiText.java#L396-L405
2,762
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/text/GuiText.java
GuiText.render
@Override public void render(GuiRenderer renderer) { update(); if (StringUtils.isEmpty(cache)) return; int x = screenPosition.x(); int y = screenPosition.y(); int z = zIndex.getAsInt(); ClipArea area = null; if (parent instanceof UIComponent) z += parent.getZIndex(); if (parent instanceof IClipable) area = ((IClipable) parent).getClipArea(); render(renderer, x, y, z, area); }
java
@Override public void render(GuiRenderer renderer) { update(); if (StringUtils.isEmpty(cache)) return; int x = screenPosition.x(); int y = screenPosition.y(); int z = zIndex.getAsInt(); ClipArea area = null; if (parent instanceof UIComponent) z += parent.getZIndex(); if (parent instanceof IClipable) area = ((IClipable) parent).getClipArea(); render(renderer, x, y, z, area); }
[ "@", "Override", "public", "void", "render", "(", "GuiRenderer", "renderer", ")", "{", "update", "(", ")", ";", "if", "(", "StringUtils", ".", "isEmpty", "(", "cache", ")", ")", "return", ";", "int", "x", "=", "screenPosition", ".", "x", "(", ")", ";...
Renders all the text based on its set position. @param renderer the renderer
[ "Renders", "all", "the", "text", "based", "on", "its", "set", "position", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/text/GuiText.java#L484-L500
2,763
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/modmessage/ModMessageManager.java
ModMessageManager.register
public static void register(IMalisisMod mod, Object messageHandler) { register(mod, messageHandler.getClass(), messageHandler); }
java
public static void register(IMalisisMod mod, Object messageHandler) { register(mod, messageHandler.getClass(), messageHandler); }
[ "public", "static", "void", "register", "(", "IMalisisMod", "mod", ",", "Object", "messageHandler", ")", "{", "register", "(", "mod", ",", "messageHandler", ".", "getClass", "(", ")", ",", "messageHandler", ")", ";", "}" ]
Registers an object to handle mod messages. @param mod the mod @param messageHandler the message handler
[ "Registers", "an", "object", "to", "handle", "mod", "messages", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/modmessage/ModMessageManager.java#L70-L73
2,764
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/modmessage/ModMessageManager.java
ModMessageManager.message
@SuppressWarnings("unchecked") public static <T> T message(String modid, String messageName, Object... data) { //do not print warnings if mod is not loaded if (!Loader.isModLoaded(modid)) return null; Collection<Pair<Object, Method>> messageList = messages.get(modid + ":" + messageName); if (messageList.size() == 0) { MalisisCore.log.warn("No message handler matching the parameters passed for {}", modid + ":" + messageName); return null; } for (Pair<Object, Method> message : messageList) { if (checkParameters(message.getRight(), data)) { try { return (T) message.getRight().invoke(message.getLeft(), data); } catch (ReflectiveOperationException e) { MalisisCore.log.warn("An error happened processing the message :", e); } } } return null; }
java
@SuppressWarnings("unchecked") public static <T> T message(String modid, String messageName, Object... data) { //do not print warnings if mod is not loaded if (!Loader.isModLoaded(modid)) return null; Collection<Pair<Object, Method>> messageList = messages.get(modid + ":" + messageName); if (messageList.size() == 0) { MalisisCore.log.warn("No message handler matching the parameters passed for {}", modid + ":" + messageName); return null; } for (Pair<Object, Method> message : messageList) { if (checkParameters(message.getRight(), data)) { try { return (T) message.getRight().invoke(message.getLeft(), data); } catch (ReflectiveOperationException e) { MalisisCore.log.warn("An error happened processing the message :", e); } } } return null; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "message", "(", "String", "modid", ",", "String", "messageName", ",", "Object", "...", "data", ")", "{", "//do not print warnings if mod is not loaded", "if", "(", "!", ...
Sends a message to the another mod. @param modid the modid @param messageName the message name @param data the data
[ "Sends", "a", "message", "to", "the", "another", "mod", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/modmessage/ModMessageManager.java#L109-L140
2,765
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/EntityUtils.java
EntityUtils.getEntityRotation
public static int getEntityRotation(Entity entity, boolean sixWays) { if (entity == null) return 6; float pitch = entity.rotationPitch; if (sixWays && pitch < -45) return 4; if (sixWays && pitch > 45) return 5; return (MathHelper.floor(entity.rotationYaw * 4.0F / 360.0F + 0.5D) + 2) & 3; }
java
public static int getEntityRotation(Entity entity, boolean sixWays) { if (entity == null) return 6; float pitch = entity.rotationPitch; if (sixWays && pitch < -45) return 4; if (sixWays && pitch > 45) return 5; return (MathHelper.floor(entity.rotationYaw * 4.0F / 360.0F + 0.5D) + 2) & 3; }
[ "public", "static", "int", "getEntityRotation", "(", "Entity", "entity", ",", "boolean", "sixWays", ")", "{", "if", "(", "entity", "==", "null", ")", "return", "6", ";", "float", "pitch", "=", "entity", ".", "rotationPitch", ";", "if", "(", "sixWays", "&...
Gets the entity rotation based on where it's currently facing. @param entity the entity @param sixWays the six ways @return the entity rotation
[ "Gets", "the", "entity", "rotation", "based", "on", "where", "it", "s", "currently", "facing", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/EntityUtils.java#L180-L192
2,766
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/EntityUtils.java
EntityUtils.getPlayersWatchingChunk
@SuppressWarnings("unchecked") public static List<EntityPlayerMP> getPlayersWatchingChunk(WorldServer world, int x, int z) { if (playersWatchingChunk == null) return new ArrayList<>(); try { PlayerChunkMapEntry entry = world.getPlayerChunkMap().getEntry(x, z); if (entry == null) return Lists.newArrayList(); return (List<EntityPlayerMP>) playersWatchingChunk.get(entry); } catch (ReflectiveOperationException e) { MalisisCore.log.info("Failed to get players watching chunk :", e); return new ArrayList<>(); } }
java
@SuppressWarnings("unchecked") public static List<EntityPlayerMP> getPlayersWatchingChunk(WorldServer world, int x, int z) { if (playersWatchingChunk == null) return new ArrayList<>(); try { PlayerChunkMapEntry entry = world.getPlayerChunkMap().getEntry(x, z); if (entry == null) return Lists.newArrayList(); return (List<EntityPlayerMP>) playersWatchingChunk.get(entry); } catch (ReflectiveOperationException e) { MalisisCore.log.info("Failed to get players watching chunk :", e); return new ArrayList<>(); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "List", "<", "EntityPlayerMP", ">", "getPlayersWatchingChunk", "(", "WorldServer", "world", ",", "int", "x", ",", "int", "z", ")", "{", "if", "(", "playersWatchingChunk", "==", "null", ")"...
Gets the list of players currently watching the chunk at the coordinate. @param world the world @param x the x @param z the z @return the players watching chunk
[ "Gets", "the", "list", "of", "players", "currently", "watching", "the", "chunk", "at", "the", "coordinate", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/EntityUtils.java#L237-L255
2,767
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/EntityUtils.java
EntityUtils.getRenderViewOffset
public static Point getRenderViewOffset(float partialTick) { Entity entity = Minecraft.getMinecraft().getRenderViewEntity(); if (partialTick == 0) return new Point(entity.posX, entity.posY, entity.posZ); double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTick; double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTick; double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTick; return new Point(x, y, z); }
java
public static Point getRenderViewOffset(float partialTick) { Entity entity = Minecraft.getMinecraft().getRenderViewEntity(); if (partialTick == 0) return new Point(entity.posX, entity.posY, entity.posZ); double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTick; double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTick; double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTick; return new Point(x, y, z); }
[ "public", "static", "Point", "getRenderViewOffset", "(", "float", "partialTick", ")", "{", "Entity", "entity", "=", "Minecraft", ".", "getMinecraft", "(", ")", ".", "getRenderViewEntity", "(", ")", ";", "if", "(", "partialTick", "==", "0", ")", "return", "ne...
Gets the render view offset for the current view entity. @param partialTick the partial tick @return the render view offset
[ "Gets", "the", "render", "view", "offset", "for", "the", "current", "view", "entity", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/EntityUtils.java#L263-L273
2,768
Ordinastie/MalisisCore
src/main/java/net/malisis/core/item/MalisisItemBlock.java
MalisisItemBlock.onItemUse
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack itemStack = player.getHeldItem(hand); if (itemStack.isEmpty()) return EnumActionResult.FAIL; if (!player.canPlayerEdit(pos.offset(side), side, itemStack)) return EnumActionResult.FAIL; //first check if the block clicked can be merged with the one in hand IBlockState placedState = checkMerge(itemStack, player, world, pos, side, hitX, hitY, hitZ); BlockPos p = pos; //can't merge, offset the placed position to where the block should be placed in the world if (placedState == null) { p = pos.offset(side); float x = hitX - side.getFrontOffsetX(); float y = hitY - side.getFrontOffsetY(); float z = hitZ - side.getFrontOffsetZ(); //check for merge at the new position too placedState = checkMerge(itemStack, player, world, p, side, x, y, z); } if (placedState == null) return super.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ); //block can be merged Block block = placedState.getBlock(); if (world.checkNoEntityCollision(placedState.getCollisionBoundingBox(world, p)) && world.setBlockState(p, placedState, 3)) { SoundType soundType = block.getSoundType(placedState, world, pos, player); world.playSound(player, pos, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F); itemStack.shrink(1); } return EnumActionResult.SUCCESS; }
java
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack itemStack = player.getHeldItem(hand); if (itemStack.isEmpty()) return EnumActionResult.FAIL; if (!player.canPlayerEdit(pos.offset(side), side, itemStack)) return EnumActionResult.FAIL; //first check if the block clicked can be merged with the one in hand IBlockState placedState = checkMerge(itemStack, player, world, pos, side, hitX, hitY, hitZ); BlockPos p = pos; //can't merge, offset the placed position to where the block should be placed in the world if (placedState == null) { p = pos.offset(side); float x = hitX - side.getFrontOffsetX(); float y = hitY - side.getFrontOffsetY(); float z = hitZ - side.getFrontOffsetZ(); //check for merge at the new position too placedState = checkMerge(itemStack, player, world, p, side, x, y, z); } if (placedState == null) return super.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ); //block can be merged Block block = placedState.getBlock(); if (world.checkNoEntityCollision(placedState.getCollisionBoundingBox(world, p)) && world.setBlockState(p, placedState, 3)) { SoundType soundType = block.getSoundType(placedState, world, pos, player); world.playSound(player, pos, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F); itemStack.shrink(1); } return EnumActionResult.SUCCESS; }
[ "@", "Override", "public", "EnumActionResult", "onItemUse", "(", "EntityPlayer", "player", ",", "World", "world", ",", "BlockPos", "pos", ",", "EnumHand", "hand", ",", "EnumFacing", "side", ",", "float", "hitX", ",", "float", "hitY", ",", "float", "hitZ", ")...
onItemUse needs to be overriden to be able to handle merged blocks and components.
[ "onItemUse", "needs", "to", "be", "overriden", "to", "be", "able", "to", "handle", "merged", "blocks", "and", "components", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/item/MalisisItemBlock.java#L92-L133
2,769
Ordinastie/MalisisCore
src/main/java/net/malisis/core/item/MalisisItemBlock.java
MalisisItemBlock.checkMerge
private IBlockState checkMerge(ItemStack itemStack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { IBlockState state = world.getBlockState(pos); IMergedBlock mergedBlock = getMerged(state); if (mergedBlock == null // || (offset && !mergedBlock.doubleCheckMerge()) || !mergedBlock.canMerge(itemStack, player, world, pos, side)) return null; return mergedBlock.mergeBlock(world, pos, state, itemStack, player, side, hitX, hitY, hitZ); }
java
private IBlockState checkMerge(ItemStack itemStack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { IBlockState state = world.getBlockState(pos); IMergedBlock mergedBlock = getMerged(state); if (mergedBlock == null // || (offset && !mergedBlock.doubleCheckMerge()) || !mergedBlock.canMerge(itemStack, player, world, pos, side)) return null; return mergedBlock.mergeBlock(world, pos, state, itemStack, player, side, hitX, hitY, hitZ); }
[ "private", "IBlockState", "checkMerge", "(", "ItemStack", "itemStack", ",", "EntityPlayer", "player", ",", "World", "world", ",", "BlockPos", "pos", ",", "EnumFacing", "side", ",", "float", "hitX", ",", "float", "hitY", ",", "float", "hitZ", ")", "{", "IBloc...
Checks whether the block can be merged with the one already in the world. @param itemStack the item stack @param player the player @param world the world @param pos the pos @param side the side @param hitX the hit X @param hitY the hit Y @param hitZ the hit Z @return the i block state
[ "Checks", "whether", "the", "block", "can", "be", "merged", "with", "the", "one", "already", "in", "the", "world", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/item/MalisisItemBlock.java#L183-L192
2,770
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/animation/transformation/Scale.java
Scale.from
protected Scale from(float x, float y, float z) { fromX = x; fromY = y; fromZ = z; return this; }
java
protected Scale from(float x, float y, float z) { fromX = x; fromY = y; fromZ = z; return this; }
[ "protected", "Scale", "from", "(", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "fromX", "=", "x", ";", "fromY", "=", "y", ";", "fromZ", "=", "z", ";", "return", "this", ";", "}" ]
Sets the starting scale. @param x the x @param y the y @param z the z @return the scale
[ "Sets", "the", "starting", "scale", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/animation/transformation/Scale.java#L89-L95
2,771
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/animation/transformation/Scale.java
Scale.to
protected Scale to(float x, float y, float z) { toX = x; toY = y; toZ = z; return this; }
java
protected Scale to(float x, float y, float z) { toX = x; toY = y; toZ = z; return this; }
[ "protected", "Scale", "to", "(", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "toX", "=", "x", ";", "toY", "=", "y", ";", "toZ", "=", "z", ";", "return", "this", ";", "}" ]
Sets the target scale. @param x the x @param y the y @param z the z @return the scale
[ "Sets", "the", "target", "scale", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/animation/transformation/Scale.java#L105-L111
2,772
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/animation/transformation/Scale.java
Scale.offset
public Scale offset(float x, float y, float z) { offsetX = x; offsetY = y; offsetZ = z; return this; }
java
public Scale offset(float x, float y, float z) { offsetX = x; offsetY = y; offsetZ = z; return this; }
[ "public", "Scale", "offset", "(", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "offsetX", "=", "x", ";", "offsetY", "=", "y", ";", "offsetZ", "=", "z", ";", "return", "this", ";", "}" ]
Sets the offset for the scaling. @param x the x @param y the y @param z the z @return the scale
[ "Sets", "the", "offset", "for", "the", "scaling", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/animation/transformation/Scale.java#L121-L127
2,773
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/animation/transformation/Scale.java
Scale.doTransform
@Override protected void doTransform(ITransformable.Scale transformable, float comp) { float fromX = reversed ? this.toX : this.fromX; float toX = reversed ? this.fromX : this.toX; float fromY = reversed ? this.toY : this.fromY; float toY = reversed ? this.fromY : this.toY; float fromZ = reversed ? this.toZ : this.fromZ; float toZ = reversed ? this.fromZ : this.toZ; transformable.scale(fromX + (toX - fromX) * comp, fromY + (toY - fromY) * comp, fromZ + (toZ - fromZ) * comp, offsetX, offsetY, offsetZ); }
java
@Override protected void doTransform(ITransformable.Scale transformable, float comp) { float fromX = reversed ? this.toX : this.fromX; float toX = reversed ? this.fromX : this.toX; float fromY = reversed ? this.toY : this.fromY; float toY = reversed ? this.fromY : this.toY; float fromZ = reversed ? this.toZ : this.fromZ; float toZ = reversed ? this.fromZ : this.toZ; transformable.scale(fromX + (toX - fromX) * comp, fromY + (toY - fromY) * comp, fromZ + (toZ - fromZ) * comp, offsetX, offsetY, offsetZ); }
[ "@", "Override", "protected", "void", "doTransform", "(", "ITransformable", ".", "Scale", "transformable", ",", "float", "comp", ")", "{", "float", "fromX", "=", "reversed", "?", "this", ".", "toX", ":", "this", ".", "fromX", ";", "float", "toX", "=", "r...
Calculate the transformation. @param transformable the transformable @param comp the comp
[ "Calculate", "the", "transformation", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/animation/transformation/Scale.java#L135-L147
2,774
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/blockdata/BlockDataHandler.java
BlockDataHandler.onDataSave
@SubscribeEvent public void onDataSave(ChunkDataEvent.Save event) { NBTTagCompound nbt = event.getData(); for (HandlerInfo<?> handlerInfo : handlerInfos.values()) { ChunkData<?> chunkData = chunkData(handlerInfo.identifier, event.getWorld(), event.getChunk()); if (chunkData != null && chunkData.hasData()) { // MalisisCore.message("onDataSave (" + event.getChunk().xPosition + "/" + event.getChunk().zPosition + ") for " // + handlerInfo.identifier); ByteBuf buf = Unpooled.buffer(); chunkData.toBytes(buf); nbt.setByteArray(handlerInfo.identifier, buf.capacity(buf.writerIndex()).array()); } //unload data on save because saving is called after unload if (event.getChunk().unloadQueued) datas.get().remove(handlerInfo.identifier, event.getChunk()); } }
java
@SubscribeEvent public void onDataSave(ChunkDataEvent.Save event) { NBTTagCompound nbt = event.getData(); for (HandlerInfo<?> handlerInfo : handlerInfos.values()) { ChunkData<?> chunkData = chunkData(handlerInfo.identifier, event.getWorld(), event.getChunk()); if (chunkData != null && chunkData.hasData()) { // MalisisCore.message("onDataSave (" + event.getChunk().xPosition + "/" + event.getChunk().zPosition + ") for " // + handlerInfo.identifier); ByteBuf buf = Unpooled.buffer(); chunkData.toBytes(buf); nbt.setByteArray(handlerInfo.identifier, buf.capacity(buf.writerIndex()).array()); } //unload data on save because saving is called after unload if (event.getChunk().unloadQueued) datas.get().remove(handlerInfo.identifier, event.getChunk()); } }
[ "@", "SubscribeEvent", "public", "void", "onDataSave", "(", "ChunkDataEvent", ".", "Save", "event", ")", "{", "NBTTagCompound", "nbt", "=", "event", ".", "getData", "(", ")", ";", "for", "(", "HandlerInfo", "<", "?", ">", "handlerInfo", ":", "handlerInfos", ...
On data save. @param event the event
[ "On", "data", "save", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/blockdata/BlockDataHandler.java#L205-L227
2,775
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/blockdata/BlockDataHandler.java
BlockDataHandler.registerBlockData
public static <T> void registerBlockData(String identifier, Function<ByteBuf, T> fromBytes, Function<T, ByteBuf> toBytes) { instance.handlerInfos.put(identifier, new HandlerInfo<>(identifier, fromBytes, toBytes)); }
java
public static <T> void registerBlockData(String identifier, Function<ByteBuf, T> fromBytes, Function<T, ByteBuf> toBytes) { instance.handlerInfos.put(identifier, new HandlerInfo<>(identifier, fromBytes, toBytes)); }
[ "public", "static", "<", "T", ">", "void", "registerBlockData", "(", "String", "identifier", ",", "Function", "<", "ByteBuf", ",", "T", ">", "fromBytes", ",", "Function", "<", "T", ",", "ByteBuf", ">", "toBytes", ")", "{", "instance", ".", "handlerInfos", ...
Registers a custom block data with the specified identifier. @param <T> the generic type @param identifier the identifier @param fromBytes the from bytes @param toBytes the to bytes
[ "Registers", "a", "custom", "block", "data", "with", "the", "specified", "identifier", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/blockdata/BlockDataHandler.java#L276-L279
2,776
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/blockdata/BlockDataHandler.java
BlockDataHandler.setBlockData
static void setBlockData(int chunkX, int chunkZ, String identifier, ByteBuf data) { HandlerInfo<?> handlerInfo = instance.handlerInfos.get(identifier); if (handlerInfo == null) return; //MalisisCore.message("Received blockData (" + chunkX + "/" + chunkZ + ") for " + identifier); Chunk chunk = Utils.getClientWorld().getChunkFromChunkCoords(chunkX, chunkZ); ChunkData<?> chunkData = new ChunkData<>(handlerInfo).fromBytes(data); datas.get().put(handlerInfo.identifier, chunk, chunkData); }
java
static void setBlockData(int chunkX, int chunkZ, String identifier, ByteBuf data) { HandlerInfo<?> handlerInfo = instance.handlerInfos.get(identifier); if (handlerInfo == null) return; //MalisisCore.message("Received blockData (" + chunkX + "/" + chunkZ + ") for " + identifier); Chunk chunk = Utils.getClientWorld().getChunkFromChunkCoords(chunkX, chunkZ); ChunkData<?> chunkData = new ChunkData<>(handlerInfo).fromBytes(data); datas.get().put(handlerInfo.identifier, chunk, chunkData); }
[ "static", "void", "setBlockData", "(", "int", "chunkX", ",", "int", "chunkZ", ",", "String", "identifier", ",", "ByteBuf", "data", ")", "{", "HandlerInfo", "<", "?", ">", "handlerInfo", "=", "instance", ".", "handlerInfos", ".", "get", "(", "identifier", "...
Called on the client when receiving the data from the server, either because client started to watch the chunk or server manually sent the data. @param chunkX the chunk X @param chunkZ the chunk Z @param identifier the identifier @param data the data
[ "Called", "on", "the", "client", "when", "receiving", "the", "data", "from", "the", "server", "either", "because", "client", "started", "to", "watch", "the", "chunk", "or", "server", "manually", "sent", "the", "data", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/blockdata/BlockDataHandler.java#L375-L385
2,777
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java
GuiRenderer.setup
public void setup(float partialTick) { this.partialTick = partialTick; currentTexture = null; bindDefaultTexture(); GlStateManager.pushMatrix(); if (ignoreScale) { GlStateManager.scale(1F / scaleFactor, 1F / scaleFactor, 1); } setupGl(); startDrawing(); }
java
public void setup(float partialTick) { this.partialTick = partialTick; currentTexture = null; bindDefaultTexture(); GlStateManager.pushMatrix(); if (ignoreScale) { GlStateManager.scale(1F / scaleFactor, 1F / scaleFactor, 1); } setupGl(); startDrawing(); }
[ "public", "void", "setup", "(", "float", "partialTick", ")", "{", "this", ".", "partialTick", "=", "partialTick", ";", "currentTexture", "=", "null", ";", "bindDefaultTexture", "(", ")", ";", "GlStateManager", ".", "pushMatrix", "(", ")", ";", "if", "(", "...
Sets up the rendering and start drawing. @param partialTick the partial ticks
[ "Sets", "up", "the", "rendering", "and", "start", "drawing", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java#L162-L177
2,778
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java
GuiRenderer.enableBlending
public void enableBlending() { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.0F); GlStateManager.shadeModel(GL11.GL_SMOOTH); GlStateManager.enableColorMaterial(); }
java
public void enableBlending() { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.0F); GlStateManager.shadeModel(GL11.GL_SMOOTH); GlStateManager.enableColorMaterial(); }
[ "public", "void", "enableBlending", "(", ")", "{", "GlStateManager", ".", "enableBlend", "(", ")", ";", "GlStateManager", ".", "tryBlendFuncSeparate", "(", "GL11", ".", "GL_SRC_ALPHA", ",", "GL11", ".", "GL_ONE_MINUS_SRC_ALPHA", ",", "GL11", ".", "GL_ONE", ",", ...
Enables the blending for the rendering.
[ "Enables", "the", "blending", "for", "the", "rendering", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java#L261-L268
2,779
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java
GuiRenderer.bindTexture
public void bindTexture(GuiTexture texture) { //no change needed if (texture == currentTexture) return; next(); Minecraft.getMinecraft().getTextureManager().bindTexture(texture.getResourceLocation()); //System.out.println(currentComponent + " // Bound " + texture.getResourceLocation()); currentTexture = texture; }
java
public void bindTexture(GuiTexture texture) { //no change needed if (texture == currentTexture) return; next(); Minecraft.getMinecraft().getTextureManager().bindTexture(texture.getResourceLocation()); //System.out.println(currentComponent + " // Bound " + texture.getResourceLocation()); currentTexture = texture; }
[ "public", "void", "bindTexture", "(", "GuiTexture", "texture", ")", "{", "//no change needed", "if", "(", "texture", "==", "currentTexture", ")", "return", ";", "next", "(", ")", ";", "Minecraft", ".", "getMinecraft", "(", ")", ".", "getTextureManager", "(", ...
Bind a new texture for rendering. @param texture the texture
[ "Bind", "a", "new", "texture", "for", "rendering", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java#L275-L286
2,780
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java
GuiRenderer.drawItemStack
public void drawItemStack(ItemStack itemStack, int x, int y) { drawItemStack(itemStack, x, y, null, null, true); }
java
public void drawItemStack(ItemStack itemStack, int x, int y) { drawItemStack(itemStack, x, y, null, null, true); }
[ "public", "void", "drawItemStack", "(", "ItemStack", "itemStack", ",", "int", "x", ",", "int", "y", ")", "{", "drawItemStack", "(", "itemStack", ",", "x", ",", "y", ",", "null", ",", "null", ",", "true", ")", ";", "}" ]
Draws an itemStack to the GUI at the specified coordinates. @param itemStack the item stack @param x the x @param y the y
[ "Draws", "an", "itemStack", "to", "the", "GUI", "at", "the", "specified", "coordinates", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java#L372-L375
2,781
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java
GuiRenderer.drawItemStack
public void drawItemStack(ItemStack itemStack, int x, int y, Style format) { drawItemStack(itemStack, x, y, null, format, true); }
java
public void drawItemStack(ItemStack itemStack, int x, int y, Style format) { drawItemStack(itemStack, x, y, null, format, true); }
[ "public", "void", "drawItemStack", "(", "ItemStack", "itemStack", ",", "int", "x", ",", "int", "y", ",", "Style", "format", ")", "{", "drawItemStack", "(", "itemStack", ",", "x", ",", "y", ",", "null", ",", "format", ",", "true", ")", ";", "}" ]
Draws an itemStack to the GUI at the specified coordinates with a custom format for the label. @param itemStack the item stack @param x the x @param y the y @param format the format
[ "Draws", "an", "itemStack", "to", "the", "GUI", "at", "the", "specified", "coordinates", "with", "a", "custom", "format", "for", "the", "label", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java#L385-L388
2,782
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java
GuiRenderer.drawItemStack
public void drawItemStack(ItemStack itemStack, int x, int y, String label) { drawItemStack(itemStack, x, y, label, null, true); }
java
public void drawItemStack(ItemStack itemStack, int x, int y, String label) { drawItemStack(itemStack, x, y, label, null, true); }
[ "public", "void", "drawItemStack", "(", "ItemStack", "itemStack", ",", "int", "x", ",", "int", "y", ",", "String", "label", ")", "{", "drawItemStack", "(", "itemStack", ",", "x", ",", "y", ",", "label", ",", "null", ",", "true", ")", ";", "}" ]
Draws an itemStack to the GUI at the specified coordinates with a custom label. @param itemStack the item stack @param x the x @param y the y @param label the label
[ "Draws", "an", "itemStack", "to", "the", "GUI", "at", "the", "specified", "coordinates", "with", "a", "custom", "label", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java#L398-L401
2,783
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java
GuiRenderer.renderPickedItemStack
public boolean renderPickedItemStack(ItemStack itemStack) { if (itemStack == null || itemStack == ItemStack.EMPTY) return false; int size = itemStack.getCount(); String label = null; if (size == 0) { itemStack.setCount(size != 0 ? size : 1); label = TextFormatting.YELLOW + "0"; } itemRenderer.zLevel = 100; drawItemStack(itemStack, MalisisGui.MOUSE_POSITION.x() - 8, MalisisGui.MOUSE_POSITION.y() - 8, label, null, false); itemRenderer.zLevel = 0; return true; }
java
public boolean renderPickedItemStack(ItemStack itemStack) { if (itemStack == null || itemStack == ItemStack.EMPTY) return false; int size = itemStack.getCount(); String label = null; if (size == 0) { itemStack.setCount(size != 0 ? size : 1); label = TextFormatting.YELLOW + "0"; } itemRenderer.zLevel = 100; drawItemStack(itemStack, MalisisGui.MOUSE_POSITION.x() - 8, MalisisGui.MOUSE_POSITION.y() - 8, label, null, false); itemRenderer.zLevel = 0; return true; }
[ "public", "boolean", "renderPickedItemStack", "(", "ItemStack", "itemStack", ")", "{", "if", "(", "itemStack", "==", "null", "||", "itemStack", "==", "ItemStack", ".", "EMPTY", ")", "return", "false", ";", "int", "size", "=", "itemStack", ".", "getCount", "(...
Render the picked up itemStack at the cursor position. @param itemStack the item stack
[ "Render", "the", "picked", "up", "itemStack", "at", "the", "cursor", "position", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java#L463-L480
2,784
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java
GuiRenderer.startClipping
public void startClipping(ClipArea area) { if (area.noClip()) return; GL11.glPushAttrib(GL11.GL_SCISSOR_BIT); GL11.glEnable(GL11.GL_SCISSOR_TEST); int f = ignoreScale ? 1 : scaleFactor; int x = area.x * f; int y = Minecraft.getMinecraft().displayHeight - (area.y + area.height()) * f; int w = area.width() * f; int h = area.height() * f;; GL11.glScissor(x, y, w, h); }
java
public void startClipping(ClipArea area) { if (area.noClip()) return; GL11.glPushAttrib(GL11.GL_SCISSOR_BIT); GL11.glEnable(GL11.GL_SCISSOR_TEST); int f = ignoreScale ? 1 : scaleFactor; int x = area.x * f; int y = Minecraft.getMinecraft().displayHeight - (area.y + area.height()) * f; int w = area.width() * f; int h = area.height() * f;; GL11.glScissor(x, y, w, h); }
[ "public", "void", "startClipping", "(", "ClipArea", "area", ")", "{", "if", "(", "area", ".", "noClip", "(", ")", ")", "return", ";", "GL11", ".", "glPushAttrib", "(", "GL11", ".", "GL_SCISSOR_BIT", ")", ";", "GL11", ".", "glEnable", "(", "GL11", ".", ...
Starts clipping an area to prevent drawing outside of it. @param area the area
[ "Starts", "clipping", "an", "area", "to", "prevent", "drawing", "outside", "of", "it", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java#L487-L501
2,785
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java
GuiRenderer.endClipping
public void endClipping(ClipArea area) { if (area.noClip()) return; next(); GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glPopAttrib(); }
java
public void endClipping(ClipArea area) { if (area.noClip()) return; next(); GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glPopAttrib(); }
[ "public", "void", "endClipping", "(", "ClipArea", "area", ")", "{", "if", "(", "area", ".", "noClip", "(", ")", ")", "return", ";", "next", "(", ")", ";", "GL11", ".", "glDisable", "(", "GL11", ".", "GL_SCISSOR_TEST", ")", ";", "GL11", ".", "glPopAtt...
Ends the clipping. @param area the area
[ "Ends", "the", "clipping", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/render/GuiRenderer.java#L508-L516
2,786
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/component/AnimatedModelComponent.java
AnimatedModelComponent.render
@Override public void render(Block block, MalisisRenderer<? extends TileEntity> renderer) { if (renderer.getRenderType() == RenderType.BLOCK && animatedShapes.size() != 0) onRender(renderer.getWorldAccess(), renderer.getPos(), renderer.getBlockState()); model.resetState(); if (renderer.getRenderType() == RenderType.BLOCK) model.rotate(DirectionalComponent.getDirection(renderer.getBlockState())); staticShapes.forEach(name -> model.render(renderer, name, rp)); if (renderer.getRenderType() == RenderType.ITEM) animatedShapes.forEach(name -> model.render(renderer, name, rp)); }
java
@Override public void render(Block block, MalisisRenderer<? extends TileEntity> renderer) { if (renderer.getRenderType() == RenderType.BLOCK && animatedShapes.size() != 0) onRender(renderer.getWorldAccess(), renderer.getPos(), renderer.getBlockState()); model.resetState(); if (renderer.getRenderType() == RenderType.BLOCK) model.rotate(DirectionalComponent.getDirection(renderer.getBlockState())); staticShapes.forEach(name -> model.render(renderer, name, rp)); if (renderer.getRenderType() == RenderType.ITEM) animatedShapes.forEach(name -> model.render(renderer, name, rp)); }
[ "@", "Override", "public", "void", "render", "(", "Block", "block", ",", "MalisisRenderer", "<", "?", "extends", "TileEntity", ">", "renderer", ")", "{", "if", "(", "renderer", ".", "getRenderType", "(", ")", "==", "RenderType", ".", "BLOCK", "&&", "animat...
Only called for BLOCK and ITEM render type
[ "Only", "called", "for", "BLOCK", "and", "ITEM", "render", "type" ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/component/AnimatedModelComponent.java#L267-L280
2,787
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/floodfill/FloodFill.java
FloodFill.process
public boolean process() { if (toProcess.size() <= 0) return false; BlockPos pos = toProcess.removeFirst(); process(pos); if (onProcess != null) onProcess.accept(world, pos); return true; }
java
public boolean process() { if (toProcess.size() <= 0) return false; BlockPos pos = toProcess.removeFirst(); process(pos); if (onProcess != null) onProcess.accept(world, pos); return true; }
[ "public", "boolean", "process", "(", ")", "{", "if", "(", "toProcess", ".", "size", "(", ")", "<=", "0", ")", "return", "false", ";", "BlockPos", "pos", "=", "toProcess", ".", "removeFirst", "(", ")", ";", "process", "(", "pos", ")", ";", "if", "("...
Processes a single position. @return true, if there are more position to process
[ "Processes", "a", "single", "position", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/floodfill/FloodFill.java#L168-L179
2,788
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/floodfill/FloodFill.java
FloodFill.shouldProcessed
protected boolean shouldProcessed(BlockPos pos) { if (toProcess.contains(pos) || processed.contains(pos)) return false; return shouldProcess == null || shouldProcess.test(world, pos); }
java
protected boolean shouldProcessed(BlockPos pos) { if (toProcess.contains(pos) || processed.contains(pos)) return false; return shouldProcess == null || shouldProcess.test(world, pos); }
[ "protected", "boolean", "shouldProcessed", "(", "BlockPos", "pos", ")", "{", "if", "(", "toProcess", ".", "contains", "(", "pos", ")", "||", "processed", ".", "contains", "(", "pos", ")", ")", "return", "false", ";", "return", "shouldProcess", "==", "null"...
Checks whether the position should be processed. @param pos the pos @return true, if successful
[ "Checks", "whether", "the", "position", "should", "be", "processed", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/floodfill/FloodFill.java#L187-L193
2,789
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/floodfill/FloodFill.java
FloodFill.process
protected void process(BlockPos pos) { for (EnumFacing dir : searchDirs) { BlockPos newPos = pos.offset(dir); if (!processed.contains(newPos) && shouldProcessed(newPos)) toProcess.add(newPos); } processed.add(pos); if (processed.size() >= countLimit) toProcess.clear(); }
java
protected void process(BlockPos pos) { for (EnumFacing dir : searchDirs) { BlockPos newPos = pos.offset(dir); if (!processed.contains(newPos) && shouldProcessed(newPos)) toProcess.add(newPos); } processed.add(pos); if (processed.size() >= countLimit) toProcess.clear(); }
[ "protected", "void", "process", "(", "BlockPos", "pos", ")", "{", "for", "(", "EnumFacing", "dir", ":", "searchDirs", ")", "{", "BlockPos", "newPos", "=", "pos", ".", "offset", "(", "dir", ")", ";", "if", "(", "!", "processed", ".", "contains", "(", ...
Processes the position. @param pos the pos
[ "Processes", "the", "position", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/floodfill/FloodFill.java#L200-L211
2,790
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/Utils.java
Utils.getClientWorld
@SideOnly(Side.CLIENT) public static World getClientWorld() { return Minecraft.getMinecraft() != null ? Minecraft.getMinecraft().world : null; }
java
@SideOnly(Side.CLIENT) public static World getClientWorld() { return Minecraft.getMinecraft() != null ? Minecraft.getMinecraft().world : null; }
[ "@", "SideOnly", "(", "Side", ".", "CLIENT", ")", "public", "static", "World", "getClientWorld", "(", ")", "{", "return", "Minecraft", ".", "getMinecraft", "(", ")", "!=", "null", "?", "Minecraft", ".", "getMinecraft", "(", ")", ".", "world", ":", "null"...
Gets the client world. @return the client world
[ "Gets", "the", "client", "world", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/Utils.java#L82-L86
2,791
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/Utils.java
Utils.getClientPlayer
@SideOnly(Side.CLIENT) public static EntityPlayer getClientPlayer() { return Minecraft.getMinecraft() != null ? Minecraft.getMinecraft().player : null; }
java
@SideOnly(Side.CLIENT) public static EntityPlayer getClientPlayer() { return Minecraft.getMinecraft() != null ? Minecraft.getMinecraft().player : null; }
[ "@", "SideOnly", "(", "Side", ".", "CLIENT", ")", "public", "static", "EntityPlayer", "getClientPlayer", "(", ")", "{", "return", "Minecraft", ".", "getMinecraft", "(", ")", "!=", "null", "?", "Minecraft", ".", "getMinecraft", "(", ")", ".", "player", ":",...
Gets the client player. @return the client player
[ "Gets", "the", "client", "player", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/Utils.java#L93-L97
2,792
Ordinastie/MalisisCore
src/main/java/net/malisis/core/block/component/WallComponent.java
WallComponent.canMerge
@Override public boolean canMerge(ItemStack itemStack, EntityPlayer player, World world, BlockPos pos, EnumFacing side) { IBlockState state = world.getBlockState(pos); if (isCorner(state)) return false; return EnumFacingUtils.getRealSide(state, side) != EnumFacing.NORTH; }
java
@Override public boolean canMerge(ItemStack itemStack, EntityPlayer player, World world, BlockPos pos, EnumFacing side) { IBlockState state = world.getBlockState(pos); if (isCorner(state)) return false; return EnumFacingUtils.getRealSide(state, side) != EnumFacing.NORTH; }
[ "@", "Override", "public", "boolean", "canMerge", "(", "ItemStack", "itemStack", ",", "EntityPlayer", "player", ",", "World", "world", ",", "BlockPos", "pos", ",", "EnumFacing", "side", ")", "{", "IBlockState", "state", "=", "world", ".", "getBlockState", "(",...
Checks whether the block can be merged into a corner. @param itemStack the item stack @param player the player @param world the world @param pos the pos @param side the side @return true, if successful
[ "Checks", "whether", "the", "block", "can", "be", "merged", "into", "a", "corner", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/block/component/WallComponent.java#L107-L115
2,793
Ordinastie/MalisisCore
src/main/java/net/malisis/core/block/component/WallComponent.java
WallComponent.getBoundingBoxes
@Override public AxisAlignedBB[] getBoundingBoxes(Block block, IBlockAccess world, BlockPos pos, IBlockState state, BoundingBoxType type) { boolean corner = isCorner(state); if (type == BoundingBoxType.SELECTION && corner) return AABBUtils.identities(); AxisAlignedBB aabb = new AxisAlignedBB(0, 0, 0, 1, 1, 3 / 16F); if (world == null) aabb = AABBUtils.rotate(aabb.offset(0, 0, 0.5F), -1); if (!corner) return new AxisAlignedBB[] { aabb }; return new AxisAlignedBB[] { aabb, AABBUtils.rotate(aabb, -1) }; }
java
@Override public AxisAlignedBB[] getBoundingBoxes(Block block, IBlockAccess world, BlockPos pos, IBlockState state, BoundingBoxType type) { boolean corner = isCorner(state); if (type == BoundingBoxType.SELECTION && corner) return AABBUtils.identities(); AxisAlignedBB aabb = new AxisAlignedBB(0, 0, 0, 1, 1, 3 / 16F); if (world == null) aabb = AABBUtils.rotate(aabb.offset(0, 0, 0.5F), -1); if (!corner) return new AxisAlignedBB[] { aabb }; return new AxisAlignedBB[] { aabb, AABBUtils.rotate(aabb, -1) }; }
[ "@", "Override", "public", "AxisAlignedBB", "[", "]", "getBoundingBoxes", "(", "Block", "block", ",", "IBlockAccess", "world", ",", "BlockPos", "pos", ",", "IBlockState", "state", ",", "BoundingBoxType", "type", ")", "{", "boolean", "corner", "=", "isCorner", ...
Gets the bounding boxes for the block. @param block the block @param world the world @param pos the pos @param type the type @return the bounding boxes
[ "Gets", "the", "bounding", "boxes", "for", "the", "block", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/block/component/WallComponent.java#L207-L222
2,794
Ordinastie/MalisisCore
src/main/java/net/malisis/core/configuration/setting/Setting.java
Setting.load
public void load(Configuration config) { String comment = ""; for (String c : comments) { if (MalisisCore.isClient()) comment += I18n.format(c) + " "; else comment += c + " "; } property = config.get(category, key, writeValue(defaultValue), comment, type); value = readValue(property.getString()); if (value == null) throw new NullPointerException("readPropertyValue should not return null!"); }
java
public void load(Configuration config) { String comment = ""; for (String c : comments) { if (MalisisCore.isClient()) comment += I18n.format(c) + " "; else comment += c + " "; } property = config.get(category, key, writeValue(defaultValue), comment, type); value = readValue(property.getString()); if (value == null) throw new NullPointerException("readPropertyValue should not return null!"); }
[ "public", "void", "load", "(", "Configuration", "config", ")", "{", "String", "comment", "=", "\"\"", ";", "for", "(", "String", "c", ":", "comments", ")", "{", "if", "(", "MalisisCore", ".", "isClient", "(", ")", ")", "comment", "+=", "I18n", ".", "...
Loads the configuration. @param config the config
[ "Loads", "the", "configuration", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/configuration/setting/Setting.java#L111-L126
2,795
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/syncer/Syncer.java
Syncer.getFieldIndexes
private int getFieldIndexes(ISyncHandler<?, ? extends ISyncableData> handler, String... syncNames) { int indexes = 0; for (String str : syncNames) { ObjectData od = handler.getObjectData(str); if (od != null) indexes |= 1 << od.getIndex(); } return indexes; }
java
private int getFieldIndexes(ISyncHandler<?, ? extends ISyncableData> handler, String... syncNames) { int indexes = 0; for (String str : syncNames) { ObjectData od = handler.getObjectData(str); if (od != null) indexes |= 1 << od.getIndex(); } return indexes; }
[ "private", "int", "getFieldIndexes", "(", "ISyncHandler", "<", "?", ",", "?", "extends", "ISyncableData", ">", "handler", ",", "String", "...", "syncNames", ")", "{", "int", "indexes", "=", "0", ";", "for", "(", "String", "str", ":", "syncNames", ")", "{...
Gets the indexes of the sync fields into a single integer. @param handler the handler @param syncNames the sync names @return the field indexes
[ "Gets", "the", "indexes", "of", "the", "sync", "fields", "into", "a", "single", "integer", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/syncer/Syncer.java#L253-L263
2,796
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/syncer/Syncer.java
Syncer.getFieldValues
private Map<String, Object> getFieldValues(Object caller, ISyncHandler<?, ? extends ISyncableData> handler, String... syncNames) { Map<String, Object> values = new LinkedHashMap<>(); for (String str : syncNames) { ObjectData od = handler.getObjectData(str); if (od != null) values.put(str, od.get(caller)); } return values; }
java
private Map<String, Object> getFieldValues(Object caller, ISyncHandler<?, ? extends ISyncableData> handler, String... syncNames) { Map<String, Object> values = new LinkedHashMap<>(); for (String str : syncNames) { ObjectData od = handler.getObjectData(str); if (od != null) values.put(str, od.get(caller)); } return values; }
[ "private", "Map", "<", "String", ",", "Object", ">", "getFieldValues", "(", "Object", "caller", ",", "ISyncHandler", "<", "?", ",", "?", "extends", "ISyncableData", ">", "handler", ",", "String", "...", "syncNames", ")", "{", "Map", "<", "String", ",", "...
Gets the field values for the specified names. @param caller the caller @param handler the handler @param syncNames the sync names @return the field values
[ "Gets", "the", "field", "values", "for", "the", "specified", "names", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/syncer/Syncer.java#L273-L284
2,797
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/syncer/Syncer.java
Syncer.doSync
private <T, S extends ISyncableData> void doSync(T caller, String... syncNames) { @SuppressWarnings("unchecked") ISyncHandler<T, S> handler = (ISyncHandler<T, S>) getHandler(caller); if (handler == null) return; S data = handler.getSyncData(caller); int indexes = getFieldIndexes(handler, syncNames); Map<String, Object> values = getFieldValues(caller, handler, syncNames); SyncerMessage.Packet<T, S> packet = new Packet<>(getHandlerId(caller.getClass()), data, indexes, values); handler.send(caller, packet); }
java
private <T, S extends ISyncableData> void doSync(T caller, String... syncNames) { @SuppressWarnings("unchecked") ISyncHandler<T, S> handler = (ISyncHandler<T, S>) getHandler(caller); if (handler == null) return; S data = handler.getSyncData(caller); int indexes = getFieldIndexes(handler, syncNames); Map<String, Object> values = getFieldValues(caller, handler, syncNames); SyncerMessage.Packet<T, S> packet = new Packet<>(getHandlerId(caller.getClass()), data, indexes, values); handler.send(caller, packet); }
[ "private", "<", "T", ",", "S", "extends", "ISyncableData", ">", "void", "doSync", "(", "T", "caller", ",", "String", "...", "syncNames", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "ISyncHandler", "<", "T", ",", "S", ">", "handler", "="...
Synchronizes the specified fields names and sends the corresponding packet. @param <T> the type of the caller @param caller the caller @param syncNames the sync names
[ "Synchronizes", "the", "specified", "fields", "names", "and", "sends", "the", "corresponding", "packet", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/syncer/Syncer.java#L293-L307
2,798
Ordinastie/MalisisCore
src/main/java/net/malisis/core/util/syncer/Syncer.java
Syncer.updateValues
public <T> void updateValues(T receiver, ISyncHandler<T, ? extends ISyncableData> handler, Map<String, Object> values) { if (receiver == null || handler == null) return; for (Entry<String, Object> entry : values.entrySet()) { ObjectData od = handler.getObjectData(entry.getKey()); if (od != null) od.set(receiver, entry.getValue()); } }
java
public <T> void updateValues(T receiver, ISyncHandler<T, ? extends ISyncableData> handler, Map<String, Object> values) { if (receiver == null || handler == null) return; for (Entry<String, Object> entry : values.entrySet()) { ObjectData od = handler.getObjectData(entry.getKey()); if (od != null) od.set(receiver, entry.getValue()); } }
[ "public", "<", "T", ">", "void", "updateValues", "(", "T", "receiver", ",", "ISyncHandler", "<", "T", ",", "?", "extends", "ISyncableData", ">", "handler", ",", "Map", "<", "String", ",", "Object", ">", "values", ")", "{", "if", "(", "receiver", "==", ...
Update the fields values for the receiver object. @param receiver the caller @param handler the handler @param values the values
[ "Update", "the", "fields", "values", "for", "the", "receiver", "object", "." ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/syncer/Syncer.java#L324-L335
2,799
Ordinastie/MalisisCore
src/main/java/net/malisis/core/asm/mixin/core/client/MixinTextureMap.java
MixinTextureMap.onLoadTextureAtlas
@Inject(method = "loadTextureAtlas", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILSOFT) private void onLoadTextureAtlas(IResourceManager resourceManager, CallbackInfo ci, int i, Stitcher stitcher, int j, int k, ProgressManager.ProgressBar bar) { Icon.BLOCK_TEXTURE_WIDTH = stitcher.getCurrentWidth(); Icon.BLOCK_TEXTURE_HEIGHT = stitcher.getCurrentHeight(); }
java
@Inject(method = "loadTextureAtlas", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILSOFT) private void onLoadTextureAtlas(IResourceManager resourceManager, CallbackInfo ci, int i, Stitcher stitcher, int j, int k, ProgressManager.ProgressBar bar) { Icon.BLOCK_TEXTURE_WIDTH = stitcher.getCurrentWidth(); Icon.BLOCK_TEXTURE_HEIGHT = stitcher.getCurrentHeight(); }
[ "@", "Inject", "(", "method", "=", "\"loadTextureAtlas\"", ",", "at", "=", "@", "At", "(", "\"RETURN\"", ")", ",", "locals", "=", "LocalCapture", ".", "CAPTURE_FAILSOFT", ")", "private", "void", "onLoadTextureAtlas", "(", "IResourceManager", "resourceManager", "...
capture atlas size
[ "capture", "atlas", "size" ]
4f8e1fa462d5c372fc23414482ba9f429881cc54
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/asm/mixin/core/client/MixinTextureMap.java#L47-L52