Skip to content

Commit

Permalink
Just SO many changes. I'd write a more detailed log if I could remember.
Browse files Browse the repository at this point in the history
  • Loading branch information
kd8lvt committed Dec 22, 2024
1 parent 3a70657 commit 502663d
Show file tree
Hide file tree
Showing 60 changed files with 907 additions and 503 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ replay_*.log
/output/
/1.20.4-srcs/
/remappedSrc/
/src/main/generated/
/src/main/generated/
vanilla_assets
115 changes: 97 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,109 @@
//file:noinspection GroovyAssignabilityCheck
//file:noinspection GrUnresolvedAccess
plugins { //Incredibly annoying I can't offload this block to a non-build.gradle file :(
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
//Required for versioning.gradle - not loaded if not needed
id 'org.ajoberstar.grgit' version '5.3.0' apply false
plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'maven-publish'
}

sourceSets {
loom.mixin.add(main, "exclusionzone.refmap.json")
version = project.mod_version
group = project.maven_group

base {
archivesName = project.archives_base_name
}

repositories {
maven { url 'https://maven.fallenbreath.me/releases' }
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {
//conditional-mixin
url 'https://maven.fallenbreath.me/releases'
}
}

loom {
splitEnvironmentSourceSets()

mods {
"exclusionzone" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}

accessWidenerPath = file("src/main/resources/${modid}.accesswidener")

mixin {
defaultRefmapName = "exclusionzone.refmap.json"
}
}

fabricApi {
configureDataGeneration {
client = true
}
}

dependencies {
modImplementation 'me.fallenbreath:conditional-mixin-fabric:0.6.3'
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Suggested, to bundle it into your mod jar. Choose a method your build system provides
include 'me.fallenbreath:conditional-mixin-fabric:0.6.3'
//Conditional Mixin - allows 1.21 and 1.20.1 to work with the same jar
//Required to build. Unsure if it needs to be included, but it's recommended by the CM dev.
modImplementation "me.fallenbreath:conditional-mixin-fabric:${project.conditional_mixin_version}"
include "me.fallenbreath:conditional-mixin-fabric:${project.conditional_mixin_version}"
}

//Feel free to download these .gradle files and inspect them :)
processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 21
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}"}
}
}

// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_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.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

//Preset to build for Java 21 using Yarn, and output a sources jar on build.
apply from:"https://kd8lvt.com/gradle/minecraft/fabric/presets/yarn.j21.withSources.gradle"
//Oh hey, versioning.gradle, lookit that.
apply from:"https://kd8lvt.com/gradle/minecraft/versioning.gradle"
sourcesJar.dependsOn.add(runDatagen)
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ loader_version=0.16.9
# Fabric API
fabric_version=0.107.0+1.21.1

# Conditional Mixin
conditional_mixin_version=0.6.3

# Mod Properties
mod_version=1.0.7
mod_version=1.0.8
game_version=1.21.0+1.21.1
archives_base_name=exclusionzone
modid=exclusionzone
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
21 changes: 7 additions & 14 deletions src/main/java/com/kd8lvt/exclusionzone/ExclusionZone.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package com.kd8lvt.exclusionzone;

import com.kd8lvt.exclusionzone.event.ModEventHandlers;
import com.kd8lvt.exclusionzone.registry.ModItems;
import com.kd8lvt.exclusionzone.registry.ModRegistries;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.item.ItemGroup;
import net.minecraft.server.MinecraftServer;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.Identifier;
import net.minecraft.world.biome.Biome;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static com.kd8lvt.exclusionzone.api.CommonConstants.MOD_ID;
import static com.kd8lvt.exclusionzone.api.CommonConstants.SERVER;

public class ExclusionZone implements ModInitializer {
public static final String MOD_ID = "exclusionzone";
public static RegistryEntry<Biome> BIOME;
public static final boolean IN_DEV = FabricLoader.getInstance().isDevelopmentEnvironment();
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static MinecraftServer Server = null;

@Override
public void onInitialize() {
Expand All @@ -31,18 +32,10 @@ public void onInitialize() {
//TODO: Get rid of this and do things properly
@Deprecated(forRemoval = true,since="1.6.0")
public static void runCommand(String cmd) {
if (Server != null) Server.getCommandManager().executeWithPrefix(Server.getCommandSource().withSilent(),cmd);
if (SERVER != null) SERVER.getCommandManager().executeWithPrefix(SERVER.getCommandSource().withSilent(),cmd);
}

public static Identifier id(String id) {
return Identifier.of(MOD_ID,id);
}

public static void setServer(MinecraftServer server) {
Server = server;
}

public static void TabEntryCollector(ItemGroup.DisplayContext ignoredDisplayContext, ItemGroup.Entries entries) {
ModItems.CreativeTabSetup(entries);
}
}
17 changes: 17 additions & 0 deletions src/main/java/com/kd8lvt/exclusionzone/api/CommonConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.kd8lvt.exclusionzone.api;

import com.kd8lvt.exclusionzone.api.types.CachedValue;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.biome.Biome;

import static com.kd8lvt.exclusionzone.ExclusionZone.id;

public final class CommonConstants {
public static final String MOD_ID = "exclusionzone";
public static MinecraftServer SERVER;
public static final CachedValue<RegistryEntry<Biome>> BIOME = new CachedValue<>(
()-> SERVER.getOverworld().getRegistryManager().get(RegistryKeys.BIOME).getEntry(id("exclusionzone")).get()
);
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package com.kd8lvt.exclusionzone.api.datagen.lang;

import com.kd8lvt.exclusionzone.content.item.BlockItemArtifact;
import com.kd8lvt.exclusionzone.content.item.base.IHasResearchNotes;
import com.kd8lvt.exclusionzone.registry.ModRegistries;
import com.kd8lvt.exclusionzone.registry.ModStatusEffects;
import com.kd8lvt.exclusionzone.registry.ModTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.minecraft.block.Block;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.PotionItem;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;

import java.util.Locale;
import java.util.concurrent.CompletableFuture;

import static com.kd8lvt.exclusionzone.ExclusionZone.MOD_ID;
import static com.kd8lvt.exclusionzone.api.CommonConstants.MOD_ID;

public abstract class AbstractExclusionZoneLangProvider extends FabricLanguageProvider {
public AbstractExclusionZoneLangProvider(FabricDataOutput dataOutput, Locale locale, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
Expand All @@ -36,6 +41,10 @@ public static void addPotion(TranslationBuilder builder, String id, String name)
addPotion(builder,id,name,name);
}

public static void add(TranslationBuilder builder, Identifier id, String translation) {
builder.add(id.toTranslationKey(),translation);
}

/**
* Adds translations for the various minecraft-generated potion types, all in one go.
* @param builder The {@link TranslationBuilder} to add translations to
Expand All @@ -52,14 +61,6 @@ public static void addPotion(TranslationBuilder builder, String id, String effec
builder.add("item.minecraft.tipped_arrow.effect."+id,"Tipped Arrow of "+name);
}

public static void addAttribute(TranslationBuilder builder, String id, String translated) {
addMisc(builder,"attribute",id,translated);
}

public static void addEnchantment(TranslationBuilder builder, String id, String translated) {
addMisc(builder,"enchantment",id,translated);
}

private static void addMisc(TranslationBuilder builder, String pfx, String id, String translated) {
builder.add(pfx+"."+MOD_ID+"."+id,translated);
}
Expand All @@ -78,6 +79,16 @@ public void addAllItems(TranslationBuilder builder) {
}
}
}
for (Block block: ModRegistries.BLOCKS.ENTRIES_BY_VALUE.keySet()) {
if (new ItemStack(block).getItem() == Items.AIR) continue;
if (block.asItem() instanceof BlockItemArtifact) continue;
this.onItemFound(builder, block.asItem());
if (block instanceof IHasResearchNotes artifact) {
for (int i =0;i<artifact.getTooltips().size();i++) {
this.onTooltipFound(builder,block.asItem(),block.getTranslationKey()+".research_notes_"+i,i);
}
}
}
}

public abstract void onItemFound(TranslationBuilder builder, Item item);
Expand Down
Loading

0 comments on commit 502663d

Please sign in to comment.