Skip to content

Commit

Permalink
Portals Highlighting feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Jul 25, 2023
1 parent 2a3a67b commit 68e3ecb
Show file tree
Hide file tree
Showing 25 changed files with 778 additions and 381 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ Or a modpack zip with these jars is included in the Github releases.
* [Adjustable minimap scaling that increases how many chunks are visible](https://cdn.discordapp.com/attachments/971140948593635335/1109734742842146937/Temurin-1.8.0_352_2023.03.29_-_16.16.08.32.DVR.mp4)
* [NewChunks Highlighting in MiniMap and WorldMap.](https://cdn.discordapp.com/attachments/971140948593635335/1109735633045434408/Base_Profile_2023.01.02_-_11.26.22.02.DVR.mp4)
* [WorldDownloader 4.1.1.0](https://github.com/Pokechu22/WorldDownloader/) integration (does not work with Future's Forge WDL jar)
* [Highlights chunks as they are downloaded in the Minimap and WorldMap.](https://cdn.discordapp.com/attachments/971140948593635335/1109735287006961705/Temurin-1.8.0_352_2023.01.02_-_18.54.28.04.DVR.mp4)
* [Baritone](https://github.com/cabaletta/baritone) integration
* Baritone Goals synced as temporary waypoints
* [Point and Click Travel](https://cdn.discordapp.com/attachments/1005598555186139156/1125306712300204082/Base_Profile_2023.07.02_-_23.04.34.09.DVR.mp4)
* [Waystones](https://legacy.curseforge.com/minecraft/mc-mods/waystones) integration
* Syncs Waystones as temporary waypoints
* [Portal Skip Highlighting in Minimap and WorldMap](https://cdn.discordapp.com/attachments/1029572347818151947/1109656254265163816/Base_Profile_2023.05.20_-_18.34.34.34.DVR.mp4). Detects chunks where a portal could have been loaded.
* [Portal Highlighting in Minimap and WorldMap.](https://cdn.discordapp.com/attachments/1127463054804779028/1133251771217752175/Base_Profile_2023.07.24_-_21.02.36.03.mp4)
* [Transparent minimap background instead of wasted black screen space.](https://cdn.discordapp.com/attachments/963821382569979904/1088651890335686716/2023-03-23_19.26.36.png)
* [Fast map region writes](https://cdn.discordapp.com/attachments/963821382569979904/1049947847467995196/Temurin-1.8.0_345_2022.12.06_-_22.44.28.05.DVR.mp4). Prevent missed chunks in map while traveling at very high speeds.
* Allow multiple MC instances to read/write to the same map concurrently
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ dependencies {
implementation(fg.deobf("maven.modrinth:xaeros-world-map:1.31.0_Forge_1.12"))
implementation(fg.deobf("maven.modrinth:xaeros-minimap:23.6.0_Forge_1.12"))
implementation(fg.deobf('cabaletta:baritone-deobf-unoptimized-mcp-dev:1.2')).setChanging(true)
implementation(fg.deobf("curse.maven:waystones-245755:2859589"))
compileOnly(fg.deobf("curse.maven:waystones-245755:2859589"))

annotationProcessor('org.spongepowered:mixin:0.8.5:processor') {
exclude module: 'gson'
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/xaeroplus/event/ChunkDataEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package xaeroplus.event;

import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.fml.common.eventhandler.Event;

public class ChunkDataEvent extends Event {
private final boolean isFullChunk;
private final Chunk chunk;

public ChunkDataEvent(final boolean isFullChunk, final Chunk chunk) {
this.isFullChunk = isFullChunk;
this.chunk = chunk;
}

public boolean isFullChunk() {
return this.isFullChunk;
}

public Chunk getChunk() {
return this.chunk;
}
}
14 changes: 14 additions & 0 deletions src/main/java/xaeroplus/mixin/client/MixinGuiMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
import xaeroplus.module.ModuleManager;
import xaeroplus.module.impl.NewChunks;
import xaeroplus.module.impl.PortalSkipDetection;
import xaeroplus.module.impl.Portals;
import xaeroplus.settings.XaeroPlusSettingRegistry;
import xaeroplus.util.*;
import xaeroplus.util.highlights.HighlightAtChunkPos;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -1101,6 +1103,18 @@ public void customDrawScreen(int scaledMouseX, int scaledMouseY, float partialTi
}
GuiHelper.drawRectList(rects, portalSkipDetection.getPortalSkipChunksColor());
}
if (XaeroPlusSettingRegistry.portalsEnabledSetting.getValue() && !mc.gameSettings.hideGUI) {
final List<GuiHelper.Rect> rects = new ArrayList<>(32);
final Portals portals = ModuleManager.getModule(Portals.class);
for (final HighlightAtChunkPos c : portals.getPortalsInRegion(leafRegionMinX, leafRegionMinZ, leveledSideInRegions, Shared.customDimensionId)) {
final float left = (float) ((c.x << 4) - flooredCameraX);
final float top = (float) ((c.z << 4) - flooredCameraZ);
final float right = left + 16;
final float bottom = top + 16;
rects.add(new GuiHelper.Rect(left, top, right, bottom));
}
GuiHelper.drawRectList(rects, portals.getPortalsColor());
}
if (XaeroPlusSettingRegistry.wdlEnabledSetting.getValue()
&& !mc.gameSettings.hideGUI
&& WDLHelper.isWdlPresent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import xaeroplus.module.ModuleManager;
import xaeroplus.module.impl.NewChunks;
import xaeroplus.module.impl.PortalSkipDetection;
import xaeroplus.module.impl.Portals;
import xaeroplus.settings.XaeroPlusSettingRegistry;
import xaeroplus.util.*;

Expand Down Expand Up @@ -343,6 +344,21 @@ public void drawMinimap(XaeroMinimapSession minimapSession, MinimapRendererHelpe
}
GuiHelper.drawRectList(rects, ModuleManager.getModule(PortalSkipDetection.class).getPortalSkipChunksColor());
}
if (XaeroPlusSettingRegistry.portalsEnabledSetting.getValue()) {
final List<GuiHelper.Rect> rects = new ArrayList<>(32);
for (int t = 0; t < 16; ++t) {
final int chunkPosX = chunk.getX() * 4 + t % 4;
final int chunkPosZ = chunk.getZ() * 4 + t / 4;
if (ModuleManager.getModule(Portals.class).isPortalChunk(chunkPosX, chunkPosZ, Shared.customDimensionId)) {
final float left = drawX + 16 * (t % 4);
final float top = drawZ + 16 * (t / 4);
final float right = left + 16;
final float bottom = top + 16;
rects.add(new GuiHelper.Rect(left, top, right, bottom));
}
}
GuiHelper.drawRectList(rects, ModuleManager.getModule(Portals.class).getPortalsColor());
}
if (XaeroPlusSettingRegistry.wdlEnabledSetting.getValue()
&& WDLHelper.isWdlPresent()
&& WDLHelper.isDownloading()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package xaeroplus.mixin.client.mc;

import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.network.play.server.SPacketChunkData;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import xaeroplus.XaeroPlus;
import xaeroplus.event.ChunkDataEvent;

@Mixin(NetHandlerPlayClient.class)
public class MixinNetHandlerPlayClient {
@Shadow
private WorldClient world;

@Inject(method = "handleChunkData", at = @At("RETURN"))
public void handleChunkData(final SPacketChunkData packetIn, final CallbackInfo ci) {
XaeroPlus.EVENT_BUS.post(new ChunkDataEvent(packetIn.isFullChunk(), this.world.getChunk(packetIn.getChunkX(), packetIn.getChunkZ())));
}
}
5 changes: 3 additions & 2 deletions src/main/java/xaeroplus/module/impl/NewChunks.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import xaeroplus.module.Module;
import xaeroplus.settings.XaeroPlusSettingRegistry;
import xaeroplus.util.ColorHelper;
import xaeroplus.util.HighlightAtChunkPos;
import xaeroplus.util.highlights.HighlightAtChunkPos;
import xaeroplus.util.newchunks.NewChunksCache;
import xaeroplus.util.newchunks.NewChunksLocalCache;
import xaeroplus.util.newchunks.NewChunksSavingCache;
Expand All @@ -23,13 +23,14 @@
public class NewChunks extends Module {
private NewChunksCache newChunksCache = new NewChunksLocalCache();
private int newChunksColor = getColor(255, 0, 0, 100);
private static final String DATABASE_NAME = "XaeroPlusNewChunks";

public void setNewChunksCache(boolean disk) {
try {
Long2LongOpenHashMap map = newChunksCache.getNewChunksState();
newChunksCache.onDisable();
if (disk) {
newChunksCache = new NewChunksSavingCache();
newChunksCache = new NewChunksSavingCache(DATABASE_NAME);
} else {
newChunksCache = new NewChunksLocalCache();
}
Expand Down
Loading

0 comments on commit 68e3ecb

Please sign in to comment.