diff --git a/.gitignore b/.gitignore index d0b65f00..eb49f0ce 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ out *.ipr *.iws *.iml -.idea # gradle build diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..33e97fdd --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,11 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml + +jarRepositories.xml +uiDesigner.xml \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 00000000..41c8fbb4 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 00000000..6e6eec11 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 00000000..b589d56e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 00000000..c26b135d --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/PhosCodeStyle.xml b/.idea/inspectionProfiles/PhosCodeStyle.xml new file mode 100644 index 00000000..4b5bd5b1 --- /dev/null +++ b/.idea/inspectionProfiles/PhosCodeStyle.xml @@ -0,0 +1,28 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..d77aa703 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..2bfae1f8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..e4f6507d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/remote-targets.xml b/.idea/remote-targets.xml new file mode 100644 index 00000000..7a8ddc42 --- /dev/null +++ b/.idea/remote-targets.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Phosphophyllite b/Phosphophyllite index e4685db6..d1b37c8d 160000 --- a/Phosphophyllite +++ b/Phosphophyllite @@ -1 +1 @@ -Subproject commit e4685db6443344fc3ac1b9b844a7fc5f4ee9863c +Subproject commit d1b37c8d53a79a897de0c219bc12411ea57d809a diff --git a/Quartz b/Quartz index 077a68fa..310fc60a 160000 --- a/Quartz +++ b/Quartz @@ -1 +1 @@ -Subproject commit 077a68fa5a191044ae67ce493163eaf8b4027d7b +Subproject commit 310fc60af9a3710ecb3d99d67b3cf0928c765e06 diff --git a/build.gradle b/build.gradle index ff91782e..f527a318 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,14 @@ plugins { + id 'java-library' id 'eclipse' id 'idea' id 'maven-publish' - id 'net.neoforged.gradle' version '[6.0.18,6.2)' - id 'org.spongepowered.mixin' version '0.7.+' - id 'org.parchmentmc.librarian.forgegradle' version '1.+' + id 'net.neoforged.gradle.userdev' version '7.0.+' + id 'net.neoforged.gradle.mixin' version '7.0.+' } -evaluationDependsOnChildren() +evaluationDependsOn(':Phosphophyllite') +evaluationDependsOn(':Quartz') version = "${majorVersion}.${minorVersion}.${patchVersion}" if (!"${postfixVersion}".isEmpty()) { @@ -20,63 +21,53 @@ base { } java.toolchain.languageVersion = JavaLanguageVersion.of(17) -println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" - -minecraft { - mappings channel: mapping_channel, version: mapping_version - - copyIdeResources = true - accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') - - runs { - // applies to all the run configs below - configureEach { - workingDirectory project.file("run/${it.name}") - - property 'forge.logging.markers', 'SCAN,REGISTRIES' - property 'forge.logging.console.level', 'debug' - - mods { - "${mod_id}" { - source sourceSets.main - } - Quartz { - source project(':Quartz').sourceSets.main - } - Phosphophyllite { - source project(':Phosphophyllite').sourceSets.main - } + +//accessTransformers { +// file 'src/main/resources/META-INF/accesstransformer.cfg' +//} + +runs { + configureEach { + workingDirectory project.file("run/${it.name}") + + systemProperty 'forge.logging.markers', 'SCAN,REGISTRIES' + systemProperty 'forge.logging.console.level', 'debug' + + modSource project.sourceSets.main + modSource project(':Quartz').sourceSets.main + modSource project(':Phosphophyllite').sourceSets.main + + dependencies { + runtime("org.lwjgl:lwjgl-opencl:3.3.1") { + transitive(false) + } + runtime("org.lwjgl:lwjgl-vulkan:3.3.1"){ + transitive(false) } } + } - client { - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - property 'forge.enabledGameTestNamespaces', mod_id - } + client { + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + } - server { - property 'forge.enabledGameTestNamespaces', mod_id - args '--nogui' - } + server { + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + programArgument '--nogui' + } - gameTestServer { - property 'forge.enabledGameTestNamespaces', mod_id - } + gameTestServer { + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + } - data { - args '--mod', mod_id, '--all', '--existing-mod', 'biggerreactors', '--existing-mod', 'phosphophyllite', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - } + data { + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() } } // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } -mixin { - config 'quartz.mixins.json' - config 'phosphophyllite.mixins.json' -} - repositories { maven { url = "https://www.cursemaven.com" @@ -101,39 +92,39 @@ repositories { } dependencies { - minecraft "net.neoforged:forge:${mc_version}-${neo_version}" + implementation "net.neoforged:neoforge:${neo_version}" compileOnly project(':Phosphophyllite') compileOnly project(':Quartz') compileOnly("cc.tweaked:cc-tweaked-${cc_mc_version}-core-api:${cc_version}") - compileOnly(fg.deobf("cc.tweaked:cc-tweaked-${cc_mc_version}-forge-api:${cc_version}")) - runtimeOnly(fg.deobf("cc.tweaked:cc-tweaked-${cc_mc_version}-forge:${cc_version}")) + compileOnly("cc.tweaked:cc-tweaked-${cc_mc_version}-forge-api:${cc_version}") +// runtimeOnly("cc.tweaked:cc-tweaked-${cc_mc_version}-forge:${cc_version}") - compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) - compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) + compileOnly("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}") + compileOnly("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}") // at runtime, use the full JEI jar for Forge - runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) +// runtimeOnly("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}") compileOnly "mekanism:Mekanism:1.19.2-10.3.5.474:api" -// runtimeOnly fg.deobf('curse.maven:MEK-268560:4041164') -// runtimeOnly fg.deobf('curse.maven:MEKG-268566:4041168') -// runtimeOnly fg.deobf('curse.maven:COFHCore-69162:4385216') -// runtimeOnly fg.deobf('curse.maven:ThermalFoundation-222880:4382373') -// runtimeOnly fg.deobf('curse.maven:ThermalExpansion-69163:4382371') -// runtimeOnly fg.deobf('curse.maven:ThermalDynamics-227443:4391160') +// runtimeOnly 'curse.maven:MEK-268560:4041164' +// runtimeOnly 'curse.maven:MEKG-268566:4041168' +// runtimeOnly 'curse.maven:COFHCore-69162:4385216' +// runtimeOnly 'curse.maven:ThermalFoundation-222880:4382373' +// runtimeOnly 'curse.maven:ThermalExpansion-69163:4382371' +// runtimeOnly 'curse.maven:ThermalDynamics-227443:4391160' -// runtimeOnly fg.deobf('curse.maven:Rubidium-574856:4448157') - runtimeOnly fg.deobf('curse.maven:Oculus-581495:4578741') +// runtimeOnly 'curse.maven:Rubidium-574856:4448157' +// runtimeOnly 'curse.maven:Oculus-581495:4578741' -// runtimeOnly fg.deobf('curse.maven:WorldStripper-250603:3545856') -// runtimeOnly fg.deobf('curse.maven:CW-399558:3926815') +// runtimeOnly 'curse.maven:WorldStripper-250603:3545856') +// runtimeOnly 'curse.maven:CW-399558:3926815') - minecraftLibrary("org.lwjgl:lwjgl-opencl:3.3.1") { + compileOnly("org.lwjgl:lwjgl-opencl:3.3.1") { transitive(false) } - minecraftLibrary ("org.lwjgl:lwjgl-vulkan:3.3.1"){ + compileOnly("org.lwjgl:lwjgl-vulkan:3.3.1"){ transitive(false) } } @@ -159,7 +150,7 @@ gradle.projectsEvaluated { var replaceProperties = [ minecraft_version : mc_version, neo_version : neo_version, - loader_version : neo_version.substring(0, neo_version.indexOf('.')), + loader_version : loader_version, version : version, phos_version_range : project.project(":Phosphophyllite").property("compatibility").toString(), quartz_version_range: project.project(":Quartz").property("compatibility").toString(), @@ -215,27 +206,22 @@ publishing { } } -// NeoGradle is dumb, and generates the run configs incorrectly, this fixes them -tasks.register('zzz_copyRunConfigsToTmpDir', Copy) { - from '.idea/runConfigurations' - into '.idea/runConfigurations1' -} - -tasks.register('zzz_depeteTmpDir', Delete) { - delete '.idea/runConfigurations1' -} - -tasks.register('_createIntellijRunsThatWork', Copy) { - dependsOn 'genIntellijRuns' - mustRunAfter 'genIntellijRuns' - dependsOn 'zzz_copyRunConfigsToTmpDir' - mustRunAfter 'zzz_copyRunConfigsToTmpDir' +// NeoGradle bug, this works around it +gradle.projectsEvaluated { + var subProjects = List.of(project.project(':Quartz'), project.project(':Phosphophyllite')) - from '.idea/runConfigurations1' - into '.idea/runConfigurations' - filter { String line -> line.replace("out/production/classes", "build/classes/java/main") } - filter { String line -> line.replace("out/production/resources", "build/resources/main") } - filter { String line -> line.replace("copyIntellijResources", "prepareRunClientCompile") } + var neoFormJoinDownloadAssetsTaskName = null + for (final def taskName in project.tasks.getNames()) { + if (taskName.contains("neoFormJoined") && taskName.contains("DownloadAssets")) { + neoFormJoinDownloadAssetsTaskName = taskName + break + } + } - finalizedBy 'zzz_depeteTmpDir' + var lastTask = project.tasks.getByPath(neoFormJoinDownloadAssetsTaskName) + for (final def subProject in subProjects) { + var nextTask = subProject.tasks.getByPath(neoFormJoinDownloadAssetsTaskName); + lastTask.mustRunAfter(nextTask) + lastTask = nextTask + } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 23cf7483..5cbdcf29 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,12 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mc_version=1.20.1 -mapping_channel=parchment -mapping_version=2023.07.09-1.20.1 -neo_version=47.1.76 +mc_version=1.20.4 +mapping_channel=official +mapping_version=1.20.4 +neo_version=20.4.156-beta +loader_version=1 + cc_mc_version=1.20.1 cc_version=1.106.1 diff --git a/src/main/java/net/roguelogix/biggerreactors/BiggerReactors.java b/src/main/java/net/roguelogix/biggerreactors/BiggerReactors.java index 02eb950f..2c6998ad 100644 --- a/src/main/java/net/roguelogix/biggerreactors/BiggerReactors.java +++ b/src/main/java/net/roguelogix/biggerreactors/BiggerReactors.java @@ -3,13 +3,11 @@ import it.unimi.dsi.fastutil.objects.ReferenceArrayList; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.MinecraftForge; -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 net.roguelogix.biggerreactors.machine.client.CyaniteReprocessorScreen; -import net.roguelogix.biggerreactors.machine.containers.CyaniteReprocessorContainer; +import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; +import net.neoforged.fml.loading.FMLLoader; +import net.neoforged.neoforge.common.NeoForge; import net.roguelogix.biggerreactors.multiblocks.heatexchanger.client.HeatExchangerFluidPortScreen; import net.roguelogix.biggerreactors.multiblocks.heatexchanger.client.HeatExchangerTerminalScreen; import net.roguelogix.biggerreactors.multiblocks.heatexchanger.containers.HeatExchangerFluidPortContainer; @@ -41,8 +39,8 @@ public class BiggerReactors { public BiggerReactors() { new Registry(new ReferenceArrayList<>(), ReferenceArrayList.of(new ResourceLocation(Phosphophyllite.modid, "creative_tab"), new ResourceLocation(Quartz.modid, "creative_tab"))); - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientSetup); - MinecraftForge.EVENT_BUS.addListener(this::onReloadData); + ModLoadingContext.get().getActiveContainer().getEventBus().addListener(this::onClientSetup); + NeoForge.EVENT_BUS.addListener(this::onReloadData); version = FMLLoader.getLoadingModList().getModFileById(modid).versionString(); } @@ -55,8 +53,8 @@ public void onReloadData(final ReloadDataEvent reloadDataEvent) { public void onClientSetup(final FMLClientSetupEvent e) { // TODO: 6/28/20 Registry. // Since I already have the comment here, also need to do a capability registry. I have a somewhat dumb capability to register. - MenuScreens.register(CyaniteReprocessorContainer.INSTANCE, - CyaniteReprocessorScreen::new); +// MenuScreens.register(CyaniteReprocessorContainer.INSTANCE, +// CyaniteReprocessorScreen::new); MenuScreens.register(ReactorTerminalContainer.INSTANCE, CommonReactorTerminalScreen::new); MenuScreens.register(ReactorCoolantPortContainer.INSTANCE, diff --git a/src/main/java/net/roguelogix/biggerreactors/blocks/materials/DeepslateUraniumOre.java b/src/main/java/net/roguelogix/biggerreactors/blocks/materials/DeepslateUraniumOre.java index be5fd761..21551e33 100644 --- a/src/main/java/net/roguelogix/biggerreactors/blocks/materials/DeepslateUraniumOre.java +++ b/src/main/java/net/roguelogix/biggerreactors/blocks/materials/DeepslateUraniumOre.java @@ -1,5 +1,6 @@ package net.roguelogix.biggerreactors.blocks.materials; +import net.minecraft.util.valueproviders.ConstantInt; import net.minecraft.world.level.block.DropExperienceBlock; import net.minecraft.world.level.block.SoundType; import net.roguelogix.phosphophyllite.registry.RegisterBlock; @@ -11,7 +12,7 @@ public class DeepslateUraniumOre extends DropExperienceBlock { public static final DeepslateUraniumOre INSTANCE = new DeepslateUraniumOre(); public DeepslateUraniumOre() { - super( + super(ConstantInt.of(0), Properties.of() .sound(SoundType.DEEPSLATE) .explosionResistance(3.0F) diff --git a/src/main/java/net/roguelogix/biggerreactors/blocks/materials/UraniumOre.java b/src/main/java/net/roguelogix/biggerreactors/blocks/materials/UraniumOre.java index bca46dcd..f1716e01 100644 --- a/src/main/java/net/roguelogix/biggerreactors/blocks/materials/UraniumOre.java +++ b/src/main/java/net/roguelogix/biggerreactors/blocks/materials/UraniumOre.java @@ -1,5 +1,6 @@ package net.roguelogix.biggerreactors.blocks.materials; +import net.minecraft.util.valueproviders.ConstantInt; import net.minecraft.world.level.block.DropExperienceBlock; import net.minecraft.world.level.block.SoundType; import net.roguelogix.phosphophyllite.registry.RegisterBlock; @@ -10,7 +11,7 @@ public class UraniumOre extends DropExperienceBlock { public static final UraniumOre INSTANCE = new UraniumOre(); public UraniumOre() { - super( + super(ConstantInt.of(0), Properties.of() .sound(SoundType.STONE) .explosionResistance(3.0F) diff --git a/src/main/java/net/roguelogix/biggerreactors/client/Biselector.java b/src/main/java/net/roguelogix/biggerreactors/client/Biselector.java index 6eeb74cd..5e91958b 100644 --- a/src/main/java/net/roguelogix/biggerreactors/client/Biselector.java +++ b/src/main/java/net/roguelogix/biggerreactors/client/Biselector.java @@ -6,8 +6,8 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.phosphophyllite.client.gui.screens.PhosphophylliteScreen; import net.roguelogix.phosphophyllite.client.gui.RenderHelper; import net.roguelogix.phosphophyllite.client.gui.elements.InteractiveElement; diff --git a/src/main/java/net/roguelogix/biggerreactors/client/CommonButton.java b/src/main/java/net/roguelogix/biggerreactors/client/CommonButton.java index 1cd83a89..4d553479 100644 --- a/src/main/java/net/roguelogix/biggerreactors/client/CommonButton.java +++ b/src/main/java/net/roguelogix/biggerreactors/client/CommonButton.java @@ -6,8 +6,8 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.phosphophyllite.client.gui.RenderHelper; import net.roguelogix.phosphophyllite.client.gui.screens.PhosphophylliteScreen; import net.roguelogix.phosphophyllite.client.gui.elements.InteractiveElement; diff --git a/src/main/java/net/roguelogix/biggerreactors/client/CommonRender.java b/src/main/java/net/roguelogix/biggerreactors/client/CommonRender.java index c810e688..ede26eda 100644 --- a/src/main/java/net/roguelogix/biggerreactors/client/CommonRender.java +++ b/src/main/java/net/roguelogix/biggerreactors/client/CommonRender.java @@ -6,9 +6,9 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.level.material.Fluid; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fluids.FluidStack; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.neoforge.fluids.FluidStack; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.phosphophyllite.client.gui.RenderHelper; import net.roguelogix.phosphophyllite.client.gui.elements.RenderedElement; diff --git a/src/main/java/net/roguelogix/biggerreactors/client/TextBox.java b/src/main/java/net/roguelogix/biggerreactors/client/TextBox.java index d51626f2..ec2396d1 100644 --- a/src/main/java/net/roguelogix/biggerreactors/client/TextBox.java +++ b/src/main/java/net/roguelogix/biggerreactors/client/TextBox.java @@ -11,8 +11,8 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.phosphophyllite.client.gui.screens.PhosphophylliteScreen; import net.roguelogix.phosphophyllite.client.gui.RenderHelper; diff --git a/src/main/java/net/roguelogix/biggerreactors/client/Triselector.java b/src/main/java/net/roguelogix/biggerreactors/client/Triselector.java index a8e388d6..d4feb169 100644 --- a/src/main/java/net/roguelogix/biggerreactors/client/Triselector.java +++ b/src/main/java/net/roguelogix/biggerreactors/client/Triselector.java @@ -1,16 +1,15 @@ package net.roguelogix.biggerreactors.client; -import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.phosphophyllite.client.gui.RenderHelper; -import net.roguelogix.phosphophyllite.client.gui.screens.PhosphophylliteScreen; import net.roguelogix.phosphophyllite.client.gui.elements.InteractiveElement; +import net.roguelogix.phosphophyllite.client.gui.screens.PhosphophylliteScreen; import javax.annotation.Nonnull; import javax.annotation.Nullable; diff --git a/src/main/java/net/roguelogix/biggerreactors/client/deps/jei/BiggerReactorsJEIPlugin.java b/src/main/java/net/roguelogix/biggerreactors/client/deps/jei/BiggerReactorsJEIPlugin.java index 8f395064..9ee76e67 100644 --- a/src/main/java/net/roguelogix/biggerreactors/client/deps/jei/BiggerReactorsJEIPlugin.java +++ b/src/main/java/net/roguelogix/biggerreactors/client/deps/jei/BiggerReactorsJEIPlugin.java @@ -10,7 +10,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.AirBlock; import net.minecraft.world.level.block.LiquidBlock; -import net.minecraftforge.fluids.FluidStack; +import net.neoforged.neoforge.fluids.FluidStack; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.Config; import net.roguelogix.biggerreactors.client.deps.jei.classic.reactor.BlockModeratorCategory; diff --git a/src/main/java/net/roguelogix/biggerreactors/client/deps/jei/classic/reactor/FluidModeratorCategory.java b/src/main/java/net/roguelogix/biggerreactors/client/deps/jei/classic/reactor/FluidModeratorCategory.java index 51ff7c1c..5f25b7e7 100644 --- a/src/main/java/net/roguelogix/biggerreactors/client/deps/jei/classic/reactor/FluidModeratorCategory.java +++ b/src/main/java/net/roguelogix/biggerreactors/client/deps/jei/classic/reactor/FluidModeratorCategory.java @@ -1,6 +1,5 @@ package net.roguelogix.biggerreactors.client.deps.jei.classic.reactor; -import com.mojang.blaze3d.vertex.PoseStack; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.ingredient.IRecipeSlotsView; @@ -14,7 +13,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; +import net.neoforged.neoforge.fluids.FluidStack; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.multiblocks.reactor.blocks.ReactorTerminal; import net.roguelogix.biggerreactors.registries.ReactorModeratorRegistry; diff --git a/src/main/java/net/roguelogix/biggerreactors/machine/blocks/CyaniteReprocessor.java b/src/main/java/net/roguelogix/biggerreactors/machine/blocks/CyaniteReprocessor.java index 01d58056..a48b1fb4 100644 --- a/src/main/java/net/roguelogix/biggerreactors/machine/blocks/CyaniteReprocessor.java +++ b/src/main/java/net/roguelogix/biggerreactors/machine/blocks/CyaniteReprocessor.java @@ -1,108 +1,107 @@ -package net.roguelogix.biggerreactors.machine.blocks; - -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.LivingEntity; -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.*; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityTicker; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraftforge.common.ToolAction; -import net.roguelogix.biggerreactors.machine.tiles.CyaniteReprocessorTile; -import net.roguelogix.phosphophyllite.registry.RegisterBlock; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class CyaniteReprocessor extends BaseEntityBlock implements EntityBlock{ - - public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; - public static final BooleanProperty ENABLED = BlockStateProperties.ENABLED; - - @RegisterBlock(name = "cyanite_reprocessor", tileEntityClass = CyaniteReprocessorTile.class) - public static final CyaniteReprocessor INSTANCE = new CyaniteReprocessor(); - - public CyaniteReprocessor() { - super(Properties.of() - .sound(SoundType.STONE) - .destroyTime(1.0F) - .explosionResistance(1.0F) - .requiresCorrectToolForDrops()); - this.registerDefaultState(this.getStateDefinition().any() - .setValue(FACING, Direction.NORTH) - .setValue(ENABLED, Boolean.FALSE)); - } - - public static Direction getFacingFromEntity(BlockPos clickedBlockPos, LivingEntity entity) { - return Direction.getNearest((float) (entity.getX() - clickedBlockPos.getX()), 0.0F, (float) (entity.getZ() - clickedBlockPos.getZ())); - } - - @Nonnull - @Override - public RenderShape getRenderShape(@Nonnull BlockState blockState) { - return RenderShape.MODEL; - } - - @Nullable - @Override - public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { - return CyaniteReprocessorTile.SUPPLIER.create(pos, state); - } - - @Nullable - @Override - public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType type) { - return (a, b, c, tile) -> { - assert tile instanceof CyaniteReprocessorTile; - ((CyaniteReprocessorTile) tile).tick(); - }; - } - - @Override - public void createBlockStateDefinition(StateDefinition.Builder builder) { - builder.add(FACING).add(ENABLED); - } - - @Nonnull - @Override - public InteractionResult use(@Nonnull BlockState blockState, Level world, @Nonnull BlockPos blockPos, @Nonnull Player player, @Nonnull InteractionHand hand, @Nonnull BlockHitResult trace) { - BlockEntity tile = world.getBlockEntity(blockPos); - if (tile instanceof CyaniteReprocessorTile) { - return ((CyaniteReprocessorTile) tile).onBlockActivated(blockState, world, blockPos, player, hand, trace); - } - return InteractionResult.FAIL; - } - - - - @Override - public void onRemove(BlockState blockState, Level world, BlockPos blockPos, BlockState newBlockState, boolean isMoving) { - if (blockState.getBlock() != newBlockState.getBlock()) { - BlockEntity tile = world.getBlockEntity(blockPos); - if (tile instanceof CyaniteReprocessorTile) { - ((CyaniteReprocessorTile) tile).onReplaced(blockState, world, blockPos, newBlockState, isMoving); - } - super.onRemove(blockState, world, blockPos, newBlockState, isMoving); - } - } - - @Override - public void setPlacedBy(@Nonnull Level world, @Nonnull BlockPos blockPos, @Nonnull BlockState blockState, @Nullable LivingEntity entity, @Nonnull ItemStack stack) { - if (entity != null) { - world.setBlock(blockPos, blockState - .setValue(FACING, getFacingFromEntity(blockPos, entity)) - .setValue(ENABLED, false), 2); - } - } -} +//package net.roguelogix.biggerreactors.machine.blocks; +// +//import net.minecraft.core.BlockPos; +//import net.minecraft.core.Direction; +//import net.minecraft.world.InteractionHand; +//import net.minecraft.world.InteractionResult; +//import net.minecraft.world.entity.LivingEntity; +//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.*; +//import net.minecraft.world.level.block.entity.BlockEntity; +//import net.minecraft.world.level.block.entity.BlockEntityTicker; +//import net.minecraft.world.level.block.entity.BlockEntityType; +//import net.minecraft.world.level.block.state.BlockState; +//import net.minecraft.world.level.block.state.StateDefinition; +//import net.minecraft.world.level.block.state.properties.BlockStateProperties; +//import net.minecraft.world.level.block.state.properties.BooleanProperty; +//import net.minecraft.world.level.block.state.properties.DirectionProperty; +//import net.minecraft.world.phys.BlockHitResult; +//import net.roguelogix.biggerreactors.machine.tiles.CyaniteReprocessorTile; +//import net.roguelogix.phosphophyllite.registry.RegisterBlock; +// +//import javax.annotation.Nonnull; +//import javax.annotation.Nullable; +// +//public class CyaniteReprocessor extends Block implements EntityBlock{ +// +// public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; +// public static final BooleanProperty ENABLED = BlockStateProperties.ENABLED; +// +// @RegisterBlock(name = "cyanite_reprocessor", tileEntityClass = CyaniteReprocessorTile.class) +// public static final CyaniteReprocessor INSTANCE = new CyaniteReprocessor(); +// +// public CyaniteReprocessor() { +// super(Properties.of() +// .sound(SoundType.STONE) +// .destroyTime(1.0F) +// .explosionResistance(1.0F) +// .requiresCorrectToolForDrops()); +// this.registerDefaultState(this.getStateDefinition().any() +// .setValue(FACING, Direction.NORTH) +// .setValue(ENABLED, Boolean.FALSE)); +// } +// +// public static Direction getFacingFromEntity(BlockPos clickedBlockPos, LivingEntity entity) { +// return Direction.getNearest((float) (entity.getX() - clickedBlockPos.getX()), 0.0F, (float) (entity.getZ() - clickedBlockPos.getZ())); +// } +// +// @Nonnull +// @Override +// public RenderShape getRenderShape(@Nonnull BlockState blockState) { +// return RenderShape.MODEL; +// } +// +// @Nullable +// @Override +// public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { +// return CyaniteReprocessorTile.SUPPLIER.create(pos, state); +// } +// +// @Nullable +// @Override +// public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType type) { +// return (a, b, c, tile) -> { +// assert tile instanceof CyaniteReprocessorTile; +// ((CyaniteReprocessorTile) tile).tick(); +// }; +// } +// +// @Override +// public void createBlockStateDefinition(StateDefinition.Builder builder) { +// builder.add(FACING).add(ENABLED); +// } +// +// @Nonnull +// @Override +// public InteractionResult use(@Nonnull BlockState blockState, Level world, @Nonnull BlockPos blockPos, @Nonnull Player player, @Nonnull InteractionHand hand, @Nonnull BlockHitResult trace) { +// BlockEntity tile = world.getBlockEntity(blockPos); +// if (tile instanceof CyaniteReprocessorTile) { +// return ((CyaniteReprocessorTile) tile).onBlockActivated(blockState, world, blockPos, player, hand, trace); +// } +// return InteractionResult.FAIL; +// } +// +// +// +// @Override +// public void onRemove(BlockState blockState, Level world, BlockPos blockPos, BlockState newBlockState, boolean isMoving) { +// if (blockState.getBlock() != newBlockState.getBlock()) { +// BlockEntity tile = world.getBlockEntity(blockPos); +// if (tile instanceof CyaniteReprocessorTile) { +// ((CyaniteReprocessorTile) tile).onReplaced(blockState, world, blockPos, newBlockState, isMoving); +// } +// super.onRemove(blockState, world, blockPos, newBlockState, isMoving); +// } +// } +// +// @Override +// public void setPlacedBy(@Nonnull Level world, @Nonnull BlockPos blockPos, @Nonnull BlockState blockState, @Nullable LivingEntity entity, @Nonnull ItemStack stack) { +// if (entity != null) { +// world.setBlock(blockPos, blockState +// .setValue(FACING, getFacingFromEntity(blockPos, entity)) +// .setValue(ENABLED, false), 2); +// } +// } +//} diff --git a/src/main/java/net/roguelogix/biggerreactors/machine/client/CyaniteReprocessorScreen.java b/src/main/java/net/roguelogix/biggerreactors/machine/client/CyaniteReprocessorScreen.java index 35f2a0fa..466310a5 100644 --- a/src/main/java/net/roguelogix/biggerreactors/machine/client/CyaniteReprocessorScreen.java +++ b/src/main/java/net/roguelogix/biggerreactors/machine/client/CyaniteReprocessorScreen.java @@ -1,117 +1,117 @@ -package net.roguelogix.biggerreactors.machine.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.level.material.Fluids; -import net.roguelogix.biggerreactors.BiggerReactors; -import net.roguelogix.biggerreactors.client.CommonRender; -import net.roguelogix.biggerreactors.machine.containers.CyaniteReprocessorContainer; -import net.roguelogix.biggerreactors.machine.state.CyaniteReprocessorState; -import net.roguelogix.phosphophyllite.client.gui.screens.PhosphophylliteScreen; -import net.roguelogix.phosphophyllite.client.gui.RenderHelper; -import net.roguelogix.phosphophyllite.client.gui.elements.RenderedElement; -import net.roguelogix.phosphophyllite.client.gui.elements.TooltipElement; - -import javax.annotation.Nonnull; - -public class CyaniteReprocessorScreen extends PhosphophylliteScreen { - - private static final ResourceLocation DEFAULT_TEXTURE = new ResourceLocation(BiggerReactors.modid, "textures/screen/cyanite_reprocessor.png"); - - private CyaniteReprocessorState cyaniteReprocessorState; - - public CyaniteReprocessorScreen(CyaniteReprocessorContainer container, Inventory playerInventory, Component title) { - super(container, playerInventory, title, DEFAULT_TEXTURE, 176, 175); - - // Initialize reprocessor state. - cyaniteReprocessorState = (CyaniteReprocessorState) this.getMenu().getGuiPacket(); - } - - /** - * Initialize the screen. - */ - @Override - public void init() { - super.init(); - - // Set title to be drawn in the center. - this.titleLabelX = (this.getXSize() / 2) - (this.getFont().width(this.getTitle()) / 2); - - // Initialize tooltips: - this.initTooltips(); - - // Initialize controls: - - // Initialize gauges: - this.initGauges(); - - // Initialize symbols: - this.initSymbols(); - } - - /** - * Initialize tooltips. - */ - public void initTooltips() { - // (Left) Internal battery: - this.addScreenElement(new TooltipElement<>(this, 8, 6, 16, 16, Component.translatable("screen.biggerreactors.cyanite_reprocessor.internal_battery.tooltip"))); - } - - /** - * Initialize gauges. - */ - public void initGauges() { - // (Top) Internal battery: - RenderedElement internalBattery = new RenderedElement<>(this, 7, 25, 18, 64, 0, 152, Component.empty()); - internalBattery.onRender = (@Nonnull GuiGraphics graphics, int mX, int mY) -> CommonRender.renderEnergyGauge(graphics, - internalBattery, cyaniteReprocessorState.energyStored, cyaniteReprocessorState.energyCapacity); - this.addScreenElement(internalBattery); - - // (Top) Water tank: - RenderedElement waterTank = new RenderedElement<>(this, 151, 25, 18, 64, 0, 152, Component.empty()); - waterTank.onRender = (@Nonnull GuiGraphics graphics, int mX, int mY) -> CommonRender.renderFluidGauge(graphics, - waterTank, cyaniteReprocessorState.waterStored, cyaniteReprocessorState.waterCapacity, - Fluids.WATER.getSource()); - this.addScreenElement(waterTank); - - // (Center) Progress bar: - RenderedElement progressBar = new RenderedElement<>(this, 75, 40, 24, 18, 0, 175, null); - progressBar.onRender = (@Nonnull GuiGraphics graphics, int mX, int mY) -> CyaniteReprocessorScreen.renderProgressBar(graphics, - progressBar, cyaniteReprocessorState.workTime, cyaniteReprocessorState.workTimeTotal); - this.addScreenElement(progressBar); - } - - /** - * Initialize symbols. - */ - public void initSymbols() { - // (Right) Water tank symbol: - RenderedElement waterTankSymbol = new RenderedElement<>(this, 152, 6, 16, 16, 48, 175, Component.translatable("screen.biggerreactors.cyanite_reprocessor.water_tank.tooltip")); - waterTankSymbol.onRender = (@Nonnull GuiGraphics graphics, int mX, int mY) -> RenderHelper.drawMaskedFluid(graphics, - waterTankSymbol.x, waterTankSymbol.y, 0, - waterTankSymbol.width, waterTankSymbol.height, - waterTankSymbol.u, waterTankSymbol.v, Fluids.WATER.getSource()); - this.addScreenElement(waterTankSymbol); - } - - /** - * Render the progress bar. - * - * @param poseStack The current pose stack. - * @param symbol The symbol to draw as. - * @param workTime The time the machine has been working. - * @param workTimeTotal The total time needed for completion. - */ - private static void renderProgressBar(@Nonnull GuiGraphics graphics, @Nonnull RenderedElement symbol, int workTime, int workTimeTotal) { - // If there's no progress, there's no need to draw. - if ((workTime > 0) && (workTimeTotal > 0)) { - // Calculate how much needs to be rendered. - int renderSize = (int) ((symbol.width * workTime) / workTimeTotal); - // Render progress. - symbol.blit(graphics, renderSize, symbol.height, symbol.u + 24, symbol.v); - } - } -} +//package net.roguelogix.biggerreactors.machine.client; +// +//import com.mojang.blaze3d.vertex.PoseStack; +//import net.minecraft.client.gui.GuiGraphics; +//import net.minecraft.network.chat.Component; +//import net.minecraft.resources.ResourceLocation; +//import net.minecraft.world.entity.player.Inventory; +//import net.minecraft.world.level.material.Fluids; +//import net.roguelogix.biggerreactors.BiggerReactors; +//import net.roguelogix.biggerreactors.client.CommonRender; +//import net.roguelogix.biggerreactors.machine.containers.CyaniteReprocessorContainer; +//import net.roguelogix.biggerreactors.machine.state.CyaniteReprocessorState; +//import net.roguelogix.phosphophyllite.client.gui.screens.PhosphophylliteScreen; +//import net.roguelogix.phosphophyllite.client.gui.RenderHelper; +//import net.roguelogix.phosphophyllite.client.gui.elements.RenderedElement; +//import net.roguelogix.phosphophyllite.client.gui.elements.TooltipElement; +// +//import javax.annotation.Nonnull; +// +//public class CyaniteReprocessorScreen extends PhosphophylliteScreen { +// +// private static final ResourceLocation DEFAULT_TEXTURE = new ResourceLocation(BiggerReactors.modid, "textures/screen/cyanite_reprocessor.png"); +// +// private CyaniteReprocessorState cyaniteReprocessorState; +// +// public CyaniteReprocessorScreen(CyaniteReprocessorContainer container, Inventory playerInventory, Component title) { +// super(container, playerInventory, title, DEFAULT_TEXTURE, 176, 175); +// +// // Initialize reprocessor state. +// cyaniteReprocessorState = (CyaniteReprocessorState) this.getMenu().getGuiPacket(); +// } +// +// /** +// * Initialize the screen. +// */ +// @Override +// public void init() { +// super.init(); +// +// // Set title to be drawn in the center. +// this.titleLabelX = (this.getXSize() / 2) - (this.getFont().width(this.getTitle()) / 2); +// +// // Initialize tooltips: +// this.initTooltips(); +// +// // Initialize controls: +// +// // Initialize gauges: +// this.initGauges(); +// +// // Initialize symbols: +// this.initSymbols(); +// } +// +// /** +// * Initialize tooltips. +// */ +// public void initTooltips() { +// // (Left) Internal battery: +// this.addScreenElement(new TooltipElement<>(this, 8, 6, 16, 16, Component.translatable("screen.biggerreactors.cyanite_reprocessor.internal_battery.tooltip"))); +// } +// +// /** +// * Initialize gauges. +// */ +// public void initGauges() { +// // (Top) Internal battery: +// RenderedElement internalBattery = new RenderedElement<>(this, 7, 25, 18, 64, 0, 152, Component.empty()); +// internalBattery.onRender = (@Nonnull GuiGraphics graphics, int mX, int mY) -> CommonRender.renderEnergyGauge(graphics, +// internalBattery, cyaniteReprocessorState.energyStored, cyaniteReprocessorState.energyCapacity); +// this.addScreenElement(internalBattery); +// +// // (Top) Water tank: +// RenderedElement waterTank = new RenderedElement<>(this, 151, 25, 18, 64, 0, 152, Component.empty()); +// waterTank.onRender = (@Nonnull GuiGraphics graphics, int mX, int mY) -> CommonRender.renderFluidGauge(graphics, +// waterTank, cyaniteReprocessorState.waterStored, cyaniteReprocessorState.waterCapacity, +// Fluids.WATER.getSource()); +// this.addScreenElement(waterTank); +// +// // (Center) Progress bar: +// RenderedElement progressBar = new RenderedElement<>(this, 75, 40, 24, 18, 0, 175, null); +// progressBar.onRender = (@Nonnull GuiGraphics graphics, int mX, int mY) -> CyaniteReprocessorScreen.renderProgressBar(graphics, +// progressBar, cyaniteReprocessorState.workTime, cyaniteReprocessorState.workTimeTotal); +// this.addScreenElement(progressBar); +// } +// +// /** +// * Initialize symbols. +// */ +// public void initSymbols() { +// // (Right) Water tank symbol: +// RenderedElement waterTankSymbol = new RenderedElement<>(this, 152, 6, 16, 16, 48, 175, Component.translatable("screen.biggerreactors.cyanite_reprocessor.water_tank.tooltip")); +// waterTankSymbol.onRender = (@Nonnull GuiGraphics graphics, int mX, int mY) -> RenderHelper.drawMaskedFluid(graphics, +// waterTankSymbol.x, waterTankSymbol.y, 0, +// waterTankSymbol.width, waterTankSymbol.height, +// waterTankSymbol.u, waterTankSymbol.v, Fluids.WATER.getSource()); +// this.addScreenElement(waterTankSymbol); +// } +// +// /** +// * Render the progress bar. +// * +// * @param poseStack The current pose stack. +// * @param symbol The symbol to draw as. +// * @param workTime The time the machine has been working. +// * @param workTimeTotal The total time needed for completion. +// */ +// private static void renderProgressBar(@Nonnull GuiGraphics graphics, @Nonnull RenderedElement symbol, int workTime, int workTimeTotal) { +// // If there's no progress, there's no need to draw. +// if ((workTime > 0) && (workTimeTotal > 0)) { +// // Calculate how much needs to be rendered. +// int renderSize = (int) ((symbol.width * workTime) / workTimeTotal); +// // Render progress. +// symbol.blit(graphics, renderSize, symbol.height, symbol.u + 24, symbol.v); +// } +// } +//} diff --git a/src/main/java/net/roguelogix/biggerreactors/machine/containers/CyaniteReprocessorContainer.java b/src/main/java/net/roguelogix/biggerreactors/machine/containers/CyaniteReprocessorContainer.java index 5831c58a..385bab9f 100644 --- a/src/main/java/net/roguelogix/biggerreactors/machine/containers/CyaniteReprocessorContainer.java +++ b/src/main/java/net/roguelogix/biggerreactors/machine/containers/CyaniteReprocessorContainer.java @@ -1,116 +1,116 @@ -package net.roguelogix.biggerreactors.machine.containers; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.ContainerLevelAccess; -import net.minecraft.world.inventory.MenuType; -import net.minecraft.world.inventory.Slot; -import net.minecraft.world.item.ItemStack; -import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.items.SlotItemHandler; -import net.roguelogix.biggerreactors.machine.blocks.CyaniteReprocessor; -import net.roguelogix.biggerreactors.machine.tiles.CyaniteReprocessorTile; -import net.roguelogix.biggerreactors.machine.tiles.impl.CyaniteReprocessorItemHandler; -import net.roguelogix.phosphophyllite.client.gui.GuiSync; -import net.roguelogix.phosphophyllite.registry.ContainerSupplier; -import net.roguelogix.phosphophyllite.registry.RegisterContainer; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -@RegisterContainer(name = "cyanite_reprocessor") -public class CyaniteReprocessorContainer extends AbstractContainerMenu implements GuiSync.IGUIPacketProvider { - - @RegisterContainer.Type - public static MenuType INSTANCE; - @RegisterContainer.Supplier - public static final ContainerSupplier SUPPLIER = CyaniteReprocessorContainer::new; - - private Player player; - private CyaniteReprocessorTile tileEntity; - - public CyaniteReprocessorContainer(int windowId, BlockPos blockPos, Player player) { - super(CyaniteReprocessorContainer.INSTANCE, windowId); - this.player = player; - this.tileEntity = (CyaniteReprocessorTile) player.level().getBlockEntity(blockPos); - this.getGuiPacket(); - - // Populate machine slots. - if (this.tileEntity != null) { - IItemHandler handler = tileEntity.getItemHandler(); - // Add input slot. - this.addSlot(new SlotItemHandler(handler, CyaniteReprocessorItemHandler.INPUT_SLOT_INDEX, 44, 41)); - // Add output slot. - this.addSlot(new SlotItemHandler(handler, CyaniteReprocessorItemHandler.OUTPUT_SLOT_INDEX, 116, 41)); - } - - // Populate player inventory. - this.populatePlayerInventory(); - } - - /** - * @return The current state of the machine. - */ - @Nullable - @Override - public GuiSync.IGUIPacket getGuiPacket() { - return this.tileEntity.cyaniteReprocessorState; - } - - @Override - public boolean stillValid(@Nonnull Player player) { - assert this.tileEntity.getLevel() != null; - return stillValid(ContainerLevelAccess.create(tileEntity.getLevel(), tileEntity.getBlockPos()), - player, CyaniteReprocessor.INSTANCE); - } - - @Nonnull - @Override - public ItemStack quickMoveStack(@Nonnull Player player, int index) { - ItemStack itemStackA = ItemStack.EMPTY; - Slot slot = this.slots.get(index); - int inventorySize = this.tileEntity.getContainerSize(); - - if (slot.hasItem()) { - ItemStack itemStackB = slot.getItem(); - itemStackA = itemStackB.copy(); - - if (index < inventorySize) { - if (!this.moveItemStackTo(itemStackB, inventorySize, this.slots.size(), true)) { - return ItemStack.EMPTY; - } - } else if (!this.moveItemStackTo(itemStackB, 0, inventorySize, false)) { - return ItemStack.EMPTY; - } - - if (itemStackB.getCount() == 0) { - slot.set(ItemStack.EMPTY); - } else { - slot.setChanged(); - } - } - - return itemStackA; - } - - /** - * Draw and initialize the player's inventory. - */ - private void populatePlayerInventory() { - int guiOffset = 93; - - // Add player inventory; - for (int rowIndex = 0; rowIndex < 3; rowIndex++) { - for (int columnIndex = 0; columnIndex < 9; columnIndex++) { - this.addSlot(new Slot(player.getInventory(), (columnIndex + rowIndex * 9 + 9), - (8 + columnIndex * 18), (guiOffset + rowIndex * 18))); - } - } - // Add player hotbar. - for (int columnIndex = 0; columnIndex < 9; columnIndex++) { - this.addSlot( - new Slot(player.getInventory(), columnIndex, (8 + columnIndex * 18), (guiOffset + 58))); - } - } -} +//package net.roguelogix.biggerreactors.machine.containers; +// +//import net.minecraft.core.BlockPos; +//import net.minecraft.world.entity.player.Player; +//import net.minecraft.world.inventory.AbstractContainerMenu; +//import net.minecraft.world.inventory.ContainerLevelAccess; +//import net.minecraft.world.inventory.MenuType; +//import net.minecraft.world.inventory.Slot; +//import net.minecraft.world.item.ItemStack; +//import net.minecraftforge.items.IItemHandler; +//import net.minecraftforge.items.SlotItemHandler; +//import net.roguelogix.biggerreactors.machine.blocks.CyaniteReprocessor; +//import net.roguelogix.biggerreactors.machine.tiles.CyaniteReprocessorTile; +//import net.roguelogix.biggerreactors.machine.tiles.impl.CyaniteReprocessorItemHandler; +//import net.roguelogix.phosphophyllite.client.gui.GuiSync; +//import net.roguelogix.phosphophyllite.registry.ContainerSupplier; +//import net.roguelogix.phosphophyllite.registry.RegisterContainer; +// +//import javax.annotation.Nonnull; +//import javax.annotation.Nullable; +// +//@RegisterContainer(name = "cyanite_reprocessor") +//public class CyaniteReprocessorContainer extends AbstractContainerMenu implements GuiSync.IGUIPacketProvider { +// +// @RegisterContainer.Type +// public static MenuType INSTANCE; +// @RegisterContainer.Supplier +// public static final ContainerSupplier SUPPLIER = CyaniteReprocessorContainer::new; +// +// private Player player; +// private CyaniteReprocessorTile tileEntity; +// +// public CyaniteReprocessorContainer(int windowId, BlockPos blockPos, Player player) { +// super(CyaniteReprocessorContainer.INSTANCE, windowId); +// this.player = player; +// this.tileEntity = (CyaniteReprocessorTile) player.level().getBlockEntity(blockPos); +// this.getGuiPacket(); +// +// // Populate machine slots. +// if (this.tileEntity != null) { +// IItemHandler handler = tileEntity.getItemHandler(); +// // Add input slot. +// this.addSlot(new SlotItemHandler(handler, CyaniteReprocessorItemHandler.INPUT_SLOT_INDEX, 44, 41)); +// // Add output slot. +// this.addSlot(new SlotItemHandler(handler, CyaniteReprocessorItemHandler.OUTPUT_SLOT_INDEX, 116, 41)); +// } +// +// // Populate player inventory. +// this.populatePlayerInventory(); +// } +// +// /** +// * @return The current state of the machine. +// */ +// @Nullable +// @Override +// public GuiSync.IGUIPacket getGuiPacket() { +// return this.tileEntity.cyaniteReprocessorState; +// } +// +// @Override +// public boolean stillValid(@Nonnull Player player) { +// assert this.tileEntity.getLevel() != null; +// return stillValid(ContainerLevelAccess.create(tileEntity.getLevel(), tileEntity.getBlockPos()), +// player, CyaniteReprocessor.INSTANCE); +// } +// +// @Nonnull +// @Override +// public ItemStack quickMoveStack(@Nonnull Player player, int index) { +// ItemStack itemStackA = ItemStack.EMPTY; +// Slot slot = this.slots.get(index); +// int inventorySize = this.tileEntity.getContainerSize(); +// +// if (slot.hasItem()) { +// ItemStack itemStackB = slot.getItem(); +// itemStackA = itemStackB.copy(); +// +// if (index < inventorySize) { +// if (!this.moveItemStackTo(itemStackB, inventorySize, this.slots.size(), true)) { +// return ItemStack.EMPTY; +// } +// } else if (!this.moveItemStackTo(itemStackB, 0, inventorySize, false)) { +// return ItemStack.EMPTY; +// } +// +// if (itemStackB.getCount() == 0) { +// slot.set(ItemStack.EMPTY); +// } else { +// slot.setChanged(); +// } +// } +// +// return itemStackA; +// } +// +// /** +// * Draw and initialize the player's inventory. +// */ +// private void populatePlayerInventory() { +// int guiOffset = 93; +// +// // Add player inventory; +// for (int rowIndex = 0; rowIndex < 3; rowIndex++) { +// for (int columnIndex = 0; columnIndex < 9; columnIndex++) { +// this.addSlot(new Slot(player.getInventory(), (columnIndex + rowIndex * 9 + 9), +// (8 + columnIndex * 18), (guiOffset + rowIndex * 18))); +// } +// } +// // Add player hotbar. +// for (int columnIndex = 0; columnIndex < 9; columnIndex++) { +// this.addSlot( +// new Slot(player.getInventory(), columnIndex, (8 + columnIndex * 18), (guiOffset + 58))); +// } +// } +//} diff --git a/src/main/java/net/roguelogix/biggerreactors/machine/state/CyaniteReprocessorState.java b/src/main/java/net/roguelogix/biggerreactors/machine/state/CyaniteReprocessorState.java index af0971fe..e94faf91 100644 --- a/src/main/java/net/roguelogix/biggerreactors/machine/state/CyaniteReprocessorState.java +++ b/src/main/java/net/roguelogix/biggerreactors/machine/state/CyaniteReprocessorState.java @@ -1,72 +1,72 @@ -package net.roguelogix.biggerreactors.machine.state; - -import net.roguelogix.biggerreactors.machine.tiles.CyaniteReprocessorTile; -import net.roguelogix.phosphophyllite.client.gui.GuiSync; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.HashMap; -import java.util.Map; - -public class CyaniteReprocessorState implements GuiSync.IGUIPacket { - - /** - * The number of ticks the current item has processed for. - */ - public int workTime = 0; - /** - * The total amount of time required to process the item. - */ - public int workTimeTotal = 0; - - /** - * The amount of energy stored in the machine. - */ - public int energyStored = 0; - /** - * The max energy capacity of the machine. - */ - public int energyCapacity = 0; - - /** - * The amount of water stored in the machine. - */ - public int waterStored = 0; - /** - * The max water capacity of the machine. - */ - public int waterCapacity = 0; - - /** - * The tile whose information this belongs to. - */ - CyaniteReprocessorTile cyaniteReprocessorTile; - - public CyaniteReprocessorState(CyaniteReprocessorTile cyaniteReprocessorTile) { - this.cyaniteReprocessorTile = cyaniteReprocessorTile; - } - - @Override - public void read(@Nonnull Map data) { - this.workTime = (Integer) data.get("workTime"); - this.workTimeTotal = (Integer) data.get("workTimeTotal"); - this.energyStored = (Integer) data.get("energyStored"); - this.energyCapacity = (Integer) data.get("energyCapacity"); - this.waterStored = (Integer) data.get("waterStored"); - this.waterCapacity = (Integer) data.get("waterCapacity"); - } - - @Nullable - @Override - public Map write() { - this.cyaniteReprocessorTile.updateState(); - HashMap data = new HashMap<>(); - data.put("workTime", this.workTime); - data.put("workTimeTotal", this.workTimeTotal); - data.put("energyStored", this.energyStored); - data.put("energyCapacity", this.energyCapacity); - data.put("waterStored", this.waterStored); - data.put("waterCapacity", this.waterCapacity); - return data; - } -} +//package net.roguelogix.biggerreactors.machine.state; +// +//import net.roguelogix.biggerreactors.machine.tiles.CyaniteReprocessorTile; +//import net.roguelogix.phosphophyllite.client.gui.GuiSync; +// +//import javax.annotation.Nonnull; +//import javax.annotation.Nullable; +//import java.util.HashMap; +//import java.util.Map; +// +//public class CyaniteReprocessorState implements GuiSync.IGUIPacket { +// +// /** +// * The number of ticks the current item has processed for. +// */ +// public int workTime = 0; +// /** +// * The total amount of time required to process the item. +// */ +// public int workTimeTotal = 0; +// +// /** +// * The amount of energy stored in the machine. +// */ +// public int energyStored = 0; +// /** +// * The max energy capacity of the machine. +// */ +// public int energyCapacity = 0; +// +// /** +// * The amount of water stored in the machine. +// */ +// public int waterStored = 0; +// /** +// * The max water capacity of the machine. +// */ +// public int waterCapacity = 0; +// +// /** +// * The tile whose information this belongs to. +// */ +// CyaniteReprocessorTile cyaniteReprocessorTile; +// +// public CyaniteReprocessorState(CyaniteReprocessorTile cyaniteReprocessorTile) { +// this.cyaniteReprocessorTile = cyaniteReprocessorTile; +// } +// +// @Override +// public void read(@Nonnull Map data) { +// this.workTime = (Integer) data.get("workTime"); +// this.workTimeTotal = (Integer) data.get("workTimeTotal"); +// this.energyStored = (Integer) data.get("energyStored"); +// this.energyCapacity = (Integer) data.get("energyCapacity"); +// this.waterStored = (Integer) data.get("waterStored"); +// this.waterCapacity = (Integer) data.get("waterCapacity"); +// } +// +// @Nullable +// @Override +// public Map write() { +// this.cyaniteReprocessorTile.updateState(); +// HashMap data = new HashMap<>(); +// data.put("workTime", this.workTime); +// data.put("workTimeTotal", this.workTimeTotal); +// data.put("energyStored", this.energyStored); +// data.put("energyCapacity", this.energyCapacity); +// data.put("waterStored", this.waterStored); +// data.put("waterCapacity", this.waterCapacity); +// return data; +// } +//} diff --git a/src/main/java/net/roguelogix/biggerreactors/machine/tiles/CyaniteReprocessorTile.java b/src/main/java/net/roguelogix/biggerreactors/machine/tiles/CyaniteReprocessorTile.java index 57ea9ebb..d2a79442 100644 --- a/src/main/java/net/roguelogix/biggerreactors/machine/tiles/CyaniteReprocessorTile.java +++ b/src/main/java/net/roguelogix/biggerreactors/machine/tiles/CyaniteReprocessorTile.java @@ -1,482 +1,471 @@ -package net.roguelogix.biggerreactors.machine.tiles; - - -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.Component; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.*; -import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BaseContainerBlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.energy.EnergyStorage; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidTank; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fluids.capability.templates.FluidTank; -import net.minecraftforge.network.NetworkHooks; -import net.minecraftforge.items.IItemHandler; -import net.roguelogix.biggerreactors.BiggerReactors; -import net.roguelogix.biggerreactors.Config; -import net.roguelogix.biggerreactors.api.IWorkHandler; -import net.roguelogix.biggerreactors.api.WorkHandler; -import net.roguelogix.biggerreactors.machine.blocks.CyaniteReprocessor; -import net.roguelogix.biggerreactors.machine.containers.CyaniteReprocessorContainer; -import net.roguelogix.biggerreactors.machine.state.CyaniteReprocessorState; -import net.roguelogix.biggerreactors.machine.tiles.impl.CyaniteReprocessorItemHandler; -import net.roguelogix.biggerreactors.items.ingots.BlutoniumIngot; -import net.roguelogix.phosphophyllite.client.gui.api.IHasUpdatableState; -import net.roguelogix.phosphophyllite.debug.DebugTool; -import net.roguelogix.phosphophyllite.registry.RegisterTile; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.Objects; - -public class CyaniteReprocessorTile extends BaseContainerBlockEntity implements MenuProvider, IHasUpdatableState { - - @RegisterTile("cyanite_reprocessor") - public static final BlockEntityType.BlockEntitySupplier SUPPLIER = new RegisterTile.Producer<>(CyaniteReprocessorTile::new); - - /** - * The (mostly) current state of the machine. - */ - public final CyaniteReprocessorState cyaniteReprocessorState = new CyaniteReprocessorState(this); - /** - * The work handler. - */ - private WorkHandler workHandler; - /** - * Capability access to the work handler. - */ - private final LazyOptional WORK_HANDLER_CAPABILITY = LazyOptional.of(() -> this.workHandler); - /** - * The item handler. - */ - private CyaniteReprocessorItemHandler itemHandler; - /** - * Capability access to the item handler. - */ - private final LazyOptional ITEM_HANDLER_CAPABILITY = LazyOptional.of(() -> this.itemHandler.pipeHandler()); - /** - * The energy storage. - */ - private EnergyStorage energyStorage; - /** - * Capability access to the energy storage. - */ - private final LazyOptional ENERGY_STORAGE_CAPABILITY = LazyOptional.of(() -> this.energyStorage); - /** - * The fluid tank. - */ - private FluidTank fluidTank; - /** - * Capability access to the fluid tank. - */ - private final LazyOptional FLUID_TANK_CAPABILITY = LazyOptional.of(() -> this.fluidTank); - /** - * "Anti-cheat" item stack, to ensure players don't swap items mid-process. - * - * @see CyaniteReprocessorTile#tick() - */ - private ItemStack itemPresentLastTick = ItemStack.EMPTY; - - public CyaniteReprocessorTile(BlockEntityType TYPE, BlockPos pos, BlockState state) { - super(TYPE, pos, state); - this.clearContent(); - this.updateState(); - } - - /** - * Do right-click stuff. - */ - @Nonnull - public InteractionResult onBlockActivated(@Nonnull BlockState blockState, Level world, @Nonnull BlockPos blockPos, @Nonnull Player player, @Nonnull InteractionHand hand, @Nonnull BlockHitResult trace) { - // Check for client-side. - if (world.isClientSide) { - return InteractionResult.SUCCESS; - } - - // Print tile data. - if (ItemStack.isSameItem(player.getMainHandItem(), new ItemStack(DebugTool.INSTANCE))) { - player.sendSystemMessage(Component.literal(String.format("[%s] Progress: %s/%s", BiggerReactors.modid, this.cyaniteReprocessorState.workTime, this.cyaniteReprocessorState.workTimeTotal))); - player.sendSystemMessage(Component.literal(String.format("[%s] Energy: %s/%s RF", BiggerReactors.modid, this.cyaniteReprocessorState.energyStored, this.cyaniteReprocessorState.energyCapacity))); - player.sendSystemMessage(Component.literal(String.format("[%s] Fluid Tank: %s/%s mB", BiggerReactors.modid, this.cyaniteReprocessorState.waterStored, this.cyaniteReprocessorState.waterCapacity))); - return InteractionResult.SUCCESS; - } - - // Do water bucket check. - if (ItemStack.isSameItem(player.getMainHandItem(), new ItemStack(Items.WATER_BUCKET))) { - if (this.fluidTank.getFluidAmount() <= (Config.CONFIG.CyaniteReprocessor.WaterTankCapacity - 1000)) { - this.fluidTank.fill(new FluidStack(Fluids.WATER, 1000), IFluidHandler.FluidAction.EXECUTE); - player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.BUCKET)); - } - return InteractionResult.SUCCESS; - } - - // Get container and open GUI. - NetworkHooks.openScreen((ServerPlayer) player, this, blockPos); - return InteractionResult.SUCCESS; - } - - /** - * Drop items on destruction. - */ - public void onReplaced(BlockState blockState, Level world, BlockPos blockPos, BlockState newBlockState, boolean isMoving) { - ItemStack inputStack = this.itemHandler.getStackInSlot(CyaniteReprocessorItemHandler.INPUT_SLOT_INDEX); - if (!inputStack.isEmpty()) { - Containers.dropContents(world, blockPos, new SimpleContainer(inputStack)); - } - - ItemStack outputStack = this.itemHandler.getStackInSlot(CyaniteReprocessorItemHandler.OUTPUT_SLOT_INDEX); - if (!outputStack.isEmpty()) { - Containers.dropContents(world, blockPos, new SimpleContainer(outputStack)); - } - } - - /** - * @see CyaniteReprocessorTile#getDefaultName() - */ - @Override - public Component getDisplayName() { - return this.getDefaultName(); - } - - /** - * @return The localized default name for the tile. - */ - @Override - protected Component getDefaultName() { - return Component.translatable("block.biggerreactors.cyanite_reprocessor"); - } - - /** - * Create a GUI container for the tile. - * - * @param windowId The window ID to use. - * @param playerInventory The player's inventory. - * @return A GUI container to render. - */ - @Override - protected AbstractContainerMenu createMenu(int windowId, Inventory playerInventory) { - return new CyaniteReprocessorContainer(windowId, this.getBlockPos(), playerInventory.player); - } - - /** - * @return The current state of the tile. - */ - @Override - @Nonnull - public CyaniteReprocessorState getState() { - this.updateState(); - return this.cyaniteReprocessorState; - } - - /** - * Call for an update to the current state information. - */ - @Override - public void updateState() { - this.cyaniteReprocessorState.workTime = this.workHandler.getProgress(); - this.cyaniteReprocessorState.workTimeTotal = this.workHandler.getGoal(); - this.cyaniteReprocessorState.energyStored = this.energyStorage.getEnergyStored(); - this.cyaniteReprocessorState.energyCapacity = this.energyStorage.getMaxEnergyStored(); - this.cyaniteReprocessorState.waterStored = this.fluidTank.getFluidAmount(); - this.cyaniteReprocessorState.waterCapacity = this.fluidTank.getCapacity(); - } - - /** - * @return How large this tile's inventory is. - */ - @Override - public int getContainerSize() { - return this.itemHandler.getSlots(); - } - - /** - * @return Whether or not the inventory is empty. - */ - @Override - public boolean isEmpty() { - for (int index = 0; index < this.itemHandler.getSlots(); ++index) { - if (!this.itemHandler.getStackInSlot(index).isEmpty()) { - return false; - } - } - return true; - } - - /** - * Gets the item held in the specified slot. - * - * @param index The slot index to fetch from. - * @return Any items held in that slot. - */ - @Override - public ItemStack getItem(int index) { - return this.itemHandler.getStackInSlot(index); - } - - /** - * Removes the specified number of items from the specified slot. - * - * @param index The slot index to remove from. - * @param count The number of items to remove. - * @return The items that were removed. - */ - @Override - public ItemStack removeItem(int index, int count) { - return this.itemHandler.getStackInSlot(index).split(count); - } - - /** - * Removes an entire stack fromm the specified slot. - * - * @param index The slot index to remove from. - * @return The items that were removed. - */ - @Override - public ItemStack removeItemNoUpdate(int index) { - ItemStack itemStack = this.itemHandler.getStackInSlot(index).copy(); - this.itemHandler.setStackInSlot(index, ItemStack.EMPTY); - return itemStack; - } - - /** - * Updates the stored items in the specified slot. - * - * @param index The slot index to update. - * @param stack The items to update with. - */ - @Override - public void setItem(int index, ItemStack stack) { - ItemStack oldStack = this.itemHandler.getStackInSlot(index); - boolean flag = !stack.isEmpty() && ItemStack - .isSameItem(stack, oldStack); - this.itemHandler.setStackInSlot(index, stack); - if (stack.getCount() > this.getMaxStackSize()) { - stack.setCount(this.getMaxStackSize()); - } - - if (index == 0 && !flag) { - this.workHandler.clear(); - this.setChanged(); - } - } - - /** - * Clears all data and inventory for this tile. - */ - @Override - public void clearContent() { - // Reset work. - this.workHandler = new WorkHandler(Config.CONFIG.CyaniteReprocessor.TotalWorkTime); - - // Reset items. - this.itemHandler = new CyaniteReprocessorItemHandler(); - this.itemHandler.setSize(2); - - // Reset energy. - this.energyStorage = new EnergyStorage(Config.CONFIG.CyaniteReprocessor.EnergyTankCapacity); - - // Reset fluids. - this.fluidTank = new FluidTank(Config.CONFIG.CyaniteReprocessor.WaterTankCapacity, fluid -> fluid.getFluid() == Fluids.WATER); - } - - /** - * Checks if the player can currently use this tile. - * - * @param player The player to check. - * @return True if usable, false otherwise. - */ - @Override - public boolean stillValid(Player player) { - assert this.level != null; - if (this.level.getBlockEntity(this.getBlockPos()) != this) { - return false; - } else { - return player.distanceToSqr( - (double) this.getBlockPos().getX() + 0.5D, - (double) this.getBlockPos().getY() + 0.5D, - (double) this.getBlockPos().getZ() + 0.5D) <= 64.0D; - } - } - - /** - * Read NBT data from the world. - * - * @param parentCompound The parent compound to read from. - */ - @Override - public void load(@Nonnull CompoundTag parentCompound) { - super.load(parentCompound); - CompoundTag childCompound = parentCompound.getCompound("cyaniteReprocessorState"); - - // Read work. - this.workHandler = new WorkHandler(childCompound.getInt("workTimeTotal"), childCompound.getInt("workTime")); - // Read items. - this.itemHandler.deserializeNBT(childCompound.getCompound("inventory")); - // Read energy. - this.energyStorage = new EnergyStorage(childCompound.getInt("energyCapacity"), - Config.CONFIG.CyaniteReprocessor.TransferRate, - Config.CONFIG.CyaniteReprocessor.TransferRate, - childCompound.getInt("energyStored")); - // Read fluids. - this.fluidTank = this.fluidTank.readFromNBT(childCompound.getCompound("fluidStorage")); - } - - /** - * Save NBT data to the world. - * - * @param parentCompound The parent compound to append onto. - * @return The updated compound. - */ - @Override - public final void saveAdditional(@Nonnull CompoundTag parentCompound) { - super.saveAdditional(parentCompound); - CompoundTag childCompound = new CompoundTag(); - - // Write work. - childCompound.putInt("workTime", this.workHandler.getProgress()); - childCompound.putInt("workTimeTotal", this.workHandler.getGoal()); - // Write items. - childCompound.put("inventory", this.itemHandler.serializeNBT()); - // Write energy. - childCompound.putInt("energyStored", this.energyStorage.getEnergyStored()); - childCompound.putInt("energyCapacity", this.energyStorage.getMaxEnergyStored()); - // Write fluids. - childCompound.put("fluidTank", fluidTank.writeToNBT(new CompoundTag())); - - parentCompound.put("cyaniteReprocessorState", childCompound); - } - - /** - * @return Whether or not the machine can perform work. - * @see CyaniteReprocessorTile#tick() - */ - private boolean canWork() { - // If the output slot is full, we cannot work. - if (this.getItem(CyaniteReprocessorItemHandler.OUTPUT_SLOT_INDEX).getCount() >= 64) { - return false; - } - return (this.energyStorage.getEnergyStored() >= Config.CONFIG.CyaniteReprocessor.EnergyConsumptionPerTick - && this.fluidTank.getFluidAmount() >= Config.CONFIG.CyaniteReprocessor.WaterConsumptionPerTick); - } - - /** - * Do work (if possible). - */ - public void tick() { - // Check for client-side. - assert level != null; - if (level.isClientSide()) { - return; - } - - boolean doUpdate = false; - boolean isActive = false; - ItemStack inputStack = this.itemHandler.getStackInSlot(CyaniteReprocessorItemHandler.INPUT_SLOT_INDEX); - - // Check to make sure the player doesn't try to pull a fast one. - if (!ItemStack.isSameItem(this.itemPresentLastTick, inputStack)) { - this.workHandler.clear(); - } - this.itemPresentLastTick = inputStack.copy(); - - if (inputStack.getCount() >= 2) { - // Can we continue? - if (canWork()) { - isActive = true; - doUpdate = true; - this.workHandler.increment(1); - this.energyStorage.extractEnergy(Config.CONFIG.CyaniteReprocessor.EnergyConsumptionPerTick, false); - this.fluidTank.drain(Config.CONFIG.CyaniteReprocessor.WaterConsumptionPerTick, IFluidHandler.FluidAction.EXECUTE); - // We've run out of resources, halt. - } else if (this.workHandler.getProgress() > 0) { - this.workHandler.decrement(2); - } - - // Item is done. - if (this.workHandler.isFinished()) { - this.itemHandler.extractItem(CyaniteReprocessorItemHandler.INPUT_SLOT_INDEX, 2, false); - this.itemHandler.insertItem(CyaniteReprocessorItemHandler.OUTPUT_SLOT_INDEX, new ItemStack(BlutoniumIngot.INSTANCE, 1), false); - this.workHandler.clear(); - } - } - - BlockState currentBlockState = level.getBlockState(this.getBlockPos()); - BlockState newBlockState = currentBlockState.setValue(CyaniteReprocessor.ENABLED, isActive); - if (!newBlockState.equals(currentBlockState)) { - this.level.setBlock(this.getBlockPos(), newBlockState, 3); - doUpdate = true; - } - - if (doUpdate) { - setChanged(); - } - - // Update the current machine state. - this.updateState(); - } - - /** - * Check if the tile holds a certain capability. - * - * @param capability The capability to check for. - * @param side Which side this capability should belong to. - * @param The type class of the capability. - * @return The handler for the capability, if present. - */ - @Nonnull - @Override - public LazyOptional getCapability(@Nonnull Capability capability, - @Nullable Direction side) { - // Check for work. - // TODO: While this capability is exclusive to the Reprocessor for now, it may not always be. - // The capability is technically implemented, but no registration is done. - // That oughta be fixed, so it can be checked for here. - // But I'm lazy, so I'll do that some other time. - //if (capability.equals(CapabilityWorkHandler.WORK_HANDLER_CAPABILITY)) { - // return this.WORK_HANDLER_CAPABILITY.cast(); - //} - - // Check for items. - if (capability.equals(ForgeCapabilities.ITEM_HANDLER)) { - return this.ITEM_HANDLER_CAPABILITY.cast(); - } - - // Check for energy. - if (capability.equals(ForgeCapabilities.ENERGY)) { - return this.ENERGY_STORAGE_CAPABILITY.cast(); - } - - // Check for water. - if (capability.equals(ForgeCapabilities.FLUID_HANDLER)) { - return this.FLUID_TANK_CAPABILITY.cast(); - } - - return Objects.requireNonNull(super.getCapability(capability, side)); - } - - @Override - public boolean canPlaceItem(int index, ItemStack stack) { - return this.itemHandler.isItemValid(index, stack); - } - - public CyaniteReprocessorItemHandler getItemHandler() { - return itemHandler; - } -} +//package net.roguelogix.biggerreactors.machine.tiles; +// +// +//import net.minecraft.core.BlockPos; +//import net.minecraft.core.Direction; +//import net.minecraft.nbt.CompoundTag; +//import net.minecraft.network.chat.Component; +//import net.minecraft.server.level.ServerPlayer; +//import net.minecraft.world.*; +//import net.minecraft.world.entity.player.Inventory; +//import net.minecraft.world.entity.player.Player; +//import net.minecraft.world.inventory.AbstractContainerMenu; +//import net.minecraft.world.item.ItemStack; +//import net.minecraft.world.item.Items; +//import net.minecraft.world.level.Level; +//import net.minecraft.world.level.block.entity.BaseContainerBlockEntity; +//import net.minecraft.world.level.block.entity.BlockEntityType; +//import net.minecraft.world.level.block.state.BlockState; +//import net.minecraft.world.level.material.Fluids; +//import net.minecraft.world.phys.BlockHitResult; +//import net.roguelogix.biggerreactors.BiggerReactors; +//import net.roguelogix.biggerreactors.Config; +//import net.roguelogix.biggerreactors.api.IWorkHandler; +//import net.roguelogix.biggerreactors.api.WorkHandler; +//import net.roguelogix.biggerreactors.machine.blocks.CyaniteReprocessor; +//import net.roguelogix.biggerreactors.machine.containers.CyaniteReprocessorContainer; +//import net.roguelogix.biggerreactors.machine.state.CyaniteReprocessorState; +//import net.roguelogix.biggerreactors.machine.tiles.impl.CyaniteReprocessorItemHandler; +//import net.roguelogix.biggerreactors.items.ingots.BlutoniumIngot; +//import net.roguelogix.phosphophyllite.client.gui.api.IHasUpdatableState; +//import net.roguelogix.phosphophyllite.debug.DebugTool; +//import net.roguelogix.phosphophyllite.registry.RegisterTile; +// +//import javax.annotation.Nonnull; +//import javax.annotation.Nullable; +//import java.util.Objects; +// +//public class CyaniteReprocessorTile extends BaseContainerBlockEntity implements MenuProvider, IHasUpdatableState { +// +// @RegisterTile("cyanite_reprocessor") +// public static final BlockEntityType.BlockEntitySupplier SUPPLIER = new RegisterTile.Producer<>(CyaniteReprocessorTile::new); +// +// /** +// * The (mostly) current state of the machine. +// */ +// public final CyaniteReprocessorState cyaniteReprocessorState = new CyaniteReprocessorState(this); +// /** +// * The work handler. +// */ +// private WorkHandler workHandler; +// /** +// * Capability access to the work handler. +// */ +// private final LazyOptional WORK_HANDLER_CAPABILITY = LazyOptional.of(() -> this.workHandler); +// /** +// * The item handler. +// */ +// private CyaniteReprocessorItemHandler itemHandler; +// /** +// * Capability access to the item handler. +// */ +// private final LazyOptional ITEM_HANDLER_CAPABILITY = LazyOptional.of(() -> this.itemHandler.pipeHandler()); +// /** +// * The energy storage. +// */ +// private EnergyStorage energyStorage; +// /** +// * Capability access to the energy storage. +// */ +// private final LazyOptional ENERGY_STORAGE_CAPABILITY = LazyOptional.of(() -> this.energyStorage); +// /** +// * The fluid tank. +// */ +// private FluidTank fluidTank; +// /** +// * Capability access to the fluid tank. +// */ +// private final LazyOptional FLUID_TANK_CAPABILITY = LazyOptional.of(() -> this.fluidTank); +// /** +// * "Anti-cheat" item stack, to ensure players don't swap items mid-process. +// * +// * @see CyaniteReprocessorTile#tick() +// */ +// private ItemStack itemPresentLastTick = ItemStack.EMPTY; +// +// public CyaniteReprocessorTile(BlockEntityType TYPE, BlockPos pos, BlockState state) { +// super(TYPE, pos, state); +// this.clearContent(); +// this.updateState(); +// } +// +// /** +// * Do right-click stuff. +// */ +// @Nonnull +// public InteractionResult onBlockActivated(@Nonnull BlockState blockState, Level world, @Nonnull BlockPos blockPos, @Nonnull Player player, @Nonnull InteractionHand hand, @Nonnull BlockHitResult trace) { +// // Check for client-side. +// if (world.isClientSide) { +// return InteractionResult.SUCCESS; +// } +// +// // Print tile data. +// if (ItemStack.isSameItem(player.getMainHandItem(), new ItemStack(DebugTool.INSTANCE))) { +// player.sendSystemMessage(Component.literal(String.format("[%s] Progress: %s/%s", BiggerReactors.modid, this.cyaniteReprocessorState.workTime, this.cyaniteReprocessorState.workTimeTotal))); +// player.sendSystemMessage(Component.literal(String.format("[%s] Energy: %s/%s RF", BiggerReactors.modid, this.cyaniteReprocessorState.energyStored, this.cyaniteReprocessorState.energyCapacity))); +// player.sendSystemMessage(Component.literal(String.format("[%s] Fluid Tank: %s/%s mB", BiggerReactors.modid, this.cyaniteReprocessorState.waterStored, this.cyaniteReprocessorState.waterCapacity))); +// return InteractionResult.SUCCESS; +// } +// +// // Do water bucket check. +// if (ItemStack.isSameItem(player.getMainHandItem(), new ItemStack(Items.WATER_BUCKET))) { +// if (this.fluidTank.getFluidAmount() <= (Config.CONFIG.CyaniteReprocessor.WaterTankCapacity - 1000)) { +// this.fluidTank.fill(new FluidStack(Fluids.WATER, 1000), IFluidHandler.FluidAction.EXECUTE); +// player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.BUCKET)); +// } +// return InteractionResult.SUCCESS; +// } +// +// // Get container and open GUI. +// NetworkHooks.openScreen((ServerPlayer) player, this, blockPos); +// return InteractionResult.SUCCESS; +// } +// +// /** +// * Drop items on destruction. +// */ +// public void onReplaced(BlockState blockState, Level world, BlockPos blockPos, BlockState newBlockState, boolean isMoving) { +// ItemStack inputStack = this.itemHandler.getStackInSlot(CyaniteReprocessorItemHandler.INPUT_SLOT_INDEX); +// if (!inputStack.isEmpty()) { +// Containers.dropContents(world, blockPos, new SimpleContainer(inputStack)); +// } +// +// ItemStack outputStack = this.itemHandler.getStackInSlot(CyaniteReprocessorItemHandler.OUTPUT_SLOT_INDEX); +// if (!outputStack.isEmpty()) { +// Containers.dropContents(world, blockPos, new SimpleContainer(outputStack)); +// } +// } +// +// /** +// * @see CyaniteReprocessorTile#getDefaultName() +// */ +// @Override +// public Component getDisplayName() { +// return this.getDefaultName(); +// } +// +// /** +// * @return The localized default name for the tile. +// */ +// @Override +// protected Component getDefaultName() { +// return Component.translatable("block.biggerreactors.cyanite_reprocessor"); +// } +// +// /** +// * Create a GUI container for the tile. +// * +// * @param windowId The window ID to use. +// * @param playerInventory The player's inventory. +// * @return A GUI container to render. +// */ +// @Override +// protected AbstractContainerMenu createMenu(int windowId, Inventory playerInventory) { +// return new CyaniteReprocessorContainer(windowId, this.getBlockPos(), playerInventory.player); +// } +// +// /** +// * @return The current state of the tile. +// */ +// @Override +// @Nonnull +// public CyaniteReprocessorState getState() { +// this.updateState(); +// return this.cyaniteReprocessorState; +// } +// +// /** +// * Call for an update to the current state information. +// */ +// @Override +// public void updateState() { +// this.cyaniteReprocessorState.workTime = this.workHandler.getProgress(); +// this.cyaniteReprocessorState.workTimeTotal = this.workHandler.getGoal(); +// this.cyaniteReprocessorState.energyStored = this.energyStorage.getEnergyStored(); +// this.cyaniteReprocessorState.energyCapacity = this.energyStorage.getMaxEnergyStored(); +// this.cyaniteReprocessorState.waterStored = this.fluidTank.getFluidAmount(); +// this.cyaniteReprocessorState.waterCapacity = this.fluidTank.getCapacity(); +// } +// +// /** +// * @return How large this tile's inventory is. +// */ +// @Override +// public int getContainerSize() { +// return this.itemHandler.getSlots(); +// } +// +// /** +// * @return Whether or not the inventory is empty. +// */ +// @Override +// public boolean isEmpty() { +// for (int index = 0; index < this.itemHandler.getSlots(); ++index) { +// if (!this.itemHandler.getStackInSlot(index).isEmpty()) { +// return false; +// } +// } +// return true; +// } +// +// /** +// * Gets the item held in the specified slot. +// * +// * @param index The slot index to fetch from. +// * @return Any items held in that slot. +// */ +// @Override +// public ItemStack getItem(int index) { +// return this.itemHandler.getStackInSlot(index); +// } +// +// /** +// * Removes the specified number of items from the specified slot. +// * +// * @param index The slot index to remove from. +// * @param count The number of items to remove. +// * @return The items that were removed. +// */ +// @Override +// public ItemStack removeItem(int index, int count) { +// return this.itemHandler.getStackInSlot(index).split(count); +// } +// +// /** +// * Removes an entire stack fromm the specified slot. +// * +// * @param index The slot index to remove from. +// * @return The items that were removed. +// */ +// @Override +// public ItemStack removeItemNoUpdate(int index) { +// ItemStack itemStack = this.itemHandler.getStackInSlot(index).copy(); +// this.itemHandler.setStackInSlot(index, ItemStack.EMPTY); +// return itemStack; +// } +// +// /** +// * Updates the stored items in the specified slot. +// * +// * @param index The slot index to update. +// * @param stack The items to update with. +// */ +// @Override +// public void setItem(int index, ItemStack stack) { +// ItemStack oldStack = this.itemHandler.getStackInSlot(index); +// boolean flag = !stack.isEmpty() && ItemStack +// .isSameItem(stack, oldStack); +// this.itemHandler.setStackInSlot(index, stack); +// if (stack.getCount() > this.getMaxStackSize()) { +// stack.setCount(this.getMaxStackSize()); +// } +// +// if (index == 0 && !flag) { +// this.workHandler.clear(); +// this.setChanged(); +// } +// } +// +// /** +// * Clears all data and inventory for this tile. +// */ +// @Override +// public void clearContent() { +// // Reset work. +// this.workHandler = new WorkHandler(Config.CONFIG.CyaniteReprocessor.TotalWorkTime); +// +// // Reset items. +// this.itemHandler = new CyaniteReprocessorItemHandler(); +// this.itemHandler.setSize(2); +// +// // Reset energy. +// this.energyStorage = new EnergyStorage(Config.CONFIG.CyaniteReprocessor.EnergyTankCapacity); +// +// // Reset fluids. +// this.fluidTank = new FluidTank(Config.CONFIG.CyaniteReprocessor.WaterTankCapacity, fluid -> fluid.getFluid() == Fluids.WATER); +// } +// +// /** +// * Checks if the player can currently use this tile. +// * +// * @param player The player to check. +// * @return True if usable, false otherwise. +// */ +// @Override +// public boolean stillValid(Player player) { +// assert this.level != null; +// if (this.level.getBlockEntity(this.getBlockPos()) != this) { +// return false; +// } else { +// return player.distanceToSqr( +// (double) this.getBlockPos().getX() + 0.5D, +// (double) this.getBlockPos().getY() + 0.5D, +// (double) this.getBlockPos().getZ() + 0.5D) <= 64.0D; +// } +// } +// +// /** +// * Read NBT data from the world. +// * +// * @param parentCompound The parent compound to read from. +// */ +// @Override +// public void load(@Nonnull CompoundTag parentCompound) { +// super.load(parentCompound); +// CompoundTag childCompound = parentCompound.getCompound("cyaniteReprocessorState"); +// +// // Read work. +// this.workHandler = new WorkHandler(childCompound.getInt("workTimeTotal"), childCompound.getInt("workTime")); +// // Read items. +// this.itemHandler.deserializeNBT(childCompound.getCompound("inventory")); +// // Read energy. +// this.energyStorage = new EnergyStorage(childCompound.getInt("energyCapacity"), +// Config.CONFIG.CyaniteReprocessor.TransferRate, +// Config.CONFIG.CyaniteReprocessor.TransferRate, +// childCompound.getInt("energyStored")); +// // Read fluids. +// this.fluidTank = this.fluidTank.readFromNBT(childCompound.getCompound("fluidStorage")); +// } +// +// /** +// * Save NBT data to the world. +// * +// * @param parentCompound The parent compound to append onto. +// * @return The updated compound. +// */ +// @Override +// public final void saveAdditional(@Nonnull CompoundTag parentCompound) { +// super.saveAdditional(parentCompound); +// CompoundTag childCompound = new CompoundTag(); +// +// // Write work. +// childCompound.putInt("workTime", this.workHandler.getProgress()); +// childCompound.putInt("workTimeTotal", this.workHandler.getGoal()); +// // Write items. +// childCompound.put("inventory", this.itemHandler.serializeNBT()); +// // Write energy. +// childCompound.putInt("energyStored", this.energyStorage.getEnergyStored()); +// childCompound.putInt("energyCapacity", this.energyStorage.getMaxEnergyStored()); +// // Write fluids. +// childCompound.put("fluidTank", fluidTank.writeToNBT(new CompoundTag())); +// +// parentCompound.put("cyaniteReprocessorState", childCompound); +// } +// +// /** +// * @return Whether or not the machine can perform work. +// * @see CyaniteReprocessorTile#tick() +// */ +// private boolean canWork() { +// // If the output slot is full, we cannot work. +// if (this.getItem(CyaniteReprocessorItemHandler.OUTPUT_SLOT_INDEX).getCount() >= 64) { +// return false; +// } +// return (this.energyStorage.getEnergyStored() >= Config.CONFIG.CyaniteReprocessor.EnergyConsumptionPerTick +// && this.fluidTank.getFluidAmount() >= Config.CONFIG.CyaniteReprocessor.WaterConsumptionPerTick); +// } +// +// /** +// * Do work (if possible). +// */ +// public void tick() { +// // Check for client-side. +// assert level != null; +// if (level.isClientSide()) { +// return; +// } +// +// boolean doUpdate = false; +// boolean isActive = false; +// ItemStack inputStack = this.itemHandler.getStackInSlot(CyaniteReprocessorItemHandler.INPUT_SLOT_INDEX); +// +// // Check to make sure the player doesn't try to pull a fast one. +// if (!ItemStack.isSameItem(this.itemPresentLastTick, inputStack)) { +// this.workHandler.clear(); +// } +// this.itemPresentLastTick = inputStack.copy(); +// +// if (inputStack.getCount() >= 2) { +// // Can we continue? +// if (canWork()) { +// isActive = true; +// doUpdate = true; +// this.workHandler.increment(1); +// this.energyStorage.extractEnergy(Config.CONFIG.CyaniteReprocessor.EnergyConsumptionPerTick, false); +// this.fluidTank.drain(Config.CONFIG.CyaniteReprocessor.WaterConsumptionPerTick, IFluidHandler.FluidAction.EXECUTE); +// // We've run out of resources, halt. +// } else if (this.workHandler.getProgress() > 0) { +// this.workHandler.decrement(2); +// } +// +// // Item is done. +// if (this.workHandler.isFinished()) { +// this.itemHandler.extractItem(CyaniteReprocessorItemHandler.INPUT_SLOT_INDEX, 2, false); +// this.itemHandler.insertItem(CyaniteReprocessorItemHandler.OUTPUT_SLOT_INDEX, new ItemStack(BlutoniumIngot.INSTANCE, 1), false); +// this.workHandler.clear(); +// } +// } +// +// BlockState currentBlockState = level.getBlockState(this.getBlockPos()); +// BlockState newBlockState = currentBlockState.setValue(CyaniteReprocessor.ENABLED, isActive); +// if (!newBlockState.equals(currentBlockState)) { +// this.level.setBlock(this.getBlockPos(), newBlockState, 3); +// doUpdate = true; +// } +// +// if (doUpdate) { +// setChanged(); +// } +// +// // Update the current machine state. +// this.updateState(); +// } +// +// /** +// * Check if the tile holds a certain capability. +// * +// * @param capability The capability to check for. +// * @param side Which side this capability should belong to. +// * @param The type class of the capability. +// * @return The handler for the capability, if present. +// */ +// @Nonnull +// @Override +// public LazyOptional getCapability(@Nonnull Capability capability, +// @Nullable Direction side) { +// // Check for work. +// // TODO: While this capability is exclusive to the Reprocessor for now, it may not always be. +// // The capability is technically implemented, but no registration is done. +// // That oughta be fixed, so it can be checked for here. +// // But I'm lazy, so I'll do that some other time. +// //if (capability.equals(CapabilityWorkHandler.WORK_HANDLER_CAPABILITY)) { +// // return this.WORK_HANDLER_CAPABILITY.cast(); +// //} +// +// // Check for items. +// if (capability.equals(ForgeCapabilities.ITEM_HANDLER)) { +// return this.ITEM_HANDLER_CAPABILITY.cast(); +// } +// +// // Check for energy. +// if (capability.equals(ForgeCapabilities.ENERGY)) { +// return this.ENERGY_STORAGE_CAPABILITY.cast(); +// } +// +// // Check for water. +// if (capability.equals(ForgeCapabilities.FLUID_HANDLER)) { +// return this.FLUID_TANK_CAPABILITY.cast(); +// } +// +// return Objects.requireNonNull(super.getCapability(capability, side)); +// } +// +// @Override +// public boolean canPlaceItem(int index, ItemStack stack) { +// return this.itemHandler.isItemValid(index, stack); +// } +// +// public CyaniteReprocessorItemHandler getItemHandler() { +// return itemHandler; +// } +//} diff --git a/src/main/java/net/roguelogix/biggerreactors/machine/tiles/impl/CyaniteReprocessorItemHandler.java b/src/main/java/net/roguelogix/biggerreactors/machine/tiles/impl/CyaniteReprocessorItemHandler.java index 1f54324b..a9b3c6ee 100644 --- a/src/main/java/net/roguelogix/biggerreactors/machine/tiles/impl/CyaniteReprocessorItemHandler.java +++ b/src/main/java/net/roguelogix/biggerreactors/machine/tiles/impl/CyaniteReprocessorItemHandler.java @@ -1,8 +1,8 @@ package net.roguelogix.biggerreactors.machine.tiles.impl; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.items.ItemStackHandler; +import net.neoforged.neoforge.items.IItemHandler; +import net.neoforged.neoforge.items.ItemStackHandler; import net.roguelogix.biggerreactors.items.ingots.BlutoniumIngot; import net.roguelogix.biggerreactors.items.ingots.CyaniteIngot; diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/blocks/HeatExchangerBaseBlock.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/blocks/HeatExchangerBaseBlock.java index ed7ce4de..b37a931b 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/blocks/HeatExchangerBaseBlock.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/blocks/HeatExchangerBaseBlock.java @@ -12,7 +12,6 @@ import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraftforge.network.NetworkHooks; import net.roguelogix.phosphophyllite.modular.block.PhosphophylliteBlock; import net.roguelogix.phosphophyllite.multiblock.rectangular.IRectangularMultiblockBlock; @@ -55,7 +54,7 @@ public InteractionResult onUse(BlockState state, Level level, BlockPos pos, Play if (hand == InteractionHand.MAIN_HAND && state.hasProperty(ASSEMBLED) && state.getValue(ASSEMBLED)) { if (level.getBlockEntity(pos) instanceof MenuProvider menuProvider) { if (!level.isClientSide) { - NetworkHooks.openScreen((ServerPlayer) player, menuProvider, pos); + player.openMenu(menuProvider, pos); } return InteractionResult.SUCCESS; } diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/client/HeatExchangerFluidPortScreen.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/client/HeatExchangerFluidPortScreen.java index bcac3ee6..91a8605c 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/client/HeatExchangerFluidPortScreen.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/client/HeatExchangerFluidPortScreen.java @@ -6,8 +6,8 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.player.Inventory; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.client.Biselector; import net.roguelogix.biggerreactors.client.SelectorColors; diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/client/HeatExchangerTerminalScreen.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/client/HeatExchangerTerminalScreen.java index 7bbfc30d..24ce8a5c 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/client/HeatExchangerTerminalScreen.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/client/HeatExchangerTerminalScreen.java @@ -9,9 +9,8 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.registries.ForgeRegistries; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.Config; import net.roguelogix.biggerreactors.client.CommonRender; @@ -145,22 +144,22 @@ private void initGauges() { @Override public void containerTick() { // Check if condenser intake fluid changed. - if (!heatExchangerState.condenserIntakeFluid.equals(Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(condenserIntakeFluid)).toString())) { + if (!heatExchangerState.condenserIntakeFluid.equals(Objects.requireNonNull(BuiltInRegistries.FLUID.getKey(condenserIntakeFluid)).toString())) { condenserIntakeFluid = BuiltInRegistries.FLUID.get(new ResourceLocation(heatExchangerState.condenserIntakeFluid)); } // Check if evaporator intake fluid changed. - if (!heatExchangerState.evaporatorIntakeFluid.equals(Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(evaporatorIntakeFluid)).toString())) { + if (!heatExchangerState.evaporatorIntakeFluid.equals(Objects.requireNonNull(BuiltInRegistries.FLUID.getKey(evaporatorIntakeFluid)).toString())) { evaporatorIntakeFluid = BuiltInRegistries.FLUID.get(new ResourceLocation(heatExchangerState.evaporatorIntakeFluid)); } // Check if condenser exhaust fluid changed. - if (!heatExchangerState.condenserExhaustFluid.equals(Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(condenserExhaustFluid)).toString())) { + if (!heatExchangerState.condenserExhaustFluid.equals(Objects.requireNonNull(BuiltInRegistries.FLUID.getKey(condenserExhaustFluid)).toString())) { condenserExhaustFluid = BuiltInRegistries.FLUID.get(new ResourceLocation(heatExchangerState.condenserExhaustFluid)); } // Check if evaporator exhaust fluid changed. - if (!heatExchangerState.evaporatorExhaustFluid.equals(Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(evaporatorExhaustFluid)).toString())) { + if (!heatExchangerState.evaporatorExhaustFluid.equals(Objects.requireNonNull(BuiltInRegistries.FLUID.getKey(evaporatorExhaustFluid)).toString())) { evaporatorExhaustFluid = BuiltInRegistries.FLUID.get(new ResourceLocation(heatExchangerState.evaporatorExhaustFluid)); } } diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/deps/HeatExchangerPeripheral.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/deps/HeatExchangerPeripheral.java index 55b02a2c..10826d1b 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/deps/HeatExchangerPeripheral.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/deps/HeatExchangerPeripheral.java @@ -4,8 +4,7 @@ import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaFunction; import dan200.computercraft.api.peripheral.IPeripheral; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.multiblocks.heatexchanger.HeatExchangerMultiblockController; import net.roguelogix.biggerreactors.util.FluidTransitionTank; @@ -27,8 +26,8 @@ public class HeatExchangerPeripheral implements IPeripheral { final Channel evaporator; final InternalEnvironment internalEnvironment; - public static LazyOptional create(@Nonnull Supplier controllerSupplier) { - return LazyOptional.of(() -> new HeatExchangerPeripheral(controllerSupplier)); + public static HeatExchangerPeripheral create(@Nonnull Supplier controllerSupplier) { + return new HeatExchangerPeripheral(controllerSupplier); } public HeatExchangerPeripheral(Supplier rawControllerSupplier) { @@ -94,7 +93,7 @@ public ChannelFluid(LamdbaExceptionUtils.Supplier_WithExceptions tileEntityTypeIn, BlockP super(tileEntityTypeIn, pos, state); } - private static final Capability CAPABILITY_PERIPHERAL = CapabilityManager.get(new CapabilityToken<>(){}); - - @Override - public LazyOptional capability(Capability cap, final @Nullable Direction side) { - if (cap == CAPABILITY_PERIPHERAL) { - return HeatExchangerPeripheral.create(this::controller).cast(); - } - return super.capability(cap, side); - } + // TODO: computercraft capability +// private static final Capability CAPABILITY_PERIPHERAL = CapabilityManager.get(new CapabilityToken<>(){}); +// +// @Override +// public LazyOptional capability(Capability cap, final @Nullable Direction side) { +// if (cap == CAPABILITY_PERIPHERAL) { +// return HeatExchangerPeripheral.create(this::controller).cast(); +// } +// return super.capability(cap, side); +// } } diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/tiles/HeatExchangerFluidPortTile.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/tiles/HeatExchangerFluidPortTile.java index e6e12a4a..824d7fec 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/tiles/HeatExchangerFluidPortTile.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/tiles/HeatExchangerFluidPortTile.java @@ -1,6 +1,5 @@ package net.roguelogix.biggerreactors.multiblocks.heatexchanger.tiles; -import mekanism.api.chemical.gas.IGasHandler; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -15,22 +14,18 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityManager; -import net.minecraftforge.common.capabilities.CapabilityToken; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fluids.capability.templates.FluidTank; +import net.neoforged.neoforge.capabilities.Capabilities; +import net.neoforged.neoforge.fluids.capability.templates.FluidTank; import net.roguelogix.biggerreactors.multiblocks.heatexchanger.blocks.HeatExchangerFluidPortBlock; import net.roguelogix.biggerreactors.multiblocks.heatexchanger.containers.HeatExchangerFluidPortContainer; import net.roguelogix.biggerreactors.multiblocks.heatexchanger.state.HeatExchangerFluidPortState; import net.roguelogix.phosphophyllite.client.gui.api.IHasUpdatableState; import net.roguelogix.phosphophyllite.fluids.FluidHandlerWrapper; import net.roguelogix.phosphophyllite.fluids.IPhosphophylliteFluidHandler; -import net.roguelogix.phosphophyllite.fluids.MekanismGasWrappers; import net.roguelogix.phosphophyllite.multiblock.common.IEventMultiblock; import net.roguelogix.phosphophyllite.multiblock.validated.IValidatedMultiblock; +import net.roguelogix.phosphophyllite.registry.CapabilityRegistration; +import net.roguelogix.phosphophyllite.registry.RegisterCapability; import net.roguelogix.phosphophyllite.registry.RegisterTile; import net.roguelogix.phosphophyllite.util.BlockStates; @@ -50,23 +45,27 @@ public class HeatExchangerFluidPortTile extends HeatExchangerBaseTile implements @RegisterTile("heat_exchanger_fluid_port") public static final BlockEntityType.BlockEntitySupplier SUPPLIER = new RegisterTile.Producer<>(HeatExchangerFluidPortTile::new); + @RegisterCapability + private static final CapabilityRegistration FLUID_HANDLER_CAP_REGISTRATION = CapabilityRegistration.tileCap(Capabilities.FluidHandler.BLOCK, HeatExchangerFluidPortTile.class); + public HeatExchangerFluidPortTile(BlockEntityType tileEntityTypeIn, BlockPos pos, BlockState state) { super(tileEntityTypeIn, pos, state); } - private static final Capability GAS_HANDLER_CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){}); - - @Override - public LazyOptional capability(Capability cap, @Nullable Direction side) { - if (cap == ForgeCapabilities.FLUID_HANDLER) { - return fluidHandlerCapability().cast(); - } - if (cap == GAS_HANDLER_CAPABILITY) { - return LazyOptional.of(() -> MekanismGasWrappers.wrap(this)).cast(); - } - return super.capability(cap, side); - } + // TODO: mek gas +// private static final Capability GAS_HANDLER_CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){}); +// +// @Override +// public LazyOptional capability(Capability cap, @Nullable Direction side) { +// if (cap == ForgeCapabilities.FLUID_HANDLER) { +// return fluidHandlerCapability().cast(); +// } +// if (cap == GAS_HANDLER_CAPABILITY) { +// return LazyOptional.of(() -> MekanismGasWrappers.wrap(this)).cast(); +// } +// return super.capability(cap, side); +// } private IPhosphophylliteFluidHandler HETank; @@ -173,7 +172,7 @@ public long pushFluid() { if (!connected || inlet) { return 0; } - if (handlerOptional.isPresent()) { + if (handler != null) { Fluid fluid = HETank.fluidTypeInTank(1); long amount = HETank.fluidAmountInTank(1); amount = HETank.drain(fluid, null, amount, true); @@ -181,7 +180,6 @@ public long pushFluid() { amount = HETank.drain(fluid, null, amount, false); return amount; } else { - handlerOptional = LazyOptional.empty(); handler = null; connected = false; } @@ -190,38 +188,30 @@ public long pushFluid() { private boolean connected = false; Direction outputDirection = null; - LazyOptional handlerOptional = LazyOptional.empty(); IPhosphophylliteFluidHandler handler = null; FluidTank EMPTY_TANK = new FluidTank(0); @SuppressWarnings("DuplicatedCode") public void neighborChanged() { - handlerOptional = LazyOptional.empty(); handler = null; if (outputDirection == null) { connected = false; return; } assert level != null; - BlockEntity te = level.getBlockEntity(worldPosition.relative(outputDirection)); - if (te == null) { - connected = false; - return; - } + final var outputCap = level.getCapability(Capabilities.FluidHandler.BLOCK, worldPosition.relative(outputDirection), outputDirection.getOpposite()); connected = false; - LazyOptional waterOutput = te.getCapability(ForgeCapabilities.FLUID_HANDLER, outputDirection.getOpposite()); - if (waterOutput.isPresent()) { + if (outputCap != null) { connected = true; - handlerOptional = waterOutput; - handler = FluidHandlerWrapper.wrap(waterOutput.orElse(EMPTY_TANK)); - } else if (GAS_HANDLER_CAPABILITY != null) { - LazyOptional gasOptional = te.getCapability(GAS_HANDLER_CAPABILITY, outputDirection.getOpposite()); - if (gasOptional.isPresent()) { - IGasHandler gasHandler = gasOptional.orElse(MekanismGasWrappers.EMPTY_TANK); - connected = true; - handlerOptional = gasOptional; - handler = MekanismGasWrappers.wrap(gasHandler); - } + handler = FluidHandlerWrapper.wrap(outputCap); +// } else if (GAS_HANDLER_CAPABILITY != null) { +// LazyOptional gasOptional = te.getCapability(GAS_HANDLER_CAPABILITY, outputDirection.getOpposite()); +// if (gasOptional.isPresent()) { +// IGasHandler gasHandler = gasOptional.orElse(MekanismGasWrappers.EMPTY_TANK); +// connected = true; +// handlerOptional = gasOptional; +// handler = MekanismGasWrappers.wrap(gasHandler); +// } } } diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/tiles/HeatExchangerTerminalTile.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/tiles/HeatExchangerTerminalTile.java index 8f44f897..ecd0d7e8 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/tiles/HeatExchangerTerminalTile.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/heatexchanger/tiles/HeatExchangerTerminalTile.java @@ -2,6 +2,7 @@ import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Inventory; @@ -9,7 +10,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.registries.ForgeRegistries; import net.roguelogix.biggerreactors.multiblocks.heatexchanger.blocks.HeatExchangerTerminalBlock; import net.roguelogix.biggerreactors.multiblocks.heatexchanger.containers.HeatExchangerTerminalContainer; import net.roguelogix.biggerreactors.multiblocks.heatexchanger.state.HeatExchangerState; @@ -48,19 +48,19 @@ public void updateState() { state.condenserTankSize = controller().condenserTank.perSideCapacity; - state.condenserIntakeFluid = ForgeRegistries.FLUIDS.getKey(controller().condenserTank.fluidTypeInTank(0)).toString(); + state.condenserIntakeFluid = BuiltInRegistries.FLUID.getKey(controller().condenserTank.fluidTypeInTank(0)).toString(); state.condenserIntakeFluidAmount = controller().condenserTank.fluidAmountInTank(0); - state.condenserExhaustFluid = ForgeRegistries.FLUIDS.getKey(controller().condenserTank.fluidTypeInTank(1)).toString(); + state.condenserExhaustFluid = BuiltInRegistries.FLUID.getKey(controller().condenserTank.fluidTypeInTank(1)).toString(); state.condenserExhaustFluidAmount = controller().condenserTank.fluidAmountInTank(1); state.evaporatorTankSize = controller().evaporatorTank.perSideCapacity; - state.evaporatorIntakeFluid = ForgeRegistries.FLUIDS.getKey(controller().evaporatorTank.fluidTypeInTank(0)).toString(); + state.evaporatorIntakeFluid = BuiltInRegistries.FLUID.getKey(controller().evaporatorTank.fluidTypeInTank(0)).toString(); state.evaporatorIntakeFluidAmount = controller().evaporatorTank.fluidAmountInTank(0); - state.evaporatorExhaustFluid = ForgeRegistries.FLUIDS.getKey(controller().evaporatorTank.fluidTypeInTank(1)).toString(); + state.evaporatorExhaustFluid = BuiltInRegistries.FLUID.getKey(controller().evaporatorTank.fluidTypeInTank(1)).toString(); state.evaporatorExhaustFluidAmount = controller().evaporatorTank.fluidAmountInTank(1); diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/ReactorMultiblockController.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/ReactorMultiblockController.java index ec01572d..e37063f9 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/ReactorMultiblockController.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/ReactorMultiblockController.java @@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.level.Level; @@ -12,7 +13,6 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluids; -import net.minecraftforge.registries.ForgeRegistries; import net.roguelogix.biggerreactors.Config; import net.roguelogix.biggerreactors.multiblocks.reactor.blocks.ReactorBaseBlock; import net.roguelogix.biggerreactors.multiblocks.reactor.blocks.ReactorFuelRod; @@ -807,20 +807,20 @@ public void updateReactorState(ReactorState reactorState) { reactorState.coolantStored = coolantTank.liquidAmount(); reactorState.coolantCapacity = coolantTank.perSideCapacity(); coolantTankWrapper.liquidType(); - reactorState.coolantResourceLocation = Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(coolantTankWrapper.liquidType())).toString(); + reactorState.coolantResourceLocation = Objects.requireNonNull(BuiltInRegistries.FLUID.getKey(coolantTankWrapper.liquidType())).toString(); reactorState.exhaustStored = coolantTank.vaporAmount(); reactorState.exhaustCapacity = coolantTank.perSideCapacity(); coolantTankWrapper.vaporType(); - reactorState.exhaustResourceLocation = Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(coolantTankWrapper.vaporType())).toString(); + reactorState.exhaustResourceLocation = Objects.requireNonNull(BuiltInRegistries.FLUID.getKey(coolantTankWrapper.vaporType())).toString(); } else { reactorState.coolantStored = 0; reactorState.coolantCapacity = 0; - reactorState.coolantResourceLocation = Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(Fluids.EMPTY)).toString(); + reactorState.coolantResourceLocation = Objects.requireNonNull(BuiltInRegistries.FLUID.getKey(Fluids.EMPTY)).toString(); reactorState.exhaustStored = 0; reactorState.exhaustCapacity = 0; - reactorState.exhaustResourceLocation = Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(Fluids.EMPTY)).toString(); + reactorState.exhaustResourceLocation = Objects.requireNonNull(BuiltInRegistries.FLUID.getKey(Fluids.EMPTY)).toString(); } reactorState.caseHeatStored = simulation.stackHeat(); reactorState.fuelHeatStored = simulation.fuelHeat(); diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/blocks/ReactorBaseBlock.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/blocks/ReactorBaseBlock.java index d7dd2e00..2ef531ea 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/blocks/ReactorBaseBlock.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/blocks/ReactorBaseBlock.java @@ -13,7 +13,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.phys.BlockHitResult; -import net.minecraftforge.network.NetworkHooks; import net.roguelogix.biggerreactors.multiblocks.reactor.state.ReactorActivity; import net.roguelogix.phosphophyllite.modular.block.PhosphophylliteBlock; import net.roguelogix.phosphophyllite.multiblock.rectangular.IRectangularMultiblockBlock; @@ -71,7 +70,7 @@ public InteractionResult onUse(BlockState state, Level level, BlockPos pos, Play if (hand == InteractionHand.MAIN_HAND && state.hasProperty(ASSEMBLED) && state.getValue(ASSEMBLED)) { if (level.getBlockEntity(pos) instanceof MenuProvider menuProvider) { if (!level.isClientSide) { - NetworkHooks.openScreen((ServerPlayer) player, menuProvider, pos); + player.openMenu(menuProvider, pos); } return InteractionResult.SUCCESS; } diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/blocks/ReactorFuelRod.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/blocks/ReactorFuelRod.java index 2e19c8c1..c1854bc2 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/blocks/ReactorFuelRod.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/blocks/ReactorFuelRod.java @@ -9,8 +9,8 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.IntegerProperty; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.multiblocks.reactor.tiles.ReactorFuelRodTile; import net.roguelogix.phosphophyllite.registry.RegisterBlock; diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/blocks/ReactorManifold.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/blocks/ReactorManifold.java index 2ad4d966..f822a24c 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/blocks/ReactorManifold.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/blocks/ReactorManifold.java @@ -7,8 +7,8 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.Config; import net.roguelogix.biggerreactors.multiblocks.reactor.tiles.ReactorManifoldTile; import net.roguelogix.phosphophyllite.modular.block.IConnectedTexture; diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ActiveReactorTerminalScreen.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ActiveReactorTerminalScreen.java index 1ab4a58e..336c9e68 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ActiveReactorTerminalScreen.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ActiveReactorTerminalScreen.java @@ -9,9 +9,8 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.registries.ForgeRegistries; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.client.CommonRender; import net.roguelogix.biggerreactors.multiblocks.reactor.containers.ReactorTerminalContainer; @@ -155,11 +154,11 @@ public void containerTick() { this.getMinecraft().setScreen(new PassiveReactorTerminalScreen(this.menu, this.inventory, this.title)); } // Check if coolant type changed. - if (!reactorState.coolantResourceLocation.equals(Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(coolantFluid)).toString())) { + if (!reactorState.coolantResourceLocation.equals(Objects.requireNonNull(BuiltInRegistries.FLUID.getKey(coolantFluid)).toString())) { coolantFluid = BuiltInRegistries.FLUID.get(new ResourceLocation(reactorState.coolantResourceLocation)); } // Check if exhaust type changed. - if (!reactorState.exhaustResourceLocation.equals(Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(exhaustFluid)).toString())) { + if (!reactorState.exhaustResourceLocation.equals(Objects.requireNonNull(BuiltInRegistries.FLUID.getKey(exhaustFluid)).toString())) { exhaustFluid = BuiltInRegistries.FLUID.get(new ResourceLocation(reactorState.exhaustResourceLocation)); } } @@ -167,7 +166,7 @@ public void containerTick() { /** * Draw the status text for this screen. * - * @param poseStack The current pose stack. +// * @param poseStack The current pose stack. * @param mouseX The x position of the mouse. * @param mouseY The y position of the mouse. * @param partialTicks Partial ticks. @@ -187,7 +186,7 @@ public void render(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float /** * Render the progress bar. * - * @param poseStack The current pose stack. +// * @param poseStack The current pose stack. * @param symbol The symbol to draw as. * @param reactorActivity Current status of the reactor. * @param workTime The time the machine has been working. diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/CommonReactorTerminalScreen.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/CommonReactorTerminalScreen.java index 1e47c4a1..c51873d6 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/CommonReactorTerminalScreen.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/CommonReactorTerminalScreen.java @@ -6,8 +6,8 @@ import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.player.Inventory; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.Config; import net.roguelogix.biggerreactors.client.Biselector; import net.roguelogix.biggerreactors.client.SelectorColors; diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/PassiveReactorTerminalScreen.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/PassiveReactorTerminalScreen.java index e4365190..d5e8d07c 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/PassiveReactorTerminalScreen.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/PassiveReactorTerminalScreen.java @@ -5,8 +5,8 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.client.CommonRender; import net.roguelogix.biggerreactors.multiblocks.reactor.containers.ReactorTerminalContainer; diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorAccessPortScreen.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorAccessPortScreen.java index 8d5beeb2..74eeb70b 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorAccessPortScreen.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorAccessPortScreen.java @@ -6,8 +6,8 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.player.Inventory; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.client.Biselector; import net.roguelogix.biggerreactors.client.SelectorColors; diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorControlRodScreen.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorControlRodScreen.java index edda669f..fe5eb06f 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorControlRodScreen.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorControlRodScreen.java @@ -8,8 +8,8 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.player.Inventory; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.client.CommonButton; import net.roguelogix.biggerreactors.client.TextBox; diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorCoolantPortScreen.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorCoolantPortScreen.java index 7dc08aff..02ce0b45 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorCoolantPortScreen.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorCoolantPortScreen.java @@ -1,13 +1,12 @@ package net.roguelogix.biggerreactors.multiblocks.reactor.client; -import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.player.Inventory; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.client.Biselector; import net.roguelogix.biggerreactors.client.SelectorColors; diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorRedstonePortScreen.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorRedstonePortScreen.java index ca5252d1..cf9d48d8 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorRedstonePortScreen.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/client/ReactorRedstonePortScreen.java @@ -1,22 +1,21 @@ package net.roguelogix.biggerreactors.multiblocks.reactor.client; -import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.player.Inventory; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.client.*; import net.roguelogix.biggerreactors.multiblocks.reactor.containers.ReactorRedstonePortContainer; import net.roguelogix.biggerreactors.multiblocks.reactor.state.ReactorRedstonePortSelection; import net.roguelogix.biggerreactors.multiblocks.reactor.state.ReactorRedstonePortState; import net.roguelogix.biggerreactors.multiblocks.reactor.state.ReactorRedstonePortTriggers; -import net.roguelogix.phosphophyllite.client.gui.screens.PhosphophylliteScreen; import net.roguelogix.phosphophyllite.client.gui.elements.InteractiveElement; import net.roguelogix.phosphophyllite.client.gui.elements.RenderedElement; +import net.roguelogix.phosphophyllite.client.gui.screens.PhosphophylliteScreen; import javax.annotation.Nonnull; diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/deps/ReactorPeripheral.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/deps/ReactorPeripheral.java index 80dcc1ca..60a84c7f 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/deps/ReactorPeripheral.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/deps/ReactorPeripheral.java @@ -4,7 +4,6 @@ import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaFunction; import dan200.computercraft.api.peripheral.IPeripheral; -import net.minecraftforge.common.util.LazyOptional; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.multiblocks.reactor.ReactorMultiblockController; import net.roguelogix.biggerreactors.multiblocks.reactor.simulation.IReactorSimulation; @@ -19,8 +18,8 @@ public class ReactorPeripheral implements IPeripheral { - public static LazyOptional create(@Nonnull Supplier controllerSupplier) { - return LazyOptional.of(() -> new ReactorPeripheral(controllerSupplier)); + public static ReactorPeripheral create(@Nonnull Supplier controllerSupplier) { + return new ReactorPeripheral(controllerSupplier); } @Nonnull diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/simulation/accellerated/vk/VkMemUtil.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/simulation/accellerated/vk/VkMemUtil.java index 04611d33..096b5ad0 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/simulation/accellerated/vk/VkMemUtil.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/simulation/accellerated/vk/VkMemUtil.java @@ -134,19 +134,19 @@ private Info attemptAllocInSpace(Info freeAlloc, long size, long alignment) { if (alignmentWaste > 0) { final var newAllocs = freeAlloc.split(alignmentWaste); // not concurrent modification because this will always return - freeAllocations.add(newAllocs.first); - freeAlloc = newAllocs.second; + freeAllocations.add(newAllocs.first()); + freeAlloc = newAllocs.second(); - int index = freeAllocations.indexOf(newAllocs.first); + int index = freeAllocations.indexOf(newAllocs.first()); collapseFreeAllocationWithNext(index - 1); collapseFreeAllocationWithNext(index); } if (freeAlloc.size > size) { final var newAllocs = freeAlloc.split(size); // not concurrent modification because this will always return - freeAlloc = newAllocs.first; - freeAllocations.add(newAllocs.second); - int index = freeAllocations.indexOf(newAllocs.second); + freeAlloc = newAllocs.first(); + freeAllocations.add(newAllocs.second()); + int index = freeAllocations.indexOf(newAllocs.second()); collapseFreeAllocationWithNext(index - 1); collapseFreeAllocationWithNext(index); } diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorAccessPortTile.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorAccessPortTile.java index 632d7e10..fe205fa9 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorAccessPortTile.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorAccessPortTile.java @@ -1,6 +1,5 @@ package net.roguelogix.biggerreactors.multiblocks.reactor.tiles; -import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.registries.BuiltInRegistries; @@ -17,11 +16,8 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.items.wrapper.EmptyHandler; +import net.neoforged.neoforge.capabilities.Capabilities; +import net.neoforged.neoforge.items.IItemHandler; import net.roguelogix.biggerreactors.Config; import net.roguelogix.biggerreactors.blocks.materials.MaterialBlock; import net.roguelogix.biggerreactors.items.ingots.BlutoniumIngot; @@ -34,22 +30,26 @@ import net.roguelogix.phosphophyllite.debug.DebugInfo; import net.roguelogix.phosphophyllite.multiblock.common.IEventMultiblock; import net.roguelogix.phosphophyllite.multiblock.validated.IValidatedMultiblock; +import net.roguelogix.phosphophyllite.registry.CapabilityRegistration; +import net.roguelogix.phosphophyllite.registry.RegisterCapability; import net.roguelogix.phosphophyllite.registry.RegisterTile; import net.roguelogix.phosphophyllite.util.BlockStates; +import net.roguelogix.phosphophyllite.util.NonnullDefault; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; import static net.roguelogix.biggerreactors.multiblocks.reactor.blocks.ReactorAccessPort.PortDirection.*; -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault +@NonnullDefault public class ReactorAccessPortTile extends ReactorBaseTile implements IItemHandler, MenuProvider, IHasUpdatableState, IEventMultiblock.AssemblyStateTransition { @RegisterTile("reactor_access_port") public static final BlockEntityType.BlockEntitySupplier SUPPLIER = new RegisterTile.Producer<>(ReactorAccessPortTile::new); + @RegisterCapability + private static final CapabilityRegistration ITEM_HANDLER_CAP_REGISTRATION = CapabilityRegistration.tileCap(Capabilities.ItemHandler.BLOCK, ReactorAccessPortTile.class); + private static final TagKey uraniumIngotTag = TagKey.create(BuiltInRegistries.ITEM.key(), new ResourceLocation("forge:ingots/uranium")); private static final TagKey uraniumBlockTag = TagKey.create(BuiltInRegistries.ITEM.key(), new ResourceLocation("forge:storage_blocks/uranium")); @@ -109,16 +109,6 @@ public void onAssemblyStateTransition(IValidatedMultiblock.AssemblyState oldStat neighborChanged(); } - LazyOptional itemStackHandler = LazyOptional.of(() -> this); - - @Override - protected LazyOptional capability(Capability cap, @Nullable Direction side) { - if (cap == ForgeCapabilities.ITEM_HANDLER) { - return itemStackHandler.cast(); - } - return super.capability(cap, side); - } - @Override public int getSlots() { return 3; @@ -130,7 +120,7 @@ public ItemStack getStackInSlot(int slot) { if (nullableController() == null) { return ItemStack.EMPTY; } - var reactorSim = controller().simulation(); + @Nullable var reactorSim = controller().simulation(); if(reactorSim == null){ return ItemStack.EMPTY; } @@ -220,16 +210,15 @@ public boolean isItemValid(int slot, ItemStack stack) { } public int pushWaste(int waste, boolean simulated) { - if (itemOutput.isPresent()) { - IItemHandler output = itemOutput.orElse(EmptyHandler.INSTANCE); + if (itemOutput != null) { waste /= Config.CONFIG.Reactor.FuelMBPerIngot; int wasteHandled = 0; - for (int i = 0; i < output.getSlots(); i++) { + for (int i = 0; i < itemOutput.getSlots(); i++) { if (waste == 0) { break; } ItemStack toInsertStack = new ItemStack(CyaniteIngot.INSTANCE, waste); - ItemStack remainingStack = output.insertItem(i, toInsertStack, simulated); + ItemStack remainingStack = itemOutput.insertItem(i, toInsertStack, simulated); wasteHandled += toInsertStack.getCount() - remainingStack.getCount(); waste -= toInsertStack.getCount() - remainingStack.getCount(); } @@ -243,16 +232,15 @@ public void ejectWaste() { } public int pushFuel(int fuel, boolean simulated) { - if (itemOutput.isPresent()) { - IItemHandler output = itemOutput.orElse(EmptyHandler.INSTANCE); + if (itemOutput != null) { fuel /= Config.CONFIG.Reactor.FuelMBPerIngot; int fuelHandled = 0; - for (int i = 0; i < output.getSlots(); i++) { + for (int i = 0; i < itemOutput.getSlots(); i++) { if (fuel == 0) { break; } ItemStack toInsertStack = new ItemStack(UraniumIngot.INSTANCE, fuel); - ItemStack remainingStack = output.insertItem(i, toInsertStack, simulated); + ItemStack remainingStack = itemOutput.insertItem(i, toInsertStack, simulated); fuelHandled += toInsertStack.getCount() - remainingStack.getCount(); fuel -= toInsertStack.getCount() - remainingStack.getCount(); } @@ -265,26 +253,22 @@ public void ejectFuel() { controller().extractFuel(pushFuel((int) controller().extractFuel(Integer.MAX_VALUE, true), false), false); } + @Nullable Direction itemOutputDirection; boolean connected; - LazyOptional itemOutput = LazyOptional.empty(); + @Nullable + IItemHandler itemOutput = null; public final ReactorAccessPortState reactorAccessPortState = new ReactorAccessPortState(this); @SuppressWarnings("DuplicatedCode") public void neighborChanged() { - itemOutput = LazyOptional.empty(); if (itemOutputDirection == null) { connected = false; return; } assert level != null; - BlockEntity te = level.getBlockEntity(worldPosition.relative(itemOutputDirection)); - if (te == null) { - connected = false; - return; - } - itemOutput = te.getCapability(ForgeCapabilities.ITEM_HANDLER, itemOutputDirection.getOpposite()); - connected = itemOutput.isPresent(); + itemOutput = level.getCapability(Capabilities.ItemHandler.BLOCK, worldPosition.relative(itemOutputDirection), itemOutputDirection.getOpposite()); + connected = itemOutput != null; } @Override diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorComputerPortTile.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorComputerPortTile.java index c51956ed..fe992b4e 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorComputerPortTile.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorComputerPortTile.java @@ -6,10 +6,6 @@ import net.minecraft.core.Direction; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityManager; -import net.minecraftforge.common.capabilities.CapabilityToken; -import net.minecraftforge.common.util.LazyOptional; import net.roguelogix.biggerreactors.multiblocks.reactor.deps.ReactorPeripheral; import net.roguelogix.phosphophyllite.multiblock.common.IEventMultiblock; import net.roguelogix.phosphophyllite.registry.RegisterTile; @@ -28,30 +24,31 @@ public ReactorComputerPortTile(BlockEntityType TYPE, BlockPos pos, BlockState super(TYPE, pos, state); } - private static final Capability CAPABILITY_PERIPHERAL = CapabilityManager.get(new CapabilityToken<>(){}); - - private LazyOptional peripheralCapability; - - { - // avoids classloading without CC existing - if (CAPABILITY_PERIPHERAL.isRegistered()) { - peripheralCapability = ReactorPeripheral.create(this::controller); - } - } - - @Override - public LazyOptional capability(Capability cap, final @Nullable Direction side) { - if (cap == CAPABILITY_PERIPHERAL) { - return peripheralCapability.cast(); - } - return super.capability(cap, side); - } + // TODO: computercraft capability +// private static final Capability CAPABILITY_PERIPHERAL = CapabilityManager.get(new CapabilityToken<>(){}); +// +// private LazyOptional peripheralCapability; +// +// { +// // avoids classloading without CC existing +// if (CAPABILITY_PERIPHERAL.isRegistered()) { +// peripheralCapability = ReactorPeripheral.create(this::controller); +// } +// } +// +// @Override +// public LazyOptional capability(Capability cap, final @Nullable Direction side) { +// if (cap == CAPABILITY_PERIPHERAL) { +// return peripheralCapability.cast(); +// } +// return super.capability(cap, side); +// } @Override public void onAssembly() { // class loading BS, dont remove this if - if (CAPABILITY_PERIPHERAL.isRegistered()) { - peripheralCapability.ifPresent(ReactorPeripheral::rebuildControlRodList); - } +// if (CAPABILITY_PERIPHERAL.isRegistered()) { +// peripheralCapability.ifPresent(ReactorPeripheral::rebuildControlRodList); +// } } } diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorCoolantPortTile.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorCoolantPortTile.java index 1f43ebc9..1517b265 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorCoolantPortTile.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorCoolantPortTile.java @@ -1,6 +1,5 @@ package net.roguelogix.biggerreactors.multiblocks.reactor.tiles; -import mekanism.api.chemical.gas.IGasHandler; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -10,29 +9,23 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityManager; -import net.minecraftforge.common.capabilities.CapabilityToken; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fluids.capability.templates.FluidTank; -import net.roguelogix.biggerreactors.multiblocks.reactor.util.ReactorTransitionTank; +import net.neoforged.neoforge.capabilities.Capabilities; import net.roguelogix.biggerreactors.multiblocks.reactor.blocks.ReactorAccessPort; import net.roguelogix.biggerreactors.multiblocks.reactor.blocks.ReactorCoolantPort; import net.roguelogix.biggerreactors.multiblocks.reactor.containers.ReactorCoolantPortContainer; import net.roguelogix.biggerreactors.multiblocks.reactor.state.ReactorCoolantPortState; +import net.roguelogix.biggerreactors.multiblocks.reactor.util.ReactorTransitionTank; +import net.roguelogix.phosphophyllite.client.gui.api.IHasUpdatableState; import net.roguelogix.phosphophyllite.fluids.FluidHandlerWrapper; import net.roguelogix.phosphophyllite.fluids.IPhosphophylliteFluidHandler; -import net.roguelogix.phosphophyllite.client.gui.api.IHasUpdatableState; -import net.roguelogix.phosphophyllite.fluids.MekanismGasWrappers; import net.roguelogix.phosphophyllite.multiblock.common.IEventMultiblock; import net.roguelogix.phosphophyllite.multiblock.validated.IValidatedMultiblock; +import net.roguelogix.phosphophyllite.registry.CapabilityRegistration; +import net.roguelogix.phosphophyllite.registry.RegisterCapability; import net.roguelogix.phosphophyllite.registry.RegisterTile; import net.roguelogix.phosphophyllite.util.BlockStates; @@ -48,23 +41,27 @@ public class ReactorCoolantPortTile extends ReactorBaseTile implements IPhosphop @RegisterTile("reactor_coolant_port") public static final BlockEntityType.BlockEntitySupplier SUPPLIER = new RegisterTile.Producer<>(ReactorCoolantPortTile::new); + @RegisterCapability + private static final CapabilityRegistration FLUID_HANDLER_CAP_REGISTRATION = CapabilityRegistration.tileCap(Capabilities.FluidHandler.BLOCK, ReactorCoolantPortTile.class); + public ReactorCoolantPortTile(BlockEntityType TYPE, BlockPos pos, BlockState state) { super(TYPE, pos, state); } - - private static final Capability GAS_HANDLER_CAPABILITY = CapabilityManager.get(new CapabilityToken<>() { - }); - - @Override - public LazyOptional capability(Capability cap, @Nullable Direction side) { - if (cap == ForgeCapabilities.FLUID_HANDLER) { - return LazyOptional.of(() -> this).cast(); - } - if (cap == GAS_HANDLER_CAPABILITY) { - return LazyOptional.of(() -> MekanismGasWrappers.wrap(this)).cast(); - } - return super.capability(cap, side); - } + + // TODO: mek gas cap registration, needs to not be a hard-dep +// private static final Capability GAS_HANDLER_CAPABILITY = CapabilityManager.get(new CapabilityToken<>() { +// }); +// +// @Override +// public LazyOptional capability(Capability cap, @Nullable Direction side) { +// if (cap == ForgeCapabilities.FLUID_HANDLER) { +// return LazyOptional.of(() -> this).cast(); +// } +// if (cap == GAS_HANDLER_CAPABILITY) { +// return LazyOptional.of(() -> MekanismGasWrappers.wrap(this)).cast(); +// } +// return super.capability(cap, side); +// } @Nullable private ReactorTransitionTank transitionTank; @@ -138,7 +135,7 @@ public long pushFluid() { if (!connected || direction == INLET) { return 0; } - if (handlerOptional.isPresent() && transitionTank != null) { + if (handler != null && transitionTank != null) { Fluid fluid = transitionTank.vaporType(); long amount = transitionTank.vaporAmount(); amount = transitionTank.drain(fluid, null, amount, true); @@ -146,7 +143,6 @@ public long pushFluid() { amount = transitionTank.drain(fluid, null, amount, false); return amount; } else { - handlerOptional = LazyOptional.empty(); handler = null; connected = false; } @@ -156,40 +152,32 @@ public long pushFluid() { private boolean connected = false; Direction steamOutputDirection = null; - LazyOptional handlerOptional = LazyOptional.empty(); IPhosphophylliteFluidHandler handler = null; - FluidTank EMPTY_TANK = new FluidTank(0); private ReactorAccessPort.PortDirection direction = INLET; public final ReactorCoolantPortState reactorCoolantPortState = new ReactorCoolantPortState(this); @SuppressWarnings("DuplicatedCode") public void neighborChanged() { - handlerOptional = LazyOptional.empty(); handler = null; if (steamOutputDirection == null) { connected = false; return; } assert level != null; - BlockEntity te = level.getBlockEntity(worldPosition.relative(steamOutputDirection)); - if (te == null) { - connected = false; - return; - } + final var capHandler = level.getCapability(Capabilities.FluidHandler.BLOCK, worldPosition.relative(steamOutputDirection), steamOutputDirection.getOpposite()); connected = false; - LazyOptional fluidOptional = te.getCapability(ForgeCapabilities.FLUID_HANDLER, steamOutputDirection.getOpposite()); - if (fluidOptional.isPresent()) { + if (capHandler != null) { connected = true; - handlerOptional = fluidOptional; - handler = FluidHandlerWrapper.wrap(fluidOptional.orElse(EMPTY_TANK)); - } else if (GAS_HANDLER_CAPABILITY != null) { - LazyOptional gasOptional = te.getCapability(GAS_HANDLER_CAPABILITY, steamOutputDirection.getOpposite()); - if (gasOptional.isPresent()) { - IGasHandler gasHandler = gasOptional.orElse(MekanismGasWrappers.EMPTY_TANK); - connected = true; - handlerOptional = gasOptional; - handler = MekanismGasWrappers.wrap(gasHandler); - } + handler = FluidHandlerWrapper.wrap(capHandler); + // TODO: mek gas +// } else if (GAS_HANDLER_CAPABILITY != null) { +// LazyOptional gasOptional = te.getCapability(GAS_HANDLER_CAPABILITY, steamOutputDirection.getOpposite()); +// if (gasOptional.isPresent()) { +// IGasHandler gasHandler = gasOptional.orElse(MekanismGasWrappers.EMPTY_TANK); +// connected = true; +// handlerOptional = gasOptional; +// handler = MekanismGasWrappers.wrap(gasHandler); +// } } } diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorPowerTapTile.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorPowerTapTile.java index 1153d379..91bd9fd1 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorPowerTapTile.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/reactor/tiles/ReactorPowerTapTile.java @@ -5,23 +5,21 @@ import net.minecraft.core.Direction; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.common.util.LazyOptional; +import net.roguelogix.phosphophyllite.capability.CachedWrappedBlockCapability; import net.roguelogix.phosphophyllite.energy.IEnergyTile; import net.roguelogix.phosphophyllite.energy.IPhosphophylliteEnergyHandler; import net.roguelogix.phosphophyllite.multiblock.common.IEventMultiblock; import net.roguelogix.phosphophyllite.multiblock.validated.IValidatedMultiblock; import net.roguelogix.phosphophyllite.registry.RegisterTile; import net.roguelogix.phosphophyllite.util.BlockStates; +import net.roguelogix.phosphophyllite.util.NonnullDefault; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import static net.roguelogix.biggerreactors.multiblocks.reactor.blocks.ReactorPowerTap.ConnectionState.*; -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault +@NonnullDefault public class ReactorPowerTapTile extends ReactorBaseTile implements IEnergyTile, IPhosphophylliteEnergyHandler, IEventMultiblock.AssemblyStateTransition { @RegisterTile("reactor_power_tap") @@ -32,13 +30,13 @@ public ReactorPowerTapTile(BlockEntityType TYPE, BlockPos pos, BlockState sta } private boolean connected = false; + @Nullable Direction powerOutputDirection = null; - LazyOptional thisCap = LazyOptional.of(() -> this); @Override - public LazyOptional energyHandler() { - return thisCap; + public IPhosphophylliteEnergyHandler energyHandler(Direction direction) { + return this; } private void setConnected(boolean newState) { @@ -49,14 +47,19 @@ private void setConnected(boolean newState) { } } - LazyOptional outputOptional = LazyOptional.empty(); - IPhosphophylliteEnergyHandler output; + @Nullable + CachedWrappedBlockCapability output = null; public long distributePower(long toDistribute, boolean simulate) { - if (outputOptional.isPresent()) { - return Math.max(0, output.insertEnergy(toDistribute, simulate)); + if(output == null) { + return 0; } - return 0; + @Nullable + final var outputCap = output.getCapability(); + if (outputCap == null) { + return 0; + } + return Math.max(0, outputCap.insertEnergy(toDistribute, simulate)); } @Override @@ -69,11 +72,11 @@ public long extractEnergy(long maxExtract, boolean simulate) { if (maxExtract <= 0 || nullableController() == null || controller().assemblyState() != IValidatedMultiblock.AssemblyState.ASSEMBLED) { return 0; } - var reactorSim = controller().simulation(); + @Nullable var reactorSim = controller().simulation(); if (reactorSim == null) { return 0; } - var battery = reactorSim.battery(); + @Nullable var battery = reactorSim.battery(); if (battery == null) { return 0; } @@ -88,11 +91,11 @@ public long extractEnergy(long maxExtract, boolean simulate) { @Override public long energyStored() { if (nullableController() != null) { - var reactorSim = controller().simulation(); + @Nullable var reactorSim = controller().simulation(); if (reactorSim == null) { return 0; } - var battery = reactorSim.battery(); + @Nullable var battery = reactorSim.battery(); if (battery == null) { return 0; } @@ -104,11 +107,11 @@ public long energyStored() { @Override public long maxEnergyStored() { if (nullableController() != null) { - var reactorSim = controller().simulation(); + @Nullable var reactorSim = controller().simulation(); if (reactorSim == null) { return 0; } - var battery = reactorSim.battery(); + @Nullable var battery = reactorSim.battery(); if (battery == null) { return 0; } @@ -119,20 +122,13 @@ public long maxEnergyStored() { @SuppressWarnings("DuplicatedCode") public void neighborChanged() { - outputOptional = LazyOptional.empty(); output = null; if (powerOutputDirection == null) { setConnected(false); return; } - - final var outputCap = this.findEnergyCapability(powerOutputDirection); - setConnected(outputCap.isPresent()); - if (connected) { - outputOptional = outputCap; - //noinspection DataFlowIssue - output = outputOptional.orElse(null); - } + output = findEnergyCapability(powerOutputDirection); + setConnected(output.getCapability() != null); } @Override diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/TurbineMultiblockController.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/TurbineMultiblockController.java index aa10256d..6e64b251 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/TurbineMultiblockController.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/TurbineMultiblockController.java @@ -5,11 +5,11 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Vec3i; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.AirBlock; import net.minecraft.world.level.block.Block; -import net.minecraftforge.registries.ForgeRegistries; import net.roguelogix.biggerreactors.Config; import net.roguelogix.biggerreactors.multiblocks.turbine.blocks.TurbineBaseBlock; import net.roguelogix.biggerreactors.multiblocks.turbine.blocks.TurbineRotorBlade; @@ -538,11 +538,11 @@ public void updateDataPacket(TurbineState turbineState) { turbineState.intakeStored = simulation.fluidTank().vaporAmount(); turbineState.intakeCapacity = simulation.fluidTank().perSideCapacity(); - turbineState.intakeResourceLocation = ForgeRegistries.FLUIDS.getKey(simulation().fluidTank().vaporType()).toString(); + turbineState.intakeResourceLocation = BuiltInRegistries.FLUID.getKey(simulation().fluidTank().vaporType()).toString(); turbineState.exhaustStored = simulation.fluidTank().liquidAmount(); turbineState.exhaustCapacity = simulation.fluidTank().perSideCapacity(); - turbineState.exhaustResourceLocation = ForgeRegistries.FLUIDS.getKey(simulation().fluidTank().liquidType()).toString(); + turbineState.exhaustResourceLocation = BuiltInRegistries.FLUID.getKey(simulation().fluidTank().liquidType()).toString(); turbineState.energyStored = simulation.battery().stored(); turbineState.energyCapacity = simulation.battery().capacity(); diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/blocks/TurbineBaseBlock.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/blocks/TurbineBaseBlock.java index 7c003b03..e66190d8 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/blocks/TurbineBaseBlock.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/blocks/TurbineBaseBlock.java @@ -14,7 +14,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.phys.BlockHitResult; -import net.minecraftforge.network.NetworkHooks; import net.roguelogix.biggerreactors.multiblocks.turbine.state.TurbineActivity; import net.roguelogix.phosphophyllite.modular.block.PhosphophylliteBlock; import net.roguelogix.phosphophyllite.multiblock.IMultiblockBlock; @@ -72,7 +71,7 @@ public InteractionResult onUse(BlockState state, Level level, BlockPos pos, Play if (hand == InteractionHand.MAIN_HAND && state.hasProperty(ASSEMBLED) && state.getValue(ASSEMBLED)) { if (level.getBlockEntity(pos) instanceof MenuProvider menuProvider) { if (!level.isClientSide) { - NetworkHooks.openScreen((ServerPlayer) player, menuProvider, pos); + player.openMenu(menuProvider, pos); } return InteractionResult.SUCCESS; } diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/client/TurbineFluidPortScreen.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/client/TurbineFluidPortScreen.java index c2ae239f..7c50196e 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/client/TurbineFluidPortScreen.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/client/TurbineFluidPortScreen.java @@ -5,8 +5,8 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.client.Biselector; import net.roguelogix.biggerreactors.client.SelectorColors; diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/client/TurbineTerminalScreen.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/client/TurbineTerminalScreen.java index 9722c590..e70c7642 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/client/TurbineTerminalScreen.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/client/TurbineTerminalScreen.java @@ -11,7 +11,6 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; -import net.minecraftforge.registries.ForgeRegistries; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.Config; import net.roguelogix.biggerreactors.client.Biselector; @@ -280,11 +279,11 @@ public void containerTick() { turbineState = (TurbineState) this.getMenu().getGuiPacket(); super.containerTick(); // Check if intake type changed. - if (!turbineState.intakeResourceLocation.equals(Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(intakeFluid)).toString())) { + if (!turbineState.intakeResourceLocation.equals(Objects.requireNonNull(BuiltInRegistries.FLUID.getKey(intakeFluid)).toString())) { intakeFluid = BuiltInRegistries.FLUID.get(new ResourceLocation(turbineState.intakeResourceLocation)); } // Check if exhaust type changed. - if (!turbineState.exhaustResourceLocation.equals(Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(exhaustFluid)).toString())) { + if (!turbineState.exhaustResourceLocation.equals(Objects.requireNonNull(BuiltInRegistries.FLUID.getKey(exhaustFluid)).toString())) { exhaustFluid = BuiltInRegistries.FLUID.get(new ResourceLocation(turbineState.exhaustResourceLocation)); } } diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/deps/TurbinePeripheral.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/deps/TurbinePeripheral.java index 4c1459fa..7636c209 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/deps/TurbinePeripheral.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/deps/TurbinePeripheral.java @@ -4,8 +4,7 @@ import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaFunction; import dan200.computercraft.api.peripheral.IPeripheral; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.multiblocks.turbine.TurbineMultiblockController; import net.roguelogix.biggerreactors.multiblocks.turbine.state.VentState; @@ -22,8 +21,8 @@ public class TurbinePeripheral implements IPeripheral { @Nonnull private final LamdbaExceptionUtils.Supplier_WithExceptions controllerSupplier; - public static LazyOptional create(@Nonnull Supplier controllerSupplier) { - return LazyOptional.of(() -> new TurbinePeripheral(controllerSupplier)); + public static TurbinePeripheral create(@Nonnull Supplier controllerSupplier) { + return new TurbinePeripheral(controllerSupplier); } public TurbinePeripheral(@Nonnull Supplier rawControllerSupplier) { @@ -147,7 +146,7 @@ public TankFluid(LamdbaExceptionUtils.Supplier_WithExceptions { long extract(long toExtract); diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/simulation/ITurbineFluidTank.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/simulation/ITurbineFluidTank.java index f695bc9b..0b28cf22 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/simulation/ITurbineFluidTank.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/simulation/ITurbineFluidTank.java @@ -2,7 +2,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.material.Fluid; -import net.minecraftforge.common.util.INBTSerializable; +import net.neoforged.neoforge.common.util.INBTSerializable; import net.roguelogix.phosphophyllite.fluids.IPhosphophylliteFluidHandler; public interface ITurbineFluidTank extends INBTSerializable, IPhosphophylliteFluidHandler { diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/simulation/ITurbineSimulation.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/simulation/ITurbineSimulation.java index e0399faa..b99c0e4f 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/simulation/ITurbineSimulation.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/simulation/ITurbineSimulation.java @@ -1,7 +1,7 @@ package net.roguelogix.biggerreactors.multiblocks.turbine.simulation; import net.minecraft.nbt.CompoundTag; -import net.minecraftforge.common.util.INBTSerializable; +import net.neoforged.neoforge.common.util.INBTSerializable; import net.roguelogix.biggerreactors.multiblocks.turbine.state.VentState; import net.roguelogix.biggerreactors.registries.TurbineCoilRegistry; import org.joml.Vector4i; diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbineComputerPortTile.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbineComputerPortTile.java index 7c6683b5..2549b72f 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbineComputerPortTile.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbineComputerPortTile.java @@ -6,10 +6,6 @@ import net.minecraft.core.Direction; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityManager; -import net.minecraftforge.common.capabilities.CapabilityToken; -import net.minecraftforge.common.util.LazyOptional; import net.roguelogix.biggerreactors.multiblocks.turbine.deps.TurbinePeripheral; import net.roguelogix.phosphophyllite.registry.RegisterTile; @@ -27,14 +23,15 @@ public TurbineComputerPortTile(BlockEntityType TYPE, BlockPos pos, BlockState super(TYPE, pos, state); } - private static final Capability CAPABILITY_PERIPHERAL = CapabilityManager.get(new CapabilityToken<>(){}); - - @Override - public LazyOptional capability(Capability cap, final @Nullable Direction side) { - if (cap == CAPABILITY_PERIPHERAL) { - return TurbinePeripheral.create(this::controller).cast(); - } - return super.capability(cap, side); - } - + // TODO: computercraft capability +// private static final Capability CAPABILITY_PERIPHERAL = CapabilityManager.get(new CapabilityToken<>(){}); +// +// @Override +// public LazyOptional capability(Capability cap, final @Nullable Direction side) { +// if (cap == CAPABILITY_PERIPHERAL) { +// return TurbinePeripheral.create(this::controller).cast(); +// } +// return super.capability(cap, side); +// } +// } diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbineFluidPortTile.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbineFluidPortTile.java index 13b564f0..d4209be5 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbineFluidPortTile.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbineFluidPortTile.java @@ -15,13 +15,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityManager; -import net.minecraftforge.common.capabilities.CapabilityToken; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fluids.capability.templates.FluidTank; +import net.neoforged.neoforge.capabilities.Capabilities; import net.roguelogix.biggerreactors.multiblocks.turbine.blocks.TurbineFluidPort; import net.roguelogix.biggerreactors.multiblocks.turbine.containers.TurbineFluidPortContainer; import net.roguelogix.biggerreactors.multiblocks.turbine.simulation.ITurbineFluidTank; @@ -32,6 +26,8 @@ import net.roguelogix.phosphophyllite.fluids.MekanismGasWrappers; import net.roguelogix.phosphophyllite.multiblock.common.IEventMultiblock; import net.roguelogix.phosphophyllite.multiblock.validated.IValidatedMultiblock; +import net.roguelogix.phosphophyllite.registry.CapabilityRegistration; +import net.roguelogix.phosphophyllite.registry.RegisterCapability; import net.roguelogix.phosphophyllite.registry.RegisterTile; import net.roguelogix.phosphophyllite.util.BlockStates; @@ -47,22 +43,26 @@ public class TurbineFluidPortTile extends TurbineBaseTile implements IPhosphophy @RegisterTile("turbine_fluid_port") public static final BlockEntityType.BlockEntitySupplier SUPPLIER = new RegisterTile.Producer<>(TurbineFluidPortTile::new); + @RegisterCapability + private static final CapabilityRegistration FLUID_HANDLER_CAP_REGISTRATION = CapabilityRegistration.tileCap(Capabilities.FluidHandler.BLOCK, TurbineFluidPortTile.class); + public TurbineFluidPortTile(BlockEntityType TYPE, BlockPos pos, BlockState state) { super(TYPE, pos, state); } - private static final Capability GAS_HANDLER_CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){}); - - @Override - public LazyOptional capability(Capability cap, @Nullable Direction side) { - if (cap == ForgeCapabilities.FLUID_HANDLER) { - return LazyOptional.of(() -> this).cast(); - } - if (cap == GAS_HANDLER_CAPABILITY) { - return LazyOptional.of(() -> MekanismGasWrappers.wrap(this)).cast(); - } - return super.capability(cap, side); - } + // TODO: mek gas +// private static final Capability GAS_HANDLER_CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){}); +// +// @Override +// public LazyOptional capability(Capability cap, @Nullable Direction side) { +// if (cap == ForgeCapabilities.FLUID_HANDLER) { +// return LazyOptional.of(() -> this).cast(); +// } +// if (cap == GAS_HANDLER_CAPABILITY) { +// return LazyOptional.of(() -> MekanismGasWrappers.wrap(this)).cast(); +// } +// return super.capability(cap, side); +// } private ITurbineFluidTank transitionTank; @@ -135,8 +135,7 @@ public long pushFluid() { if (!connected || direction == INLET) { return 0; } - if (handlerOptional.isPresent()) { - + if (handler != null) { Fluid fluid = transitionTank.liquidType(); long amount = transitionTank.liquidAmount(); amount = transitionTank.drain(fluid, null, amount, true); @@ -144,7 +143,6 @@ public long pushFluid() { amount = transitionTank.drain(fluid, null, amount, false); return amount; } else { - handlerOptional = LazyOptional.empty(); handler = null; connected = false; } @@ -154,40 +152,36 @@ public long pushFluid() { private boolean connected = false; Direction waterOutputDirection = null; - LazyOptional handlerOptional = LazyOptional.empty(); IPhosphophylliteFluidHandler handler = null; - FluidTank EMPTY_TANK = new FluidTank(0); private TurbineFluidPort.PortDirection direction = INLET; public final TurbineFluidPortState fluidPortState = new TurbineFluidPortState(this); @SuppressWarnings("DuplicatedCode") public void neighborChanged() { - handlerOptional = LazyOptional.empty(); handler = null; if (waterOutputDirection == null) { connected = false; return; } assert level != null; - BlockEntity te = level.getBlockEntity(worldPosition.relative(waterOutputDirection)); - if (te == null) { + final var outputCap = level.getCapability(Capabilities.FluidHandler.BLOCK, worldPosition.relative(waterOutputDirection), waterOutputDirection.getOpposite()); + if (outputCap == null) { connected = false; return; } connected = false; - LazyOptional waterOutput = te.getCapability(ForgeCapabilities.FLUID_HANDLER, waterOutputDirection.getOpposite()); - if (waterOutput.isPresent()) { + if (outputCap != null) { connected = true; - handlerOptional = waterOutput; - handler = FluidHandlerWrapper.wrap(waterOutput.orElse(EMPTY_TANK)); - } else if (GAS_HANDLER_CAPABILITY != null) { - LazyOptional gasOptional = te.getCapability(GAS_HANDLER_CAPABILITY, waterOutputDirection.getOpposite()); - if (gasOptional.isPresent()) { - IGasHandler gasHandler = gasOptional.orElse(MekanismGasWrappers.EMPTY_TANK); - connected = true; - handlerOptional = gasOptional; - handler = MekanismGasWrappers.wrap(gasHandler); - } + handler = FluidHandlerWrapper.wrap(outputCap); + // todo: mek gas +// } else if (GAS_HANDLER_CAPABILITY != null) { +// LazyOptional gasOptional = te.getCapability(GAS_HANDLER_CAPABILITY, waterOutputDirection.getOpposite()); +// if (gasOptional.isPresent()) { +// IGasHandler gasHandler = gasOptional.orElse(MekanismGasWrappers.EMPTY_TANK); +// connected = true; +// handlerOptional = gasOptional; +// handler = MekanismGasWrappers.wrap(gasHandler); +// } } } diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbinePowerTapTile.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbinePowerTapTile.java index 0861d8c0..948a636b 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbinePowerTapTile.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbinePowerTapTile.java @@ -5,9 +5,7 @@ import net.minecraft.core.Direction; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.common.util.LazyOptional; +import net.roguelogix.phosphophyllite.capability.CachedWrappedBlockCapability; import net.roguelogix.phosphophyllite.energy.IEnergyTile; import net.roguelogix.phosphophyllite.energy.IPhosphophylliteEnergyHandler; import net.roguelogix.phosphophyllite.multiblock.common.IEventMultiblock; @@ -34,11 +32,9 @@ public TurbinePowerTapTile(BlockEntityType TYPE, BlockPos pos, BlockState sta private boolean connected = false; Direction powerOutputDirection = null; - LazyOptional thisCap = LazyOptional.of(() -> this); - @Override - public LazyOptional energyHandler() { - return thisCap; + public IPhosphophylliteEnergyHandler energyHandler(Direction direction) { + return this; } private void setConnected(boolean newState) { @@ -49,14 +45,19 @@ private void setConnected(boolean newState) { } } - LazyOptional outputOptional = LazyOptional.empty(); - IPhosphophylliteEnergyHandler output; + @Nullable + CachedWrappedBlockCapability output = null;; public long distributePower(long toDistribute, boolean simulate) { - if (outputOptional.isPresent()) { - return Math.max(0, output.insertEnergy(toDistribute, simulate)); + if(output == null) { + return 0; } - return 0; + @Nullable + final var outputCap = output.getCapability(); + if (outputCap == null) { + return 0; + } + return Math.max(0, outputCap.insertEnergy(toDistribute, simulate)); } @Override @@ -96,20 +97,14 @@ public long maxEnergyStored() { @SuppressWarnings("DuplicatedCode") public void neighborChanged() { - outputOptional = LazyOptional.empty(); output = null; if (powerOutputDirection == null) { setConnected(false); return; } - final var outputCap = this.findEnergyCapability(powerOutputDirection); - setConnected(outputCap.isPresent()); - if (connected) { - outputOptional = outputCap; - //noinspection DataFlowIssue - output = outputOptional.orElse(null); - } + output = findEnergyCapability(powerOutputDirection); + setConnected(output.getCapability() != null); } @Override diff --git a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbineRotorBearingTile.java b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbineRotorBearingTile.java index cc9737fb..1696a38d 100644 --- a/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbineRotorBearingTile.java +++ b/src/main/java/net/roguelogix/biggerreactors/multiblocks/turbine/tiles/TurbineRotorBearingTile.java @@ -8,8 +8,6 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import net.roguelogix.biggerreactors.multiblocks.turbine.blocks.TurbineRotorBlade; import net.roguelogix.biggerreactors.multiblocks.turbine.blocks.TurbineRotorShaft; import net.roguelogix.phosphophyllite.Phosphophyllite; @@ -153,15 +151,6 @@ public void onAssemblyStateTransition(IValidatedMultiblock.AssemblyState oldStat sendFullUpdate = Phosphophyllite.tickNumber() + 10; } - @OnlyIn(Dist.CLIENT) - @Override - public AABB getRenderBoundingBox() { - if (AABB == null) { - return INFINITE_EXTENT_AABB; - } - return AABB; - } - static { Quartz.EVENT_BUS.addListener(TurbineRotorBearingTile::onQuartzStartup); } diff --git a/src/main/java/net/roguelogix/biggerreactors/registries/FluidTransitionRegistry.java b/src/main/java/net/roguelogix/biggerreactors/registries/FluidTransitionRegistry.java index 7b3fb4d6..0d17743d 100644 --- a/src/main/java/net/roguelogix/biggerreactors/registries/FluidTransitionRegistry.java +++ b/src/main/java/net/roguelogix/biggerreactors/registries/FluidTransitionRegistry.java @@ -5,7 +5,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.level.material.Fluid; -import net.minecraftforge.registries.ForgeRegistries; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.phosphophyllite.config.ConfigValue; import net.roguelogix.phosphophyllite.data.DatapackLoader; @@ -174,8 +173,8 @@ public static void loadRegistry() { } })); } else { - if (ForgeRegistries.FLUIDS.containsKey(transitionData.liquid)) { - Fluid fluid = ForgeRegistries.FLUIDS.getValue(transitionData.liquid); + if (BuiltInRegistries.FLUID.containsKey(transitionData.liquid)) { + Fluid fluid = BuiltInRegistries.FLUID.get(transitionData.liquid); liquids.add(fluid); } @@ -196,8 +195,8 @@ public static void loadRegistry() { } })); } else { - if (ForgeRegistries.FLUIDS.containsKey(transitionData.gas)) { - Fluid fluid = ForgeRegistries.FLUIDS.getValue(transitionData.gas); + if (BuiltInRegistries.FLUID.containsKey(transitionData.gas)) { + Fluid fluid = BuiltInRegistries.FLUID.get(transitionData.gas); gases.add(fluid); } @@ -212,13 +211,13 @@ public static void loadRegistry() { for (Fluid liquid : transition.liquids) { if (liquidTransitions.put(liquid, transition) != null) { - BiggerReactors.LOGGER.error("Duplicate transitions given for liquid fluid " + ForgeRegistries.FLUIDS.getKey(liquid).toString()); + BiggerReactors.LOGGER.error("Duplicate transitions given for liquid fluid " + BuiltInRegistries.FLUID.getKey(liquid).toString()); } } for (Fluid gas : transition.gases) { if (gasTransitions.put(gas, transition) != null) { - BiggerReactors.LOGGER.error("Duplicate transitions given for gas fluid " + ForgeRegistries.FLUIDS.getKey(gas).toString()); + BiggerReactors.LOGGER.error("Duplicate transitions given for gas fluid " + BuiltInRegistries.FLUID.getKey(gas).toString()); } } diff --git a/src/main/java/net/roguelogix/biggerreactors/registries/ReactorModeratorRegistry.java b/src/main/java/net/roguelogix/biggerreactors/registries/ReactorModeratorRegistry.java index e4ce915f..86bab906 100644 --- a/src/main/java/net/roguelogix/biggerreactors/registries/ReactorModeratorRegistry.java +++ b/src/main/java/net/roguelogix/biggerreactors/registries/ReactorModeratorRegistry.java @@ -13,11 +13,11 @@ import net.minecraft.world.item.BucketItem; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.material.Fluid; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.OnDatapackSyncEvent; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.fml.loading.FMLEnvironment; -import net.minecraftforge.registries.ForgeRegistries; +import net.neoforged.fml.loading.FMLEnvironment; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.OnDatapackSyncEvent; +import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent; +import net.neoforged.neoforge.network.handling.IPayloadContext; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.Config; import net.roguelogix.phosphophyllite.config.ConfigValue; @@ -161,13 +161,13 @@ public static void loadRegistry() { blockTagOptional.ifPresent(holders -> holders.forEach(blockHolder -> { var element = blockHolder.value(); registry.put(element, properties); - BiggerReactors.LOGGER.debug("Loaded moderator " + ForgeRegistries.BLOCKS.getKey(element)); + BiggerReactors.LOGGER.debug("Loaded moderator " + BuiltInRegistries.BLOCK.getKey(element)); })); } case registry -> { // cant check against air, because air is a valid thing to load - if (ForgeRegistries.BLOCKS.containsKey(moderatorData.location)) { - registry.put(ForgeRegistries.BLOCKS.getValue(moderatorData.location), properties); + if (BuiltInRegistries.BLOCK.containsKey(moderatorData.location)) { + registry.put(BuiltInRegistries.BLOCK.get(moderatorData.location), properties); BiggerReactors.LOGGER.debug("Loaded moderator " + moderatorData.location); } } @@ -177,13 +177,13 @@ public static void loadRegistry() { var element = fluidHolder.value(); Block elementBlock = element.defaultFluidState().createLegacyBlock().getBlock(); registry.put(elementBlock, properties); - BiggerReactors.LOGGER.debug("Loaded moderator " + ForgeRegistries.FLUIDS.getKey(element)); + BiggerReactors.LOGGER.debug("Loaded moderator " + BuiltInRegistries.FLUID.getKey(element)); })); } case fluid -> { // cant check against air, because air is a valid thing to load - if (ForgeRegistries.FLUIDS.containsKey(moderatorData.location)) { - Fluid fluid = ForgeRegistries.FLUIDS.getValue(moderatorData.location); + if (BuiltInRegistries.FLUID.containsKey(moderatorData.location)) { + Fluid fluid = BuiltInRegistries.FLUID.get(moderatorData.location); assert fluid != null; Block block = fluid.defaultFluidState().createLegacyBlock().getBlock(); registry.put(block, properties); @@ -197,15 +197,15 @@ public static void loadRegistry() { public static class Client { - private static final SimplePhosChannel CHANNEL = new SimplePhosChannel(new ResourceLocation(BiggerReactors.modid, "moderator_sync_channel"), "0", Client::readSync); + private static final SimplePhosChannel CHANNEL = new SimplePhosChannel(new ResourceLocation(BiggerReactors.modid, "moderator_sync_channel"), Client::readSync, null); private static final ObjectOpenHashSet moderatorBlocks = new ObjectOpenHashSet<>(); private static final Object2ObjectOpenHashMap moderatorProperties = new Object2ObjectOpenHashMap<>(); @OnModLoad private static void onModLoad() { - MinecraftForge.EVENT_BUS.addListener(Client::datapackEvent); + NeoForge.EVENT_BUS.addListener(Client::datapackEvent); if (FMLEnvironment.dist.isClient()) { - MinecraftForge.EVENT_BUS.addListener(Client::toolTipEvent); + NeoForge.EVENT_BUS.addListener(Client::toolTipEvent); } } @@ -225,7 +225,7 @@ private static PhosphophylliteCompound writeSync() { final var list = new ObjectArrayList(); final var propertiesList = new ObjectArrayList(); for (final var value : registry.entrySet()) { - final var location = ForgeRegistries.BLOCKS.getKey(value.getKey()); + final var location = BuiltInRegistries.BLOCK.getKey(value.getKey()); if (location == null) { continue; } @@ -244,7 +244,7 @@ private static PhosphophylliteCompound writeSync() { return compound; } - private static void readSync(PhosphophylliteCompound compound) { + private static void readSync(PhosphophylliteCompound compound, IPayloadContext context) { moderatorBlocks.clear(); //noinspection unchecked final var list = (List) compound.getList("list"); @@ -256,7 +256,7 @@ private static void readSync(PhosphophylliteCompound compound) { for (int i = 0; i < list.size(); i++) { var blockLocation = list.get(i); var properties = propertiesList.get(i); - final var block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockLocation)); + final var block = BuiltInRegistries.BLOCK.get(new ResourceLocation(blockLocation)); if (block == null) { return; } diff --git a/src/main/java/net/roguelogix/biggerreactors/registries/TurbineCoilRegistry.java b/src/main/java/net/roguelogix/biggerreactors/registries/TurbineCoilRegistry.java index 9e25bb07..3f653f2d 100644 --- a/src/main/java/net/roguelogix/biggerreactors/registries/TurbineCoilRegistry.java +++ b/src/main/java/net/roguelogix/biggerreactors/registries/TurbineCoilRegistry.java @@ -11,11 +11,11 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.item.BlockItem; import net.minecraft.world.level.block.Block; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.OnDatapackSyncEvent; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.fml.loading.FMLEnvironment; -import net.minecraftforge.registries.ForgeRegistries; +import net.neoforged.fml.loading.FMLEnvironment; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.OnDatapackSyncEvent; +import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent; +import net.neoforged.neoforge.network.handling.IPayloadContext; import net.roguelogix.biggerreactors.BiggerReactors; import net.roguelogix.biggerreactors.Config; import net.roguelogix.phosphophyllite.config.ConfigValue; @@ -94,12 +94,12 @@ public static void loadRegistry() { blockTagOptional.ifPresent(holders -> holders.forEach(blockHolder -> { var element = blockHolder.value(); registry.put(element, properties); - BiggerReactors.LOGGER.debug("Loaded coil " + ForgeRegistries.BLOCKS.getKey(element)); + BiggerReactors.LOGGER.debug("Loaded coil " + BuiltInRegistries.BLOCK.getKey(element)); })); } else { // cant check against air, because air is a valid thing to load - if (ForgeRegistries.BLOCKS.containsKey(coilData.location)) { - registry.put(ForgeRegistries.BLOCKS.getValue(coilData.location), properties); + if (BuiltInRegistries.BLOCK.containsKey(coilData.location)) { + registry.put(BuiltInRegistries.BLOCK.get(coilData.location), properties); BiggerReactors.LOGGER.debug("Loaded coil " + coilData.location); } } @@ -109,15 +109,15 @@ public static void loadRegistry() { public static class Client { - private static final SimplePhosChannel CHANNEL = new SimplePhosChannel(new ResourceLocation(BiggerReactors.modid, "coil_sync_channel"), "0", Client::readSync); + private static final SimplePhosChannel CHANNEL = new SimplePhosChannel(new ResourceLocation(BiggerReactors.modid, "coil_sync_channel"), Client::readSync, null); private static final ObjectOpenHashSet coilBlocks = new ObjectOpenHashSet<>(); private static final Object2ObjectOpenHashMap coilProperties = new Object2ObjectOpenHashMap<>(); @OnModLoad private static void onModLoad() { - MinecraftForge.EVENT_BUS.addListener(Client::datapackEvent); + NeoForge.EVENT_BUS.addListener(Client::datapackEvent); if (FMLEnvironment.dist.isClient()) { - MinecraftForge.EVENT_BUS.addListener(Client::toolTipEvent); + NeoForge.EVENT_BUS.addListener(Client::toolTipEvent); } } @@ -137,7 +137,7 @@ private static PhosphophylliteCompound writeSync() { final var list = new ObjectArrayList(); final var propertiesList = new ObjectArrayList(); for (final var value : registry.entrySet()) { - final var location = ForgeRegistries.BLOCKS.getKey(value.getKey()); + final var location = BuiltInRegistries.BLOCK.getKey(value.getKey()); if (location == null) { continue; } @@ -154,7 +154,7 @@ private static PhosphophylliteCompound writeSync() { return compound; } - private static void readSync(PhosphophylliteCompound compound) { + private static void readSync(PhosphophylliteCompound compound, IPayloadContext context) { coilBlocks.clear(); //noinspection unchecked final var list = (List) compound.getList("list"); @@ -166,7 +166,7 @@ private static void readSync(PhosphophylliteCompound compound) { for (int i = 0; i < list.size(); i++) { var value = list.get(i); var properties = propertiesList.get(i); - final var block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(value)); + final var block = BuiltInRegistries.BLOCK.get(new ResourceLocation(value)); if (block == null) { return; } diff --git a/src/main/java/net/roguelogix/biggerreactors/util/FluidTransitionTank.java b/src/main/java/net/roguelogix/biggerreactors/util/FluidTransitionTank.java index 70208aab..8054e4ae 100644 --- a/src/main/java/net/roguelogix/biggerreactors/util/FluidTransitionTank.java +++ b/src/main/java/net/roguelogix/biggerreactors/util/FluidTransitionTank.java @@ -1,12 +1,12 @@ package net.roguelogix.biggerreactors.util; import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; -import net.minecraftforge.common.util.INBTSerializable; -import net.minecraftforge.registries.ForgeRegistries; +import net.neoforged.neoforge.common.util.INBTSerializable; import net.roguelogix.biggerreactors.registries.FluidTransitionRegistry; import net.roguelogix.phosphophyllite.fluids.IPhosphophylliteFluidHandler; import net.roguelogix.phosphophyllite.util.HeatBody; @@ -231,9 +231,9 @@ public FluidTransitionRegistry.FluidTransition activeTransition() { public CompoundTag serializeNBT() { CompoundTag nbt = new CompoundTag(); if (inFluid != null) { - nbt.putString("inFluid", ForgeRegistries.FLUIDS.getKey(inFluid).toString()); + nbt.putString("inFluid", BuiltInRegistries.FLUID.getKey(inFluid).toString()); nbt.putLong("inAmount", inAmount); - nbt.putString("outFluid", ForgeRegistries.FLUIDS.getKey(outFluid).toString()); + nbt.putString("outFluid", BuiltInRegistries.FLUID.getKey(outFluid).toString()); nbt.putLong("outAmount", outAmount); } return nbt; @@ -245,8 +245,8 @@ public void deserializeNBT(CompoundTag nbt) { return; } ResourceLocation inFluidLocation = new ResourceLocation(nbt.getString("inFluid")); - if (ForgeRegistries.FLUIDS.containsKey(inFluidLocation)) { - Fluid newInFluid = ForgeRegistries.FLUIDS.getValue(inFluidLocation); + if (BuiltInRegistries.FLUID.containsKey(inFluidLocation)) { + Fluid newInFluid = BuiltInRegistries.FLUID.get(inFluidLocation); if (newInFluid == null) { return; } @@ -262,8 +262,8 @@ public void deserializeNBT(CompoundTag nbt) { List outFluidList = (condenser ? newTransition.liquids : newTransition.gases); Fluid newOutFluid = null; ResourceLocation outFluidLocation = new ResourceLocation(nbt.getString("outFluid")); - if (ForgeRegistries.FLUIDS.containsKey(outFluidLocation)) { - Fluid oldOutFluid = ForgeRegistries.FLUIDS.getValue(outFluidLocation); + if (BuiltInRegistries.FLUID.containsKey(outFluidLocation)) { + Fluid oldOutFluid = BuiltInRegistries.FLUID.get(outFluidLocation); if (outFluidList.contains(oldOutFluid)) { newOutFluid = oldOutFluid; } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 5321a912..feaf9f50 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -8,7 +8,7 @@ modId="biggerreactors" version="${version}" displayName="Bigger Reactors" displayURL="https://biggerseries.net/" -logoFile="BiggerReactors.png" +logoFile="biggerreactors.png" credits="ErogeneousBeef for the original Big Reactors mod, that this is spiritually (and semi-literally) derived from" authors="RogueLogix, gizmocodes, Ridanisaurus" description=''' @@ -20,26 +20,26 @@ Official continuation of Big Reactors ''' [[dependencies.biggerreactors]] - modId="forge" - mandatory=true + modId="neoforge" + required=true versionRange="[${neo_version},)" ordering="NONE" side="BOTH" [[dependencies.biggerreactors]] modId="minecraft" - mandatory=true + required=true versionRange="[${minecraft_version}]" ordering="NONE" side="BOTH" [[dependencies.biggerreactors]] modId="phosphophyllite" - mandatory=true + required=true versionRange="${phos_version_range}" ordering="NONE" side="BOTH" [[dependencies.biggerreactors]] modId="quartz" - mandatory=true + required=true versionRange="${quartz_version_range}" ordering="NONE" side="BOTH" diff --git a/src/main/resources/BiggerReactors.png b/src/main/resources/biggerreactors.png similarity index 100% rename from src/main/resources/BiggerReactors.png rename to src/main/resources/biggerreactors.png