Skip to content

Commit

Permalink
Port to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Jun 17, 2024
1 parent 8d3bc8a commit 9d4d7e9
Show file tree
Hide file tree
Showing 22 changed files with 167 additions and 150 deletions.
57 changes: 32 additions & 25 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
alias(libs.plugins.neogradle)
alias(libs.plugins.moddev)
alias(libs.plugins.spotless)
}

Expand All @@ -9,7 +9,7 @@ base.archivesName = modId
version = System.getenv("FULLENG_VERSION") ?: "0.0.0"
group = "gripe.90"

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

repositories {
mavenLocal()
Expand All @@ -33,18 +33,11 @@ repositories {
}

dependencies {
implementation(libs.neoforge)
implementation(libs.ae2)
implementation(libs.requester)
runtimeOnly(libs.jade)
}

minecraft {
accessTransformers {
file("src/main/resources/META-INF/accesstransformer.cfg")
}
}

sourceSets {
main {
resources.srcDir(file("src/generated/resources"))
Expand All @@ -57,26 +50,40 @@ sourceSets {
}
}

runs {
configureEach {
workingDirectory(file("run"))
systemProperty("forge.logging.console.level", "info")
neoForge {
version = libs.versions.neoforge.get()

modSource(sourceSets.main.get())
mods {
create(modId) {
sourceSet(sourceSets.main.get())
sourceSet(sourceSets.getByName("data"))
}
}

create("client")
create("server") { workingDirectory(file("run/server")) }
runs {
configureEach {
gameDirectory = file("run")
}

create("data") {
programArguments.addAll(
"--mod", modId,
"--all",
"--output", file("src/generated/resources/").absolutePath,
"--existing", file("src/main/resources/").absolutePath
)
create("client") {
client()
}

modSource(sourceSets.getByName("data"))
create("server") {
server()
gameDirectory = file("run/server")
}

create("data") {
data()
programArguments.addAll(
"--mod", modId,
"--all",
"--output", file("src/generated/resources/").absolutePath,
"--existing", file("src/main/resources/").absolutePath
)
sourceSet = sourceSets.getByName("data")
}
}
}

Expand All @@ -102,7 +109,7 @@ tasks {
)

inputs.properties(props)
filesMatching("META-INF/mods.toml") {
filesMatching("META-INF/neoforge.mods.toml") {
expand(props)
}
}
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties

This file was deleted.

10 changes: 5 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
pluginManagement {
repositories {
maven { url = uri("https://maven.neoforged.net/") }
maven { url = uri("https://maven.neoforged.net/releases") }
gradlePluginPortal()
}
}

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
plugin("neogradle", "net.neoforged.gradle.userdev").version("7.0.97")
plugin("moddev", "net.neoforged.moddev").version("0.1.85")
plugin("spotless", "com.diffplug.spotless").version("6.23.3")

library("neoforge", "net.neoforged", "neoforge").version("20.4.209")
version("neoforge", "21.0.13-beta")

version("ae2", "17.12.1-beta")
version("ae2", "19.0.2-alpha")
library("ae2", "appeng", "appliedenergistics2-neoforge").versionRef("ae2")

version("requester", "1.20.4-1.1.6")
library("requester", "maven.modrinth", "merequester").version("cj9FGAyI")

library("jade", "maven.modrinth", "jade").version("9rrZAORZ")
library("jade", "maven.modrinth", "jade").version("gF1TRsRm")
}
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;

import org.jetbrains.annotations.NotNull;

import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.loot.BlockLootSubProvider;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;
Expand All @@ -21,17 +23,17 @@
import gripe._90.fulleng.definition.FullEngBlocks;

public class FullDropProvider extends LootTableProvider {
public FullDropProvider(PackOutput output) {
super(output, Set.of(), List.of(new SubProviderEntry(BlockLoot::new, LootContextParamSets.BLOCK)));
public FullDropProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
super(output, Set.of(), List.of(new SubProviderEntry(BlockLoot::new, LootContextParamSets.BLOCK)), registries);
}

private static class BlockLoot extends BlockLootSubProvider {
protected BlockLoot() {
super(Set.of(), FeatureFlags.DEFAULT_FLAGS);
protected BlockLoot(HolderLookup.Provider registries) {
super(Set.of(), FeatureFlags.DEFAULT_FLAGS, registries);
}

@Override
public void generate(@NotNull BiConsumer<ResourceLocation, LootTable.Builder> writer) {
public void generate(@NotNull BiConsumer<ResourceKey<LootTable>, LootTable.Builder> writer) {
generate();
map.forEach(writer);
}
Expand Down
11 changes: 6 additions & 5 deletions src/data/java/gripe/_90/fulleng/datagen/FullEngData.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.data.event.GatherDataEvent;

import gripe._90.fulleng.FullblockEnergistics;

@SuppressWarnings("unused")
@Mod.EventBusSubscriber(modid = FullblockEnergistics.MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
@EventBusSubscriber(modid = FullblockEnergistics.MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class FullEngData {
@SubscribeEvent
public static void onGatherData(GatherDataEvent event) {
var generator = event.getGenerator();
var output = generator.getPackOutput();
var registries = event.getLookupProvider();

generator.addProvider(event.includeServer(), new FullRecipeProvider(output));
generator.addProvider(event.includeServer(), new FullDropProvider(output));
generator.addProvider(event.includeServer(), new FullTagProvider(output, event.getLookupProvider()));
generator.addProvider(event.includeServer(), new FullDropProvider(output, registries));
generator.addProvider(event.includeServer(), new FullRecipeProvider(output, registries));
generator.addProvider(event.includeServer(), new FullTagProvider(output, registries));

generator.addProvider(event.includeClient(), new FullLanguageProvider(output));
generator.addProvider(event.includeClient(), new FullModelProvider(output, event.getExistingFileHelper()));
Expand Down
29 changes: 13 additions & 16 deletions src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ protected void registerStatesAndModels() {

private void terminal(BlockDefinition<?> terminal, String texturePrefix) {
var existing = models().existingFileHelper;
existing.trackGenerated(new ResourceLocation(texturePrefix + "_bright"), ModelProvider.TEXTURE);
existing.trackGenerated(new ResourceLocation(texturePrefix + "_medium"), ModelProvider.TEXTURE);
existing.trackGenerated(new ResourceLocation(texturePrefix + "_dark"), ModelProvider.TEXTURE);
existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_bright"), ModelProvider.TEXTURE);
existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_medium"), ModelProvider.TEXTURE);
existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_dark"), ModelProvider.TEXTURE);

var onModel = terminal != FullEngBlocks.TERMINAL
? models().withExistingParent(
"block/" + terminal.id().getPath(), FullblockEnergistics.MODID + ":block/terminal")
.texture("lightsBright", texturePrefix + "_bright")
.texture("lightsMedium", texturePrefix + "_medium")
.texture("lightsDark", texturePrefix + "_dark")
.renderType("cutout")
: models().getExistingFile(FullblockEnergistics.makeId("block/terminal"));

multiVariantGenerator(terminal, Variant.variant())
Expand All @@ -62,27 +63,23 @@ private void terminal(BlockDefinition<?> terminal, String texturePrefix) {

private void monitor(BlockDefinition<?> monitor, String texturePrefix) {
var existing = models().existingFileHelper;
var storage = monitor == FullEngBlocks.STORAGE_MONITOR;

existing.trackGenerated(new ResourceLocation(texturePrefix + "_bright"), ModelProvider.TEXTURE);
existing.trackGenerated(new ResourceLocation(texturePrefix + "_medium"), ModelProvider.TEXTURE);
existing.trackGenerated(new ResourceLocation(texturePrefix + "_dark"), ModelProvider.TEXTURE);

existing.trackGenerated(
new ResourceLocation(texturePrefix + "_medium" + (storage ? "" : "_locked")), ModelProvider.TEXTURE);
existing.trackGenerated(
new ResourceLocation(texturePrefix + "_dark" + (!storage ? "" : "_locked")), ModelProvider.TEXTURE);
existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_bright"), ModelProvider.TEXTURE);
existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_medium"), ModelProvider.TEXTURE);
existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_dark"), ModelProvider.TEXTURE);
existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_dark_locked"), ModelProvider.TEXTURE);

var unlockedModel = models().withExistingParent(
"block/" + monitor.id().getPath(), FullblockEnergistics.MODID + ":block/terminal")
.texture("lightsBright", texturePrefix + "_bright")
.texture("lightsMedium", texturePrefix + "_medium")
.texture("lightsDark", texturePrefix + "_dark");
.texture("lightsDark", texturePrefix + "_dark")
.renderType("cutout");
var lockedModel = models().withExistingParent(
"block/" + monitor.id().getPath(), FullblockEnergistics.MODID + ":block/terminal")
.texture("lightsBright", texturePrefix + "_bright")
.texture("lightsMedium", texturePrefix + "_medium" + (storage ? "" : "_locked"))
.texture("lightsDark", texturePrefix + "_dark" + (!storage ? "" : "_locked"));
.texture("lightsMedium", texturePrefix + "_medium")
.texture("lightsDark", texturePrefix + "_dark_locked")
.renderType("cutout");

multiVariantGenerator(monitor, Variant.variant())
.with(createFacingSpinDispatch())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package gripe._90.fulleng.datagen;

import java.util.concurrent.CompletableFuture;

import org.jetbrains.annotations.NotNull;

import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.RecipeCategory;
Expand All @@ -17,8 +20,8 @@
import gripe._90.fulleng.integration.Addons;

public class FullRecipeProvider extends RecipeProvider {
public FullRecipeProvider(PackOutput output) {
super(output);
public FullRecipeProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
super(output, registries);
}

@Override
Expand Down
26 changes: 8 additions & 18 deletions src/main/java/gripe/_90/fulleng/FullblockEnergistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
import java.util.Objects;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.phys.BlockHitResult;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.client.event.ModelEvent;
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
import net.neoforged.neoforge.network.PacketDistributor;
import net.neoforged.neoforge.registries.RegisterEvent;

import appeng.api.AECapabilities;
Expand All @@ -31,7 +30,6 @@
import appeng.client.render.ColorableBlockEntityBlockColor;
import appeng.client.render.StaticItemColor;
import appeng.core.AppEng;
import appeng.core.network.NetworkHandler;
import appeng.core.network.serverbound.PartLeftClickPacket;
import appeng.init.client.InitScreens;
import appeng.util.InteractionUtil;
Expand All @@ -50,7 +48,7 @@ public class FullblockEnergistics {
public static final String MODID = "fulleng";

public static ResourceLocation makeId(String path) {
return new ResourceLocation(MODID, path);
return ResourceLocation.fromNamespaceAndPath(MODID, path);
}

public FullblockEnergistics(IEventBus modEventBus) {
Expand Down Expand Up @@ -109,18 +107,18 @@ private Client(IEventBus modEventBus) {
modEventBus.addListener(this::initBlockEntityRenders);
modEventBus.addListener(this::registerBlockColourProviders);
modEventBus.addListener(this::registerItemColourProviders);
modEventBus.addListener(this::setRenderLayers);
NeoForge.EVENT_BUS.addListener(this::addConversionMonitorHook);
}

private void initScreens(FMLClientSetupEvent ignoredEvent) {
private void initScreens(RegisterMenuScreensEvent event) {
InitScreens.register(
event,
PatternAccessTerminalMenu.TYPE_FULLBLOCK,
PatternAccessTermScreen<PatternAccessTerminalMenu>::new,
"/screens/terminals/pattern_access_terminal.json");

if (Addons.REQUESTER.isLoaded()) {
RequesterIntegration.initScreen();
RequesterIntegration.initScreen(event);
}
}

Expand All @@ -141,13 +139,6 @@ private void registerItemColourProviders(RegisterColorHandlersEvent.Item event)
}
}

@SuppressWarnings("deprecation")
private void setRenderLayers(FMLClientSetupEvent ignoredEvent) {
for (var block : FullEngBlocks.getBlocks()) {
ItemBlockRenderTypes.setRenderLayer(block.block(), RenderType.cutout());
}
}

private void addConversionMonitorHook(PlayerInteractEvent.LeftClickBlock event) {
var level = event.getLevel();

Expand All @@ -157,9 +148,8 @@ private void addConversionMonitorHook(PlayerInteractEvent.LeftClickBlock event)
}

if (level.getBlockEntity(hitResult.getBlockPos()) instanceof ConversionMonitorBlockEntity) {
NetworkHandler.instance()
.sendToServer(new PartLeftClickPacket(
hitResult, InteractionUtil.isInAlternateUseMode(event.getEntity())));
PacketDistributor.sendToServer(new PartLeftClickPacket(
hitResult, InteractionUtil.isInAlternateUseMode(event.getEntity())));
Objects.requireNonNull(Minecraft.getInstance().gameMode).destroyDelay = 5;
event.setCanceled(true);
}
Expand Down
Loading

0 comments on commit 9d4d7e9

Please sign in to comment.