diff options
Diffstat (limited to 'src/main/java/makamys/lodmod/util')
-rw-r--r-- | src/main/java/makamys/lodmod/util/BufferWriter.java | 46 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/util/GuiHelper.java | 61 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/util/MCUtil.java | 20 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/util/SpriteUtil.java | 55 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/util/Util.java | 88 |
5 files changed, 0 insertions, 270 deletions
diff --git a/src/main/java/makamys/lodmod/util/BufferWriter.java b/src/main/java/makamys/lodmod/util/BufferWriter.java deleted file mode 100644 index ae81be1..0000000 --- a/src/main/java/makamys/lodmod/util/BufferWriter.java +++ /dev/null @@ -1,46 +0,0 @@ -package makamys.lodmod.util; - -import java.nio.ByteBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.nio.ShortBuffer; - -public class BufferWriter { - - private ByteBuffer buf; - - private FloatBuffer floatBuffer; - private ShortBuffer shortBuffer; - private IntBuffer intBuffer; - - public BufferWriter(ByteBuffer buf) { - this.buf = buf; - this.floatBuffer = buf.asFloatBuffer(); - this.shortBuffer = buf.asShortBuffer(); - this.intBuffer = buf.asIntBuffer(); - } - - private void incrementPosition(int add) { - buf.position(buf.position() + add); - floatBuffer.position(buf.position() / 4); - shortBuffer.position(buf.position() / 2); - intBuffer.position(buf.position() / 4); - } - - public void writeFloat(float x) { - try { - floatBuffer.put(x); - - incrementPosition(4); - } catch(Exception e){ - e.printStackTrace(); - } - } - - public void writeInt(int x) { - intBuffer.put(x); - - incrementPosition(4); - } - -}
\ No newline at end of file diff --git a/src/main/java/makamys/lodmod/util/GuiHelper.java b/src/main/java/makamys/lodmod/util/GuiHelper.java deleted file mode 100644 index 3054237..0000000 --- a/src/main/java/makamys/lodmod/util/GuiHelper.java +++ /dev/null @@ -1,61 +0,0 @@ -package makamys.lodmod.util; - -import org.lwjgl.opengl.GL11; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Tessellator; - -public class GuiHelper { - - public static void begin() { - GL11.glDisable(GL11.GL_TEXTURE_2D); - - Minecraft mc = Minecraft.getMinecraft(); - - //GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); - GL11.glMatrixMode(GL11.GL_PROJECTION); - //GL11.glEnable(GL11.GL_COLOR_MATERIAL); - GL11.glLoadIdentity(); - GL11.glOrtho(0.0D, (double)mc.displayWidth, (double)mc.displayHeight, 0.0D, 1000.0D, 3000.0D); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glLoadIdentity(); - GL11.glTranslatef(0.0F, 0.0F, -2000.0F); - //GL11.glLineWidth(1.0F); - //GL11.glDisable(GL11.GL_TEXTURE_2D); - } - - public static void drawRectangle(int x, int y, int w, int h, int color) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setColorOpaque_I(color); - tessellator.addVertex(x, y, 0); - tessellator.addVertex(x, y+h, 0); - tessellator.addVertex(x+w, y+h, 0); - tessellator.addVertex(x+w, y, 0); - - tessellator.draw(); - } - - public static void drawRectangle(int x, int y, int w, int h, int color, int opacity) { - GL11.glEnable(GL11.GL_BLEND); - - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_I(color, opacity); - tessellator.addVertex(x, y, 0); - tessellator.addVertex(x, y+h, 0); - tessellator.addVertex(x+w, y+h, 0); - tessellator.addVertex(x+w, y, 0); - - tessellator.draw(); - - GL11.glDisable(GL11.GL_BLEND); - } - - public static void end() { - //GL11.glDisable(GL11.GL_BLEND); - - //GL11.glEnable(GL11.GL_TEXTURE_2D); - } - -} diff --git a/src/main/java/makamys/lodmod/util/MCUtil.java b/src/main/java/makamys/lodmod/util/MCUtil.java deleted file mode 100644 index 7f81d74..0000000 --- a/src/main/java/makamys/lodmod/util/MCUtil.java +++ /dev/null @@ -1,20 +0,0 @@ -package makamys.lodmod.util; - -import net.minecraft.world.biome.BiomeGenBase; - -public class MCUtil { - - public static float getBiomeTemperatureVanilla(BiomeGenBase biome, int p_150564_1_, int p_150564_2_, int p_150564_3_){ - if (p_150564_2_ > 64) - { - float f = (float)BiomeGenBase.temperatureNoise - .func_151601_a((double)p_150564_1_ * 1.0D / 8.0D, (double)p_150564_3_ * 1.0D / 8.0D) * 4.0F; - return biome.temperature - (f + (float)p_150564_2_ - 64.0F) * 0.05F / 30.0F; - } - else - { - return biome.temperature; - } - } - -} diff --git a/src/main/java/makamys/lodmod/util/SpriteUtil.java b/src/main/java/makamys/lodmod/util/SpriteUtil.java deleted file mode 100644 index 34bc544..0000000 --- a/src/main/java/makamys/lodmod/util/SpriteUtil.java +++ /dev/null @@ -1,55 +0,0 @@ -package makamys.lodmod.util; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.world.ChunkCoordIntPair; - -public class SpriteUtil { - - private static int[] spriteIndexMap; - public static List<TextureAtlasSprite> sprites; - - private static Map<Long, Integer> uv2spriteIndex = new HashMap<>(); - - private static int findSpriteIndexForUV(float u, float v) { - Map<String, TextureAtlasSprite> uploadedSprites = ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).mapUploadedSprites; - - int spriteIndex = 0; - for(TextureAtlasSprite tas : uploadedSprites.values()) { - if(tas.getMinU() <= u && u <= tas.getMaxU() && tas.getMinV() <= v && v <= tas.getMaxV()) { - break; - } - spriteIndex++; - } - return spriteIndex; - } - - public static int getSpriteIndexForUV(float u, float v){ - long key = ChunkCoordIntPair.chunkXZ2Int((int)(u * Integer.MAX_VALUE), (int)(v * Integer.MAX_VALUE)); - int index = uv2spriteIndex.getOrDefault(key, -1); - if(index == -1) { - index = findSpriteIndexForUV(u, v); - uv2spriteIndex.put(key, index); - } - return index; - } - - public static TextureAtlasSprite getSprite(int i){ - if(i >= 0 && i < sprites.size()) { - return sprites.get(i); - } else { - return null; - } - } - - public static void init() { - Map<String, TextureAtlasSprite> uploadedSprites = ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).mapUploadedSprites; - sprites = uploadedSprites.values().stream().collect(Collectors.toList()); - } -} diff --git a/src/main/java/makamys/lodmod/util/Util.java b/src/main/java/makamys/lodmod/util/Util.java deleted file mode 100644 index 6ca5f86..0000000 --- a/src/main/java/makamys/lodmod/util/Util.java +++ /dev/null @@ -1,88 +0,0 @@ -package makamys.lodmod.util; - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; - -import net.minecraft.launchwrapper.Launch; - -public class Util { - - private static boolean allowResourceOverrides = Boolean.parseBoolean(System.getProperty("lodmod.allowResourceOverrides", "false")); - - public static Path getResourcePath(String relPath) { - if(allowResourceOverrides) { - File overrideFile = new File(new File(Launch.minecraftHome, "lodmod/resources"), relPath); - if(overrideFile.exists()) { - return overrideFile.toPath(); - } - } - - try { - URL resourceURL = Util.class.getClassLoader().getResource(relPath); - - switch(resourceURL.getProtocol()) { - case "jar": - String urlString = resourceURL.getPath(); - int lastExclamation = urlString.lastIndexOf('!'); - String newURLString = urlString.substring(0, lastExclamation); - return FileSystems.newFileSystem(new File(URI.create(newURLString)).toPath(), null).getPath(relPath); - case "file": - return new File(URI.create(resourceURL.toString())).toPath(); - default: - return null; - } - } catch(IOException e) { - return null; - } - } - - public static String readFile(String path){ - try { - return new String(Files.readAllBytes(Util.getResourcePath(path))); - } catch (IOException e) { - e.printStackTrace(); - } - return ""; - } - - public static byte[] byteBufferToArray(ByteBuffer buffer) { - byte[] dst = new byte[buffer.limit()]; - int pos = buffer.position(); - buffer.position(0); - buffer.get(dst); - buffer.position(pos); - return dst; - } - - public static int[] intBufferToArray(IntBuffer buffer) { - int[] dst = new int[buffer.limit()]; - int pos = buffer.position(); - buffer.position(0); - buffer.get(dst); - buffer.position(pos); - return dst; - } - - public static float[] floatBufferToArray(FloatBuffer buffer) { - float[] dst = new float[buffer.limit()]; - int pos = buffer.position(); - buffer.position(0); - buffer.get(dst); - buffer.position(pos); - return dst; - } - - public static double distSq(double x1, double y1, double z1, double x2, double y2, double z2) { - return Math.pow(x1 - x2, 2) + - Math.pow(y1 - y2, 2) + - Math.pow(z1 - z2, 2); - } -} |