diff options
author | NotAPenguin <michiel.vandeginste@gmail.com> | 2024-09-02 23:17:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-02 23:17:17 +0200 |
commit | 1b820de08a05070909a267e17f033fcf58ac8710 (patch) | |
tree | 02831a025986a06b20f87e5bcc69d1e0c639a342 /src/main/java/detrav/gui/textures | |
parent | afd3fd92b6a6ab9ab0d0dc3214e6bc8ff7a86c9b (diff) | |
download | GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.gz GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.bz2 GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.zip |
The Great Renaming (#3014)
* move kekztech to a single root dir
* move detrav to a single root dir
* move gtnh-lanthanides to a single root dir
* move tectech and delete some gross reflection in gt++
* remove more reflection inside gt5u
* delete more reflection in gt++
* fix imports
* move bartworks and bwcrossmod
* fix proxies
* move galactigreg and ggfab
* move gtneioreplugin
* try to fix gt++ bee loader
* apply the rename rules to BW
* apply rename rules to bwcrossmod
* apply rename rules to detrav scanner mod
* apply rename rules to galacticgreg
* apply rename rules to ggfab
* apply rename rules to goodgenerator
* apply rename rules to gtnh-lanthanides
* apply rename rules to gt++
* apply rename rules to kekztech
* apply rename rules to kubatech
* apply rename rules to tectech
* apply rename rules to gt
apply the rename rules to gt
* fix tt import
* fix mui hopefully
* fix coremod except intergalactic
* rename assline recipe class
* fix a class name i stumbled on
* rename StructureUtility to GTStructureUtility to prevent conflict with structurelib
* temporary rename of GTTooltipDataCache to old name
* fix gt client/server proxy names
Diffstat (limited to 'src/main/java/detrav/gui/textures')
-rw-r--r-- | src/main/java/detrav/gui/textures/DetravMapTexture.java | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/src/main/java/detrav/gui/textures/DetravMapTexture.java b/src/main/java/detrav/gui/textures/DetravMapTexture.java new file mode 100644 index 0000000000..e8e35dc82d --- /dev/null +++ b/src/main/java/detrav/gui/textures/DetravMapTexture.java @@ -0,0 +1,145 @@ +package detrav.gui.textures; + +import java.awt.Color; +import java.awt.image.BufferedImage; +import java.awt.image.WritableRaster; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.AbstractTexture; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.client.resources.IResourceManager; + +import org.lwjgl.opengl.GL11; + +import detrav.net.ProspectingPacket; + +/** + * Created by wital_000 on 21.03.2016. + */ +public class DetravMapTexture extends AbstractTexture { + + public final ProspectingPacket packet; + private String selected = "All"; + public int width = -1; + public int height = -1; + public boolean invert = false; + + public DetravMapTexture(ProspectingPacket aPacket) { + packet = aPacket; + } + + private BufferedImage getImage() { + final int backgroundColor = invert ? Color.GRAY.getRGB() : Color.WHITE.getRGB(); + final int wh = (packet.size * 2 + 1) * 16; + + BufferedImage image = new BufferedImage(wh, wh, BufferedImage.TYPE_INT_ARGB); + WritableRaster raster = image.getRaster(); + + int playerI = packet.posX - (packet.chunkX - packet.size) * 16 - 1; // Correct player offset + int playerJ = packet.posZ - (packet.chunkZ - packet.size) * 16 - 1; + for (int i = 0; i < wh; i++) { + for (int j = 0; j < wh; j++) { + image.setRGB(i, j, backgroundColor); + if (packet.map[i][j] != null) { + if (packet.ptype == 0 || packet.ptype == 1) { + for (short meta : packet.map[i][j].values()) { + final String name = packet.metaMap.get(meta); + if (!selected.equals("All") && !selected.equals(name)) continue; + + image.setRGB(i, j, packet.ores.getOrDefault(name, Color.BLACK.getRGB()) | 0XFF000000); + break; + } + } else if (packet.ptype == 2) { + final short fluidId = packet.map[i][j].get((byte) 1), + fluidSize = packet.map[i][j].get((byte) 2); + final String name = packet.metaMap.get(fluidId); + + // Variables used to locate within a chunk. + final int k = (i % 16), l = (j % 16); + + if (((k + l * 16) * 3) < (fluidSize + 48) + && (selected.equals("All") || selected.equals(name))) { + image.setRGB(i, j, packet.ores.getOrDefault(name, Color.BLACK.getRGB()) | 0XFF000000); + } + } else if (packet.ptype == 3) { + final short meta = packet.map[i][j].get((byte) 1); + image.setRGB(i, j, ((meta & 0xFF) << 16) + ((meta & 0xFF) << 8) + ((meta & 0xFF)) | 0XFF000000); + } + } + // draw player pos + if (i == playerI || j == playerJ) { + raster.setSample(i, j, 0, (raster.getSample(i, j, 0) + 255) / 2); + raster.setSample(i, j, 1, raster.getSample(i, j, 1) / 2); + raster.setSample(i, j, 2, raster.getSample(i, j, 2) / 2); + } + // draw grid + if ((i) % 16 == 0 || (j) % 16 == 0) { + raster.setSample(i, j, 0, raster.getSample(i, j, 0) / 2); + raster.setSample(i, j, 1, raster.getSample(i, j, 1) / 2); + raster.setSample(i, j, 2, raster.getSample(i, j, 2) / 2); + } + + } + } + + return image; + } + + @Override + public void loadTexture(IResourceManager resourceManager) { + this.deleteGlTexture(); + if (packet != null) { + int tId = getGlTextureId(); + if (tId < 0) return; + TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), getImage(), false, false); + width = packet.getSize(); + height = packet.getSize(); + } + } + + public void loadTexture(IResourceManager resourceManager, boolean invert) { + this.invert = invert; + loadTexture(resourceManager); + } + + public void loadTexture(IResourceManager resourceManager, String selected, boolean invert) { + this.selected = selected; + loadTexture(resourceManager, invert); + } + + public int glBindTexture() { + if (this.glTextureId < 0) return this.glTextureId; + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.getGlTextureId()); + return this.glTextureId; + } + + public void draw(int x, int y) { + float f = 1F / (float) width; + float f1 = 1F / (float) height; + int u = 0, v = 0; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV( + (double) (x), + (double) (y + height), + 0, + (double) ((float) (u) * f), + (double) ((float) (v + height) * f1)); + tessellator.addVertexWithUV( + (double) (x + width), + (double) (y + height), + 0, + (double) ((float) (u + width) * f), + (double) ((float) (v + height) * f1)); + tessellator.addVertexWithUV( + (double) (x + width), + (double) (y), + 0, + (double) ((float) (u + width) * f), + (double) ((float) (v) * f1)); + tessellator + .addVertexWithUV((double) (x), (double) (y), 0, (double) ((float) (u) * f), (double) ((float) (v) * f1)); + tessellator.draw(); + } + +} |