Delete unused classes and refactor util-classes for a consistent naming

This commit is contained in:
Blue (Lukas Rieger) 2019-11-23 15:35:20 +01:00
parent 3f2d5e7e14
commit 60bde768c0
16 changed files with 42 additions and 129 deletions

View File

@ -29,7 +29,7 @@ import com.flowpowered.math.matrix.Matrix3f;
import com.flowpowered.math.vector.Vector2f;
import com.flowpowered.math.vector.Vector3f;
import de.bluecolored.bluemap.core.util.MathUtil;
import de.bluecolored.bluemap.core.util.MathUtils;
public class Face {
@ -202,7 +202,7 @@ public class Face {
}
public Vector3f getFaceNormal(){
return MathUtil.getSurfaceNormal(p1, p2, p3);
return MathUtils.getSurfaceNormal(p1, p2, p3);
}
private void normlizeNormals(){

View File

@ -43,7 +43,7 @@ import de.bluecolored.bluemap.core.render.RenderSettings;
import de.bluecolored.bluemap.core.render.WorldTile;
import de.bluecolored.bluemap.core.resourcepack.ResourcePack;
import de.bluecolored.bluemap.core.util.AABB;
import de.bluecolored.bluemap.core.util.FileUtil;
import de.bluecolored.bluemap.core.util.FileUtils;
import de.bluecolored.bluemap.core.world.ChunkNotGeneratedException;
public class HiresModelManager {
@ -162,7 +162,7 @@ public class HiresModelManager {
* Returns the file for a tile
*/
public File getFile(Vector2i tilePos){
return FileUtil.coordsToFile(fileRoot, tilePos, "json.gz");
return FileUtils.coordsToFile(fileRoot, tilePos, "json.gz");
}
}

View File

@ -39,7 +39,7 @@ import de.bluecolored.bluemap.core.resourcepack.NoSuchResourceException;
import de.bluecolored.bluemap.core.resourcepack.NoSuchTextureException;
import de.bluecolored.bluemap.core.resourcepack.ResourcePack;
import de.bluecolored.bluemap.core.util.AABB;
import de.bluecolored.bluemap.core.util.MathUtil;
import de.bluecolored.bluemap.core.util.MathUtils;
import de.bluecolored.bluemap.core.world.Block;
import de.bluecolored.bluemap.core.world.ChunkNotGeneratedException;
import de.bluecolored.bluemap.core.world.WorldChunk;
@ -91,12 +91,12 @@ public class HiresModelRenderer {
blockModel.translate(new Vector3f(x, y, z).sub(min.toFloat()));
color = MathUtil.overlayColors(blockModel.getMapColor(), color);
color = MathUtils.overlayColors(blockModel.getMapColor(), color);
//TODO: quick hack to random offset grass
if (block.getBlock().getId().equals("grass")){
float dx = (MathUtil.hashToFloat(x, y, z, 123984) - 0.5f) * 0.75f;
float dz = (MathUtil.hashToFloat(x, y, z, 345542) - 0.5f) * 0.75f;
float dx = (MathUtils.hashToFloat(x, y, z, 123984) - 0.5f) * 0.75f;
float dz = (MathUtils.hashToFloat(x, y, z, 345542) - 0.5f) * 0.75f;
blockModel.translate(new Vector3f(dx, 0, dz));
}

View File

@ -27,7 +27,7 @@ package de.bluecolored.bluemap.core.render.hires.blockmodel;
import com.flowpowered.math.vector.Vector4f;
import de.bluecolored.bluemap.core.model.Model;
import de.bluecolored.bluemap.core.util.MathUtil;
import de.bluecolored.bluemap.core.util.MathUtils;
/**
* A model with some extra information about the BlockState it represents
@ -62,7 +62,7 @@ public class BlockStateModel extends Model {
}
public void mergeMapColor(Vector4f mapColor) {
this.mapColor = MathUtil.blendColors(this.mapColor, mapColor);
this.mapColor = MathUtils.blendColors(this.mapColor, mapColor);
}
}

View File

@ -45,7 +45,7 @@ import de.bluecolored.bluemap.core.resourcepack.NoSuchTextureException;
import de.bluecolored.bluemap.core.resourcepack.ResourcePack;
import de.bluecolored.bluemap.core.resourcepack.TextureProvider.Texture;
import de.bluecolored.bluemap.core.util.Direction;
import de.bluecolored.bluemap.core.util.MathUtil;
import de.bluecolored.bluemap.core.util.MathUtils;
import de.bluecolored.bluemap.core.util.WeighedArrayList;
import de.bluecolored.bluemap.core.world.Block;
@ -74,7 +74,7 @@ public class ResourceModelBuilder {
BlockStateModel model = new BlockStateModel();
for (WeighedArrayList<BlockModelResource> bmrList : resource.getModelResources()){
BlockModelResource bmr = bmrList.get((int) Math.floor(MathUtil.hashToFloat(context.getPosition(), 23489756) * bmrList.size()));
BlockModelResource bmr = bmrList.get((int) Math.floor(MathUtils.hashToFloat(context.getPosition(), 23489756) * bmrList.size()));
model.merge(fromModelResource(bmr));
}

View File

@ -42,8 +42,8 @@ import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3f;
import de.bluecolored.bluemap.core.threejs.BufferGeometry;
import de.bluecolored.bluemap.core.util.FileUtil;
import de.bluecolored.bluemap.core.util.MathUtil;
import de.bluecolored.bluemap.core.util.FileUtils;
import de.bluecolored.bluemap.core.util.MathUtils;
import de.bluecolored.bluemap.core.util.ModelUtils;
public class LowresModel {
@ -113,7 +113,7 @@ public class LowresModel {
}
try {
FileUtil.waitForFile(file, 10, TimeUnit.SECONDS);
FileUtils.waitForFile(file, 10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new IOException("Failed to get write-access to file: " + file, e);
}
@ -163,7 +163,7 @@ public class LowresModel {
Vector3f p2 = new Vector3f(model.position[f + 3], model.position[f + 4], model.position[f + 5]);
Vector3f p3 = new Vector3f(model.position[f + 6], model.position[f + 7], model.position[f + 8]);
Vector3f n = MathUtil.getSurfaceNormal(p1, p2, p3);
Vector3f n = MathUtils.getSurfaceNormal(p1, p2, p3);
model.normal[f + 0] = n.getX(); model.normal[f + 1] = n.getY(); model.normal[f + 2] = n.getZ();
model.normal[f + 3] = n.getX(); model.normal[f + 4] = n.getY(); model.normal[f + 5] = n.getZ();

View File

@ -48,7 +48,7 @@ import com.flowpowered.math.vector.Vector4f;
import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.core.render.hires.HiresModel;
import de.bluecolored.bluemap.core.threejs.BufferGeometry;
import de.bluecolored.bluemap.core.util.FileUtil;
import de.bluecolored.bluemap.core.util.FileUtils;
public class LowresModelManager {
@ -167,7 +167,7 @@ public class LowresModelManager {
* Returns the file for a tile
*/
public File getFile(Vector2i tile){
return FileUtil.coordsToFile(fileRoot, tile, "json.gz");
return FileUtils.coordsToFile(fileRoot, tile, "json.gz");
}
private LowresModel getModel(UUID world, Vector2i tile) throws IOException {

View File

@ -27,7 +27,7 @@ package de.bluecolored.bluemap.core.resourcepack;
import com.flowpowered.math.vector.Vector3f;
import com.flowpowered.math.vector.Vector4f;
import de.bluecolored.bluemap.core.util.ConfigUtil;
import de.bluecolored.bluemap.core.util.ConfigUtils;
import de.bluecolored.bluemap.core.util.Direction;
import ninja.leaping.configurate.ConfigurationNode;
@ -49,7 +49,7 @@ public class BlockModelElementFaceResource {
this.uv = getDefaultUV(declaration.getKey().toString(), element.getFrom(), element.getTo());
ConfigurationNode uv = declaration.getNode("uv");
if (!uv.isVirtual()) this.uv = ConfigUtil.readVector4f(declaration.getNode("uv"));
if (!uv.isVirtual()) this.uv = ConfigUtils.readVector4f(declaration.getNode("uv"));
this.texture = declaration.getNode("texture").getString();
this.resolvedTexture = null;

View File

@ -27,7 +27,7 @@ package de.bluecolored.bluemap.core.resourcepack;
import com.flowpowered.math.vector.Vector3f;
import de.bluecolored.bluemap.core.util.Axis;
import de.bluecolored.bluemap.core.util.ConfigUtil;
import de.bluecolored.bluemap.core.util.ConfigUtils;
import ninja.leaping.configurate.ConfigurationNode;
public class BlockModelElementResource {
@ -49,13 +49,13 @@ public class BlockModelElementResource {
this.model = model;
try {
this.from = ConfigUtil.readVector3f(declaration.getNode("from"));
this.to = ConfigUtil.readVector3f(declaration.getNode("to"));
this.from = ConfigUtils.readVector3f(declaration.getNode("from"));
this.to = ConfigUtils.readVector3f(declaration.getNode("to"));
this.rotAngle = 0f;
ConfigurationNode rotation = declaration.getNode("rotation");
if (!rotation.isVirtual()){
this.rotOrigin = ConfigUtil.readVector3f(rotation.getNode("origin"));
this.rotOrigin = ConfigUtils.readVector3f(rotation.getNode("origin"));
this.rotAxis = Axis.fromString(rotation.getNode("axis").getString());
this.rotAngle = rotation.getNode("angle").getFloat();
this.rotRescale = rotation.getNode("rescale").getBoolean(false);

View File

@ -41,13 +41,11 @@ import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.apache.commons.io.FileUtils;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.core.util.FileUtil;
import de.bluecolored.bluemap.core.util.FileUtils;
import de.bluecolored.bluemap.core.world.BlockState;
public class ResourcePack {
@ -142,9 +140,9 @@ public class ResourcePack {
String[] texturesPattern = {"assets", ".*", "textures", "block|colormap", "*"};
return
FileUtil.matchPath(path, blockstatesPattern) ||
FileUtil.matchPath(path, modelsPattern) ||
FileUtil.matchPath(path, texturesPattern);
FileUtils.matchPath(path, blockstatesPattern) ||
FileUtils.matchPath(path, modelsPattern) ||
FileUtils.matchPath(path, texturesPattern);
}
public BlockStateResource getBlockStateResource(BlockState block) throws NoSuchResourceException, InvalidResourceDeclarationException {
@ -193,7 +191,7 @@ public class ResourcePack {
public static void downloadDefaultResource(File file) throws IOException {
if (file.exists()) file.delete();
file.getParentFile().mkdirs();
FileUtils.copyURLToFile(new URL(MINECRAFT_CLIENT_URL), file, 10000, 10000);
org.apache.commons.io.FileUtils.copyURLToFile(new URL(MINECRAFT_CLIENT_URL), file, 10000, 10000);
}
}

View File

@ -42,9 +42,9 @@ import javax.imageio.ImageIO;
import com.flowpowered.math.vector.Vector4f;
import de.bluecolored.bluemap.core.resourcepack.ResourcePack.Resource;
import de.bluecolored.bluemap.core.util.ConfigUtil;
import de.bluecolored.bluemap.core.util.FileUtil;
import de.bluecolored.bluemap.core.util.MathUtil;
import de.bluecolored.bluemap.core.util.ConfigUtils;
import de.bluecolored.bluemap.core.util.FileUtils;
import de.bluecolored.bluemap.core.util.MathUtils;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.gson.GsonConfigurationLoader;
@ -81,7 +81,7 @@ public class TextureProvider {
for (Entry<Path, Resource> entry : resources.getAllResources().entrySet()){
Path key = entry.getKey();
if (FileUtil.matchPath(key, texturesPathPattern) && key.toString().endsWith(".png")){
if (FileUtils.matchPath(key, texturesPathPattern) && key.toString().endsWith(".png")){
String path = key.subpath(3, key.getNameCount()).normalize().toString();
String id = path
.substring(0, path.length() - ".png".length())
@ -117,7 +117,7 @@ public class TextureProvider {
n.getNode("id").getString(),
n.getNode("texture").getString(),
n.getNode("transparent").getBoolean(false),
ConfigUtil.readVector4f(n.getNode("color"))
ConfigUtils.readVector4f(n.getNode("color"))
);
textures.add(t);
@ -140,7 +140,7 @@ public class TextureProvider {
n.getNode("id").setValue(t.getId());
n.getNode("texture").setValue(t.getBase64());
n.getNode("transparent").setValue(t.isHalfTransparent());
ConfigUtil.writeVector4f(n.getNode("color"), t.getColor());
ConfigUtils.writeVector4f(n.getNode("color"), t.getColor());
}
loader.save(node);
@ -194,7 +194,7 @@ public class TextureProvider {
double green = (double)((pixel >> 8) & 0xff) / (double) 0xff;
double blue = (double)((pixel >> 0) & 0xff) / (double) 0xff;
color = MathUtil.blendColors(new Vector4f(red, green, blue, alpha), color);
color = MathUtils.blendColors(new Vector4f(red, green, blue, alpha), color);
}
}

View File

@ -34,9 +34,9 @@ import com.flowpowered.math.vector.Vector4i;
import ninja.leaping.configurate.ConfigurationNode;
public class ConfigUtil {
public class ConfigUtils {
private ConfigUtil(){}
private ConfigUtils(){}
public static Vector2i readVector2i(ConfigurationNode vectorNode){
if (vectorNode.hasListChildren()){

View File

@ -33,9 +33,9 @@ import java.util.regex.Pattern;
import com.flowpowered.math.vector.Vector2i;
public class FileUtil {
public class FileUtils {
private FileUtil(){}
private FileUtils(){}
public static File coordsToFile(Path root, Vector2i coords, String fileType){
String path = "x" + coords.getX() + "z" + coords.getY();

View File

@ -29,9 +29,9 @@ import com.flowpowered.math.vector.Vector3f;
import com.flowpowered.math.vector.Vector3i;
import com.flowpowered.math.vector.Vector4f;
public class MathUtil {
public class MathUtils {
private MathUtil() {}
private MathUtils() {}
public static Vector3d getSurfaceNormal(Vector3d p1, Vector3d p2, Vector3d p3){
Vector3d u = p2.sub(p1);

View File

@ -1,54 +0,0 @@
/*
* This file is part of BlueMap, licensed under the MIT License (MIT).
*
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package de.bluecolored.bluemap.core.util;
import java.lang.ref.WeakReference;
public class UpdateDeamon extends Thread {
public WeakReference<Updateable> subject;
public long frequency;
public UpdateDeamon(Runnable subject, long frequency) {
this((Updateable) (()->subject.run()), frequency);
}
public UpdateDeamon(Updateable subject, long frequency) {
this.subject = new WeakReference<Updateable>(subject);
this.frequency = frequency;
this.setDaemon(true);
}
@Override
public void run() {
try {
while (true) {
Thread.sleep(frequency);
subject.get().update();
}
} catch (NullPointerException | InterruptedException ex) {}
}
}

View File

@ -1,31 +0,0 @@
/*
* This file is part of BlueMap, licensed under the MIT License (MIT).
*
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package de.bluecolored.bluemap.core.util;
public interface Updateable {
public void update();
}