Skip to content

Commit

Permalink
1.21 update, ModDevGradle
Browse files Browse the repository at this point in the history
  • Loading branch information
ramidzkh committed Jul 7, 2024
1 parent b01b70f commit 9d9dd68
Show file tree
Hide file tree
Showing 23 changed files with 211 additions and 177 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
.vscode/
build/
libs/
runs/
run/
46 changes: 24 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("net.neoforged.gradle.userdev") version "7.0.80"
id("net.neoforged.moddev") version "0.1.126"
id("com.matthewprenger.cursegradle") version "1.4.0"
id("com.diffplug.spotless") version "6.25.0"
id("com.modrinth.minotaur") version "2.8.7"
Expand Down Expand Up @@ -54,15 +54,11 @@ repositories {
}

dependencies {
implementation("net.neoforged:neoforge:${neoforge_version}")

// We depend on many AE2 internals, such as using their basic cell drive, thus not using classifier = "api"
implementation("appeng:appliedenergistics2-neoforge:${ae2_version}")
implementation("appeng:appliedenergistics2:${ae2_version}")

compileOnly("mekanism:Mekanism:${minecraft_version}-${mekanism_version}:api")
runtimeOnly("mekanism:Mekanism:${minecraft_version}-${mekanism_version}:all") {
exclude(group: "com.blamejared.crafttweaker")
}
runtimeOnly("mekanism:Mekanism:${minecraft_version}-${mekanism_version}:all")

implementation("dev.emi:emi-neoforge:${project.emi_version}+${project.minecraft_version}")

Expand All @@ -79,27 +75,33 @@ sourceSets {

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(21)
}
}

////////////////////
// Minecraft
runs {
configureEach {
systemProperty("forge.logging.console.level", "debug")
modSource(project.sourceSets.main)
}

client {
}

server {
programArgument("--nogui")
neoForge {
version = neoforge_version

runs {
client { client() }
server { server() }

data {
data()
programArguments.addAll(
"--mod", "appmek",
"--all",
"--output", file("src/generated/resources/").getAbsolutePath(),
"--existing", file("src/main/resources/").getAbsolutePath())
}
}

data {
programArguments.addAll("--mod", "appmek", "--all", "--output", file("src/generated/resources/").getAbsolutePath(), "--existing", file("src/main/resources/").getAbsolutePath())
mods {
appmek {
sourceSet sourceSets.main
}
}
}

Expand All @@ -121,7 +123,7 @@ tasks.withType(ProcessResources).configureEach {
]
inputs.properties(replaceProperties)

filesMatching(["META-INF/mods.toml"]) {
filesMatching(["META-INF/neoforge.mods.toml"]) {
expand replaceProperties
}
}
Expand Down
20 changes: 10 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
minecraft_version=1.20.4
neoforge_version=20.4.210
ae2_version=17.12.0-beta
mekanism_version=10.5.10.32
emi_version=1.1.4
jade_id=4980188
minecraft_version=1.21
neoforge_version=21.0.63-beta
ae2_version=19.0.8-alpha
mekanism_version=10.6.4.homebaked
emi_version=1.1.10
jade_id=5493270

loader_version_range=[2,)
neo_version_range=[20.4,)
ae2_version_range=[17.0.0,18.0.0)
mekanism_version_range=[10.5.10,11-)
loader_version_range=[1,)
neo_version_range=[21.0,)
ae2_version_range=[19.0.0,20.0.0)
mekanism_version_range=[10.6.0,11-)

org.gradle.caching=true
org.gradle.parallel=true
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
24 changes: 14 additions & 10 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -130,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -198,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/ramidzkh/mekae2/AMItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ private static Item.Properties properties() {
// For block items, the block controls the creative tab
if (item instanceof AEBaseBlockItem baseItem
&& baseItem.getBlock() instanceof AEBaseBlock baseBlock) {
baseBlock.addToMainCreativeTab(output);
baseBlock.addToMainCreativeTab(params, output);
} else if (item instanceof AEBaseItem baseItem) {
baseItem.addToMainCreativeTab(output);
baseItem.addToMainCreativeTab(params, output);
} else {
output.accept(item);
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/me/ramidzkh/mekae2/AMMenus.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.world.inventory.MenuType;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;

import appeng.api.implementations.menuobjects.IPortableTerminal;
import appeng.client.gui.me.common.MEStorageScreen;
Expand All @@ -18,9 +18,9 @@ public class AMMenus {

@SuppressWarnings("RedundantTypeArguments")
public static void initialize(IEventBus bus) {
bus.addListener((FMLClientSetupEvent event) -> event.enqueueWork(() -> {
InitScreens.<MEStorageMenu, MEStorageScreen<MEStorageMenu>>register(PORTABLE_CHEMICAL_CELL_TYPE,
bus.addListener((RegisterMenuScreensEvent event) -> {
InitScreens.<MEStorageMenu, MEStorageScreen<MEStorageMenu>>register(event, PORTABLE_CHEMICAL_CELL_TYPE,
MEStorageScreen::new, "/screens/terminals/portable_chemical_cell.json");
}));
});
}
}
2 changes: 1 addition & 1 deletion src/main/java/me/ramidzkh/mekae2/AMText.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.minecraft.network.chat.Component;

public enum AMText {
CHEMICAL("chemical"),
CHEMICALS("chemical"),
CREATIVE_TAB("creative_tab"),
QIO_FREQUENCY("qio_frequency"),
;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/me/ramidzkh/mekae2/AppliedMekanistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import me.ramidzkh.mekae2.data.MekAE2DataGenerators;
import me.ramidzkh.mekae2.qio.QioSupport;

import appeng.api.AECapabilities;
import appeng.api.behaviors.ContainerItemStrategy;
import appeng.api.behaviors.GenericInternalInventory;
import appeng.api.behaviors.GenericSlotCapacities;
Expand All @@ -42,7 +43,6 @@
import appeng.api.storage.cells.ICellGuiHandler;
import appeng.api.storage.cells.ICellHandler;
import appeng.api.upgrades.Upgrades;
import appeng.capabilities.AppEngCapabilities;
import appeng.core.definitions.AEItems;
import appeng.core.localization.GuiText;
import appeng.menu.MenuOpener;
Expand All @@ -56,7 +56,7 @@ public class AppliedMekanistics {
public static final String ID = "appmek";

public static ResourceLocation id(String path) {
return new ResourceLocation(ID, path);
return ResourceLocation.fromNamespaceAndPath(ID, path);
}

public AppliedMekanistics(IEventBus bus) {
Expand Down Expand Up @@ -109,7 +109,7 @@ private void registerPartCapabilities(RegisterPartCapabilitiesEvent event) {

private void registerGenericAdapters(RegisterCapabilitiesEvent event) {
for (var block : BuiltInRegistries.BLOCK) {
if (event.isBlockRegistered(AppEngCapabilities.GENERIC_INTERNAL_INV, block)) {
if (event.isBlockRegistered(AECapabilities.GENERIC_INTERNAL_INV, block)) {
registerGenericInvAdapter(event, block, MekCapabilities.GAS.block(),
GenericStackChemicalStorage.OfGas::new);
registerGenericInvAdapter(event, block, MekCapabilities.INFUSION.block(),
Expand Down Expand Up @@ -174,7 +174,7 @@ private void initializeAttunement() {
private static <T> void registerGenericInvAdapter(RegisterCapabilitiesEvent event, Block block,
BlockCapability<T, Direction> capability, Function<GenericInternalInventory, T> adapter) {
event.registerBlock(capability, (level, pos, state, blockEntity, context) -> {
var genericInv = level.getCapability(AppEngCapabilities.GENERIC_INTERNAL_INV, pos, state,
var genericInv = level.getCapability(AECapabilities.GENERIC_INTERNAL_INV, pos, state,
blockEntity, context);
if (genericInv != null) {
return adapter.apply(genericInv);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/ramidzkh/mekae2/MekCapabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public CapSet(ResourceLocation name, Class<T> handlerClass) {
}

private static ResourceLocation rl(String path) {
return new ResourceLocation(MekanismAPI.MEKANISM_MODID, path);
return ResourceLocation.fromNamespaceAndPath(MekanismAPI.MEKANISM_MODID, path);
}
}
57 changes: 27 additions & 30 deletions src/main/java/me/ramidzkh/mekae2/ae2/AMChemicalStackRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public void drawInGui(Minecraft minecraft, GuiGraphics guiGraphics, int x, int y
var stack = what.getStack();

Blitter.sprite(
Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(stack.getType().getIcon()))
Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS)
.apply(stack.getChemical().getIcon()))
.colorRgb(stack.getChemicalTint())
// Most fluid texture have transparency, but we want an opaque slot
.blending(false)
Expand All @@ -47,7 +48,7 @@ public void drawOnBlockFace(PoseStack poseStack, MultiBufferSource buffers, Meka
int combinedLight, Level level) {
var stack = what.getStack();
var sprite = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS)
.apply(stack.getType().getIcon());
.apply(stack.getChemical().getIcon());
var color = stack.getChemicalTint();

poseStack.pushPose();
Expand All @@ -67,34 +68,30 @@ public void drawOnBlockFace(PoseStack poseStack, MultiBufferSource buffers, Meka
var y1 = -scale / 2;

var transform = poseStack.last().pose();
buffer.vertex(transform, x0, y1, 0)
.color(color)
.uv(sprite.getU0(), sprite.getV1())
.overlayCoords(OverlayTexture.NO_OVERLAY)
.uv2(combinedLight)
.normal(0, 0, 1)
.endVertex();
buffer.vertex(transform, x1, y1, 0)
.color(color)
.uv(sprite.getU1(), sprite.getV1())
.overlayCoords(OverlayTexture.NO_OVERLAY)
.uv2(combinedLight)
.normal(0, 0, 1)
.endVertex();
buffer.vertex(transform, x1, y0, 0)
.color(color)
.uv(sprite.getU1(), sprite.getV0())
.overlayCoords(OverlayTexture.NO_OVERLAY)
.uv2(combinedLight)
.normal(0, 0, 1)
.endVertex();
buffer.vertex(transform, x0, y0, 0)
.color(color)
.uv(sprite.getU0(), sprite.getV0())
.overlayCoords(OverlayTexture.NO_OVERLAY)
.uv2(combinedLight)
.normal(0, 0, 1)
.endVertex();
buffer.addVertex(transform, x0, y1, 0)
.setColor(color)
.setUv(sprite.getU0(), sprite.getV1())
.setOverlay(OverlayTexture.NO_OVERLAY)
.setLight(combinedLight)
.setNormal(0, 0, 1);
buffer.addVertex(transform, x1, y1, 0)
.setColor(color)
.setUv(sprite.getU1(), sprite.getV1())
.setOverlay(OverlayTexture.NO_OVERLAY)
.setLight(combinedLight)
.setNormal(0, 0, 1);
buffer.addVertex(transform, x1, y0, 0)
.setColor(color)
.setUv(sprite.getU1(), sprite.getV0())
.setOverlay(OverlayTexture.NO_OVERLAY)
.setLight(combinedLight)
.setNormal(0, 0, 1);
buffer.addVertex(transform, x0, y0, 0)
.setColor(color)
.setUv(sprite.getU0(), sprite.getV0())
.setOverlay(OverlayTexture.NO_OVERLAY)
.setLight(combinedLight)
.setNormal(0, 0, 1);
poseStack.popPose();
}

Expand Down
Loading

0 comments on commit 9d9dd68

Please sign in to comment.