Skip to content

Commit

Permalink
Fabric & Forge port 1.20.1
Browse files Browse the repository at this point in the history
Made the mod work with forge and fabric, modification of commit AntiqueAtlasTeam#470

Co-Authored-By: Louis <[email protected]>
  • Loading branch information
ByteDevEs and Dev0Louis committed Oct 8, 2023
1 parent 2cf2594 commit fdc9f82
Show file tree
Hide file tree
Showing 12 changed files with 427 additions and 4 deletions.
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
architectury {
common(rootProject.enabled_platforms)
common(rootProject.enabled_platforms.split(","))
}

loom {
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Antique Atlas is a book that acts like a map featuring infinite scrolling, zoom and custom labeled markers. The map is generated around the player by calculating the average biome in each 16x16 chunk.",
"version": "${version}",
"authors": ["Hunternif", "tyra314"],
"contributors": ["coolAlias", "Kenkron", "TheCodeWarrior", "Localizations by crafteverywhere", "CapoFantasma97", "Mazdallier", "mankra", "Zerotiger"],
"contributors": ["coolAlias", "Kenkron", "TheCodeWarrior", "Localizations by crafteverywhere", "CapoFantasma97", "Mazdallier", "mankra", "Zerotiger", "Dev0Louis"],
"entrypoints": {
"main": [
"hunternif.mc.impl.atlas.fabric.AntiqueAtlasModFabric"
Expand Down
130 changes: 130 additions & 0 deletions forge/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id "me.shedaniel.unified-publishing"
}

architectury {
platformSetupLoomIde()
forge()
}

loom {
accessWidenerPath = project(":common").loom.accessWidenerPath

forge {
convertAccessWideners = true
extraAccessWideners.add loom.accessWidenerPath.get().asFile.name

mixinConfig "antiqueatlas-common.mixins.json"
mixinConfig "antiqueatlas.mixins.json"
}
}


configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentForge.extendsFrom common
}

dependencies {
forge "net.minecraftforge:forge:${rootProject.forge_version}"

modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
modApi "me.shedaniel.cloth:cloth-config-forge:${rootProject.cloth_config_version}"

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
}

processResources {
inputs.property "version", project.version

filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
}

shadowJar {
exclude "fabric.mod.json"
exclude "architectury.common.json"

configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
}

remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier null
}

jar {
classifier "dev"
}

sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}

components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}

publishing {
publications {
mavenForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}

unifiedPublishing {
project {
gameVersions = ["1.18.2"]
gameLoaders = ["forge"]
releaseType = "release"

mainPublication tasks.remapJar

relations {
depends {
curseforge = "cloth-config"
modrinth = "cloth-config"
}
depends {
curseforge = "architectury-api"
modrinth = "architectury-api"
}
}

var cfToken = System.getenv("CF_TOKEN")
if (cfToken != null) {
curseforge {
token = cfToken
id = rootProject.curseforge_id
gameVersions.addAll "Java 17"
}
}

var mrToken = System.getenv("MODRINTH_TOKEN")
if (mrToken != null) {
modrinth {
token = mrToken
id = rootProject.modrinth_id
}
}
}
}
1 change: 1 addition & 0 deletions forge/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=forge
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
package hunternif.mc.impl.atlas.client.forge;

import hunternif.mc.impl.atlas.AntiqueAtlasMod;
import hunternif.mc.impl.atlas.client.TileTextureMap;
import net.minecraft.client.MinecraftClient;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.BiomeTags;
import net.minecraft.util.Identifier;
import net.minecraft.registry.Registry;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.Tags;

import java.util.Optional;

@OnlyIn(Dist.CLIENT)
public class TileTextureMapImpl {
static public Optional<Identifier> guessFittingTextureSet(RegistryKey<Biome> biome) {
if (MinecraftClient.getInstance().world == null)
return Optional.empty();

RegistryEntry.Reference<Biome> biomeTag = MinecraftClient.getInstance().world.getRegistryManager().get(RegistryKeys.BIOME).entryOf(biome);

if (biomeTag.isIn(BiomeTags.IS_END)) {
// if (biomeTag.isIn(Tags.Biomes.END) || biomeTag.isIn(ConventionalBiomeTags.VEGETATION_SPARSE)) {
// return Optional.of(AntiqueAtlasMod.id("end_island_plants"));
// } else {
return Optional.of(AntiqueAtlasMod.id("end_island"));
// }
}

if (biomeTag.isIn(BiomeTags.IS_NETHER)) {
return Optional.of(AntiqueAtlasMod.id("soul_sand_valley"));
}

if (biomeTag.isIn(Tags.Biomes.IS_VOID)) {
return Optional.of(AntiqueAtlasMod.id("end_void"));
}

if (biomeTag.isIn(Tags.Biomes.IS_SWAMP)) {
if (biomeTag.isIn(BiomeTags.IS_HILL)) {
return Optional.of(AntiqueAtlasMod.id("swamp_hills"));
} else {
return Optional.of(AntiqueAtlasMod.id("swamp"));
}
}

if (biomeTag.isIn(BiomeTags.IS_OCEAN)
|| biomeTag.isIn(BiomeTags.IS_DEEP_OCEAN)
|| biomeTag.isIn(BiomeTags.IS_RIVER)
|| biomeTag.isIn(Tags.Biomes.IS_WATER)) {
if (biomeTag.isIn(Tags.Biomes.IS_COLD) || biomeTag.isIn(Tags.Biomes.IS_SNOWY))
return Optional.of(AntiqueAtlasMod.id("ice"));

return Optional.of(AntiqueAtlasMod.id("water"));
}

if (biomeTag.isIn(BiomeTags.IS_BEACH) || biomeTag.isIn(BiomeTags.IS_BEACH)) {
return Optional.of(AntiqueAtlasMod.id("shore"));
}

if (biomeTag.isIn(BiomeTags.IS_JUNGLE)) {
if (biomeTag.isIn(BiomeTags.IS_HILL)) {
return Optional.of(AntiqueAtlasMod.id("jungle_hills"));
} else {
return Optional.of(AntiqueAtlasMod.id("jungle"));
}
}

if (biomeTag.isIn(BiomeTags.IS_SAVANNA)) {
return Optional.of(AntiqueAtlasMod.id("savana"));
}

if (biomeTag.isIn((Tags.Biomes.IS_PLATEAU))) {
return Optional.of(AntiqueAtlasMod.id("plateau_mesa"));
}

if (biomeTag.isIn(BiomeTags.IS_FOREST)
|| biomeTag.isIn(Tags.Biomes.IS_DENSE)
|| biomeTag.isIn(Tags.Biomes.IS_SPARSE)
) {
if (biomeTag.isIn(Tags.Biomes.IS_COLD) || biomeTag.isIn(Tags.Biomes.IS_SNOWY)) {
if (biomeTag.isIn(BiomeTags.IS_HILL)) {
return Optional.of(AntiqueAtlasMod.id("snow_pines_hills"));
} else {
return Optional.of(AntiqueAtlasMod.id("snow_pines"));
}
} else {
if (biomeTag.isIn(BiomeTags.IS_HILL)) {
return Optional.of(AntiqueAtlasMod.id("forest_hills"));
} else {
return Optional.of(AntiqueAtlasMod.id("forest"));
}
}
}

if (biomeTag.isIn(Tags.Biomes.IS_PLAINS)) {
if (biomeTag.isIn(Tags.Biomes.IS_COLD)
|| biomeTag.isIn(Tags.Biomes.IS_SNOWY)
) {
if (biomeTag.isIn(BiomeTags.IS_HILL)) {
return Optional.of(AntiqueAtlasMod.id("snow_hills"));
} else {
return Optional.of(AntiqueAtlasMod.id("snow"));
}
} else {
if (biomeTag.isIn(BiomeTags.IS_HILL)) {
return Optional.of(AntiqueAtlasMod.id("hills"));
} else {
return Optional.of(AntiqueAtlasMod.id("plains"));
}
}
}

if (biomeTag.isIn(Tags.Biomes.IS_COLD)) {
if (biomeTag.isIn(BiomeTags.IS_HILL)) {
return Optional.of(AntiqueAtlasMod.id("mountains_snow_caps"));
} else {
return Optional.of(AntiqueAtlasMod.id("ice_spikes"));
}
}

if (biomeTag.isIn(Tags.Biomes.IS_HOT)) {
if (biomeTag.isIn(BiomeTags.IS_HILL)) {
return Optional.of(AntiqueAtlasMod.id("desert_hills"));
} else {
return Optional.of(AntiqueAtlasMod.id("desert"));
}
}

// if (biomeTag.isIn(Tags.Biomes.TAIGA)) {
// return Optional.of(AntiqueAtlasMod.id("snow"));
// }

// if (biomeTag.isIn(Tags.Biomes.EXTREME_HILLS)) {
// return Optional.of(AntiqueAtlasMod.id("hills"));
// }

if (biomeTag.isIn(Tags.Biomes.IS_SLOPE)) {
return Optional.of(AntiqueAtlasMod.id("mountains"));
}

if (biomeTag.isIn(Tags.Biomes.IS_PEAK)) {
return Optional.of(AntiqueAtlasMod.id("mountains_snow_caps"));
}

if (biomeTag.isIn(Tags.Biomes.IS_MUSHROOM)) {
return Optional.of(AntiqueAtlasMod.id("mushroom"));
}

if (biomeTag.isIn(BiomeTags.IS_BADLANDS)) {
return Optional.of(AntiqueAtlasMod.id("mesa"));
}

if (biomeTag.isIn(BiomeTags.IS_HILL)) {
return Optional.of(AntiqueAtlasMod.id("hills"));
}

if (biomeTag.isIn(Tags.Biomes.IS_UNDERGROUND)) {
AntiqueAtlasMod.LOG.warn("Underground biomes aren't supported yet.");
}

return TileTextureMap.guessFittingTextureSetFallback(biomeTag);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package hunternif.mc.impl.atlas.client.gui.forge;

import hunternif.mc.impl.atlas.AntiqueAtlasConfig;
import me.shedaniel.autoconfig.AutoConfig;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.ConfigScreenHandler;
import net.minecraftforge.fml.ModLoadingContext;

@OnlyIn(Dist.CLIENT)
public class AntiqueAtlasConfigMenu {
public static void init() {
ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class,
() -> new ConfigScreenHandler.ConfigScreenFactory((mc, parent) -> AutoConfig.getConfigScreen(AntiqueAtlasConfig.class, parent).get())
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package hunternif.mc.impl.atlas.forge;

import dev.architectury.platform.Platform;
import dev.architectury.platform.forge.EventBuses;
import dev.architectury.utils.Env;
import hunternif.mc.impl.atlas.AntiqueAtlasMod;
import hunternif.mc.impl.atlas.AntiqueAtlasModClient;
import hunternif.mc.impl.atlas.client.gui.forge.AntiqueAtlasConfigMenu;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

@Mod(AntiqueAtlasMod.ID)
public class AntiqueAtlasModForge
{
public AntiqueAtlasModForge()
{
// Submit our event bus to let architectury register our content on the right time
EventBuses.registerModEventBus(AntiqueAtlasMod.ID,
FMLJavaModLoadingContext.get().getModEventBus());

AntiqueAtlasMod.init();

if (Platform.getEnvironment() == Env.CLIENT)
{
AntiqueAtlasModClient.init();
AntiqueAtlasConfigMenu.init();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package hunternif.mc.impl.atlas.mixin.forge;

import net.minecraftforge.fml.loading.FMLEnvironment;

public class VolatileMixinPluginImpl
{
public static boolean isDevelopmentEnvironment() {
return !FMLEnvironment.production;
}
}
Loading

0 comments on commit fdc9f82

Please sign in to comment.