Skip to content

Commit

Permalink
Update for 1.21 & migrate to NeoForge
Browse files Browse the repository at this point in the history
  • Loading branch information
PieKing1215 committed Jun 23, 2024
1 parent aa147a6 commit d5f507b
Show file tree
Hide file tree
Showing 40 changed files with 1,068 additions and 8 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ allprojects {
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com" }
maven { url "https://maven.quiltmc.org/repository/release/" }
maven { url "https://maven.neoforged.net/releases/" }
}
}
2 changes: 1 addition & 1 deletion buildAllJars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Once it succeeds this script copies the jars into the root build/
# (trying to do all of this through gradle was using an absurd amount of memory)

versions=("1.16" "1.18" "1.19" "1.20")
versions=("1.16" "1.18" "1.19" "1.20" "1.21")

start=$(date +%s)
end=$(date +%s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.client.player.KeyboardInput;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.client.gui.Font;
import net.minecraft.resources.ResourceLocation;

import java.io.File;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -87,6 +88,8 @@ public MutableComponent fromCV(CVComponent c) {

protected abstract void drawShadow(Font font, PoseStack poseStack, String string, float x, float y, int col);

public abstract ResourceLocation parseResource(String path);

// implementation

protected boolean wasSneaking = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public enum PauseScreenMode {

public static Screen setupCloth(Screen parent){
ConfigBuilder builder = ConfigBuilder.create().setParentScreen(parent).setTitle(InvMove.instance().translatableComponent("config.invmove.title"));
builder.setDefaultBackgroundTexture(new ResourceLocation("minecraft:textures/block/spruce_planks.png"));
builder.setDefaultBackgroundTexture(InvMove.instance().parseResource("minecraft:textures/block/spruce_planks.png"));
builder.transparentBackground();

ConfigEntryBuilder eb = builder.entryBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.network.chat.MutableComponent;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.Font;
import net.minecraft.resources.ResourceLocation;

import java.io.File;
import java.util.Optional;
Expand Down Expand Up @@ -58,4 +59,9 @@ public void setOptionToggleCrouch(boolean toggleCrouch) {
protected void drawShadow(Font font, PoseStack poseStack, String string, float x, float y, int col) {

}

@Override
public ResourceLocation parseResource(String path){
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import net.minecraft.client.gui.screens.ChatScreen;
import net.minecraft.client.gui.screens.DeathScreen;
import net.minecraft.client.gui.screens.LevelLoadingScreen;
import net.minecraft.client.gui.screens.OptionsScreen;
import net.minecraft.client.gui.screens.OptionsSubScreen;
import net.minecraft.client.gui.screens.ProgressScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.ShareToLanScreen;
Expand Down Expand Up @@ -61,8 +59,6 @@ public VanillaModule16() {
super();
register(
DeathScreen.class,
OptionsScreen.class,
OptionsSubScreen.class,
ShareToLanScreen.class,
StatsScreen.class,
WinScreen.class,
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M
org.gradle.parallel=true

archives_base_name=InvMove
mod_version=0.8.6
mod_version=0.8.7
maven_artifact_id=InvMove

mod_description=Lets you move while in inventories.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;

public abstract class InvMove16 extends InvMove {
@Override
Expand All @@ -32,4 +33,9 @@ public void setOptionToggleCrouch(boolean toggleCrouch) {
protected void drawShadow(Font font, PoseStack poseStack, String string, float x, float y, int col){
font.draw(poseStack, string, x, y, col);
}

@Override
public ResourceLocation parseResource(String path){
return new ResourceLocation(path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;

public abstract class InvMove18 extends InvMove {

Expand Down Expand Up @@ -44,4 +45,9 @@ public void setOptionToggleCrouch(boolean toggleCrouch) {
protected void drawShadow(Font font, PoseStack poseStack, String string, float x, float y, int col){
font.draw(poseStack, string, x, y, col);
}

@Override
public ResourceLocation parseResource(String path){
return new ResourceLocation(path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.gui.Font;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;

public abstract class InvMove19 extends InvMove {

Expand Down Expand Up @@ -43,4 +44,9 @@ public void setOptionToggleCrouch(boolean toggleCrouch) {
protected void drawShadow(Font font, PoseStack poseStack, String string, float x, float y, int col){
font.draw(poseStack, string, x, y, col);
}

@Override
public ResourceLocation parseResource(String path){
return new ResourceLocation(path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;

public abstract class InvMove20 extends InvMove {

Expand Down Expand Up @@ -48,4 +49,9 @@ protected void drawShadow(Font font, PoseStack poseStack, String string, float x
font.drawInBatch(string, x, y, col, true, poseStack.last().pose(), buffer, Font.DisplayMode.NORMAL, 0, 15728880);
buffer.endBatch();
}

@Override
public ResourceLocation parseResource(String path){
return new ResourceLocation(path);
}
}
64 changes: 64 additions & 0 deletions mc1.21/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
}

architectury {
minecraft = minecraft_version
}

subprojects {
apply plugin: "dev.architectury.loom"

loom {
silentMojangMappingsLicense()
// clientOnlyMinecraftJar()
}

dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.officialMojangMappings()

// implementation project(path: ":crossversion:common", configuration: "namedElements")
}
}

allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"

archivesBaseName = archives_base_name
version = mod_version
group = maven_group

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 21
}

java {
withSourcesJar()
}
}

task buildAll {
dependsOn subprojects.collect { it.tasks.matching { it.name == 'build' } }

doLast {
subprojects.forEach {
def platproj = it
if(platproj.name.matches("fabric|forge|quilt")) {
copy {
from platproj.file("build/libs/${archives_base_name}-${mod_version}.jar")
into "${buildDir}/"
rename(".+", "${archives_base_name}-${project.name.substring(2)}-${mod_version}-${platproj.name.capitalize()}.jar")
}
}
}
}
}

task publishAllToMavenLocal {
dependsOn subprojects.collect { it.tasks.matching { it.name == 'publishToMavenLocal' } }
}
42 changes: 42 additions & 0 deletions mc1.21/common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

sourceSets {
main {
java {
srcDir "${project(":crossversion:common").projectDir}/src/main/java"
}
resources {
srcDir "${project(":crossversion:common").projectDir}/src/main/resources"
}
}
}

dependencies {
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"

modApi("me.shedaniel.cloth:cloth-config:${cloth_version}"){
exclude(group: "net.fabricmc")
exclude(group: "net.fabricmc.fabric-api")
}
}

architectury {
common(enabled_platforms.split(","))
}

loom {
accessWidenerPath = project(":crossversion:common").file("src/main/resources/invmove.accesswidener")
}

publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = maven_artifact_id
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.
}
}
57 changes: 57 additions & 0 deletions mc1.21/common/src/main/java/me/pieking1215/invmove/InvMove21.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package me.pieking1215.invmove;

import com.mojang.blaze3d.vertex.ByteBufferBuilder;
import com.mojang.blaze3d.vertex.PoseStack;
import me.pieking1215.invmove.module.Module;
import me.pieking1215.invmove.module.VanillaModule21;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;

public abstract class InvMove21 extends InvMove {

public InvMove21() {

super();
}

@Override
public Module getVanillaModule() {
return new VanillaModule21();
}

@Override
public MutableComponent translatableComponent(String key) {
return Component.translatable(key);
}

@Override
public MutableComponent literalComponent(String text) {
return Component.literal(text);
}

@Override
public boolean optionToggleCrouch() {
return Minecraft.getInstance().options.toggleCrouch().get();
}

@Override
public void setOptionToggleCrouch(boolean toggleCrouch) {
Minecraft.getInstance().options.toggleCrouch().set(toggleCrouch);
}

@Override
protected void drawShadow(Font font, PoseStack poseStack, String string, float x, float y, int col){
MultiBufferSource.BufferSource buffer = MultiBufferSource.immediate(new ByteBufferBuilder(786432));
font.drawInBatch(string, x, y, col, true, poseStack.last().pose(), buffer, Font.DisplayMode.NORMAL, 0, 15728880);
buffer.endBatch();
}

@Override
public ResourceLocation parseResource(String path){
return ResourceLocation.parse(path);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package me.pieking1215.invmove.module;

public class VanillaModule21 extends VanillaModule16 {
// any 1.21+ stuff could be done here
}
19 changes: 19 additions & 0 deletions mc1.21/fabric-like/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
architectury {
common(enabled_platforms.split(","))
}

loom {
accessWidenerPath = project("${parent.path}:common").loom.accessWidenerPath
}

dependencies {
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"

modImplementation("com.terraformersmc:modmenu:${modmenu_version}") {
exclude(group: "net.fabricmc")
exclude(group: "net.fabricmc.fabric-api")
}

compileOnly(project(path: "${parent.path}:common", configuration: "namedElements")) { transitive false }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package me.pieking1215.invmove.fabric_like;

public interface InvMoveInitializer {

void init();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package me.pieking1215.invmove.fabric_like;

import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import me.pieking1215.invmove.InvMoveConfig;

public class InvMoveModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return InvMoveConfig::setupCloth;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package me.pieking1215.invmove.fabric_like.mixin.client;

import me.pieking1215.invmove.InvMove;
import net.minecraft.client.gui.screens.Screen;
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;

@Mixin(Screen.class)
public class OverlayMixin {
@Inject(method = "render", at = @At("TAIL"))
public void render(CallbackInfo callbackInfo) {
InvMove.instance().drawDebugOverlay();
}
}
Loading

0 comments on commit d5f507b

Please sign in to comment.