Skip to content

Commit

Permalink
Merge branch 'master' into minimap-drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann Bernhardt committed Jan 10, 2022
2 parents 28bde49 + f677160 commit 433cb4a
Show file tree
Hide file tree
Showing 17 changed files with 245 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: |
mkdir run
echo "eula=true" > run/eula.txt
timeout 10 ./gradlew runServer || true
timeout 60 ./gradlew runServer || true
- name: Test no crashes happend
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ whitelist.json
*.ipr
*.iws
src/main/resources/mixins.*.json
dependencies/voxelmap*.jar
/data/
*.bat
Binary file added BON2-2.5.0.CUSTOM-all.jar
Binary file not shown.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

### For Minecraft 1.7.10

This mod is intended for player convenience, but may also be used as API, since it provides the location of all GT ore veins in a cache. VisualProspecting tracks all GT Ore Veins a player has found and visualizes them in JourneyMap and/or XaeroWorldMap (optional, if installed). It also visualizes tracked Thaumcraft aura nodes if TCNodeTracker if installed.
This mod is intended for player convenience, but may also be used as API, since it provides the location of all GT ore veins in a cache. VisualProspecting tracks all GT Ore Veins a player has found and visualizes them in JourneyMap and/or XaeroWorldMap (optional, if installed). It also visualizes tracked Thaumcraft aura nodes if TCNodeTracker if installed. VoxelMap will add waypoints for prospected ore veins and fluids.

VisualProspecting tracks all ores that a player interacted with, by right or by left click. It also integrates prospecting data from GTs _Advanced Seismic Prospector_, although only books that are created after this mod was added will provide integration.
You may share your findings with other players by crafting a _Prospector's Log_.
Expand Down Expand Up @@ -52,6 +52,7 @@ You may use JourneyMap's Actions Menu to achieve this or type `/visualprospectin

Does VisualProspecting run with other maps? - I runs just fine, but it has no visualization or GUI integration. If you like to add integration into other maps yourself, feel free to contact me or open a Pull Request.
- [TheLastKumquat](https://github.com/kumquat-ir) integrated XaeroWorldMap and XaeroMiniMap
- [glowredman](https://github.com/glowredman) integrated VoxelMap

### Dependencies

Expand All @@ -77,6 +78,9 @@ Does VisualProspecting run with other maps? - I runs just fine, but it has no vi
- Injected class: [_GT_Worldgenerator_Space_](https://github.com/SinTh0r4s/VisualProspecting/blob/master/src/main/java/com/sinthoras/visualprospecting/mixins/galacticgreg/GT_Worldgenerator_SpaceMixin.java)
- [Bartworks](https://github.com/GTNewHorizons/bartworks): Injects a notification call into ore vein generation.
- Injected class: [_BW_WordGenerator.WorldGenContainer_](https://github.com/SinTh0r4s/VisualProspecting/blob/master/src/main/java/com/sinthoras/visualprospecting/mixins/bartworks/WorldGenContainerMixin.java)
- [IFU](https://github.com/GTNewHorizons/IFU): Injects a notification call to add found ore veins by the ore finder wand.
- Injected class: [_ItemOreFinderTool_](https://github.com/SinTh0r4s/VisualProspecting/blob/master/src/main/java/com/sinthoras/visualprospecting/mixins/ifu/ItemOreFinderToolMixin.java)
- [VoxelMap](https://www.curseforge.com/minecraft/mc-mods/voxelmap/files/2462146): Automatically adds waypoints for prospected ore veins and fluids.

### Add Visual Prospecting as API

Expand Down
37 changes: 37 additions & 0 deletions addon.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'de.undercouch:gradle-download-task:4.1.2'
}
}

import de.undercouch.gradle.tasks.download.Download

def voxelMapFile = file("data/voxelmap_1.7.0b.jar")
def voxelMapFileDeobf = file("dependencies/voxelmap_1.7.0b-deobf.jar")

task getVoxelMap(type: Download) {
onlyIf {
!voxelMapFile.exists()
}
src "https://media.forgecdn.net/files/2462/146/mod_voxelMap_1.7.0b_for_1.7.10.litemod" //direct link to VoxelMap on CurseForge
dest voxelMapFile
mustRunAfter "deobfBinJar"
mustRunAfter "repackMinecraft"
}

task deobfVoxelMap(dependsOn: getVoxelMap, type: Exec) {
onlyIf {
!voxelMapFileDeobf.exists()
}
// VoxelMap uese Notch names, so we have to deobfuscate them
// Source for the BON2 version used: https://github.com/glowredman/BON2/tree/Official
commandLine 'java', '-jar', 'BON2-2.5.0.CUSTOM-all.jar', '--inputJar', voxelMapFile, '--outputJar', voxelMapFileDeobf, '--mcVer', '1.7.10', '--mappingsVer', 'stable_12-1.7.10', '--notch'
}

tasks.setupCIWorkspace.dependsOn deobfVoxelMap
tasks.setupDevWorkspace.dependsOn deobfVoxelMap
tasks.setupDecompWorkspace.dependsOn deobfVoxelMap
tasks.compileJava.dependsOn deobfVoxelMap
6 changes: 4 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
dependencies {
shadowImplementation("com.github.SinTh0r4s:Enklume:master-SNAPSHOT")


compile("com.github.GTNewHorizons:GT5-Unofficial:master-SNAPSHOT:dev")
compile("com.github.GTNewHorizons:TCNodeTracker:master-SNAPSHOT:dev")

compile("curse.maven:journeymap-32274:2367915")
compile files("libs/Xaeros_Minimap_21.10.11_Forge_1.7.10-deobf")
compile files("libs/XaerosWorldMap_1.14.1.10_Forge_1.7.10-deobf")
compile files("dependencies/Xaeros_Minimap_21.10.14_Forge_1.7.10-deobf.jar")
compile files("dependencies/XaerosWorldMap_1.14.1.11_Forge_1.7.10-deobf.jar")
compileOnly files("dependencies/voxelmap_1.7.0b-deobf.jar")

compileOnly("com.github.GTNewHorizons:IFU:master-SNAPSHOT:dev") {
transitive = false
Expand Down
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions src/main/java/com/sinthoras/visualprospecting/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ private static class Defaults {
public static final int minZoomLevelForUndergroundFluidDetails = 2;
public static final int uploadBandwidthBytes = 2000000;
public static final int maxTransferCacheSizeMB = 50;
public static final boolean enableVoxelMapWaypointsByDefault = false;
public static final int maxDimensionSizeMBForFastScanning = 10000;
}

private static class Categories {
public static final String general = "general";
public static final String network = "network";
public static final String integration = "integration";
public static final String caching = "caching";
}

Expand All @@ -37,6 +39,7 @@ private static class Categories {
public static double uploadBandwidthBytes = Defaults.uploadBandwidthBytes;
public static int uploadSizePerPacket = (int)(uploadBandwidthBytes / uploadPacketsPerSecond);
public static int maxTransferCacheSizeMB = Defaults.maxTransferCacheSizeMB;
public static boolean enableVoxelMapWaypointsByDefault = Defaults.enableVoxelMapWaypointsByDefault;
public static int maxDimensionSizeMBForFastScanning = Defaults.maxDimensionSizeMBForFastScanning;


Expand Down Expand Up @@ -84,6 +87,10 @@ public static void syncronizeConfiguration(File configFile) {
if(recacheVeins) {
recacheVeinsProperty.set(false);
}

Property enableVoxelMapWaypointsByDefaultProperty = configuration.get(Categories.integration, "enableVoxelMapWaypointsByDefault", Defaults.enableVoxelMapWaypointsByDefault,
"[CLIENT / VoxelMap] Enable waypoints added by prospecting GT ore veins or underground fluids by default");
enableVoxelMapWaypointsByDefault = enableVoxelMapWaypointsByDefaultProperty.getBoolean();

Property maxDimensionSizeMBForFastScanningProperty = configuration.get(Categories.caching, "maxDimensionSizeMBForFastScanning",
Defaults.maxDimensionSizeMBForFastScanning, "[Client + Server] Define the maximum size of a " +
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/sinthoras/visualprospecting/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.sinthoras.visualprospecting.hooks.HooksClient;

import cpw.mods.fml.common.Loader;
import net.minecraft.client.Minecraft;
import net.minecraft.launchwrapper.Launch;
Expand Down Expand Up @@ -44,6 +45,17 @@ public static boolean isJourneyMapInstalled() {
public static boolean isXaerosWorldMapInstalled() {
return Loader.isModLoaded("XaeroWorldMap");
}

public static boolean isVoxelMapInstalled() {
try {
// If a LiteLoader mod is present cannot be checked by calling Loader#isModLoaded.
// Instead, we check if the VoxelMap main class is present.
Class.forName("com.thevoxelbox.voxelmap.litemod.LiteModVoxelMap");
return true;
} catch (Exception e) {
return false;
}
}

public static int coordBlockToChunk(int blockCoord) {
return blockCoord < 0 ? -((-blockCoord - 1) >> 4) - 1 : blockCoord >> 4;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sinthoras.visualprospecting.database;

import com.sinthoras.visualprospecting.*;
import com.sinthoras.visualprospecting.hooks.ProspectingNotificationEvent;
import com.sinthoras.visualprospecting.network.ProspectingRequest;
import gregtech.common.blocks.GT_TileEntity_Ores;
import net.minecraft.client.Minecraft;
Expand All @@ -12,6 +13,7 @@
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;

import java.io.File;
import java.util.ArrayList;
Expand Down Expand Up @@ -44,13 +46,15 @@ public void putOreVeins(List<OreVeinPosition> oreVeinPositions) {
if(oreVeinPositions.size() == 1) {
final OreVeinPosition oreVeinPosition = oreVeinPositions.get(0);
if(putOreVein(oreVeinPosition) != DimensionCache.UpdateResult.AlreadyKnown) {
MinecraftForge.EVENT_BUS.post(new ProspectingNotificationEvent.OreVein(oreVeinPosition));
notifyNewOreVein(oreVeinPosition);
}
}
else if(oreVeinPositions.size() > 1) {
int newOreVeins = 0;
for(OreVeinPosition oreVeinPosition : oreVeinPositions) {
if(putOreVein(oreVeinPosition) != DimensionCache.UpdateResult.AlreadyKnown) {
MinecraftForge.EVENT_BUS.post(new ProspectingNotificationEvent.OreVein(oreVeinPosition));
newOreVeins++;
}
}
Expand All @@ -73,9 +77,11 @@ public void putUndergroundFluids(List<UndergroundFluidPosition> undergroundFluid
for(UndergroundFluidPosition undergroundFluidPosition : undergroundFluids) {
DimensionCache.UpdateResult updateResult = putUndergroundFluids(undergroundFluidPosition);
if(updateResult == DimensionCache.UpdateResult.New) {
MinecraftForge.EVENT_BUS.post(new ProspectingNotificationEvent.UndergroundFluid(undergroundFluidPosition));
newUndergroundFluids++;
}
if(updateResult == DimensionCache.UpdateResult.Updated) {
else if(updateResult == DimensionCache.UpdateResult.Updated) {
MinecraftForge.EVENT_BUS.post(new ProspectingNotificationEvent.UndergroundFluid(undergroundFluidPosition));
updatedUndergroundFluids++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public int getBlockZ() {
}

public boolean isDepleted() {
return depleted;
return depleted;
}

public void toggleDepleted() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.sinthoras.visualprospecting.hooks;

import com.sinthoras.visualprospecting.Utils;
import com.sinthoras.visualprospecting.VP;
import com.sinthoras.visualprospecting.database.ResetClientCacheCommand;
import com.sinthoras.visualprospecting.integration.voxelmap.VoxelMapEventHandler;

import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
Expand All @@ -13,6 +16,8 @@
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;

import org.lwjgl.input.Keyboard;

public class HooksClient extends HooksShared {
Expand All @@ -37,6 +42,9 @@ public void fmlLifeCycleEvent(FMLInitializationEvent event) {
public void fmlLifeCycleEvent(FMLPostInitializationEvent event) {
super.fmlLifeCycleEvent(event);
ClientCommandHandler.instance.registerCommand(new ResetClientCacheCommand());
if(Utils.isVoxelMapInstalled()) {
MinecraftForge.EVENT_BUS.register(new VoxelMapEventHandler());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.sinthoras.visualprospecting.hooks;

import com.sinthoras.visualprospecting.database.OreVeinPosition;
import com.sinthoras.visualprospecting.database.UndergroundFluidPosition;

import cpw.mods.fml.common.eventhandler.Event;

public class ProspectingNotificationEvent extends Event {

@Override
public boolean isCancelable() {
return false;
}

public static class OreVein extends ProspectingNotificationEvent {

private final OreVeinPosition position;

public OreVein(OreVeinPosition position) {
this.position = position;
}

public OreVeinPosition getPosition() {
return this.position;
}

}

public static class UndergroundFluid extends ProspectingNotificationEvent {

private final UndergroundFluidPosition position;

public UndergroundFluid(UndergroundFluidPosition position) {
this.position = position;
}

public UndergroundFluidPosition getPosition() {
return this.position;
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.sinthoras.visualprospecting.integration.voxelmap;

import java.lang.reflect.Method;

import com.sinthoras.visualprospecting.VP;
import com.thevoxelbox.voxelmap.interfaces.IWaypointManager;

public class IWaypointManagerReflection {

private static Method getCurrentSubworldDescriptor;

public static String getCurrentSubworldDescriptor(IWaypointManager obj, boolean arg) {
try {
return (String) getCurrentSubworldDescriptor.invoke(obj, arg);
} catch (Exception e) {
VP.error("Could not invoke IWaypointManager#if. If it failed due to a NullPointerException, look for an error message starting with \"Getting the method IWaypointManager#if failed\" further up.");
e.printStackTrace();
}
return "";
}

static {
try {
getCurrentSubworldDescriptor = IWaypointManager.class.getMethod("if", boolean.class);
} catch (Exception e) {
VP.error("Getting the method IWaypointManager#if failed, any calls to IWaypointManagerReflection#getCurrentSubworldDescriptor will return an empty String.");
e.printStackTrace();
}
}

}
Loading

0 comments on commit 433cb4a

Please sign in to comment.