Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 8ca03de
Author: simibubi <31564874+simibubi@users.noreply.github.com>
Date:   Tue Sep 3 14:10:40 2024 +0200

    Hell on Overworld

    - Fixed incorrect dimension data in train map sync

commit 86ceb9e
Merge: 97205a7 b6856bd
Author: simibubi <31564874+simibubi@users.noreply.github.com>
Date:   Tue Sep 3 12:58:34 2024 +0200

    Merge branch 'mc1.20.1/dev' into mc1.20.1/train_map_integration

commit 97205a7
Author: simibubi <31564874+simibubi@users.noreply.github.com>
Date:   Tue Sep 3 12:58:02 2024 +0200

    Tube map

    - Added fullscreen map integration for FTB Chunks and Journeymap
  • Loading branch information
simibubi committed Oct 9, 2024
1 parent bcad4bf commit 7d1a386
Show file tree
Hide file tree
Showing 38 changed files with 2,228 additions and 73 deletions.
24 changes: 24 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ repositories {
name = "squiddev"
url = "https://squiddev.cc/maven/"
}
maven {
name = "ftb"
url = "https://maven.saps.dev/releases"
}
maven {
name = "architectury"
url = "https://maven.architectury.dev/"
}
maven {
url = "https://jm.gserv.me/repository/maven-public/"
content {
includeGroup "info.journeymap"
includeGroup "mysticdrew"
}
}


maven {
url = 'https://www.cursemaven.com'
Expand Down Expand Up @@ -176,6 +192,14 @@ dependencies {
// implementation fg.deobf("curse.maven:ic2-classic-242942:5555152")
// implementation fg.deobf("curse.maven:druidcraft-340991:3101903")
// implementation fg.deobf("com.railwayteam.railways:railways-1.19.2-1.6.4:all") { transitive = false }

implementation fg.deobf("dev.architectury:architectury-forge:9.1.12")
implementation fg.deobf("dev.ftb.mods:ftb-chunks-forge:2001.3.1")
implementation fg.deobf("dev.ftb.mods:ftb-teams-forge:2001.3.0")
implementation fg.deobf("dev.ftb.mods:ftb-library-forge:2001.2.4")

implementation fg.deobf("curse.maven:journeymap-32274:5457831")
// implementation fg.deobf("ignored:journeymap-1.20.1-5.10.1-forge")

// runtimeOnly fg.deobf("curse.maven:framedblocks-441647:5399211")
// runtimeOnly fg.deobf("curse.maven:galosphere-631098:4574834")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2024-10-09T12:24:59.2028575 Registrate Provider for create [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
// 1.20.1 2024-09-03T11:32:11.6637155 Registrate Provider for create [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
60bbdf92d2ac9824ea6144955c74043a6005f79d assets/create/blockstates/acacia_window.json
6a67703c2697d81b7dc83e9d72a66f9c9ff08383 assets/create/blockstates/acacia_window_pane.json
c3ae87b62e81d8e9476eccd793bb1548d74c66a1 assets/create/blockstates/adjustable_chain_gearshift.json
Expand Down Expand Up @@ -585,8 +585,8 @@ b0d8f08968763a5f74e5cd5644377a76a9f39753 assets/create/blockstates/yellow_toolbo
fe8c497aacc641c2f01cec90bba9f19e59cc2ed2 assets/create/blockstates/yellow_valve_handle.json
e819e93fdcbe9fd9c050a052d2718ff3b3539365 assets/create/blockstates/zinc_block.json
64121dcb216381c83b4fe28aa361ea07c24c9ad0 assets/create/blockstates/zinc_ore.json
d3d30a92e4f63e8acb6aa3e3358b6e8340aa8cc1 assets/create/lang/en_ud.json
a50be2f8a02b0fdd2b5a8aae9cf8df1490015707 assets/create/lang/en_us.json
1195fdc4fb51659c921e2bbe744a35107f787aa2 assets/create/lang/en_ud.json
632d1aac7255fc0f4804f4df138ce9926134d2f9 assets/create/lang/en_us.json
a97e1060e00ae701a02e39cd4ef8054cf345fac4 assets/create/models/block/acacia_window.json
103e032c0b1a0a6a27c67da8c91179a564bd281c assets/create/models/block/acacia_window_pane_noside.json
fb00b627abda76ad4fea867ca57dbfadd24fffa3 assets/create/models/block/acacia_window_pane_noside_alt.json
Expand Down
16 changes: 16 additions & 0 deletions src/generated/resources/assets/create/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -2479,6 +2479,7 @@
"create.station.remove_auto_schedule": "ǝןnpǝɥɔS-oʇnⱯ pɹɐɔsıᗡ",
"create.station.remove_schedule": "ǝןnpǝɥɔS ǝʌǝıɹʇǝᴚ",
"create.station.retry": "ʎɹʇǝɹ puɐ sıɥʇ ǝʌןosǝᴚ",
"create.station.train_map_color": "sdɐW uo ɹoןoƆ",
"create.station.train_not_aligned": "'ǝןqɯǝssɐsıp ʇouuɐƆ",
"create.station.train_not_aligned_1": "pǝubıןɐ sǝbɐıɹɹɐɔ ןןɐ ʇou",
"create.subtitle.blaze_munch": "sǝɥɔunɯ ɹǝuɹnᗺ ǝzɐןᗺ",
Expand Down Expand Up @@ -2649,6 +2650,21 @@
"create.train_assembly.sideways_controls": "sʎɐʍǝpıs ǝɔɐɟ ʇouuɐɔ sןoɹʇuoƆ uıɐɹ⟘",
"create.train_assembly.single_bogey_carriage": "uʍo sʇı uo ǝbɐıɹɹɐɔ ɐ ʇɹoddns ʇouuɐɔ ǝdʎʇ ʎǝboᗺ sıɥ⟘",
"create.train_assembly.too_many_bogeys": "%1$s :pǝɥɔɐʇʇɐ sʎǝboᗺ ʎuɐɯ oo⟘",
"create.train_map.cannot_traverse_section": "ǝsɹǝʌɐɹʇ ʎןןnɟ ʇouuɐƆ ",
"create.train_map.conductor_missing": "buıssıW ɹoʇɔnpuoƆ >¡< ",
"create.train_map.derailed": "pǝןıɐɹǝᗡ >¡< ",
"create.train_map.for_other_train": "%1$s ɹoɟ ",
"create.train_map.fuel_boosted": "✔ pǝʇsooq ןǝnℲ ",
"create.train_map.navigation_failed": "pǝןıɐℲ uoıʇɐbıʌɐN >¡< ",
"create.train_map.player_controlled": "ɹǝʎɐןԀ ʎq pǝןןoɹʇuoƆ >- ",
"create.train_map.redstone_powered": "pǝɹǝʍoԀ ǝuoʇspǝᴚ ",
"create.train_map.schedule_interrupted": "pǝʇdnɹɹǝʇuI ǝןnpǝɥɔS >¡< ",
"create.train_map.section_reserved": "pǝʌɹǝsǝɹ uoıʇɔǝS ",
"create.train_map.toggle": "ʎɐןɹǝʌo ʞɹoʍʇǝu uıɐɹ⟘",
"create.train_map.train_at_station": "%1$s |> ",
"create.train_map.train_moving_to_station": ")ɯ%2$s( %1$s >> ",
"create.train_map.train_owned_by": "%1$s ʎq",
"create.train_map.waiting_at_signal": "ןɐubıS ʇɐ buıʇıɐM ",
"create.tunnel.selection_mode.forced_round_robin": "uıqoᴚ punoᴚ pǝɔɹoℲ",
"create.tunnel.selection_mode.forced_split": "ʇıןdS pǝɔɹoℲ",
"create.tunnel.selection_mode.prefer_nearest": "ʇsǝɹɐǝN ɹǝɟǝɹԀ",
Expand Down
16 changes: 16 additions & 0 deletions src/generated/resources/assets/create/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2479,6 +2479,7 @@
"create.station.remove_auto_schedule": "Discard Auto-Schedule",
"create.station.remove_schedule": "Retrieve Schedule",
"create.station.retry": "Resolve this and retry",
"create.station.train_map_color": "Color on Maps",
"create.station.train_not_aligned": "Cannot disassemble,",
"create.station.train_not_aligned_1": "not all carriages aligned",
"create.subtitle.blaze_munch": "Blaze Burner munches",
Expand Down Expand Up @@ -2649,6 +2650,21 @@
"create.train_assembly.sideways_controls": "Train Controls cannot face sideways",
"create.train_assembly.single_bogey_carriage": "This Bogey type cannot support a carriage on its own",
"create.train_assembly.too_many_bogeys": "Too many Bogeys attached: %1$s",
"create.train_map.cannot_traverse_section": " Cannot fully traverse",
"create.train_map.conductor_missing": " <!> Conductor Missing",
"create.train_map.derailed": " <!> Derailed",
"create.train_map.for_other_train": " for %1$s",
"create.train_map.fuel_boosted": " Fuel boosted ✔",
"create.train_map.navigation_failed": " <!> Navigation Failed",
"create.train_map.player_controlled": " -> Controlled by Player",
"create.train_map.redstone_powered": " Redstone Powered",
"create.train_map.schedule_interrupted": " <!> Schedule Interrupted",
"create.train_map.section_reserved": " Section reserved",
"create.train_map.toggle": "Train network overlay",
"create.train_map.train_at_station": " >| %1$s",
"create.train_map.train_moving_to_station": " >> %1$s (%2$sm)",
"create.train_map.train_owned_by": "by %1$s",
"create.train_map.waiting_at_signal": " Waiting at Signal",
"create.tunnel.selection_mode.forced_round_robin": "Forced Round Robin",
"create.tunnel.selection_mode.forced_split": "Forced Split",
"create.tunnel.selection_mode.prefer_nearest": "Prefer Nearest",
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/simibubi/create/AllPackets.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.function.Supplier;

import com.simibubi.create.compat.computercraft.AttachedComputerPacket;
import com.simibubi.create.compat.trainmap.TrainMapSyncPacket;
import com.simibubi.create.compat.trainmap.TrainMapSyncRequestPacket;
import com.simibubi.create.content.contraptions.ContraptionBlockChangedPacket;
import com.simibubi.create.content.contraptions.ContraptionColliderLockPacket;
import com.simibubi.create.content.contraptions.ContraptionColliderLockPacket.ContraptionColliderLockPacketRequest;
Expand Down Expand Up @@ -164,6 +166,7 @@ public enum AllPackets {
CLIPBOARD_EDIT(ClipboardEditPacket.class, ClipboardEditPacket::new, PLAY_TO_SERVER),
CONTRAPTION_COLLIDER_LOCK_REQUEST(ContraptionColliderLockPacketRequest.class,
ContraptionColliderLockPacketRequest::new, PLAY_TO_SERVER),
TRAIN_MAP_REQUEST(TrainMapSyncRequestPacket.class, TrainMapSyncRequestPacket::new, PLAY_TO_SERVER),

// Server to Client
SYMMETRY_EFFECT(SymmetryEffectPacket.class, SymmetryEffectPacket::new, PLAY_TO_CLIENT),
Expand Down Expand Up @@ -208,7 +211,8 @@ public enum AllPackets {
CONTRAPTION_ACTOR_TOGGLE(ContraptionDisableActorPacket.class, ContraptionDisableActorPacket::new, PLAY_TO_CLIENT),
CONTRAPTION_COLLIDER_LOCK(ContraptionColliderLockPacket.class, ContraptionColliderLockPacket::new, PLAY_TO_CLIENT),
ATTACHED_COMPUTER(AttachedComputerPacket.class, AttachedComputerPacket::new, PLAY_TO_CLIENT),
SERVER_DEBUG_INFO(ServerDebugInfoPacket.class, ServerDebugInfoPacket::new, PLAY_TO_CLIENT)
SERVER_DEBUG_INFO(ServerDebugInfoPacket.class, ServerDebugInfoPacket::new, PLAY_TO_CLIENT),
TRAIN_MAP_SYNC(TrainMapSyncPacket.class, TrainMapSyncPacket::new, PLAY_TO_CLIENT)
;

public static final ResourceLocation CHANNEL_NAME = Create.asResource("main");
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/simibubi/create/compat/Mods.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public enum Mods {
TCONSTRUCT,
FRAMEDBLOCKS,
XLPACKETS,
MODERNUI;
MODERNUI,
FTBCHUNKS,
JOURNEYMAP;

private final String id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public final String getTrainName() throws LuaException {
public final void setTrainName(String name) throws LuaException {
Train train = getTrainOrThrow();
train.name = Components.literal(name);
AllPackets.getChannel().send(PacketDistributor.ALL.noArg(), new TrainEditPacket.TrainEditReturnPacket(train.id, name, train.icon.getId()));
AllPackets.getChannel().send(PacketDistributor.ALL.noArg(), new TrainEditPacket.TrainEditReturnPacket(train.id, name, train.icon.getId(), train.mapColorIndex));
}

@LuaFunction
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
package com.simibubi.create.compat.trainmap;

import java.util.List;

import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.RemovedGuiUtils;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.infrastructure.config.AllConfigs;

import dev.ftb.mods.ftbchunks.client.gui.LargeMapScreen;
import dev.ftb.mods.ftbchunks.client.gui.RegionMapPanel;
import dev.ftb.mods.ftblibrary.ui.ScreenWrapper;
import dev.ftb.mods.ftblibrary.ui.Widget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.util.Mth;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.client.event.RenderTooltipEvent;
import net.minecraftforge.client.event.ScreenEvent;
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;

public class FTBChunksTrainMap {

private static int cancelTooltips = 0;
private static boolean renderingTooltip = false;
private static boolean requesting;

public static void tick() {
if (cancelTooltips > 0)
cancelTooltips--;
if (!AllConfigs.client().showTrainMapOverlay.get()
|| getAsLargeMapScreen(Minecraft.getInstance().screen) == null) {
if (requesting)
TrainMapSyncClient.stopRequesting();
requesting = false;
return;
}
TrainMapManager.tick();
requesting = true;
TrainMapSyncClient.requestData();
}

public static void cancelTooltips(RenderTooltipEvent.Pre event) {
if (getAsLargeMapScreen(Minecraft.getInstance().screen) == null)
return;
if (renderingTooltip || cancelTooltips == 0)
return;
event.setCanceled(true);
}

public static void mouseClick(InputEvent.MouseButton.Pre event) {
LargeMapScreen screen = getAsLargeMapScreen(Minecraft.getInstance().screen);
if (screen == null)
return;
if (TrainMapManager.handleToggleWidgetClick(screen.getMouseX(), screen.getMouseY(), 20, 2))
event.setCanceled(true);
}

public static void renderGui(ScreenEvent.Render.Post event) {
LargeMapScreen largeMapScreen = getAsLargeMapScreen(event.getScreen());
if (largeMapScreen == null)
return;
Object panel = ObfuscationReflectionHelper.getPrivateValue(LargeMapScreen.class, largeMapScreen, "regionPanel");
if (!(panel instanceof RegionMapPanel regionMapPanel))
return;
GuiGraphics graphics = event.getGuiGraphics();
if (!AllConfigs.client().showTrainMapOverlay.get()) {
renderToggleWidgetAndTooltip(event, largeMapScreen, graphics);
return;
}

int blocksPerRegion = 16 * 32;
int minX = Mth.floor(regionMapPanel.getScrollX());
int minY = Mth.floor(regionMapPanel.getScrollY());
float regionTileSize = largeMapScreen.getRegionTileSize() / (float) blocksPerRegion;
int regionMinX =
ObfuscationReflectionHelper.getPrivateValue(RegionMapPanel.class, regionMapPanel, "regionMinX");
int regionMinZ =
ObfuscationReflectionHelper.getPrivateValue(RegionMapPanel.class, regionMapPanel, "regionMinZ");
float mouseX = event.getMouseX();
float mouseY = event.getMouseY();

boolean linearFiltering = largeMapScreen.getRegionTileSize() * Minecraft.getInstance()
.getWindow()
.getGuiScale() < 512D;

PoseStack pose = graphics.pose();
pose.pushPose();

pose.translate(-minX, -minY, 0);
pose.scale(regionTileSize, regionTileSize, 1);
pose.translate(-regionMinX * blocksPerRegion, -regionMinZ * blocksPerRegion, 0);

mouseX += minX;
mouseY += minY;
mouseX /= regionTileSize;
mouseY /= regionTileSize;
mouseX += regionMinX * blocksPerRegion;
mouseY += regionMinZ * blocksPerRegion;

Rect2i bounds = new Rect2i(Mth.floor(minX / regionTileSize + regionMinX * blocksPerRegion),
Mth.floor(minY / regionTileSize + regionMinZ * blocksPerRegion),
Mth.floor(largeMapScreen.width / regionTileSize), Mth.floor(largeMapScreen.height / regionTileSize));

List<FormattedText> tooltip = TrainMapManager.renderAndPick(graphics, Mth.floor(mouseX), Mth.floor(mouseY),
event.getPartialTick(), linearFiltering, bounds);

pose.popPose();

if (!renderToggleWidgetAndTooltip(event, largeMapScreen, graphics) && tooltip != null) {
renderingTooltip = true;
RemovedGuiUtils.drawHoveringText(graphics, tooltip, event.getMouseX(), event.getMouseY(),
largeMapScreen.width, largeMapScreen.height, 256, Minecraft.getInstance().font);
renderingTooltip = false;
cancelTooltips = 5;
}

pose.pushPose();
pose.translate(0, 0, 300);
for (Widget widget : largeMapScreen.getWidgets()) {
if (!widget.isEnabled())
continue;
if (widget == panel)
continue;
widget.draw(graphics, largeMapScreen.getTheme(), widget.getPosX(), widget.getPosY(), widget.getWidth(),
widget.getHeight());
}
pose.popPose();
}

private static boolean renderToggleWidgetAndTooltip(ScreenEvent.Render.Post event, LargeMapScreen largeMapScreen,
GuiGraphics graphics) {
TrainMapManager.renderToggleWidget(graphics, 20, 2);
if (!TrainMapManager.isToggleWidgetHovered(event.getMouseX(), event.getMouseY(), 20, 2))
return false;

renderingTooltip = true;
RemovedGuiUtils.drawHoveringText(graphics, List.of(Lang.translate("train_map.toggle")
.component()), event.getMouseX(), event.getMouseY() + 20, largeMapScreen.width, largeMapScreen.height, 256,
Minecraft.getInstance().font);
renderingTooltip = false;
cancelTooltips = 5;
return true;
}

private static LargeMapScreen getAsLargeMapScreen(Screen screen) {
if (!(screen instanceof ScreenWrapper screenWrapper))
return null;
Object wrapped = ObfuscationReflectionHelper.getPrivateValue(ScreenWrapper.class, screenWrapper, "wrappedGui");
if (!(wrapped instanceof LargeMapScreen largeMapScreen))
return null;
return largeMapScreen;
}

}
Loading

0 comments on commit 7d1a386

Please sign in to comment.