Skip to content

Commit

Permalink
fixed #48, update mafglib version
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed May 1, 2024
1 parent 50b8aa6 commit 65ec38a
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 116 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 17
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand All @@ -26,7 +26,7 @@ jobs:
chmod +x gradlew
./gradlew build
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Artifacts-forge
path: ${{ github.workspace }}/build/libs
22 changes: 11 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Publish Release

on:
workflow_dispatch:
release:
types:
- published
on:
workflow_dispatch:
release:
types:
- published

permissions:
contents: write
Expand All @@ -14,25 +14,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 20
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 20
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'build.gradle') }}
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/actions/wrapper-validation@v3
- run: |
chmod +x gradlew
./gradlew build publishUnified --stacktrace -Porg.gradle.parallel.threads=4
./gradlew build publishMod --stacktrace -Porg.gradle.parallel.threads=4
env:
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## Change
- fix icon missing
- update mafglib to `0.1.9`
- fixed [#48](https://github.com/ThinkingStudios/Litematica-Forge/issues/48)
- update mafglib version
62 changes: 24 additions & 38 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
plugins {
id "dev.architectury.loom" version "1.4-SNAPSHOT"
id "dev.architectury.loom" version "1.5-SNAPSHOT"
id "maven-publish"
id "me.shedaniel.unified-publishing" version "0.1.+"
id "com.hypherionmc.modutils.modpublisher" version "2.+"
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name
base.archivesName = project.archives_base_name
version = "${project.mod_version}-mc${project.minecraft_version}"
group = project.maven_group

Expand Down Expand Up @@ -46,6 +44,9 @@ tasks.withType(JavaCompile) {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

withSourcesJar()
}

Expand All @@ -66,38 +67,23 @@ publishing {
}
}

unifiedPublishing {
project {
displayName = "$project.version"
releaseType = "beta"
changelog = file("CHANGELOG.md").getText('UTF-8')
gameVersions = ["1.16.4", "1.16.5"]
gameLoaders = ["forge"]

mainPublication remapJar
secondaryPublications.builtBy(sourcesJar)

relations {
depends {
curseforge = "mafglib"
modrinth = "mafglib"
}
}
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
if (CURSEFORGE_TOKEN != null) {
curseforge {
token = CURSEFORGE_TOKEN
id = project.curseforge_id
}
}

var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
if (MODRINTH_TOKEN != null) {
modrinth {
token = MODRINTH_TOKEN
id = project.modrinth_id
version = "$project.version"
}
}
publisher {
apiKeys {
modrinth System.getenv("MODRINTH_TOKEN")
curseforge System.getenv("CURSE_TOKEN")
}

setCurseID("${project.curseforge_id}")
setModrinthID("${project.modrinth_id}")
setVersionType("release")
setChangelog(file("CHANGELOG.md").getText("UTF-8"))
setVersion("${project.version}")
setDisplayName("${project.version}")
setGameVersions("1.16.4", "1.16.5")
setLoaders("forge")
setCurseEnvironment("client")
setArtifact(remapJar)
addAdditionalFile(sourcesJar)
curseDepends { required("mafglib") }
modrinthDepends { required("mafglib") }
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ loom.platform=forge
# minecraft version
minecraft_version=1.16.5
# forge version, the latest version can be found on https://files.minecraftforge.net/
forge_version=1.16.5-36.2.39
forge_version=1.16.5-36.2.42
# yarn, the latest version can be found on https://fabricmc.net/develop/
yarn_mappings=1.16.5+build.10

# Mod Properties
mod_version=0.1.7
mod_version=0.1.8
maven_group=org.thinkingstudio
archives_base_name=Forgematica
mod_id=forgematica
mod_author=ThinkingStudio

# Dependencies
malilib_version=0.1.9-mc1.16.5
malilib_version=0.1.10-mc1.16.5

# Publish Properties
modrinth_id=dCKRaeBC
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 1 addition & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
pluginManagement {
// when using additional gradle plugins like shadow,
// add their repositories to this list!
repositories {
maven { url "https://maven.fabricmc.net/" }
maven { url "https://maven.architectury.dev/" }
maven { url "https://files.minecraftforge.net/maven/" }
maven { url "https://maven.firstdark.dev/releases" }
gradlePluginPortal()
}
}
26 changes: 10 additions & 16 deletions src/main/java/fi/dy/masa/litematica/Litematica.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import fi.dy.masa.litematica.gui.GuiConfigs;
import fi.dy.masa.malilib.compat.forge.ForgePlatformUtils;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLLoader;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import fi.dy.masa.malilib.event.InitializationHandler;
Expand All @@ -15,18 +13,14 @@ public class Litematica {
public static final Logger logger = LogManager.getLogger(Reference.MOD_ID);

public Litematica() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

modEventBus.addListener(this::onInitializeClient);
}

public void onInitializeClient(FMLClientSetupEvent event) {
ForgePlatformUtils.getInstance().getClientModIgnoredServerOnly();
InitializationHandler.getInstance().registerInitializationHandler(new InitHandler());
ForgePlatformUtils.getInstance().getMod(Reference.MOD_ID).registerModConfigScreen((screen) -> {
GuiConfigs gui = new GuiConfigs();
gui.setParent(screen);
return gui;
});
if (FMLLoader.getDist().isClient()) {
ForgePlatformUtils.getInstance().getClientModIgnoredServerOnly();
InitializationHandler.getInstance().registerInitializationHandler(new InitHandler());
ForgePlatformUtils.getInstance().getMod(Reference.MOD_ID).registerModConfigScreen((screen) -> {
GuiConfigs gui = new GuiConfigs();
gui.setParent(screen);
return gui;
});
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package fi.dy.masa.litematica.mixin.compat;

import net.minecraft.block.entity.BlockEntity;
import net.minecraftforge.client.model.ModelDataManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import fi.dy.masa.litematica.world.WorldSchematic;

@Mixin(ModelDataManager.class)
public abstract class MixinModelDataManager {

/**
* if we don't catch this Forge does stupid things
* it calls requestModelData on any client world when adding a BlockEntity
* but if it's not mc.world it crashes because model data may only
* be used on the current client world
*
* @author ZacSharp
* @reason Fix about Forge's ModelData issues. See: <a href="https://github.com/ThinkingStudios/Litematica-Forge/issues/48">ThinkingStudios/Litematica-Forge issue#48</a>
* @see <a href="https://github.com/ZacSharp/litematica-forge/commit/73c96536d34bbf0612e099211c96ea77bec5e335#diff-99a005b1c70ed23a8a0ff36c1d1bd16d13a194a96e5d1cc0fb8d5eaf77098717">ZacSharp/litematica-forge commit#73c9653</a>
*/
@Inject(method = "requestModelDataRefresh", at = @At("HEAD"), cancellable = true, remap = false)
private static void requestModelDataRefresh(BlockEntity blockEntity, CallbackInfo cir) {
if (blockEntity.getWorld() instanceof WorldSchematic) {
cir.cancel();
}
}
}
12 changes: 6 additions & 6 deletions src/main/java/fi/dy/masa/litematica/world/WorldSchematic.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class WorldSchematic extends World
private final ChunkManagerSchematic chunkManagerSchematic;
private final Int2ObjectOpenHashMap<Entity> regularEntities = new Int2ObjectOpenHashMap<>();
private int nextEntityId;
public final boolean isClient;
// public final boolean isClient;

protected WorldSchematic(MutableWorldProperties mutableWorldProperties, DimensionType dimensionType, Supplier<Profiler> supplier)
{
Expand All @@ -64,18 +64,18 @@ protected WorldSchematic(MutableWorldProperties mutableWorldProperties, Dimensio
this.mc = MinecraftClient.getInstance();
this.worldRenderer = LitematicaRenderer.getInstance().getWorldRenderer();
this.chunkManagerSchematic = new ChunkManagerSchematic(this);
this.isClient = false;
// this.isClient = false;
}

public ChunkManagerSchematic getChunkProvider()
{
return this.chunkManagerSchematic;
}

@Override
public boolean isClient() {
return this.isClient;
}
// @Override
// public boolean isClient() {
// return this.isClient;
// }

@Override
public ChunkManagerSchematic getChunkManager()
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/forgematica.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"MixinWorld",
"MixinWorldChunk",
"MixinWorldRenderer",
"compat.MixinIForgeTileEntity"
"compat.MixinModelDataManager"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 65ec38a

Please sign in to comment.