mirror of https://github.com/kami-blue/client
Fixed ChunkFinder rendering bugs and close #474
This commit is contained in:
parent
9b511b3e4f
commit
4620f1bb80
|
@ -19,12 +19,14 @@ import java.nio.file.Path;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendChatMessage;
|
import static me.zeroeightsix.kami.util.MessageSendHelper.*;
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
import static org.lwjgl.opengl.GL11.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 086 and IronException
|
* @author 086 and IronException
|
||||||
|
* Rendering bugs fixed by dominikaaaa on 16/05/20
|
||||||
*/
|
*/
|
||||||
@Module.Info(
|
@Module.Info(
|
||||||
name = "ChunkFinder",
|
name = "ChunkFinder",
|
||||||
|
@ -55,11 +57,11 @@ public class ChunkFinder extends Module {
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
glDisable(GL_DEPTH_TEST);
|
// glDisable(GL_DEPTH_TEST); // makes KamiTessellator.drawBox opacity too transparent
|
||||||
glDisable(GL_TEXTURE_2D);
|
// glDisable(GL_TEXTURE_2D); // breaks KamiTessellator.drawBox colors
|
||||||
glDepthMask(false);
|
// glDepthMask(false); // makes KamiTessellator.drawBox opacity too transparent
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // breaks KamiTessellator.drawBox opacity
|
||||||
glEnable(GL_BLEND);
|
// glEnable(GL_BLEND); // makes KamiTessellator.drawBox opacity too opaque
|
||||||
glLineWidth(1.0F);
|
glLineWidth(1.0F);
|
||||||
for (Chunk chunk : chunks) {
|
for (Chunk chunk : chunks) {
|
||||||
double posX = chunk.x * 16;
|
double posX = chunk.x * 16;
|
||||||
|
@ -76,10 +78,10 @@ public class ChunkFinder extends Module {
|
||||||
glVertex3d(posX, posY, posZ);
|
glVertex3d(posX, posY, posZ);
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
glDisable(GL_BLEND);
|
// glDisable(GL_BLEND); // makes KamiTessellator.drawBox opacity too opaque
|
||||||
glDepthMask(true);
|
// glDepthMask(true); // makes KamiTessellator.drawBox opacity too transparent
|
||||||
glEnable(GL_TEXTURE_2D);
|
// glEnable(GL_TEXTURE_2D); // breaks KamiTessellator.drawBox colors
|
||||||
glEnable(GL_DEPTH_TEST);
|
// glEnable(GL_DEPTH_TEST); // makes KamiTessellator.drawBox opacity too transparent
|
||||||
glDisable(GL_LINE_SMOOTH);
|
glDisable(GL_LINE_SMOOTH);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glColor4f(1, 1, 1, 1);
|
glColor4f(1, 1, 1, 1);
|
||||||
|
@ -101,20 +103,21 @@ public class ChunkFinder extends Module {
|
||||||
if (!closeFile.getValue())
|
if (!closeFile.getValue())
|
||||||
return;
|
return;
|
||||||
closeFile.setValue(false);
|
closeFile.setValue(false);
|
||||||
sendChatMessage("close file");
|
closeSettings();
|
||||||
logWriterClose();
|
logWriterClose();
|
||||||
|
sendChatMessage(getChatName() + "Saved file!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDisable() {
|
protected void onDisable() {
|
||||||
sendChatMessage("onDisable");
|
|
||||||
logWriterClose();
|
logWriterClose();
|
||||||
chunks.clear();
|
chunks.clear();
|
||||||
|
sendChatMessage(getChatName() + "Saved and cleared chunks!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public Listener<ChunkEvent> listener = new Listener<>(event -> {
|
public Listener<ChunkEvent> listener = new Listener<>(event -> {
|
||||||
if (!event.getPacket().isFullChunk()) {
|
if (event.getPacket().isFullChunk()) {
|
||||||
chunks.add(event.getChunk());
|
chunks.add(event.getChunk());
|
||||||
dirty = true;
|
dirty = true;
|
||||||
if (saveNewChunks.getValue()) {
|
if (saveNewChunks.getValue()) {
|
||||||
|
@ -165,8 +168,8 @@ public class ChunkFinder extends Module {
|
||||||
logWriter.println(head);
|
logWriter.println(head);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
KamiMod.log.error("some exception happened when trying to start the logging -> " + e.getMessage());
|
KamiMod.log.error(getChatName() + "some exception happened when trying to start the logging -> " + e.getMessage());
|
||||||
sendChatMessage("onLogStart: " + e.getMessage());
|
sendErrorMessage(getChatName() + "onLogStart: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,15 +182,15 @@ public class ChunkFinder extends Module {
|
||||||
// If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file
|
// If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file
|
||||||
if (mc.isSingleplayer()) {
|
if (mc.isSingleplayer()) {
|
||||||
try {
|
try {
|
||||||
file = mc.getIntegratedServer().getWorld(dimension).getChunkSaveLocation();
|
file = Objects.requireNonNull(mc.getIntegratedServer()).getWorld(dimension).getChunkSaveLocation();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
KamiMod.log.error("some exception happened when getting canonicalFile -> " + e.getMessage());
|
KamiMod.log.error("some exception happened when getting canonicalFile -> " + e.getMessage());
|
||||||
sendChatMessage("onGetPath: " + e.getMessage());
|
sendErrorMessage(getChatName() + "onGetPath: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the "depth" of this directory relative the the game's run directory, 2 is the location of the world
|
// Gets the "depth" of this directory relative the the game's run directory, 2 is the location of the world
|
||||||
if (file.toPath().relativize(mc.gameDir.toPath()).getNameCount() != 2) {
|
if (Objects.requireNonNull(file).toPath().relativize(mc.gameDir.toPath()).getNameCount() != 2) {
|
||||||
// subdirectory of the main save directory for this world
|
// subdirectory of the main save directory for this world
|
||||||
|
|
||||||
file = file.getParentFile();
|
file = file.getParentFile();
|
||||||
|
@ -222,7 +225,7 @@ public class ChunkFinder extends Module {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
KamiMod.log.error("some exception happened when trying to make the file -> " + e.getMessage());
|
KamiMod.log.error("some exception happened when trying to make the file -> " + e.getMessage());
|
||||||
sendChatMessage("onCreateFile: " + e.getMessage());
|
sendErrorMessage(getChatName() + "onCreateFile: " + e.getMessage());
|
||||||
}
|
}
|
||||||
return rV;
|
return rV;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +235,7 @@ public class ChunkFinder extends Module {
|
||||||
String folderName;
|
String folderName;
|
||||||
switch (saveOption.getValue()) {
|
switch (saveOption.getValue()) {
|
||||||
case LITE_LOADER_WDL: // make folder structure like liteLoader
|
case LITE_LOADER_WDL: // make folder structure like liteLoader
|
||||||
folderName = mc.getCurrentServerData().serverName;
|
folderName = Objects.requireNonNull(mc.getCurrentServerData()).serverName;
|
||||||
|
|
||||||
rV = new File(rV, "saves");
|
rV = new File(rV, "saves");
|
||||||
rV = new File(rV, folderName);
|
rV = new File(rV, folderName);
|
||||||
|
@ -246,12 +249,12 @@ public class ChunkFinder extends Module {
|
||||||
|
|
||||||
// extra because name might be different
|
// extra because name might be different
|
||||||
if (!rV.exists()) {
|
if (!rV.exists()) {
|
||||||
sendChatMessage("nhack wdl directory doesnt exist: " + folderName);
|
sendWarningMessage(getChatName() + "nhack wdl directory doesnt exist: " + folderName);
|
||||||
sendChatMessage("creating the directory now. It is recommended to update the ip");
|
sendWarningMessage(getChatName() + "creating the directory now. It is recommended to update the ip");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: // make folder structure in .minecraft
|
default: // make folder structure in .minecraft
|
||||||
folderName = mc.getCurrentServerData().serverName + "-" + mc.getCurrentServerData().serverIP;
|
folderName = Objects.requireNonNull(mc.getCurrentServerData()).serverName + "-" + mc.getCurrentServerData().serverIP;
|
||||||
if (SystemUtils.IS_OS_WINDOWS) {
|
if (SystemUtils.IS_OS_WINDOWS) {
|
||||||
folderName = folderName.replace(":", "_");
|
folderName = folderName.replace(":", "_");
|
||||||
}
|
}
|
||||||
|
@ -264,7 +267,7 @@ public class ChunkFinder extends Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNHackInetName() {
|
private String getNHackInetName() {
|
||||||
String folderName = mc.getCurrentServerData().serverIP;
|
String folderName = Objects.requireNonNull(mc.getCurrentServerData()).serverIP;
|
||||||
if (SystemUtils.IS_OS_WINDOWS) {
|
if (SystemUtils.IS_OS_WINDOWS) {
|
||||||
folderName = folderName.replace(":", "_");
|
folderName = folderName.replace(":", "_");
|
||||||
}
|
}
|
||||||
|
@ -281,10 +284,8 @@ public class ChunkFinder extends Module {
|
||||||
|
|
||||||
String[] sp = ip.split("_");
|
String[] sp = ip.split("_");
|
||||||
String ending = sp[sp.length - 1];
|
String ending = sp[sp.length - 1];
|
||||||
if (!isInteger(ending)) { // if it is numeric it means it might be a port...
|
// if it is numeric it means it might be a port...
|
||||||
return true;
|
return !isInteger(ending);
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInteger(String s) {
|
private boolean isInteger(String s) {
|
||||||
|
@ -344,7 +345,7 @@ public class ChunkFinder extends Module {
|
||||||
if (dimension != mc.player.dimension) {
|
if (dimension != mc.player.dimension) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!mc.getCurrentServerData().serverIP.equals(ip)) { // strings need equals + this way because could be null
|
if (!Objects.requireNonNull(mc.getCurrentServerData()).serverIP.equals(ip)) { // strings need equals + this way because could be null
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -355,7 +356,7 @@ public class ChunkFinder extends Module {
|
||||||
lastInRegion = saveInRegionFolder.getValue();
|
lastInRegion = saveInRegionFolder.getValue();
|
||||||
lastSaveNormal = alsoSaveNormalCoords.getValue();
|
lastSaveNormal = alsoSaveNormalCoords.getValue();
|
||||||
dimension = mc.player.dimension;
|
dimension = mc.player.dimension;
|
||||||
ip = mc.getCurrentServerData().serverIP;
|
ip = Objects.requireNonNull(mc.getCurrentServerData()).serverIP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue