diff options
| author | Jason Mitchell <mitchej@gmail.com> | 2023-01-29 21:48:33 -0800 |
|---|---|---|
| committer | Jason Mitchell <mitchej@gmail.com> | 2023-01-29 21:48:33 -0800 |
| commit | b68f567fa1353f4d9d852db1e71682cc882ec8ee (patch) | |
| tree | 4786d95c4748744cd62a58aef57f7598e2deb9a6 /src/main/java/com/detrav/net/ProspectingPacket.java | |
| parent | e3e13bd2c4db10bba303ce66332e004215548722 (diff) | |
| download | GT5-Unofficial-b68f567fa1353f4d9d852db1e71682cc882ec8ee.tar.gz GT5-Unofficial-b68f567fa1353f4d9d852db1e71682cc882ec8ee.tar.bz2 GT5-Unofficial-b68f567fa1353f4d9d852db1e71682cc882ec8ee.zip | |
[ci skip] spotlessApply with the new settings
Diffstat (limited to 'src/main/java/com/detrav/net/ProspectingPacket.java')
| -rw-r--r-- | src/main/java/com/detrav/net/ProspectingPacket.java | 119 |
1 files changed, 57 insertions, 62 deletions
diff --git a/src/main/java/com/detrav/net/ProspectingPacket.java b/src/main/java/com/detrav/net/ProspectingPacket.java index b083e4829e..4d6fd72b82 100644 --- a/src/main/java/com/detrav/net/ProspectingPacket.java +++ b/src/main/java/com/detrav/net/ProspectingPacket.java @@ -1,35 +1,30 @@ package com.detrav.net; +import java.util.HashMap; + +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + import com.detrav.DetravScannerMod; import com.detrav.gui.DetravScannerGUI; import com.detrav.gui.textures.DetravMapTexture; -import com.detrav.utils.BartWorksHelper; import com.detrav.utils.GTppHelper; import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; import com.google.common.base.Objects; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; + import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.util.GT_LanguageManager; -import net.minecraft.util.StatCollector; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import java.util.HashMap; - -/* -//DEBUG CLASSES -import java.util.Map; -import java.util.Iterator; -import java.util.Set; -*/ /** * Created by wital_000 on 20.03.2016. */ public class ProspectingPacket extends DetravPacket { + public final int chunkX; public final int chunkZ; public final int posX; @@ -40,9 +35,8 @@ public class ProspectingPacket extends DetravPacket { public final HashMap<String, Integer> ores; public final HashMap<Short, String> metaMap; public static final HashMap<Integer, short[]> fluidColors = new HashMap<>(); - - public int level = -1; + public int level = -1; public ProspectingPacket(int chunkX, int chunkZ, int posX, int posZ, int size, int ptype) { this.chunkX = chunkX; @@ -51,28 +45,29 @@ public class ProspectingPacket extends DetravPacket { this.posZ = posZ; this.size = size; this.ptype = ptype; - this.map = new HashMap[(size*2+1)*16][(size*2+1)*16]; + this.map = new HashMap[(size * 2 + 1) * 16][(size * 2 + 1) * 16]; this.ores = new HashMap<>(); this.metaMap = new HashMap<>(); } - + private static void addOre(ProspectingPacket packet, byte y, int i, int j, short meta) { final String name; short[] rgba; try { - if(packet.ptype == 0 || packet.ptype == 1) { + if (packet.ptype == 0 || packet.ptype == 1) { // Ore or Small Ore if (meta < 7000 || meta > 7500) { if (meta > 0) { Materials tMaterial = GregTech_API.sGeneratedMaterials[meta % 1000]; rgba = tMaterial.getRGBA(); - name = tMaterial.getLocalizedNameForItem(GT_LanguageManager.getTranslation("gt.blockores." + meta + ".name")); + name = tMaterial.getLocalizedNameForItem( + GT_LanguageManager.getTranslation("gt.blockores." + meta + ".name")); } else { final Werkstoff werkstoff = Werkstoff.werkstoffHashMap.getOrDefault((short) (meta * -1), null); String translated = GT_LanguageManager.getTranslation("bw.blocktype.ore"); name = translated.replace("%material", werkstoff.getLocalizedName()); - rgba = werkstoff != null ? werkstoff.getRGBA() : new short[]{0,0,0,0}; + rgba = werkstoff != null ? werkstoff.getRGBA() : new short[] { 0, 0, 0, 0 }; } } else { gtPlusPlus.core.material.Material pMaterial = GTppHelper.decodeoresGTpp.get((short) (meta - 7000)); @@ -83,18 +78,18 @@ public class ProspectingPacket extends DetravPacket { // Fluid rgba = fluidColors.get((int) meta); if (rgba == null) { - DetravScannerMod.proxy.sendPlayerExeption( "Unknown fluid ID = " + meta + " Please add to FluidColors.java!"); - rgba = new short[]{0,0,0,0}; + DetravScannerMod.proxy + .sendPlayerExeption("Unknown fluid ID = " + meta + " Please add to FluidColors.java!"); + rgba = new short[] { 0, 0, 0, 0 }; } - + name = Objects.firstNonNull( - FluidRegistry.getFluid(meta).getLocalizedName(new FluidStack(FluidRegistry.getFluid(meta), 0)), - StatCollector.translateToLocal("gui.detrav.scanner.unknown_fluid") - ); + FluidRegistry.getFluid(meta).getLocalizedName(new FluidStack(FluidRegistry.getFluid(meta), 0)), + StatCollector.translateToLocal("gui.detrav.scanner.unknown_fluid")); } else if (packet.ptype == 3) { // Pollution name = StatCollector.translateToLocal("gui.detrav.scanner.pollution"); - rgba = new short[]{125,123,118,0}; + rgba = new short[] { 125, 123, 118, 0 }; } else { return; } @@ -106,31 +101,34 @@ public class ProspectingPacket extends DetravPacket { } public static Object decode(ByteArrayDataInput aData) { - ProspectingPacket packet = new ProspectingPacket(aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt()); + ProspectingPacket packet = new ProspectingPacket( + aData.readInt(), + aData.readInt(), + aData.readInt(), + aData.readInt(), + aData.readInt(), + aData.readInt()); packet.level = aData.readInt(); int aSize = (packet.size * 2 + 1) * 16; int checkOut = 0; - for (int i = 0; i < aSize; i++) - for (int j = 0; j < aSize; j++) { - byte kSize = aData.readByte(); - if(kSize == 0) continue; - packet.map[i][j] = new HashMap<>(); - for (int k = 0; k < kSize; k++) { - final byte y = aData.readByte(); - final short meta = aData.readShort(); - packet.map[i][j].put(y, meta); - if (packet.ptype != 2 || y == 1) addOre(packet, y, i, j, meta); - checkOut++; - } + for (int i = 0; i < aSize; i++) for (int j = 0; j < aSize; j++) { + byte kSize = aData.readByte(); + if (kSize == 0) continue; + packet.map[i][j] = new HashMap<>(); + for (int k = 0; k < kSize; k++) { + final byte y = aData.readByte(); + final short meta = aData.readShort(); + packet.map[i][j].put(y, meta); + if (packet.ptype != 2 || y == 1) addOre(packet, y, i, j, meta); + checkOut++; } + } int checkOut2 = aData.readInt(); - if(checkOut != checkOut2) return null; + if (checkOut != checkOut2) return null; return packet; } - - @Override public int getPacketID() { return 0; @@ -147,27 +145,24 @@ public class ProspectingPacket extends DetravPacket { tOut.writeInt(size); tOut.writeInt(ptype); tOut.writeInt(level); - - int aSize = (size*2+1)*16; + + int aSize = (size * 2 + 1) * 16; int checkOut = 0; - for(int i =0; i<aSize; i++) - for(int j =0; j<aSize; j++) { - if(map[i][j]==null) - tOut.writeByte(0); - else { - tOut.writeByte(map[i][j].keySet().size()); - for(byte key : map[i][j].keySet()) { - tOut.writeByte(key); - tOut.writeShort(map[i][j].get(key)); - checkOut++; - } + for (int i = 0; i < aSize; i++) for (int j = 0; j < aSize; j++) { + if (map[i][j] == null) tOut.writeByte(0); + else { + tOut.writeByte(map[i][j].keySet().size()); + for (byte key : map[i][j].keySet()) { + tOut.writeByte(key); + tOut.writeShort(map[i][j].get(key)); + checkOut++; } } + } tOut.writeInt(checkOut); return tOut.toByteArray(); } - @Override public void process() { DetravScannerGUI.newMap(new DetravMapTexture(this)); @@ -175,13 +170,13 @@ public class ProspectingPacket extends DetravPacket { } public void addBlock(int x, int y, int z, short metaData) { - int aX = x - (chunkX-size)*16; - int aZ = z - (chunkZ-size)*16; - if(map[aX][aZ] == null) map[aX][aZ] = new HashMap<>(); + int aX = x - (chunkX - size) * 16; + int aZ = z - (chunkZ - size) * 16; + if (map[aX][aZ] == null) map[aX][aZ] = new HashMap<>(); map[aX][aZ].put((byte) y, metaData); } - + public int getSize() { - return (size*2+1)*16; + return (size * 2 + 1) * 16; } } |
