From 9d4d7e93c22d40e2544110787500886098455113 Mon Sep 17 00:00:00 2001 From: 90 Date: Mon, 17 Jun 2024 17:59:26 +0100 Subject: [PATCH] Port to 1.21 --- build.gradle.kts | 57 +++++++++++-------- gradle.properties | 2 - settings.gradle.kts | 10 ++-- .../_90/fulleng/datagen/FullDropProvider.java | 14 +++-- .../_90/fulleng/datagen/FullEngData.java | 11 ++-- .../fulleng/datagen/FullModelProvider.java | 29 +++++----- .../fulleng/datagen/FullRecipeProvider.java | 7 ++- .../_90/fulleng/FullblockEnergistics.java | 26 +++------ .../gripe/_90/fulleng/block/MonitorBlock.java | 20 ++++--- .../_90/fulleng/block/TerminalBlock.java | 6 +- .../fulleng/block/entity/FullBlockEntity.java | 15 ++--- .../monitor/StorageMonitorBlockEntity.java | 19 ++++--- .../terminal/CraftingTerminalBlockEntity.java | 13 +++-- .../PatternAccessTerminalBlockEntity.java | 7 ++- .../PatternEncodingTerminalBlockEntity.java | 13 +++-- .../terminal/StorageTerminalBlockEntity.java | 24 +++++--- .../entity/terminal/TerminalBlockEntity.java | 23 +++++--- .../integration/IntegrationBlockItem.java | 4 +- .../requester/RequesterIntegration.java | 5 +- .../{mods.toml => neoforge.mods.toml} | 4 -- src/main/resources/fulleng.mixins.json | 2 +- src/main/resources/pack.mcmeta | 6 -- 22 files changed, 167 insertions(+), 150 deletions(-) delete mode 100644 gradle.properties rename src/main/resources/META-INF/{mods.toml => neoforge.mods.toml} (90%) delete mode 100644 src/main/resources/pack.mcmeta diff --git a/build.gradle.kts b/build.gradle.kts index 0aeab38..1d3696e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - alias(libs.plugins.neogradle) + alias(libs.plugins.moddev) alias(libs.plugins.spotless) } @@ -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() @@ -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")) @@ -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") + } } } @@ -102,7 +109,7 @@ tasks { ) inputs.properties(props) - filesMatching("META-INF/mods.toml") { + filesMatching("META-INF/neoforge.mods.toml") { expand(props) } } diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 821c45a..0000000 --- a/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -org.gradle.daemon=false -org.gradle.jvmargs=-Xmx2G diff --git a/settings.gradle.kts b/settings.gradle.kts index bc6f8c8..39ffdab 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,6 @@ pluginManagement { repositories { - maven { url = uri("https://maven.neoforged.net/") } + maven { url = uri("https://maven.neoforged.net/releases") } gradlePluginPortal() } } @@ -8,18 +8,18 @@ pluginManagement { 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") } } } diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java index b11a8e3..61d4ca6 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java @@ -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; @@ -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 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 writer) { + public void generate(@NotNull BiConsumer, LootTable.Builder> writer) { generate(); map.forEach(writer); } diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullEngData.java b/src/data/java/gripe/_90/fulleng/datagen/FullEngData.java index 4b9d2fa..5e04493 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullEngData.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullEngData.java @@ -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())); diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java index 574ae63..e2a556f 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java @@ -41,9 +41,9 @@ 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( @@ -51,6 +51,7 @@ private void terminal(BlockDefinition terminal, String texturePrefix) { .texture("lightsBright", texturePrefix + "_bright") .texture("lightsMedium", texturePrefix + "_medium") .texture("lightsDark", texturePrefix + "_dark") + .renderType("cutout") : models().getExistingFile(FullblockEnergistics.makeId("block/terminal")); multiVariantGenerator(terminal, Variant.variant()) @@ -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()) diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java index 833081b..e32f4d2 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java @@ -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; @@ -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 registries) { + super(output, registries); } @Override diff --git a/src/main/java/gripe/_90/fulleng/FullblockEnergistics.java b/src/main/java/gripe/_90/fulleng/FullblockEnergistics.java index f2e3afe..976c264 100644 --- a/src/main/java/gripe/_90/fulleng/FullblockEnergistics.java +++ b/src/main/java/gripe/_90/fulleng/FullblockEnergistics.java @@ -3,8 +3,6 @@ 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; @@ -12,15 +10,16 @@ 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; @@ -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; @@ -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) { @@ -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::new, "/screens/terminals/pattern_access_terminal.json"); if (Addons.REQUESTER.isLoaded()) { - RequesterIntegration.initScreen(); + RequesterIntegration.initScreen(event); } } @@ -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(); @@ -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); } diff --git a/src/main/java/gripe/_90/fulleng/block/MonitorBlock.java b/src/main/java/gripe/_90/fulleng/block/MonitorBlock.java index 6712118..11dd666 100644 --- a/src/main/java/gripe/_90/fulleng/block/MonitorBlock.java +++ b/src/main/java/gripe/_90/fulleng/block/MonitorBlock.java @@ -2,7 +2,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ItemLike; @@ -38,8 +38,14 @@ protected BlockState updateBlockStateFromBlockEntity(BlockState currentState, M } @Override - public InteractionResult onActivated( - Level level, BlockPos pos, Player player, InteractionHand hand, ItemStack heldItem, BlockHitResult hit) { + protected ItemInteractionResult useItemOn( + ItemStack heldItem, + BlockState state, + Level level, + BlockPos pos, + Player player, + InteractionHand hand, + BlockHitResult hit) { var be = getBlockEntity(level, pos); if (be != null) { @@ -47,17 +53,17 @@ public InteractionResult onActivated( if (hit.getDirection().equals(be.getFront())) { if (be.getMainNode().isActive() && Platform.hasPermissions(new DimensionalBlockPos(be), player)) { if (InteractionUtil.isInAlternateUseMode(player)) { - be.onShiftActivated(player, hand); + be.onShiftActivated(player, player.swingingArm); } else { - be.onActivated(player, hand); + be.onActivated(player, player.swingingArm); } } } } - return InteractionResult.sidedSuccess(level.isClientSide()); + return ItemInteractionResult.sidedSuccess(level.isClientSide()); } - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } } diff --git a/src/main/java/gripe/_90/fulleng/block/TerminalBlock.java b/src/main/java/gripe/_90/fulleng/block/TerminalBlock.java index bdbcd9a..1940565 100644 --- a/src/main/java/gripe/_90/fulleng/block/TerminalBlock.java +++ b/src/main/java/gripe/_90/fulleng/block/TerminalBlock.java @@ -1,10 +1,8 @@ package gripe._90.fulleng.block; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; @@ -24,8 +22,8 @@ public TerminalBlock(ItemDefinition equivalentPart) { } @Override - public InteractionResult onActivated( - Level level, BlockPos pos, Player player, InteractionHand hand, ItemStack heldItem, BlockHitResult hit) { + public InteractionResult useWithoutItem( + BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hit) { if (InteractionUtil.isInAlternateUseMode(player)) { return InteractionResult.PASS; } diff --git a/src/main/java/gripe/_90/fulleng/block/entity/FullBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/FullBlockEntity.java index 0d3e7e9..0d4752b 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/FullBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/FullBlockEntity.java @@ -2,8 +2,9 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; @@ -25,7 +26,7 @@ public FullBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockSt } @Override - protected boolean readFromStream(FriendlyByteBuf data) { + protected boolean readFromStream(RegistryFriendlyByteBuf data) { var needRedraw = super.readFromStream(data); var wasActive = isActive; isActive = data.readBoolean(); @@ -37,7 +38,7 @@ protected boolean readFromStream(FriendlyByteBuf data) { } @Override - protected void writeToStream(FriendlyByteBuf data) { + protected void writeToStream(RegistryFriendlyByteBuf data) { super.writeToStream(data); data.writeBoolean(getMainNode().isOnline()); data.writeByte(paintedColour.ordinal()); @@ -56,14 +57,14 @@ protected void loadVisualState(CompoundTag data) { } @Override - public void saveAdditional(CompoundTag data) { - super.saveAdditional(data); + public void saveAdditional(CompoundTag data, HolderLookup.Provider registries) { + super.saveAdditional(data, registries); data.putByte("paintedColor", (byte) paintedColour.ordinal()); } @Override - public void loadTag(CompoundTag data) { - super.loadTag(data); + public void loadTag(CompoundTag data, HolderLookup.Provider registries) { + super.loadTag(data, registries); if (data.contains("paintedColor")) { paintedColour = AEColor.values()[data.getByte("paintedColor")]; diff --git a/src/main/java/gripe/_90/fulleng/block/entity/monitor/StorageMonitorBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/monitor/StorageMonitorBlockEntity.java index 7b3a683..d994738 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/monitor/StorageMonitorBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/monitor/StorageMonitorBlockEntity.java @@ -3,8 +3,9 @@ import org.jetbrains.annotations.Nullable; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.context.UseOnContext; @@ -85,7 +86,7 @@ public void onCraftableChange(AEKey what) { } @Override - protected boolean readFromStream(FriendlyByteBuf data) { + protected boolean readFromStream(RegistryFriendlyByteBuf data) { var needRedraw = super.readFromStream(data); var wasLocked = data.readBoolean(); isLocked = wasLocked; @@ -104,7 +105,7 @@ protected boolean readFromStream(FriendlyByteBuf data) { } @Override - protected void writeToStream(FriendlyByteBuf data) { + protected void writeToStream(RegistryFriendlyByteBuf data) { super.writeToStream(data); data.writeBoolean(isLocked); data.writeBoolean(configuredItem != null); @@ -131,20 +132,20 @@ protected void loadVisualState(CompoundTag data) { } @Override - public void saveAdditional(CompoundTag data) { - super.saveAdditional(data); + public void saveAdditional(CompoundTag data, HolderLookup.Provider registries) { + super.saveAdditional(data, registries); data.putBoolean("isLocked", isLocked); if (configuredItem != null) { - data.put("configuredItem", configuredItem.toTagGeneric()); + data.put("configuredItem", configuredItem.toTagGeneric(registries)); } } @Override - public void loadTag(CompoundTag data) { - super.loadTag(data); + public void loadTag(CompoundTag data, HolderLookup.Provider registries) { + super.loadTag(data, registries); isLocked = data.getBoolean("isLocked"); - configuredItem = AEKey.fromTagGeneric(data.getCompound("configuredItem")); + configuredItem = AEKey.fromTagGeneric(registries, data.getCompound("configuredItem")); } public void onActivated(Player player, InteractionHand hand) { diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/CraftingTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/CraftingTerminalBlockEntity.java index 245a632..19df92d 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/CraftingTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/CraftingTerminalBlockEntity.java @@ -3,6 +3,7 @@ import java.util.List; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.MenuType; @@ -34,15 +35,15 @@ public void addAdditionalDrops(Level level, BlockPos pos, List drops) } @Override - public void loadTag(CompoundTag data) { - super.loadTag(data); - craftingGrid.readFromNBT(data, "craftingGrid"); + public void loadTag(CompoundTag data, HolderLookup.Provider registries) { + super.loadTag(data, registries); + craftingGrid.readFromNBT(data, "craftingGrid", registries); } @Override - public void saveAdditional(CompoundTag data) { - super.saveAdditional(data); - craftingGrid.writeToNBT(data, "craftingGrid"); + public void saveAdditional(CompoundTag data, HolderLookup.Provider registries) { + super.saveAdditional(data, registries); + craftingGrid.writeToNBT(data, "craftingGrid", registries); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternAccessTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternAccessTerminalBlockEntity.java index 22b1c74..e2f976d 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternAccessTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternAccessTerminalBlockEntity.java @@ -11,6 +11,7 @@ import appeng.api.networking.IGridNode; import appeng.api.storage.ILinkStatus; import appeng.api.storage.IPatternAccessTermMenuHost; +import appeng.api.util.IConfigManagerBuilder; import gripe._90.fulleng.definition.FullEngBlockEntities; import gripe._90.fulleng.menu.PatternAccessTerminalMenu; @@ -18,7 +19,11 @@ public class PatternAccessTerminalBlockEntity extends TerminalBlockEntity implements IPatternAccessTermMenuHost { public PatternAccessTerminalBlockEntity(BlockPos pos, BlockState blockState) { super(FullEngBlockEntities.PATTERN_ACCESS_TERMINAL, pos, blockState); - this.getConfigManager().registerSetting(Settings.TERMINAL_SHOW_PATTERN_PROVIDERS, ShowPatternProviders.VISIBLE); + } + + @Override + protected void registerSettings(IConfigManagerBuilder builder) { + builder.registerSetting(Settings.TERMINAL_SHOW_PATTERN_PROVIDERS, ShowPatternProviders.VISIBLE); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternEncodingTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternEncodingTerminalBlockEntity.java index b62ecfa..103b924 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternEncodingTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternEncodingTerminalBlockEntity.java @@ -3,6 +3,7 @@ import java.util.List; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.ItemStack; @@ -32,15 +33,15 @@ public void addAdditionalDrops(Level level, BlockPos pos, List drops) } @Override - public void loadTag(CompoundTag data) { - super.loadTag(data); - logic.readFromNBT(data); + public void loadTag(CompoundTag data, HolderLookup.Provider registries) { + super.loadTag(data, registries); + logic.readFromNBT(data, registries); } @Override - public void saveAdditional(CompoundTag data) { - super.saveAdditional(data); - logic.writeToNBT(data); + public void saveAdditional(CompoundTag data, HolderLookup.Provider registries) { + super.saveAdditional(data, registries); + logic.writeToNBT(data, registries); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/StorageTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/StorageTerminalBlockEntity.java index 0f07a1d..813f84f 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/StorageTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/StorageTerminalBlockEntity.java @@ -3,6 +3,7 @@ import java.util.List; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.MenuType; @@ -21,6 +22,7 @@ import appeng.api.storage.ITerminalHost; import appeng.api.storage.MEStorage; import appeng.api.storage.SupplierStorage; +import appeng.api.util.IConfigManagerBuilder; import appeng.menu.ISubMenu; import appeng.menu.MenuOpener; import appeng.menu.me.common.MEStorageMenu; @@ -39,21 +41,25 @@ public StorageTerminalBlockEntity(BlockPos pos, BlockState state) { public StorageTerminalBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { super(type, pos, blockState); - this.getConfigManager().registerSetting(Settings.SORT_BY, SortOrder.NAME); - this.getConfigManager().registerSetting(Settings.VIEW_MODE, ViewItems.ALL); - this.getConfigManager().registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING); } @Override - public void saveAdditional(CompoundTag data) { - super.saveAdditional(data); - viewCell.writeToNBT(data, "viewCell"); + protected void registerSettings(IConfigManagerBuilder builder) { + builder.registerSetting(Settings.SORT_BY, SortOrder.NAME); + builder.registerSetting(Settings.VIEW_MODE, ViewItems.ALL); + builder.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING); } @Override - public void loadTag(CompoundTag data) { - super.loadTag(data); - viewCell.readFromNBT(data, "viewCell"); + public void saveAdditional(CompoundTag data, HolderLookup.Provider registries) { + super.saveAdditional(data, registries); + viewCell.writeToNBT(data, "viewCell", registries); + } + + @Override + public void loadTag(CompoundTag data, HolderLookup.Provider registries) { + super.loadTag(data, registries); + viewCell.readFromNBT(data, "viewCell", registries); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/TerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/TerminalBlockEntity.java index 3fd081c..8816265 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/TerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/TerminalBlockEntity.java @@ -1,38 +1,45 @@ package gripe._90.fulleng.block.entity.terminal; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.inventory.MenuType; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import appeng.api.util.IConfigManager; +import appeng.api.util.IConfigManagerBuilder; import appeng.api.util.IConfigurableObject; -import appeng.util.ConfigManager; import gripe._90.fulleng.block.entity.FullBlockEntity; public abstract class TerminalBlockEntity extends FullBlockEntity implements IConfigurableObject { - private final IConfigManager cm = new ConfigManager(this::saveChanges); + private final IConfigManager cm; public TerminalBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { super(type, pos, blockState); + + var builder = IConfigManager.builder(this::saveChanges); + registerSettings(builder); + cm = builder.build(); } @Override - public void saveAdditional(CompoundTag data) { - super.saveAdditional(data); - cm.writeToNBT(data); + public void saveAdditional(CompoundTag data, HolderLookup.Provider registries) { + super.saveAdditional(data, registries); + cm.writeToNBT(data, registries); } @Override - public void loadTag(CompoundTag data) { - super.loadTag(data); - cm.readFromNBT(data); + public void loadTag(CompoundTag data, HolderLookup.Provider registries) { + super.loadTag(data, registries); + cm.readFromNBT(data, registries); } public abstract MenuType getMenuType(); + protected void registerSettings(IConfigManagerBuilder builder) {} + @Override public IConfigManager getConfigManager() { return cm; diff --git a/src/main/java/gripe/_90/fulleng/integration/IntegrationBlockItem.java b/src/main/java/gripe/_90/fulleng/integration/IntegrationBlockItem.java index 4c9b1cf..81d1297 100644 --- a/src/main/java/gripe/_90/fulleng/integration/IntegrationBlockItem.java +++ b/src/main/java/gripe/_90/fulleng/integration/IntegrationBlockItem.java @@ -5,7 +5,6 @@ import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import appeng.block.AEBaseBlockItem; @@ -19,7 +18,8 @@ public IntegrationBlockItem(Block id, Addons addon) { } @Override - public void addCheckedInformation(ItemStack stack, Level level, List lines, TooltipFlag advTooltips) { + public void addCheckedInformation( + ItemStack stack, TooltipContext context, List lines, TooltipFlag advTooltips) { if (!addon.isLoaded()) { lines.add(addon.getNotInstalledTooltip()); } diff --git a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterIntegration.java b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterIntegration.java index 4508419..7136e19 100644 --- a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterIntegration.java +++ b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterIntegration.java @@ -3,6 +3,8 @@ import com.almostreliable.merequester.Registration; import com.almostreliable.merequester.client.RequesterTerminalScreen; +import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; + import appeng.core.definitions.ItemDefinition; import appeng.init.client.InitScreens; @@ -11,8 +13,9 @@ static ItemDefinition getRequesterTerminalPart() { return Registration.REQUESTER_TERMINAL; } - public static void initScreen() { + public static void initScreen(RegisterMenuScreensEvent event) { InitScreens.register( + event, RequesterTerminalMenu.TYPE_FULLBLOCK, RequesterTerminalScreen::new, "/screens/requester_terminal.json"); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/neoforge.mods.toml similarity index 90% rename from src/main/resources/META-INF/mods.toml rename to src/main/resources/META-INF/neoforge.mods.toml index 258425e..9cce4e1 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -20,12 +20,8 @@ config = "fulleng.mixins.json" modId = "ae2" type = "required" versionRange = "[$ae2Version,$ae2VersionEnd)" -ordering = "AFTER" -side = "BOTH" [[dependencies]] modId = "merequester" type = "optional" versionRange = "[$requesterVersion,)" -ordering = "AFTER" -side = "BOTH" diff --git a/src/main/resources/fulleng.mixins.json b/src/main/resources/fulleng.mixins.json index d6faf53..876fb41 100644 --- a/src/main/resources/fulleng.mixins.json +++ b/src/main/resources/fulleng.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8.5", "package": "gripe._90.fulleng.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "mixins": ["PartLeftClickPacketMixin"], "client": ["ModelManagerMixin", "UnlitQuadHooksAccessor"], "injectors": { diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta deleted file mode 100644 index c6775b4..0000000 --- a/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "fulleng resources", - "pack_format": 9 - } -}