mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Cleanup length and size checks (#10108)
This commit is contained in:
1 parent
44a158a714
commit
eeb3eb3689
11 files changed
+20
-20
No files matched your search
@@ -271,7 +271,7 @@ public class CompositeModel implements IUnbakedGeometry<CompositeModel>
|
||||
{
|
||||
if (!Objects.equals(renderTypes, lastRenderTypes))
|
||||
{
|
||||
if (quads.size() > 0)
|
||||
if (!quads.isEmpty())
|
||||
{
|
||||
addLayer(lastRenderTypes, quads);
|
||||
quads.clear();
|
||||
@@ -302,7 +302,7 @@ public class CompositeModel implements IUnbakedGeometry<CompositeModel>
|
||||
|
||||
public BakedModel build()
|
||||
{
|
||||
if (quads.size() > 0)
|
||||
if (!quads.isEmpty())
|
||||
{
|
||||
addLayer(lastRenderTypes, quads);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class CustomLoaderBuilder<T extends ModelBuilder<T>>
|
||||
{
|
||||
json.addProperty("loader", loaderId.toString());
|
||||
|
||||
if (visibility.size() > 0)
|
||||
if (!visibility.isEmpty())
|
||||
{
|
||||
JsonObject visibilityObj = new JsonObject();
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
|
||||
*/
|
||||
public <L extends CustomLoaderBuilder<T>> L customLoader(BiFunction<T, ExistingFileHelper, L> customLoaderFactory)
|
||||
{
|
||||
Preconditions.checkState(elements.size() == 0, "Cannot use elements and custom loaders at the same time");
|
||||
Preconditions.checkState(elements.isEmpty(), "Cannot use elements and custom loaders at the same time");
|
||||
Preconditions.checkNotNull(customLoaderFactory, "customLoaderFactory must not be null");
|
||||
L customLoader = customLoaderFactory.apply(self(), existingFileHelper);
|
||||
this.customLoader = customLoader;
|
||||
@@ -339,7 +339,7 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
|
||||
|
||||
// If there were any transform properties set, add them to the output.
|
||||
JsonObject transform = rootTransforms.toJson();
|
||||
if (transform.size() > 0)
|
||||
if (!transform.isEmpty())
|
||||
{
|
||||
root.add("transform", transform);
|
||||
}
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockState
|
||||
StringBuilder activeString = new StringBuilder();
|
||||
for (Comparable<?> val : e.getValue())
|
||||
{
|
||||
if (activeString.length() > 0)
|
||||
if (!activeString.isEmpty())
|
||||
activeString.append("|");
|
||||
activeString.append(((Property) e.getKey()).getName(val));
|
||||
}
|
||||
|
||||
+1
-1
@@ -288,7 +288,7 @@ public class VariantBlockStateBuilder implements IGeneratedBlockState
|
||||
public String toString() {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
for (Map.Entry<Property<?>, Comparable<?>> entry : setStates.entrySet()) {
|
||||
if (ret.length() > 0) {
|
||||
if (!ret.isEmpty()) {
|
||||
ret.append(',');
|
||||
}
|
||||
ret.append(entry.getKey().getName())
|
||||
|
||||
@@ -150,7 +150,7 @@ public class ObjModel extends SimpleUnbakedGeometry<ObjModel>
|
||||
if (!Objects.equals(newMat, currentMat))
|
||||
{
|
||||
currentMat = newMat;
|
||||
if (currentMesh != null && currentMesh.mat == null && currentMesh.faces.size() == 0)
|
||||
if (currentMesh != null && currentMesh.mat == null && currentMesh.faces.isEmpty())
|
||||
{
|
||||
currentMesh.mat = currentMat;
|
||||
}
|
||||
@@ -233,7 +233,7 @@ public class ObjModel extends SimpleUnbakedGeometry<ObjModel>
|
||||
if (!Objects.equals(currentSmoothingGroup, smoothingGroup))
|
||||
{
|
||||
currentSmoothingGroup = smoothingGroup;
|
||||
if (currentMesh != null && currentMesh.smoothingGroup == null && currentMesh.faces.size() == 0)
|
||||
if (currentMesh != null && currentMesh.smoothingGroup == null && currentMesh.faces.isEmpty())
|
||||
{
|
||||
currentMesh.smoothingGroup = currentSmoothingGroup;
|
||||
}
|
||||
@@ -406,10 +406,10 @@ public class ObjModel extends SimpleUnbakedGeometry<ObjModel>
|
||||
{
|
||||
int[] index = indices[Math.min(i, indices.length - 1)];
|
||||
Vector4f position = new Vector4f(positions.get(index[0]), 1);
|
||||
Vec2 texCoord = index.length >= 2 && texCoords.size() > 0 ? texCoords.get(index[1]) : DEFAULT_COORDS[i];
|
||||
Vector3f norm0 = !needsNormalRecalculation && index.length >= 3 && normals.size() > 0 ? normals.get(index[2]) : faceNormal;
|
||||
Vec2 texCoord = index.length >= 2 && !texCoords.isEmpty() ? texCoords.get(index[1]) : DEFAULT_COORDS[i];
|
||||
Vector3f norm0 = !needsNormalRecalculation && index.length >= 3 && !normals.isEmpty() ? normals.get(index[2]) : faceNormal;
|
||||
Vector3f normal = norm0;
|
||||
Vector4f color = index.length >= 4 && colors.size() > 0 ? colors.get(index[3]) : COLOR_WHITE;
|
||||
Vector4f color = index.length >= 4 && !colors.isEmpty() ? colors.get(index[3]) : COLOR_WHITE;
|
||||
if (hasTransform)
|
||||
{
|
||||
normal = new Vector3f(norm0);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ObjTokenizer implements AutoCloseable
|
||||
if (currentLine.startsWith("#"))
|
||||
currentLine = "";
|
||||
|
||||
if (currentLine.length() > 0)
|
||||
if (!currentLine.isEmpty())
|
||||
{
|
||||
|
||||
boolean hasContinuation;
|
||||
@@ -63,13 +63,13 @@ public class ObjTokenizer implements AutoCloseable
|
||||
if (currentLine == null)
|
||||
break;
|
||||
|
||||
if (currentLine.length() == 0 || currentLine.startsWith("#"))
|
||||
if (currentLine.isEmpty() || currentLine.startsWith("#"))
|
||||
break;
|
||||
}
|
||||
} while (hasContinuation);
|
||||
}
|
||||
|
||||
if (lineParts.size() > 0)
|
||||
if (!lineParts.isEmpty())
|
||||
return lineParts.toArray(new String[0]);
|
||||
}
|
||||
while (ignoreEmptyLines);
|
||||
|
||||
@@ -206,7 +206,7 @@ public abstract class ParticleDescriptionProvider implements DataProvider {
|
||||
"Texture '%s' does not exist in any known resource pack", texture);
|
||||
desc.add(texture.toString());
|
||||
}
|
||||
Preconditions.checkArgument(desc.size() > 0, "The particle type '%s' must have one texture", particle);
|
||||
Preconditions.checkArgument(!desc.isEmpty(), "The particle type '%s' must have one texture", particle);
|
||||
|
||||
// Insert into map
|
||||
if (this.descriptions.putIfAbsent(particle, desc) != null) {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class AndHolderSet<T> extends CompositeHolderSet<T> {
|
||||
@Override
|
||||
protected Set<Holder<T>> createSet() {
|
||||
List<HolderSet<T>> components = this.getComponents();
|
||||
if (components.size() < 1) {
|
||||
if (components.isEmpty()) {
|
||||
return Set.of();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ChunkGenWorker implements IWorker
|
||||
@Override
|
||||
public boolean hasWork()
|
||||
{
|
||||
return queue.size() > 0;
|
||||
return !queue.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,7 +124,7 @@ public class ChunkGenWorker implements IWorker
|
||||
}
|
||||
}
|
||||
|
||||
if (queue.size() == 0)
|
||||
if (queue.isEmpty())
|
||||
{
|
||||
listener.sendSuccess(() -> Component.translatable("commands.forge.gen.complete", genned, total, dim.dimension().location()), true);
|
||||
/* TODO: Readd if/when we introduce world unloading, or get Mojang to do it.
|
||||
|
||||
@@ -125,7 +125,7 @@ class EntityCommand
|
||||
return b.getRight() - a.getRight();
|
||||
});
|
||||
|
||||
if (info.size() == 0)
|
||||
if (info.isEmpty())
|
||||
throw NO_ENTITIES.create();
|
||||
|
||||
int count = info.stream().mapToInt(Pair::getRight).sum();
|
||||
|
||||
Reference in new issue
Block a user