forked from AntiqueAtlasTeam/AntiqueAtlas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made the mod work with forge and fabric, modification of commit AntiqueAtlasTeam#470 Co-Authored-By: Louis <[email protected]>
- Loading branch information
Showing
12 changed files
with
427 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
loom.platform=forge |
168 changes: 168 additions & 0 deletions
168
forge/src/main/java/hunternif/mc/impl/atlas/client/forge/TileTextureMapImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
forge/src/main/java/hunternif/mc/impl/atlas/client/gui/forge/AntiqueAtlasConfigMenu.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
forge/src/main/java/hunternif/mc/impl/atlas/forge/AntiqueAtlasModForge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
forge/src/main/java/hunternif/mc/impl/atlas/mixin/forge/VolatileMixinPluginImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.