-
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.
- Loading branch information
0 parents
commit 02e467e
Showing
1,469 changed files
with
34,824 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Disable autocrlf on generated files, they always generate with LF | ||
# Add any extra files or paths here to make git stop saying they | ||
# are changed when only line endings change. | ||
src/generated/**/.cache/cache text eol=lf | ||
src/generated/**/*.json text eol=lf |
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,25 @@ | ||
# eclipse | ||
bin | ||
*.launch | ||
.settings | ||
.metadata | ||
.classpath | ||
.project | ||
|
||
# idea | ||
out | ||
*.ipr | ||
*.iws | ||
*.iml | ||
.idea | ||
|
||
# gradle | ||
build | ||
.gradle | ||
|
||
# other | ||
eclipse | ||
run | ||
|
||
# Files from Forge MDK | ||
forge*changelog.txt |
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,251 @@ | ||
buildscript { | ||
repositories { | ||
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below | ||
maven { url = 'https://maven.minecraftforge.net' } | ||
jcenter() | ||
mavenCentral() | ||
maven { name="sponge"; url 'https://repo.spongepowered.org/repository/maven-public/' } | ||
} | ||
dependencies { | ||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true | ||
classpath 'org.spongepowered:mixingradle:0.7.32' | ||
} | ||
} | ||
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. | ||
plugins { | ||
id 'eclipse' | ||
id 'maven-publish' | ||
} | ||
apply plugin: 'net.minecraftforge.gradle' | ||
|
||
apply plugin: 'org.spongepowered.mixin' | ||
|
||
|
||
version = '3.0' | ||
group = 'com.hexagram2021.emeraldcraft' // http://maven.apache.org/guides/mini/guide-naming-conventions.html | ||
archivesBaseName = 'emeraldcraft' | ||
|
||
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. | ||
java.toolchain.languageVersion = JavaLanguageVersion.of(17) | ||
|
||
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" | ||
minecraft { | ||
// The mappings can be changed at any time and must be in the following format. | ||
// Channel: Version: | ||
// official MCVersion Official field/method names from Mojang mapping files | ||
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official | ||
// | ||
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings. | ||
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md | ||
// | ||
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge | ||
// Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started | ||
// | ||
// Use non-default mappings at your own risk. They may not always work. | ||
// Simply re-run your setup task after changing the mappings to update your workspace. | ||
mappings channel: 'official', version: '1.18.2' | ||
|
||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default. | ||
|
||
// Default run configurations. | ||
// These can be tweaked, removed, or duplicated as needed. | ||
runs { | ||
client { | ||
workingDirectory project.file('run') | ||
|
||
// Recommended logging data for a userdev environment | ||
// The markers can be added/remove as needed separated by commas. | ||
// "SCAN": For mods scan. | ||
// "REGISTRIES": For firing of registry events. | ||
// "REGISTRYDUMP": For getting the contents of all registries. | ||
property 'forge.logging.markers', 'REGISTRIES' | ||
property 'mixin.env.remapRefMap', 'true' | ||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" | ||
|
||
// Recommended logging level for the console | ||
// You can set various levels here. | ||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels | ||
property 'forge.logging.console.level', 'debug' | ||
|
||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces. | ||
property 'forge.enabledGameTestNamespaces', 'emeraldcraft' | ||
arg "-mixin.config=emeraldcraft.mixins.json" | ||
|
||
mods { | ||
emeraldcraft { | ||
source sourceSets.main | ||
} | ||
} | ||
} | ||
|
||
server { | ||
workingDirectory project.file('run') | ||
|
||
// Recommended logging data for a userdev environment | ||
// The markers can be added/remove as needed separated by commas. | ||
// "SCAN": For mods scan. | ||
// "REGISTRIES": For firing of registry events. | ||
// "REGISTRYDUMP": For getting the contents of all registries. | ||
property 'forge.logging.markers', 'REGISTRIES' | ||
property 'mixin.env.remapRefMap', 'true' | ||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" | ||
|
||
// Recommended logging level for the console | ||
// You can set various levels here. | ||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels | ||
property 'forge.logging.console.level', 'debug' | ||
arg "-mixin.config=emeraldcraft.mixins.json" | ||
|
||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces. | ||
property 'forge.enabledGameTestNamespaces', 'emeraldcraft' | ||
|
||
mods { | ||
emeraldcraft { | ||
source sourceSets.main | ||
} | ||
} | ||
} | ||
|
||
// This run config launches GameTestServer and runs all registered gametests, then exits. | ||
// By default, the server will crash when no gametests are provided. | ||
// The gametest system is also enabled by default for other run configs under the /test command. | ||
gameTestServer { | ||
workingDirectory project.file('run') | ||
|
||
// Recommended logging data for a userdev environment | ||
// The markers can be added/remove as needed separated by commas. | ||
// "SCAN": For mods scan. | ||
// "REGISTRIES": For firing of registry events. | ||
// "REGISTRYDUMP": For getting the contents of all registries. | ||
property 'forge.logging.markers', 'REGISTRIES' | ||
property 'mixin.env.remapRefMap', 'true' | ||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" | ||
|
||
// Recommended logging level for the console | ||
// You can set various levels here. | ||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels | ||
property 'forge.logging.console.level', 'debug' | ||
|
||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces. | ||
property 'forge.enabledGameTestNamespaces', 'emeraldcraft' | ||
arg "-mixin.config=emeraldcraft.mixins.json" | ||
|
||
mods { | ||
emeraldcraft { | ||
source sourceSets.main | ||
} | ||
} | ||
} | ||
|
||
data { | ||
workingDirectory project.file('run') | ||
|
||
// Recommended logging data for a userdev environment | ||
// The markers can be added/remove as needed separated by commas. | ||
// "SCAN": For mods scan. | ||
// "REGISTRIES": For firing of registry events. | ||
// "REGISTRYDUMP": For getting the contents of all registries. | ||
property 'forge.logging.markers', 'REGISTRIES' | ||
property 'mixin.env.remapRefMap', 'true' | ||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" | ||
|
||
// Recommended logging level for the console | ||
// You can set various levels here. | ||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels | ||
property 'forge.logging.console.level', 'debug' | ||
|
||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. | ||
|
||
args '--mod', 'emeraldcraft', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') | ||
arg "-mixin.config=emeraldcraft.mixins.json" | ||
|
||
mods { | ||
emeraldcraft { | ||
source sourceSets.main | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Include resources generated by data generators. | ||
sourceSets.main.resources { srcDir 'src/generated/resources' } | ||
|
||
repositories { | ||
// Put repositories for dependencies here | ||
// ForgeGradle automatically adds the Forge maven and Maven Central for you | ||
|
||
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so: | ||
// flatDir { | ||
// dir 'libs' | ||
// } | ||
maven { // TOP | ||
url "https://cursemaven.com" | ||
} | ||
maven { // JEI | ||
name 'DVS1 Maven FS' | ||
url 'https://dvs1.progwml6.com/files/maven' | ||
} | ||
maven { //mirror | ||
name = "ModMaven" | ||
url = "https://modmaven.dev" | ||
} | ||
} | ||
|
||
dependencies { | ||
minecraft 'net.minecraftforge:forge:1.18.2-40.1.0' | ||
|
||
compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.5.5.174:api") // Adds JEI API as a compile dependency | ||
|
||
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' | ||
|
||
implementation fg.deobf("com.github.glitchfiend:TerraBlender-forge:1.18.2-1.1.0.99") //TerraBlender | ||
} | ||
|
||
// Example for how to get properties into the manifest for reading at runtime. | ||
jar { | ||
manifest { | ||
attributes([ | ||
"Specification-Title" : "Emerald Craft Mod", | ||
"Specification-Vendor" : "Hexagram", | ||
"Specification-Version" : "1", // We are version 1 of ourselves | ||
"Implementation-Title" : project.name, | ||
"Implementation-Version" : project.jar.archiveVersion, | ||
"Implementation-Vendor" : "Hexagram", | ||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), | ||
'FMLCorePluginContainsFMLMod': 'true' | ||
]) | ||
} | ||
} | ||
|
||
// Example configuration to allow publishing using the maven-publish plugin | ||
// This is the preferred method to reobfuscate your jar file | ||
jar.finalizedBy('reobfJar') | ||
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing | ||
// publish.dependsOn('reobfJar') | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
artifact jar | ||
} | ||
} | ||
repositories { | ||
maven { | ||
url "file://${project.projectDir}/mcmodsrepo" | ||
} | ||
} | ||
} | ||
|
||
mixin { | ||
// MixinGradle Settings | ||
add sourceSets.main, 'emeraldcraft.refmap.json' | ||
config 'emeraldcraft.mixins.json' | ||
|
||
debug.verbose = true | ||
debug.export = true | ||
} | ||
|
||
tasks.withType(JavaCompile).configureEach { | ||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation | ||
} |
112 changes: 112 additions & 0 deletions
112
src/main/java/com/hexagram2021/emeraldcraft/EmeraldCraft.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,112 @@ | ||
package com.hexagram2021.emeraldcraft; | ||
|
||
import com.hexagram2021.emeraldcraft.client.ClientProxy; | ||
import com.hexagram2021.emeraldcraft.common.CommonProxy; | ||
import com.hexagram2021.emeraldcraft.common.ECContent; | ||
import com.hexagram2021.emeraldcraft.common.ECSaveData; | ||
import com.hexagram2021.emeraldcraft.common.ModVanillaCompat; | ||
import com.hexagram2021.emeraldcraft.common.register.ECBlocks; | ||
import com.hexagram2021.emeraldcraft.common.register.ECRecipes; | ||
import com.hexagram2021.emeraldcraft.common.util.ECLogger; | ||
import com.hexagram2021.emeraldcraft.common.world.ECWorldGen; | ||
import com.hexagram2021.emeraldcraft.common.world.Villages; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.item.*; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.event.server.ServerStartedEvent; | ||
import net.minecraftforge.eventbus.api.EventPriority; | ||
import net.minecraftforge.eventbus.api.IEventBus; | ||
import net.minecraftforge.fml.*; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; | ||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; | ||
import net.minecraftforge.fml.loading.FMLLoader; | ||
import net.minecraftforge.network.NetworkRegistry; | ||
import net.minecraftforge.network.simple.SimpleChannel; | ||
import org.apache.logging.log4j.LogManager; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Optional; | ||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
@Mod(EmeraldCraft.MODID) | ||
public class EmeraldCraft { | ||
public static final String MODID = "emeraldcraft"; | ||
public static final String MODNAME = "Emerald Craft"; | ||
public static final String VERSION = "${version}"; | ||
|
||
public static final CommonProxy proxy = DistExecutor.safeRunForDist(bootstrapErrorToXCPInDev(() -> ClientProxy::new), bootstrapErrorToXCPInDev(() -> CommonProxy::new)); | ||
|
||
public static final SimpleChannel packetHandler = NetworkRegistry.ChannelBuilder | ||
.named(new ResourceLocation(MODID, "main")) | ||
.networkProtocolVersion(() -> VERSION) | ||
.serverAcceptedVersions(VERSION::equals) | ||
.clientAcceptedVersions(VERSION::equals) | ||
.simpleChannel(); | ||
|
||
// Complete hack: DistExecutor::safeRunForDist intentionally tries to access the "wrong" supplier in dev, which | ||
// throws an error (rather than an exception) on J16 due to trying to load a client-only class. So we need to | ||
// replace the error with an exception in dev. | ||
//* | ||
public static <T> | ||
Supplier<T> bootstrapErrorToXCPInDev(Supplier<T> in) { | ||
if(FMLLoader.isProduction()) { | ||
return in; | ||
} | ||
return () -> { | ||
try { | ||
return in.get(); | ||
} catch(BootstrapMethodError e) { | ||
throw new RuntimeException(e); | ||
} | ||
}; | ||
} | ||
//*/ | ||
|
||
public EmeraldCraft() { | ||
ECLogger.logger = LogManager.getLogger(MODID); | ||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); | ||
// bus.addListener(this::enqueueIMCs); | ||
// MinecraftForge.EVENT_BUS.addListener(this::registerCommands); | ||
MinecraftForge.EVENT_BUS.addListener(this::serverStarted); | ||
// ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ECCommonConfig.CONFIG_SPEC.getBaseSpec()); | ||
// ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ECClientConfig.CONFIG_SPEC.getBaseSpec()); | ||
// ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ECServerConfig.CONFIG_SPEC.getBaseSpec()); | ||
DeferredWorkQueue queue = DeferredWorkQueue.lookup(Optional.of(ModLoadingStage.CONSTRUCT)).orElseThrow(); | ||
Consumer<Runnable> runLater = job -> queue.enqueueWork( | ||
ModLoadingContext.get().getActiveContainer(), job | ||
); | ||
ECContent.modConstruction(bus, runLater); | ||
DistExecutor.safeRunWhenOn(Dist.CLIENT, bootstrapErrorToXCPInDev(() -> ClientProxy::modConstruction)); | ||
|
||
MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, ECWorldGen::biomeModification); | ||
bus.addListener(this::setup); | ||
MinecraftForge.EVENT_BUS.register(this); | ||
} | ||
|
||
public void setup(FMLCommonSetupEvent event) { | ||
event.enqueueWork(Villages::init); | ||
event.enqueueWork(ECContent::init); | ||
event.enqueueWork(ModVanillaCompat::setup); | ||
} | ||
|
||
public void serverStarted(ServerStartedEvent event) { | ||
ServerLevel world = event.getServer().getLevel(Level.OVERWORLD); | ||
if(!world.isClientSide) { | ||
ECSaveData worldData = world.getDataStorage().computeIfAbsent(ECSaveData::new, ECSaveData::new, ECSaveData.dataName); | ||
ECSaveData.setInstance(worldData); | ||
} | ||
} | ||
|
||
public static final CreativeModeTab ITEM_GROUP = new CreativeModeTab(MODID) { | ||
@Override | ||
@Nonnull | ||
public ItemStack makeIcon() { | ||
return new ItemStack(ECBlocks.TO_STAIRS.get(new ResourceLocation(ResourceLocation.DEFAULT_NAMESPACE, "emerald_block"))); | ||
} | ||
}; | ||
} |
Oops, something went wrong.