-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- renamed some asset files/directories to be all lowercase
- Loading branch information
Showing
328 changed files
with
732 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package gregtech.api.net; | ||
|
||
import net.minecraft.network.PacketBuffer; | ||
|
||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class SProspectingPacket { | ||
public int chunkX; | ||
public int chunkZ; | ||
public int posX; | ||
public int posZ; | ||
public int mode; | ||
public HashMap<Byte, String>[][] map; | ||
public Set<String> ores; | ||
|
||
public SProspectingPacket(int chunkX, int chunkZ, int posX, int posZ, int mode) { | ||
this.chunkX = chunkX; | ||
this.chunkZ = chunkZ; | ||
this.posX = posX; | ||
this.posZ = posZ; | ||
this.mode = mode; | ||
if (mode == 1) | ||
map = new HashMap[1][1]; | ||
else | ||
map = new HashMap[16][16]; | ||
|
||
ores = new HashSet<>(); | ||
} | ||
|
||
public static SProspectingPacket readPacketData(PacketBuffer buffer) { | ||
SProspectingPacket packet = new SProspectingPacket(buffer.readInt(), buffer.readInt(), buffer.readInt(), buffer.readInt(), buffer.readInt()); | ||
int aSize = 0; | ||
if (packet.mode == 0) | ||
aSize = 16; | ||
else if (packet.mode == 1) | ||
aSize = 1; | ||
int checkOut = 0; | ||
for (int i = 0; i < aSize; i++) | ||
for (int j = 0; j < aSize; j++) { | ||
byte kSize = buffer.readByte(); | ||
if (kSize == 0) continue; | ||
packet.map[i][j] = new HashMap<>(); | ||
for (int k = 0; k < kSize; k++) { | ||
byte y = buffer.readByte(); | ||
String name = buffer.readString(1000); | ||
packet.map[i][j].put(y, name); | ||
if (packet.mode != 1 || y == 1) | ||
packet.ores.add(name); | ||
checkOut++; | ||
} | ||
} | ||
int checkOut2 = buffer.readInt(); | ||
if (checkOut != checkOut2) { | ||
return null; | ||
} | ||
return packet; | ||
} | ||
|
||
public void writePacketData(PacketBuffer buffer) { | ||
buffer.writeInt(chunkX); | ||
buffer.writeInt(chunkZ); | ||
buffer.writeInt(posX); | ||
buffer.writeInt(posZ); | ||
buffer.writeInt(mode); | ||
int aSize = 0; | ||
if (this.mode == 0) | ||
aSize = 16; | ||
else if (this.mode == 1) | ||
aSize = 1; | ||
int checkOut = 0; | ||
for (int i = 0; i < aSize; i++) | ||
for (int j = 0; j < aSize; j++) { | ||
if (map[i][j] == null) | ||
buffer.writeByte(0); | ||
else { | ||
buffer.writeByte(map[i][j].keySet().size()); | ||
for (byte key : map[i][j].keySet()) { | ||
buffer.writeByte(key); | ||
buffer.writeString(map[i][j].get(key)); | ||
checkOut++; | ||
} | ||
} | ||
} | ||
buffer.writeInt(checkOut); | ||
} | ||
|
||
public void addBlock(int x, int y, int z, String orePrefix) { | ||
if (this.mode == 0) { | ||
if (map[x][z] == null) | ||
map[x][z] = new HashMap<>(); | ||
map[x][z].put((byte) y, orePrefix); | ||
ores.add(orePrefix); | ||
} else if (this.mode == 1) { | ||
if (map[x][z] == null) | ||
map[x][z] = new HashMap<>(); | ||
map[x][z].put((byte) y, orePrefix); | ||
if (y == 1) { | ||
ores.add(orePrefix); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/main/java/gregtech/common/terminal/app/prospector/OreProspectorApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package gregtech.common.terminal.app.prospector; | ||
|
||
import gregtech.api.gui.GuiTextures; | ||
import gregtech.api.gui.widgets.ImageWidget; | ||
import gregtech.api.terminal.app.AbstractApplication; | ||
import gregtech.api.terminal.os.TerminalOSWidget; | ||
import gregtech.api.terminal.os.TerminalTheme; | ||
import gregtech.api.terminal.os.menu.IMenuComponent; | ||
import gregtech.common.terminal.app.prospector.widget.WidgetOreList; | ||
import gregtech.common.terminal.app.prospector.widget.WidgetProspectingMap; | ||
import gregtech.common.terminal.component.ClickComponent; | ||
import gregtech.common.terminal.component.SearchComponent; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
|
||
public class OreProspectorApp extends AbstractApplication implements | ||
SearchComponent.IWidgetSearch<String> { | ||
WidgetOreList widgetOreList; | ||
WidgetProspectingMap widgetProspectingMap; | ||
|
||
public OreProspectorApp() { | ||
super("ore_prospector", GuiTextures.SCANNER_OVERLAY); | ||
} | ||
|
||
@Override | ||
public AbstractApplication createApp(TerminalOSWidget os, boolean isClient, NBTTagCompound nbt) { //333, 232 | ||
OreProspectorApp app = new OreProspectorApp(); | ||
app.addWidget(new ImageWidget(0, 0, 333, 232, TerminalTheme.COLOR_B_2)); | ||
int chunkRadius = 7; | ||
int offset = (232 - 32 * 7 + 16) / 2; | ||
if (isClient) { | ||
app.widgetOreList = new WidgetOreList(32 * chunkRadius - 16, offset, 333 - 32 * chunkRadius + 16, 232 - 2 * offset); | ||
app.addWidget(app.widgetOreList); | ||
} | ||
app.widgetProspectingMap = new WidgetProspectingMap(0, offset, chunkRadius, app.widgetOreList, 0, 1); | ||
app.addWidget(1, app.widgetProspectingMap); | ||
return app; | ||
} | ||
|
||
@Override | ||
public List<IMenuComponent> getMenuComponents() { | ||
ClickComponent darkMode = new ClickComponent().setIcon(GuiTextures.ICON_VISIBLE).setHoverText("terminal.prospector.vis_mode").setClickConsumer(cd->{ | ||
if (cd.isClient) { | ||
widgetProspectingMap.setDarkMode(!widgetProspectingMap.getDarkMode()); | ||
} | ||
}); | ||
return Arrays.asList(darkMode, new SearchComponent<>(this)); | ||
} | ||
|
||
@Override | ||
public String resultDisplay(String result) { | ||
if (widgetOreList != null) { | ||
return widgetOreList.ores.get(result); | ||
} | ||
return ""; | ||
} | ||
|
||
@Override | ||
public void selectResult(String result) { | ||
if (widgetOreList != null) { | ||
widgetOreList.setSelected(result); | ||
} | ||
} | ||
|
||
@Override | ||
public void search(String word, Consumer<String> find) { | ||
if (widgetOreList != null) { | ||
word = word.toLowerCase(); | ||
for (Map.Entry<String, String> entry : widgetOreList.ores.entrySet()) { | ||
if (entry.getKey().toLowerCase().contains(word) || entry.getValue().toLowerCase().contains(word)) { | ||
find.accept(entry.getKey()); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.