diff --git a/.github/runtime-test-config/random_complement.cfg b/.github/runtime-test-config/random_complement.cfg new file mode 100644 index 00000000..4fc99b51 --- /dev/null +++ b/.github/runtime-test-config/random_complement.cfg @@ -0,0 +1,111 @@ +# Configuration file + +general { + # Enable additional item information prompts + B:ExTooltip=true + + ae2 { + # Sets the texture index used for the crafting item slot + # Min: 0 + # Max: 6 + I:CraftingSlotTextureIndex=1 + + # Enable the whole AE ecosystem integration + B:Enable=false + + # Disable the Build permission check for AE2's security station + B:SecurityCache=true + + # Make the grid always think it's full of energy + B:debugEnergy=false + + # Drag item from JEI into the search box to automatically enter the name + B:dragJeiItemToSearchBox=true + + # Allow multiple pattern to synthesize the same product + # May have potential performance implications; consider disabling if not needed. + B:enableBranchCraft=true + + # Enable miss craft feature + B:enableMissCraft=true + + # Use the new Patten Terminal Gui + # Closing will cause all patterns created while enabled to become invalid. + B:newPattenGui=true + } + + ic2 { + # The additional energy storage provided by each Energy Storage Upgrade + I:energyStorageEnergy=10000 + + # The increased energy consumption caused by each Overclocker Upgrade + D:overclockerEnergy=1.6 + + # The reduced processing time effected by each Overclocker Upgrade + D:overclockerTime=0.7 + } + + lazyae { + # Fixes related to the lazy ae feature may occasionally introduce errors; disabling it can prevent such issues. + B:EnableRepair=true + } + + te5 { + # Set the efficiency of the Fuel Catalyzer, which defaults to 15 + I:FuelCatalyzer=15 + + # Whether to enable energy consumption boost, just like the original upgrade state + B:FuelCatalyzerQuantityChanges=true + + # Whether to enable energy consumption boost, just like the original upgrade state + B:IncreasedEnergyConsumption=false + + # The maximum chance of modifying an item to be reused is 100 + B:SecondaryProbability=true + + # Prevent the Thermal Expansion Cyclic Assembler from operating when the output slot contains items to avoid potential bugs + B:SequentialFabricatorMixin=true + } + + ftbu { + # Change the name of the nbtedit command of FTB + B:ModifyCmdEditNBT=false + } + + tf5 { + # When the offhand has a red map and the player is crouching, cancel the clear setting + B:RedDiagramOfTheDeputy=true + } + + botania { + # Allow the use of sparks on Botanical Brewery + B:BrewerySparkSupport=false + + # Fix some bugs. If there is a problem as a result, it should be closed + B:BugFix=true + + # Allow flor geradora to directly link to the mana pool + B:FlowerLinkPool=false + + # Allow the use of sparks on Runic Altar + B:RuneAltarSparkSupport=false + + # If false, Spark Support will not take effect + B:SparkSupport=false + } + + cofhcohe { + # Modify the number of upgrades that can be placed in slots + # Min: 1 + # Max: 64 + I:SocketLimitModified=1 + } + + nee { + # Whether to enable NEE compatibility for ae2exttable. + B:ae2e=true + } + +} + + diff --git a/gradle/scripts/dependencies.gradle b/gradle/scripts/dependencies.gradle index 0bcef3e5..168d8dd2 100644 --- a/gradle/scripts/dependencies.gradle +++ b/gradle/scripts/dependencies.gradle @@ -30,6 +30,10 @@ repositories { name = 'Modrinth' url = 'https://api.modrinth.com/maven' } + maven { + name = 'jitpack' + url = 'https://jitpack.io' + } maven { name = "GTNH Maven" url = uri("https://nexus.gtnewhorizons.com/repository/public/") @@ -107,16 +111,10 @@ dependencies { modImplementation 'curse.maven:the-one-probe-245211:2667280' modCompileOnly 'curse.maven:FTB-Library-237167:2985811' modCompileOnly 'curse.maven:FTBU-237102:3157548' - modImplementation 'curse.maven:ae2-extended-life-570458:6302098' - modCompileOnly 'curse.maven:better-meteorite-1264853:6525827' - modImplementation 'curse.maven:ae2fluidcraft-rework-unofficial-1404390:7742544' - modCompileOnly('curse.maven:MekanismEnergistics-1027681:5775101') { - accessTransformers.configure(it) { - config = project.file('accesstransformers/mekanism-energistics.cfg') - } - } - modCompileOnly 'curse.maven:nae2-884359:5380800' - modImplementation 'curse.maven:CodeChickenLib-242818:2779848' + modImplementation 'com.github.FormlessDragon:AppliedCompatibility:v1.0.1:dev' + modImplementation 'com.github.FormlessDragon:Applied-Energistics-2-Supergiant:v1.1.0:dev' + modCompileOnly 'com.github.FormlessDragon:Applied-Mekanistics:v1.2.1:dev' + modImplementation 'curse.maven:codechicken-lib-cre-1328922:6898525' modImplementation 'curse.maven:wanionlib-253043:4623135' modCompileOnly 'curse.maven:avaritia-1-1x-unofficial-1165010:7939693' modCompileOnly 'curse.maven:eternal-singularity-253077:2922583' @@ -148,7 +146,6 @@ dependencies { modCompileOnly 'curse.maven:more-electric-tools-366298:3491973' modCompileOnly 'curse.maven:extrabotany-299086:3112313' modCompileOnly 'curse.maven:libnine-322344:3073839' - modCompileOnly 'curse.maven:lazy-ae2-322347:3254160' modCompileOnly 'curse.maven:better-chat-363860:3048407' modCompileOnly 'curse.maven:lunatriuscore-225605:2489549' modCompileOnly 'curse.maven:immersive-petroleum-268250:3382321' @@ -165,7 +162,7 @@ dependencies { modCompileOnly 'curse.maven:guide-api-228832:2645992' modCompileOnly 'curse.maven:patchouli-306770:3162874' modCompileOnly 'curse.maven:libvulpes-236541:3801015' - modCompileOnly 'curse.maven:random-complement-1198138:9009274' + modCompileOnly 'curse.maven:random-complement-1198138:8828633' modCompileOnly 'curse.maven:actually-additions-228404:3117927' modCompileOnly 'curse.maven:artemislib-313590:2741812' modImplementation 'curse.maven:brandons-core-231382:3408276' @@ -212,7 +209,6 @@ dependencies { config = project.file('accesstransformers/astral-sorcery.cfg') } } - modCompileOnly 'curse.maven:ae2-crafting-tree-legacy-1121489:5814089' modCompileOnly 'curse.maven:applecore-224472:2969118' modCompileOnly 'curse.maven:spice-of-life-carrot-edition-277616:2959847' modCompileOnly 'curse.maven:just-enough-resources-jer-240630:4440935' @@ -228,7 +224,6 @@ dependencies { modCompileOnly 'curse.maven:athenaeum-284350:3063275' modCompileOnly 'curse.maven:better-builders-wands-238403:2691084' modCompileOnly 'curse.maven:better-loading-screen-229302:6771073' - modCompileOnly 'curse.maven:betterer-p2p-943734:7231397' modCompileOnly 'curse.maven:celeritas-extra-1451214:9182637' modCompileOnly 'curse.maven:electroblobs-wizardry-265642:8320066' modCompileOnly 'curse.maven:ender-core-ceu-1530852:8734025' @@ -252,7 +247,6 @@ dependencies { modCompileOnly 'curse.maven:more-flux-storage-1492345:7805126' modCompileOnly 'curse.maven:more-overlays-243478:2745657' modCompileOnly 'curse.maven:mrcrayfish-furniture-mod-55438:3865259' - modCompileOnly 'curse.maven:not-enough-energistics-515565:6325382' modCompileOnly 'curse.maven:omlib-254334:3466259' modCompileOnly 'curse.maven:openmodularturrets-224663:3466431' modCompileOnly 'curse.maven:packagedauto-308380:7329681' @@ -348,4 +342,5 @@ dependencies { config = project.file('accesstransformers/thermal-foundation.cfg') } } + modCompileOnly "curse.maven:mouse-tweaks-unofficial-461660:5876158" } diff --git a/gradle/scripts/extra.gradle b/gradle/scripts/extra.gradle index 319363cf..2e406cae 100644 --- a/gradle/scripts/extra.gradle +++ b/gradle/scripts/extra.gradle @@ -140,6 +140,201 @@ tasks.register('installRuntimeTestClient', JavaExec) { } } +def runtimeTestConfigDir = layout.projectDirectory.dir('.github/runtime-test-config') +def runtimeTestServerConfigDir = layout.buildDirectory.dir('runtime-test/server/config') +def runtimeTestInstanceTemplate = layout.buildDirectory.file( + 'runtime-test/cleanroom-instance-template.zip' +) +def runtimeTestTemplateRequiredEntries = [ + 'instance.cfg', + 'mmc-pack.json', + 'patches/net.minecraft.json', + 'patches/net.minecraftforge.json', + 'patches/org.lwjgl3.json' +] + +def runtimeTestConfigFiles = providers.provider { + def dir = runtimeTestConfigDir.asFile + if (!dir.isDirectory()) { + return [] + } + def files = dir.listFiles({ candidate -> + candidate.isFile() && candidate.name.endsWith('.cfg') + } as FileFilter) + if (files == null) { + return [] + } + return files.toList().sort { left, right -> left.name <=> right.name } +} + +def downloadRuntimeTestTemplate = { String downloadUrl, File target -> + def partial = new File(target.parentFile, "${target.name}.part") + def lastError = null + for (int attempt = 1; attempt <= 3; attempt++) { + try { + java.net.HttpURLConnection connection = + java.net.URI.create(downloadUrl).toURL().openConnection() + connection.setConnectTimeout(30000) + connection.setReadTimeout(120000) + connection.setInstanceFollowRedirects(true) + connection.setRequestProperty('User-Agent', 'novaeng-runtime-test') + def status = connection.getResponseCode() + if (status != 200) { + throw new GradleException("HTTP ${status}") + } + partial.withOutputStream { output -> + connection.getInputStream().withCloseable { input -> + input.transferTo(output) + } + } + connection.disconnect() + return partial + } catch (Exception error) { + lastError = error + partial.delete() + logger.lifecycle( + "[RuntimeTest] 模板下载第 ${attempt} 次失败:${error.message}" + ) + if (attempt < 3) { + Thread.sleep(2000L * attempt) + } + } + } + throw new GradleException( + "无法下载 Cleanroom 模板 ${downloadUrl}:${lastError}" + ) +} + +def stageRuntimeTestServerConfig = tasks.register('stageRuntimeTestServerConfig', Sync) { + group = 'unimined' + description = '把 .github/runtime-test-config 下的 cfg 放到运行时测试服务端的 config 目录。' + from(runtimeTestConfigDir) { + include '*.cfg' + } + into(runtimeTestServerConfigDir) + duplicatesStrategy = DuplicatesStrategy.FAIL +} + +def injectRuntimeTestClientConfig = tasks.register('injectRuntimeTestClientConfig') { + group = 'unimined' + description = '把运行时测试配置注入 Cleanroom MMC 模板 zip,解压后即成为客户端的 config。' + inputs.files(runtimeTestConfigFiles) + inputs.property('cleanroomVersion', cleanroomVersion) + inputs.property('requiredEntries', runtimeTestTemplateRequiredEntries) + outputs.upToDateWhen { false } + doLast { + def configFiles = runtimeTestConfigFiles.get() + if (configFiles.isEmpty()) { + logger.lifecycle( + '[RuntimeTest] .github/runtime-test-config 下没有 cfg,跳过客户端配置注入。' + ) + return + } + + def templateFile = runtimeTestInstanceTemplate.get().asFile + if (!templateFile.isFile()) { + templateFile.parentFile.mkdirs() + def templateUrl = 'https://github.com/CleanroomMC/Cleanroom/releases/download/' + + "${cleanroomVersion}/cleanroom-${cleanroomVersion}.zip" + logger.lifecycle("[RuntimeTest] 本地缺少模板,开始下载:${templateUrl}") + def downloaded = downloadRuntimeTestTemplate(templateUrl, templateFile) + java.nio.file.Files.move( + downloaded.toPath(), + templateFile.toPath(), + java.nio.file.StandardCopyOption.REPLACE_EXISTING + ) + } + + def additions = new LinkedHashMap() + configFiles.each { configFile -> + additions.put("minecraft/config/${configFile.name}".toString(), configFile) + } + + def rewritten = new File(templateFile.parentFile, "${templateFile.name}.injected") + rewritten.delete() + def written = new LinkedHashSet() + new java.util.zip.ZipFile(templateFile).withCloseable { sourceZip -> + def rawOutput = new FileOutputStream(rewritten) + try { + new java.util.zip.ZipOutputStream( + new BufferedOutputStream(rawOutput) + ).withCloseable { targetZip -> + sourceZip.entries().each { entry -> + if (additions.containsKey(entry.name)) { + // 模板自带同名配置:丢弃,稍后写入我们的版本。 + return + } + def copied = new java.util.zip.ZipEntry(entry.name) + copied.time = entry.time + if (entry.comment != null) { + copied.comment = entry.comment + } + if (entry.extra != null) { + copied.extra = entry.extra + } + targetZip.putNextEntry(copied) + if (!entry.isDirectory()) { + sourceZip.getInputStream(entry).withCloseable { input -> + input.transferTo(targetZip) + } + } + targetZip.closeEntry() + written.add(entry.name) + } + additions.each { entryName, configFile -> + def added = new java.util.zip.ZipEntry(entryName) + added.time = configFile.lastModified() + targetZip.putNextEntry(added) + configFile.withInputStream { input -> + input.transferTo(targetZip) + } + targetZip.closeEntry() + written.add(entryName) + } + } + } finally { + rawOutput.close() + } + } + + runtimeTestTemplateRequiredEntries.each { requiredEntry -> + if (!written.contains(requiredEntry)) { + rewritten.delete() + throw new GradleException( + "Cleanroom 模板缺少 ${requiredEntry},已放弃写入注入后的模板。" + ) + } + } + additions.keySet().each { injectedEntry -> + if (!written.contains(injectedEntry)) { + rewritten.delete() + throw new GradleException("配置注入失败:${injectedEntry} 未写入模板。") + } + } + if (rewritten.length() <= 0L) { + rewritten.delete() + throw new GradleException('注入后的模板为空,已放弃覆盖原模板。') + } + + java.nio.file.Files.move( + rewritten.toPath(), + templateFile.toPath(), + java.nio.file.StandardCopyOption.REPLACE_EXISTING + ) + logger.lifecycle( + "[RuntimeTest] 已向客户端模板注入 ${additions.size()} 个配置:" + + additions.keySet().join(', ') + ) + } +} + +tasks.named('stageRuntimeTestMods') { + dependsOn stageRuntimeTestServerConfig +} +tasks.named('installRuntimeTestClient') { + dependsOn injectRuntimeTestClientConfig +} + tasks.register('printRuntimeTestPaths') { doLast { println "runtimeTestModsDir=${runtimeTestModsDir.get().asFile.absolutePath}" diff --git a/src/main/java/github/kasuminova/novaeng/NovaEngCoreConfig.java b/src/main/java/github/kasuminova/novaeng/NovaEngCoreConfig.java index d0f81f2c..07aa4db7 100644 --- a/src/main/java/github/kasuminova/novaeng/NovaEngCoreConfig.java +++ b/src/main/java/github/kasuminova/novaeng/NovaEngCoreConfig.java @@ -81,7 +81,7 @@ public static class Performance { @Config.Comment("Avoid replaying MMCE comparator notifications for an already committed mutation.") public boolean coalesceMmceNotifications = true; @Config.RequiresMcRestart - @Config.Comment("Reuse supported AE interface insertion preparation within an MMCE output operation.") + @Config.Comment("Let an MMCE item output bus insert its products straight into the ME network of a target that exposes AE2 grid storage but no item handler of its own. The AE item key of each stack is reused for the rest of that output operation.") public boolean batchAe2Outputs = true; @Config.RequiresMcRestart @Config.Comment("Release oversized idle VintageFix scratch after two low-use 64-task windows. Actinium mesh scratch is controlled in actinium-options.json.") @@ -691,11 +691,6 @@ public static class Server { @Config.Comment("Walk the known structure starts of a map generator from a cached array instead of probing its open hash map on every position query.") public boolean optimizeStructureLookup = true; - @Config.RequiresMcRestart - @Config.Name("OptimizeAe2ItemListCapacity") - @Config.Comment("Start an AE2 item list with the capacity of the largest list seen so far instead of growing it from the default capacity, which removes a chain of rehashes from every item list built for a crafting job.") - public boolean optimizeAe2ItemListCapacity = true; - @Config.RequiresMcRestart @Config.Name("OptimizeBiomeIdLookup") @Config.Comment("Resolve a biome from a copied id table. A registry keeps its ids in a Guava HashBiMap, so asking it for a biome by id boxes the id and walks a hash bucket, and Forge's wrapper never fills the vanilla array that would answer that in one step; a world generator asks for a biome by id for every chunk it decorates. The table is dropped whenever the registry rewrites its id mapping, including the renumbering done when a world is loaded. Applies on both sides.") diff --git a/src/main/java/github/kasuminova/novaeng/NovaEngineeringCore.java b/src/main/java/github/kasuminova/novaeng/NovaEngineeringCore.java index 645565c0..c1fe9356 100644 --- a/src/main/java/github/kasuminova/novaeng/NovaEngineeringCore.java +++ b/src/main/java/github/kasuminova/novaeng/NovaEngineeringCore.java @@ -8,7 +8,6 @@ import github.kasuminova.novaeng.common.integration.DECoreBindingIndex; import github.kasuminova.novaeng.common.machine.MMAltar; import github.kasuminova.novaeng.common.network.ParallelNetworkManager; -import github.kasuminova.novaeng.common.network.PktAutoCraftConfirm; import github.kasuminova.novaeng.common.network.PktCellDriveStatusUpdate; import github.kasuminova.novaeng.common.network.PktECalculatorGUIData; import github.kasuminova.novaeng.common.network.PktEFabricatorGUIAction; @@ -34,7 +33,6 @@ import github.kasuminova.novaeng.common.performance.MeteorWriteBatch; import github.kasuminova.novaeng.common.performance.RecipeContextPool; import github.kasuminova.novaeng.common.profiler.SPacketProfiler; -import github.kasuminova.novaeng.common.util.AutoCraftingQueue; import github.kasuminova.novaeng.common.util.MixinDecisions; import github.kasuminova.novaeng.common.util.NovaBiomeIdCache; import github.kasuminova.novaeng.novaeng_core.Tags; @@ -59,8 +57,7 @@ @Mod(modid = Tags.MOD_ID, name = Tags.MOD_NAME, version = Tags.VERSION, dependencies = "required-after:modularmachinery@[2.3.0,);" + "required-after:theoneprobe;" + - "required-after:appliedenergistics2@[v0.56.4,);" + - "required-after:ae2fc@[2.6.3-r,);" + + "required-after:ae2@[1.0.17,);" + "required-after-client:lumenized@[1.0.2,);" + "after:astralsorcery" , @@ -126,7 +123,6 @@ public void preInit(FMLPreInitializationEvent event) { NET_CHANNEL.registerMessage(PktCProfilerReply.class, PktCProfilerReply.class, start++, Side.SERVER); NET_CHANNEL.registerMessage(PktGeocentricDrillControl.class, PktGeocentricDrillControl.class, start++, Side.SERVER); NET_CHANNEL.registerMessage(PktItemDisplay.class, PktItemDisplay.class, start++, Side.SERVER); - NET_CHANNEL.registerMessage(PktAutoCraftConfirm.class, PktAutoCraftConfirm.class, start++, Side.SERVER); proxy.preInit(); @@ -183,7 +179,6 @@ public void onServerStopping(FMLServerStoppingEvent event) { // that outlived its world's unload would keep that world - and every chunk and // entity in it - for the rest of the process. Nothing survives a server stop. HyperNetCaches.clear(); - AutoCraftingQueue.clearAll(); if (Mods.BM2.isPresent()) { MMAltar.clearCache(); } diff --git a/src/main/java/github/kasuminova/novaeng/client/ClientProxy.java b/src/main/java/github/kasuminova/novaeng/client/ClientProxy.java index bb8743e6..0fb3300c 100644 --- a/src/main/java/github/kasuminova/novaeng/client/ClientProxy.java +++ b/src/main/java/github/kasuminova/novaeng/client/ClientProxy.java @@ -1,8 +1,5 @@ package github.kasuminova.novaeng.client; -import appeng.api.features.IWirelessTermHandler; -import appeng.helpers.WirelessTerminalGuiObject; -import baubles.api.BaublesApi; import github.kasuminova.mmce.client.renderer.MachineControllerRenderer; import github.kasuminova.novaeng.client.book.BookTransformerAppendModifiers; import github.kasuminova.novaeng.client.gui.GuiECalculatorController; @@ -14,7 +11,6 @@ import github.kasuminova.novaeng.client.gui.GuiHyperNetTerminal; import github.kasuminova.novaeng.client.gui.GuiMachineAssemblyTool; import github.kasuminova.novaeng.client.gui.GuiModularServerAssembler; -import github.kasuminova.novaeng.client.gui.GuiNEWCraftConfirm; import github.kasuminova.novaeng.client.gui.GuiSingularityCore; import github.kasuminova.novaeng.client.handler.BlockAngelRendererHandler; import github.kasuminova.novaeng.client.handler.ClientEventHandler; @@ -305,14 +301,6 @@ public Object getClientGuiElement(final int id, final EntityPlayer player, final case EFABRICATOR_PATTERN_BUS -> new GuiEFabricatorPatternBus((EFabricatorPatternBus) present, player); case GEOCENTRIC_DRILL_CONTROLLER -> new GuiGeocentricDrill((GeocentricDrillController) present, player); case ECALCULATOR_CONTROLLER -> new GuiECalculatorController((ECalculatorController) present, player); - case AUTO_CRAFTGUI -> { - var stack = y == 1 ? BaublesApi.getBaublesHandler(player).getStackInSlot(x) - : player.inventory.getStackInSlot(x); - if (stack.getItem() instanceof IWirelessTermHandler wt) { - yield new GuiNEWCraftConfirm(player.inventory, - new WirelessTerminalGuiObject(wt, stack, player, player.world, x, y, Integer.MIN_VALUE)); - } else yield null; - } case MACHINE_ASSEMBLY_TOOL -> new GuiMachineAssemblyTool(player); }; } diff --git a/src/main/java/github/kasuminova/novaeng/client/gui/GuiEFabricatorPatternBus.java b/src/main/java/github/kasuminova/novaeng/client/gui/GuiEFabricatorPatternBus.java index 841469ae..a335eb42 100644 --- a/src/main/java/github/kasuminova/novaeng/client/gui/GuiEFabricatorPatternBus.java +++ b/src/main/java/github/kasuminova/novaeng/client/gui/GuiEFabricatorPatternBus.java @@ -1,6 +1,6 @@ package github.kasuminova.novaeng.client.gui; -import appeng.client.gui.AEBaseGui; +import ae2.client.gui.AEBaseGui; import github.kasuminova.novaeng.common.container.ContainerEFabricatorPatternBus; import github.kasuminova.novaeng.common.tile.ecotech.efabricator.EFabricatorPatternBus; import github.kasuminova.novaeng.novaeng_core.Tags; @@ -9,13 +9,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; -public class GuiEFabricatorPatternBus extends AEBaseGui { +public class GuiEFabricatorPatternBus extends AEBaseGui { public static final ResourceLocation GUI_TEXTURE = new ResourceLocation(Tags.MOD_ID, "textures/gui/efabricator_pattern_bus.png"); public GuiEFabricatorPatternBus(final EFabricatorPatternBus owner, final EntityPlayer player) { - super(new ContainerEFabricatorPatternBus(owner, player)); + super(new ContainerEFabricatorPatternBus(owner, player), player.inventory); this.xSize = 230; this.ySize = 232; this.guiLeft = (this.width - this.xSize) / 2; @@ -29,7 +29,8 @@ public void drawFG(final int offsetX, final int offsetY, final int mouseX, final } @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, + final float partialTicks) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(GUI_TEXTURE); this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); diff --git a/src/main/java/github/kasuminova/novaeng/client/gui/GuiNEWCraftConfirm.java b/src/main/java/github/kasuminova/novaeng/client/gui/GuiNEWCraftConfirm.java deleted file mode 100644 index 8cd29e8d..00000000 --- a/src/main/java/github/kasuminova/novaeng/client/gui/GuiNEWCraftConfirm.java +++ /dev/null @@ -1,65 +0,0 @@ -package github.kasuminova.novaeng.client.gui; - -import appeng.client.gui.implementations.GuiCraftConfirm; -import appeng.helpers.WirelessTerminalGuiObject; -import github.kasuminova.novaeng.NovaEngineeringCore; -import github.kasuminova.novaeng.client.util.RCGuiCraftConfirm; -import github.kasuminova.novaeng.common.network.PktAutoCraftConfirm; -import github.kasuminova.novaeng.mixin.ae2.AccessorGuiCraftConfirm; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.entity.player.InventoryPlayer; - -import java.io.IOException; - -public class GuiNEWCraftConfirm extends GuiCraftConfirm implements RCGuiCraftConfirm { - private final AccessorGuiCraftConfirm utils = (AccessorGuiCraftConfirm) this; - private GuiButton cancel; - private GuiButton start; - - public GuiNEWCraftConfirm(final InventoryPlayer inventory, final WirelessTerminalGuiObject terminal) { - super(inventory, terminal); - } - - public GuiButton getCancel() { - return this.cancel; - } - - public void setCancel(final GuiButton cancel) { - this.cancel = cancel; - } - - public GuiButton getStart() { - return this.start; - } - - public void setStart(final GuiButton start) { - this.start = start; - } - - public AccessorGuiCraftConfirm getUtils() { - return this.utils; - } - - @Override - public void initGui() { - super.initGui(); - this.cancel = this.utils.getCancel(); - this.start = this.utils.getStart(); - } - - @Override - protected void actionPerformed(final GuiButton button) throws IOException { - if (button == this.cancel) { - if (isShiftKeyDown()) { - this.rc$addMissBookmark(); - } - NovaEngineeringCore.NET_CHANNEL.sendToServer(new PktAutoCraftConfirm()); - this.mc.player.closeScreenAndDropStack(); - return; - } - super.actionPerformed(button); - if (button == this.start) { - this.mc.player.closeScreenAndDropStack(); - } - } -} diff --git a/src/main/java/github/kasuminova/novaeng/client/gui/widget/ecalculator/MonitorPanel.java b/src/main/java/github/kasuminova/novaeng/client/gui/widget/ecalculator/MonitorPanel.java index a4e29e64..b972d07a 100644 --- a/src/main/java/github/kasuminova/novaeng/client/gui/widget/ecalculator/MonitorPanel.java +++ b/src/main/java/github/kasuminova/novaeng/client/gui/widget/ecalculator/MonitorPanel.java @@ -1,6 +1,6 @@ package github.kasuminova.novaeng.client.gui.widget.ecalculator; -import appeng.api.storage.data.IAEItemStack; +import ae2.api.stacks.GenericStack; import github.kasuminova.mmce.client.gui.util.MousePos; import github.kasuminova.mmce.client.gui.util.RenderPos; import github.kasuminova.mmce.client.gui.util.RenderSize; @@ -285,11 +285,11 @@ public Task(final ECalculatorData.ECPUData ecpuData) { setWidthHeight(WIDTH, HEIGHT); setUseScissor(false); setMargin(2, 0, 2, 0); - final IAEItemStack crafting = ecpuData.crafting(); + final GenericStack crafting = ecpuData.crafting(); this.usedMemory = ecpuData.usedMemory(); this.parallelismPreSecond = ecpuData.parallelismPreSecond(); this.cpuUsage = ecpuData.cpuUsagePerSecond(); - addWidget(new SlotItemVirtualJEI(crafting.createItemStack()).setAbsXY(ITEM_OFFSET_X, ITEM_OFFSET_Y)); + addWidget(new SlotItemVirtualJEI(crafting.what().wrapForDisplayOrFilter()).setAbsXY(ITEM_OFFSET_X, ITEM_OFFSET_Y)); } @Override diff --git a/src/main/java/github/kasuminova/novaeng/client/gui/widget/efabricator/PatternPanel.java b/src/main/java/github/kasuminova/novaeng/client/gui/widget/efabricator/PatternPanel.java index 4e7ea2e3..e23b56ca 100644 --- a/src/main/java/github/kasuminova/novaeng/client/gui/widget/efabricator/PatternPanel.java +++ b/src/main/java/github/kasuminova/novaeng/client/gui/widget/efabricator/PatternPanel.java @@ -1,7 +1,8 @@ package github.kasuminova.novaeng.client.gui.widget.efabricator; -import appeng.api.networking.crafting.ICraftingPatternDetails; -import appeng.api.storage.data.IAEItemStack; +import ae2.api.crafting.IPatternDetails; +import ae2.api.stacks.AEKey; +import ae2.api.stacks.GenericStack; import github.kasuminova.mmce.client.gui.util.MousePos; import github.kasuminova.mmce.client.gui.util.RenderFunction; import github.kasuminova.mmce.client.gui.util.RenderPos; @@ -69,8 +70,8 @@ public PatternPanel() { addWidget(internal); } - private static String getClearColorName(final IAEItemStack input) { - return COLOR_CODE_PATTERN.matcher(input.getDefinition().getDisplayName()).replaceAll(""); + private static String getClearColorName(final AEKey input) { + return COLOR_CODE_PATTERN.matcher(input.getDisplayName().getFormattedText()).replaceAll(""); } @Override @@ -100,6 +101,7 @@ public boolean onGuiEvent(final GuiEvent event) { if (patternSet.isEmpty()) { continue; } + for (final EFabricatorPatternData.PatternData pattern : patternSet) { final BlockPos pos = pattern.pos(); final ItemStack patternStack = pattern.pattern(); @@ -113,7 +115,7 @@ public boolean onGuiEvent(final GuiEvent event) { continue; } - final Int2ObjectMap slotMap = patterns.computeIfAbsent(pos, key -> new Int2ObjectLinkedOpenHashMap<>()); + final Int2ObjectMap slotMap = patterns.computeIfAbsent(pos, _ -> new Int2ObjectLinkedOpenHashMap<>()); PatternSlot slot = slotMap.get(slotID); if (slot == null) { slot = new PatternSlot(pos, slotID); @@ -131,20 +133,24 @@ public boolean onGuiEvent(final GuiEvent event) { for (Int2ObjectMap slotPattern : patterns.values()) { for (final PatternSlot slot : slotPattern.values()) { - ICraftingPatternDetails details = slot.getDetails(); + IPatternDetails details = slot.getDetails(); if (details == null) { continue; } - IAEItemStack[] inputs = details.getCondensedInputs(); - IAEItemStack primaryOutput = details.getPrimaryOutput(); + IPatternDetails.IInput[] inputs = details.getInputs(); + GenericStack primaryOutput = details.getPrimaryOutput(); - for (final IAEItemStack input : inputs) { - String displayName = getClearColorName(input); + for (final IPatternDetails.IInput input : inputs) { + GenericStack[] possibleInputs = input.possibleInputs(); + if (possibleInputs.length == 0) { + continue; + } + String displayName = getClearColorName(possibleInputs[0].what()); inputSearchStorage.put(displayName.toLowerCase(), slot); } if (primaryOutput != null) { - String displayName = getClearColorName(primaryOutput); + String displayName = getClearColorName(primaryOutput.what()); outputSearchStorage.put(displayName.toLowerCase(), slot); } } @@ -163,20 +169,24 @@ public boolean onGuiEvent(final GuiEvent event) { if (changed == null) { continue; } - ICraftingPatternDetails details = changed.getDetails(); + IPatternDetails details = changed.getDetails(); if (details == null) { continue; } - IAEItemStack[] inputs = details.getCondensedInputs(); - IAEItemStack primaryOutput = details.getPrimaryOutput(); + IPatternDetails.IInput[] inputs = details.getInputs(); + GenericStack primaryOutput = details.getPrimaryOutput(); - for (final IAEItemStack input : inputs) { - String displayName = getClearColorName(input); + for (final IPatternDetails.IInput input : inputs) { + GenericStack[] possibleInputs = input.possibleInputs(); + if (possibleInputs.length == 0) { + continue; + } + String displayName = getClearColorName(possibleInputs[0].what()); inputSearchStorage.put(displayName.toLowerCase(), changed); } if (primaryOutput != null) { - String displayName = getClearColorName(primaryOutput); + String displayName = getClearColorName(primaryOutput.what()); outputSearchStorage.put(displayName.toLowerCase(), changed); } } diff --git a/src/main/java/github/kasuminova/novaeng/client/gui/widget/efabricator/PatternSlot.java b/src/main/java/github/kasuminova/novaeng/client/gui/widget/efabricator/PatternSlot.java index ffd12ce5..72c8df34 100644 --- a/src/main/java/github/kasuminova/novaeng/client/gui/widget/efabricator/PatternSlot.java +++ b/src/main/java/github/kasuminova/novaeng/client/gui/widget/efabricator/PatternSlot.java @@ -1,9 +1,9 @@ package github.kasuminova.novaeng.client.gui.widget.efabricator; -import appeng.api.implementations.ICraftingPatternItem; -import appeng.api.networking.crafting.ICraftingPatternDetails; -import appeng.api.storage.data.IAEItemStack; -import appeng.util.item.AEItemStack; +import ae2.api.crafting.IPatternDetails; +import ae2.api.crafting.PatternDetailsHelper; +import ae2.api.stacks.AEItemKey; +import ae2.api.stacks.GenericStack; import github.kasuminova.mmce.client.gui.util.MousePos; import github.kasuminova.mmce.client.gui.util.RenderPos; import github.kasuminova.mmce.client.gui.util.RenderSize; @@ -24,12 +24,12 @@ public class PatternSlot extends SlotItemVirtual { - private static final WeakHashMap> DETAILS_CACHE = new WeakHashMap<>(); + private static final WeakHashMap> DETAILS_CACHE = new WeakHashMap<>(); private final BlockPos slotOwnerPos; private final int slotIndex; - private ICraftingPatternDetails details = null; + private IPatternDetails details = null; public PatternSlot(final BlockPos slotOwnerPos, final int slotIndex) { this.slotOwnerPos = slotOwnerPos; @@ -41,8 +41,13 @@ public PatternSlot(final BlockPos slotOwnerPos, final int slotIndex) { public void render(final WidgetGui widgetGui, final RenderSize renderSize, final RenderPos renderPos, final MousePos mousePos) { final ItemStack prevStack = stackInSlot; if (details != null) { - IAEItemStack primaryOutput = details.getPrimaryOutput(); - stackInSlot = primaryOutput.getCachedItemStack(primaryOutput.getStackSize()); + GenericStack primaryOutput = details.getPrimaryOutput(); + if (primaryOutput.what() instanceof AEItemKey itemKey) { + final int amount = (int) Math.min(Integer.MAX_VALUE, primaryOutput.amount()); + stackInSlot = itemKey.toStack(amount); + } else { + stackInSlot = GenericStack.wrapInItemStack(primaryOutput); + } } super.render(widgetGui, renderSize, renderPos, mousePos); stackInSlot = prevStack; @@ -72,24 +77,15 @@ public boolean equals(final Object obj) { @Override public SlotItemVirtual setStackInSlot(final ItemStack stackInSlot) { - if (stackInSlot.getItem() instanceof ICraftingPatternItem patternItem) { - AEItemStack key = AEItemStack.fromItemStack(stackInSlot); - if (key == null) { - this.details = null; - return super.setStackInSlot(stackInSlot); - } - - if (DETAILS_CACHE.containsKey(key)) { - WeakReference ref = DETAILS_CACHE.get(key); - if (ref != null) { - this.details = ref.get(); - } else { - this.details = patternItem.getPatternForItem(stackInSlot, Minecraft.getMinecraft().world); - DETAILS_CACHE.put(key.copy(), new WeakReference<>(this.details)); - } + AEItemKey key = AEItemKey.of(stackInSlot); + if (key != null) { + WeakReference ref = DETAILS_CACHE.get(key); + IPatternDetails cachedDetails = ref == null ? null : ref.get(); + if (cachedDetails != null) { + this.details = cachedDetails; } else { - this.details = patternItem.getPatternForItem(stackInSlot, Minecraft.getMinecraft().world); - DETAILS_CACHE.put(key.copy(), new WeakReference<>(this.details)); + this.details = PatternDetailsHelper.decodePattern(stackInSlot, Minecraft.getMinecraft().world); + DETAILS_CACHE.put(key, new WeakReference<>(this.details)); } } else { this.details = null; @@ -99,7 +95,7 @@ public SlotItemVirtual setStackInSlot(final ItemStack stackInSlot) { } @Nullable - public ICraftingPatternDetails getDetails() { + public IPatternDetails getDetails() { return details; } diff --git a/src/main/java/github/kasuminova/novaeng/client/gui/widget/vanilla/GuiButtonImageExt.java b/src/main/java/github/kasuminova/novaeng/client/gui/widget/vanilla/GuiButtonImageExt.java deleted file mode 100644 index 2069f38b..00000000 --- a/src/main/java/github/kasuminova/novaeng/client/gui/widget/vanilla/GuiButtonImageExt.java +++ /dev/null @@ -1,62 +0,0 @@ -package github.kasuminova.novaeng.client.gui.widget.vanilla; - -import appeng.client.gui.widgets.ITooltip; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButtonImage; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.NotNull; - -public class GuiButtonImageExt extends GuiButtonImage implements ITooltip { - - private String message = ""; - - public GuiButtonImageExt(final int buttonId, final int xIn, final int yIn, final int widthIn, final int heightIn, final int textureOffestX, final int textureOffestY, final int p_i47392_8_, final ResourceLocation resource) { - super(buttonId, xIn, yIn, widthIn, heightIn, textureOffestX, textureOffestY, p_i47392_8_, resource); - } - - @Override - public void drawButton(final @NotNull Minecraft mc, final int mouseX, final int mouseY, final float partialTicks) { - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); - GlStateManager.color(1f, 1f, 1f, 1f); - super.drawButton(mc, mouseX, mouseY, partialTicks); - } - - @Override - public String getMessage() { - return message; - } - - public GuiButtonImageExt setMessage(final String message) { - this.message = message; - return this; - } - - @Override - public int xPos() { - return x; - } - - @Override - public int yPos() { - return y; - } - - @Override - public int getWidth() { - return width; - } - - @Override - public int getHeight() { - return height; - } - - @Override - public boolean isVisible() { - return visible; - } - -} diff --git a/src/main/java/github/kasuminova/novaeng/client/handler/BlockAngelRendererHandler.java b/src/main/java/github/kasuminova/novaeng/client/handler/BlockAngelRendererHandler.java index 4c7ba74b..84bd2699 100644 --- a/src/main/java/github/kasuminova/novaeng/client/handler/BlockAngelRendererHandler.java +++ b/src/main/java/github/kasuminova/novaeng/client/handler/BlockAngelRendererHandler.java @@ -6,12 +6,11 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -19,7 +18,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.lwjgl.opengl.GL11; -@SuppressWarnings("MethodMayBeStatic") public class BlockAngelRendererHandler { public static final BlockAngelRendererHandler INSTANCE = new BlockAngelRendererHandler(); @@ -27,41 +25,46 @@ private BlockAngelRendererHandler() { } protected static void renderAngelBlockToWorld(final BlockPos renderPos) { + Minecraft mc = Minecraft.getMinecraft(); Entity view = getViewEntity(); - float partialTicks = Minecraft.getMinecraft().getRenderPartialTicks(); + float partialTicks = mc.getRenderPartialTicks(); double tx = view.lastTickPosX + ((view.posX - view.lastTickPosX) * partialTicks); double ty = view.lastTickPosY + ((view.posY - view.lastTickPosY) * partialTicks); double tz = view.lastTickPosZ + ((view.posZ - view.lastTickPosZ) * partialTicks); - GlStateManager.translate(-tx, -ty, -tz); - GlStateManager.color(1F, 1F, 1F, 0.5F); - GlStateManager.disableDepth(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_DST_COLOR); - - BlockRendererDispatcher brd = Minecraft.getMinecraft().getBlockRendererDispatcher(); - Tessellator tes = Tessellator.getInstance(); - BufferBuilder vb = tes.getBuffer(); - VertexFormat blockFormat = DefaultVertexFormats.BLOCK; GlStateManager.pushMatrix(); - GlStateManager.translate(renderPos.getX(), renderPos.getY(), renderPos.getZ()); - GlStateManager.translate(0.125, 0.125, 0.125); - GlStateManager.scale(0.75, 0.75, 0.75); + try { + GlStateManager.translate(-tx, -ty, -tz); + GlStateManager.translate(renderPos.getX(), renderPos.getY(), renderPos.getZ()); + GlStateManager.translate(0.125D, 0.125D, 0.125D); + GlStateManager.scale(0.75F, 0.75F, 0.75F); + + GlStateManager.color(1F, 1F, 1F, 0.5F); + GlStateManager.disableDepth(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_DST_COLOR); - vb.begin(GL11.GL_QUADS, blockFormat); - brd.renderBlock( - BlockAngel.INSTANCE.getDefaultState(), - BlockPos.ORIGIN, - Minecraft.getMinecraft().world, - vb - ); - tes.draw(); + mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - GlStateManager.popMatrix(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.enableDepth(); - GlStateManager.color(1F, 1F, 1F, 1F); + Tessellator tess = Tessellator.getInstance(); + BufferBuilder buf = tess.getBuffer(); + buf.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + + mc.getBlockRendererDispatcher().renderBlock( + BlockAngel.INSTANCE.getDefaultState(), + BlockPos.ORIGIN, + mc.world, + buf + ); + tess.draw(); + } finally { + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.disableBlend(); + GlStateManager.enableDepth(); + GlStateManager.color(1F, 1F, 1F, 1F); + GlStateManager.popMatrix(); + } } protected static Entity getViewEntity() { diff --git a/src/main/java/github/kasuminova/novaeng/client/util/RCGuiCraftConfirm.java b/src/main/java/github/kasuminova/novaeng/client/util/RCGuiCraftConfirm.java deleted file mode 100644 index 18398de2..00000000 --- a/src/main/java/github/kasuminova/novaeng/client/util/RCGuiCraftConfirm.java +++ /dev/null @@ -1,8 +0,0 @@ -package github.kasuminova.novaeng.client.util; - -public interface RCGuiCraftConfirm { - - default void rc$addMissBookmark() { - - } -} diff --git a/src/main/java/github/kasuminova/novaeng/common/CommonProxy.java b/src/main/java/github/kasuminova/novaeng/common/CommonProxy.java index 485a7f52..46386d39 100644 --- a/src/main/java/github/kasuminova/novaeng/common/CommonProxy.java +++ b/src/main/java/github/kasuminova/novaeng/common/CommonProxy.java @@ -1,9 +1,5 @@ package github.kasuminova.novaeng.common; -import appeng.api.AEApi; -import baubles.api.BaublesApi; -import com.circulation.random_complement.common.util.MEHandler; -import github.kasuminova.mmce.common.integration.ModIntegrationAE2; import github.kasuminova.novaeng.NovaEngCoreConfig; import github.kasuminova.novaeng.common.adapter.RecipeAdapterExtended; import github.kasuminova.novaeng.common.container.ContainerECalculatorController; @@ -14,10 +10,8 @@ import github.kasuminova.novaeng.common.container.ContainerGeocentricDrill; import github.kasuminova.novaeng.common.container.ContainerHyperNetTerminal; import github.kasuminova.novaeng.common.container.ContainerModularServerAssembler; -import github.kasuminova.novaeng.common.container.ContainerNEWCraftConfirm; import github.kasuminova.novaeng.common.container.ContainerSingularityCore; import github.kasuminova.novaeng.common.enchantment.MagicBreaking; -import github.kasuminova.novaeng.common.estorage.EStorageCellHandler; import github.kasuminova.novaeng.common.handler.ECalculatorEventHandler; import github.kasuminova.novaeng.common.handler.EFabricatorEventHandler; import github.kasuminova.novaeng.common.handler.EStorageEventHandler; @@ -69,7 +63,6 @@ import github.kasuminova.novaeng.common.trait.Register; import github.kasuminova.novaeng.common.util.MachineCoolants; import github.kasuminova.novaeng.common.util.MixinDecisions; -import github.kasuminova.novaeng.mixin.ae2.AccessorCellRegistry; import github.kasuminova.novaeng.novaeng_core.Tags; import hellfirepvp.modularmachinery.ModularMachinery; import hellfirepvp.modularmachinery.common.base.Mods; @@ -94,7 +87,7 @@ public CommonProxy() { } private static boolean hasDeniedAccess(final EFabricatorController controller, final EntityPlayer player) { - return controller != null && controller.getChannel() != null && ModIntegrationAE2.securityCheck(player, controller.getChannel().getProxy()); + return controller != null && controller.getChannel() != null && !controller.getChannel().getMainNode().isActive(); } public void setColor(final String ore, final int color) { @@ -172,9 +165,6 @@ public void init() { RegistryMachineSpecial.registrySpecialMachine(SmallOreDrill.INSTANCE); } } - if (Mods.AE2.isPresent()) { - ((AccessorCellRegistry) AEApi.instance().registries().cell()).getHandlers().addFirst(EStorageCellHandler.INSTANCE); - } Register.INSTANCE.registerModifiers(); } @@ -223,14 +213,9 @@ public Object getServerGuiElement(final int id, final EntityPlayer player, final new ContainerGeocentricDrill((GeocentricDrillController) present, player); case ECALCULATOR_CONTROLLER -> { final var controller = (ECalculatorController) present; - yield controller != null && controller.getChannel() != null && ModIntegrationAE2.securityCheck(player, controller.getChannel().getProxy()) + yield controller != null && controller.getChannel() != null && !controller.getChannel().getMainNode().isActive() ? null : new ContainerECalculatorController(controller, player); } - case AUTO_CRAFTGUI -> { - final var stack = y == 1 ? BaublesApi.getBaublesHandler(player).getStackInSlot(x) : player.inventory.getStackInSlot(x); - final var terminal = MEHandler.getTerminalGuiObject(stack, player, x, y); - yield terminal == null ? null : new ContainerNEWCraftConfirm(player.inventory, terminal); - } case MACHINE_ASSEMBLY_TOOL -> null; }; } @@ -245,7 +230,7 @@ public enum GuiType { ESTORAGE_CONTROLLER(EStorageController.class), SINGULARITY_CORE(github.kasuminova.novaeng.common.tile.machine.SingularityCore.class), EFABRICATOR_CONTROLLER(EFabricatorController.class), EFABRICATOR_PATTERN_SEARCH(EFabricatorController.class), EFABRICATOR_PATTERN_BUS(EFabricatorPatternBus.class), GEOCENTRIC_DRILL_CONTROLLER(GeocentricDrillController.class), - ECALCULATOR_CONTROLLER(ECalculatorController.class), AUTO_CRAFTGUI(null), MACHINE_ASSEMBLY_TOOL(null); + ECALCULATOR_CONTROLLER(ECalculatorController.class), MACHINE_ASSEMBLY_TOOL(null); public static final GuiType[] VALUES = values(); public final Class requiredTileEntity; diff --git a/src/main/java/github/kasuminova/novaeng/common/block/ecotech/ecalculator/BlockECalculatorCellDrive.java b/src/main/java/github/kasuminova/novaeng/common/block/ecotech/ecalculator/BlockECalculatorCellDrive.java index 33356a48..a3a3a14b 100644 --- a/src/main/java/github/kasuminova/novaeng/common/block/ecotech/ecalculator/BlockECalculatorCellDrive.java +++ b/src/main/java/github/kasuminova/novaeng/common/block/ecotech/ecalculator/BlockECalculatorCellDrive.java @@ -1,6 +1,6 @@ package github.kasuminova.novaeng.common.block.ecotech.ecalculator; -import appeng.tile.inventory.AppEngInternalInventory; +import ae2.util.inv.AppEngInternalInventory; import github.kasuminova.novaeng.common.block.ecotech.ecalculator.prop.DriveLink; import github.kasuminova.novaeng.common.block.ecotech.ecalculator.prop.DriveStatus; import github.kasuminova.novaeng.common.block.ecotech.ecalculator.prop.DriveStorageLevel; @@ -81,11 +81,11 @@ public void breakBlock(World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockStat TileEntity te = worldIn.getTileEntity(pos); if (te instanceof ECalculatorCellDrive drive) { AppEngInternalInventory inv = drive.getDriveInv(); - for (int i = 0; i < inv.getSlots(); i++) { + for (int i = 0; i < inv.size(); i++) { ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty()) { spawnAsEntity(worldIn, pos, stack); - inv.setStackInSlot(i, ItemStack.EMPTY); + inv.setItemDirect(i, ItemStack.EMPTY); } } } diff --git a/src/main/java/github/kasuminova/novaeng/common/block/ecotech/ecalculator/BlockECalculatorThreadCore.java b/src/main/java/github/kasuminova/novaeng/common/block/ecotech/ecalculator/BlockECalculatorThreadCore.java index ca9722e5..b0f7cd8e 100644 --- a/src/main/java/github/kasuminova/novaeng/common/block/ecotech/ecalculator/BlockECalculatorThreadCore.java +++ b/src/main/java/github/kasuminova/novaeng/common/block/ecotech/ecalculator/BlockECalculatorThreadCore.java @@ -1,6 +1,6 @@ package github.kasuminova.novaeng.common.block.ecotech.ecalculator; -import appeng.me.cluster.implementations.CraftingCPUCluster; +import ae2.me.cluster.implementations.CraftingCPUCluster; import github.kasuminova.mmce.common.util.Sides; import github.kasuminova.novaeng.NovaEngineeringCore; import github.kasuminova.novaeng.common.block.ecotech.ecalculator.prop.Levels; diff --git a/src/main/java/github/kasuminova/novaeng/common/block/ecotech/efabricator/BlockEFabricatorPatternBus.java b/src/main/java/github/kasuminova/novaeng/common/block/ecotech/efabricator/BlockEFabricatorPatternBus.java index 93925f13..37dbdb3f 100644 --- a/src/main/java/github/kasuminova/novaeng/common/block/ecotech/efabricator/BlockEFabricatorPatternBus.java +++ b/src/main/java/github/kasuminova/novaeng/common/block/ecotech/efabricator/BlockEFabricatorPatternBus.java @@ -1,6 +1,6 @@ package github.kasuminova.novaeng.common.block.ecotech.efabricator; -import appeng.tile.inventory.AppEngInternalInventory; +import ae2.util.inv.AppEngInternalInventory; import github.kasuminova.novaeng.common.CommonProxy; import github.kasuminova.novaeng.common.block.prop.FacingProp; import github.kasuminova.novaeng.common.core.CreativeTabNovaEng; @@ -76,11 +76,11 @@ public void breakBlock(World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockStat TileEntity te = worldIn.getTileEntity(pos); if (te instanceof EFabricatorPatternBus terminal) { AppEngInternalInventory inv = terminal.getPatterns(); - for (int i = 0; i < inv.getSlots(); i++) { + for (int i = 0; i < inv.size(); i++) { ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty()) { spawnAsEntity(worldIn, pos, stack); - inv.setStackInSlot(i, ItemStack.EMPTY); + inv.setItemDirect(i, ItemStack.EMPTY); } } } diff --git a/src/main/java/github/kasuminova/novaeng/common/block/ecotech/estorage/BlockEStorageCellDrive.java b/src/main/java/github/kasuminova/novaeng/common/block/ecotech/estorage/BlockEStorageCellDrive.java index 38558445..7ce39bb7 100644 --- a/src/main/java/github/kasuminova/novaeng/common/block/ecotech/estorage/BlockEStorageCellDrive.java +++ b/src/main/java/github/kasuminova/novaeng/common/block/ecotech/estorage/BlockEStorageCellDrive.java @@ -1,17 +1,15 @@ package github.kasuminova.novaeng.common.block.ecotech.estorage; -import appeng.api.AEApi; -import appeng.api.storage.ICellInventoryHandler; -import appeng.api.storage.IStorageChannel; -import appeng.api.storage.data.IAEStack; -import appeng.tile.inventory.AppEngCellInventory; +import ae2.api.storage.StorageCells; +import ae2.api.storage.cells.StorageCell; +import ae2.api.storage.cells.StorageCellStatistics; +import ae2.util.inv.AppEngCellInventory; import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStatus; import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStorageCapacity; import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStorageLevel; import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStorageType; import github.kasuminova.novaeng.common.block.prop.FacingProp; import github.kasuminova.novaeng.common.core.CreativeTabNovaEng; -import github.kasuminova.novaeng.common.estorage.EStorageCellHandler; import github.kasuminova.novaeng.common.item.estorage.EStorageCell; import github.kasuminova.novaeng.common.tile.ecotech.estorage.EStorageCellDrive; import github.kasuminova.novaeng.novaeng_core.Tags; @@ -35,7 +33,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.Collection; import java.util.List; @SuppressWarnings("deprecation") @@ -78,11 +75,11 @@ public void breakBlock(World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockStat TileEntity te = worldIn.getTileEntity(pos); if (te instanceof EStorageCellDrive drive) { AppEngCellInventory inv = drive.getDriveInv(); - for (int i = 0; i < inv.getSlots(); i++) { + for (int i = 0; i < inv.size(); i++) { ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty()) { spawnAsEntity(worldIn, pos, stack); - inv.setStackInSlot(i, ItemStack.EMPTY); + inv.setItemDirect(i, ItemStack.EMPTY); } } } @@ -97,7 +94,6 @@ public int getLightValue(@Nonnull final IBlockState state) { @Nonnull @Override - @SuppressWarnings("rawtypes") public IBlockState getActualState(@Nonnull final IBlockState state, @Nonnull final IBlockAccess world, @Nonnull final BlockPos pos) { TileEntity te = world.getTileEntity(pos); if (!(te instanceof EStorageCellDrive drive)) { @@ -109,31 +105,18 @@ public IBlockState getActualState(@Nonnull final IBlockState state, @Nonnull fin return state; } - EStorageCellHandler handler = EStorageCellHandler.getHandler(stack); - if (handler == null) { + StorageCell cellInventory = StorageCells.getCellInventory(stack, null); + if (!(cellInventory instanceof StorageCellStatistics)) { return state; } - EStorageCell cell = (EStorageCell) stack.getItem(); + EStorageCell cell = (EStorageCell) stack.getItem(); DriveStorageLevel level = cell.getLevel(); DriveStorageType type = EStorageCellDrive.getCellType(cell); if (type == null) { return state; } - final Collection>> storageChannels = AEApi.instance().storage().storageChannels(); - ICellInventoryHandler cellInventory = null; - for (final IStorageChannel> channel : storageChannels) { - cellInventory = handler.getCellInventory(stack, drive, channel); - if (cellInventory != null) { - break; - } - } - - if (cellInventory == null) { - return state; - } - return state.withProperty(DriveStorageLevel.STORAGE_LEVEL, level) .withProperty(DriveStorageType.STORAGE_TYPE, type) .withProperty(DriveStatus.STATUS, drive.isWriting() ? DriveStatus.RUN : DriveStatus.IDLE) diff --git a/src/main/java/github/kasuminova/novaeng/common/command/CommandBuilder.java b/src/main/java/github/kasuminova/novaeng/common/command/CommandBuilder.java index e93c0492..f017f7cd 100644 --- a/src/main/java/github/kasuminova/novaeng/common/command/CommandBuilder.java +++ b/src/main/java/github/kasuminova/novaeng/common/command/CommandBuilder.java @@ -29,7 +29,7 @@ private CommandBuilder() { } @Override - public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, String @NotNull [] args) { + public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, @NotNull String[] args) { if (args.length >= 2) { switch (args[0]) { case "tick" -> isTickWork = args[1].equals("true"); diff --git a/src/main/java/github/kasuminova/novaeng/common/container/ContainerEFabricatorPatternBus.java b/src/main/java/github/kasuminova/novaeng/common/container/ContainerEFabricatorPatternBus.java index 30d44869..351c405c 100644 --- a/src/main/java/github/kasuminova/novaeng/common/container/ContainerEFabricatorPatternBus.java +++ b/src/main/java/github/kasuminova/novaeng/common/container/ContainerEFabricatorPatternBus.java @@ -1,8 +1,8 @@ package github.kasuminova.novaeng.common.container; -import appeng.container.AEBaseContainer; -import appeng.container.slot.SlotRestrictedInput; -import appeng.tile.inventory.AppEngInternalInventory; +import ae2.container.AEBaseContainer; +import ae2.container.slot.RestrictedInputSlot; +import ae2.util.inv.AppEngInternalInventory; import github.kasuminova.novaeng.common.tile.ecotech.efabricator.EFabricatorPatternBus; import lombok.Getter; import net.minecraft.entity.player.EntityPlayer; @@ -19,13 +19,13 @@ public ContainerEFabricatorPatternBus(final EFabricatorPatternBus owner, final E super(player.inventory, owner); this.owner = owner; - this.bindPlayerInventory(getInventoryPlayer(), 27, 150); + this.addPlayerInventorySlots(27, 150); AppEngInternalInventory patterns = owner.getPatterns(); for (int row = 0; row < ROWS; row++) { for (int col = 0; col < COLS; col++) { - this.addSlotToContainer(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, patterns, - (row * COLS) + col, 8 + (col * 18), 28 + (row * 18), getInventoryPlayer())); + this.addSlotToContainer(new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.ENCODED_PATTERN, patterns, + (row * COLS) + col, 8 + (col * 18), 28 + (row * 18))); } } } diff --git a/src/main/java/github/kasuminova/novaeng/common/container/ContainerNEWCraftConfirm.java b/src/main/java/github/kasuminova/novaeng/common/container/ContainerNEWCraftConfirm.java deleted file mode 100644 index 98e51138..00000000 --- a/src/main/java/github/kasuminova/novaeng/common/container/ContainerNEWCraftConfirm.java +++ /dev/null @@ -1,53 +0,0 @@ -package github.kasuminova.novaeng.common.container; - -import appeng.api.networking.crafting.ICraftingCPU; -import appeng.api.networking.crafting.ICraftingGrid; -import appeng.api.networking.security.IActionHost; -import appeng.container.implementations.ContainerCraftConfirm; -import appeng.helpers.WirelessTerminalGuiObject; -import appeng.me.helpers.PlayerSource; -import github.kasuminova.novaeng.common.util.AutoCraftingQueue; -import github.kasuminova.novaeng.mixin.ae2.AccessorContainerCraftConfirm; -import github.kasuminova.novaeng.mixin.ae2.AccessorCraftingCPURecord; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; - -public class ContainerNEWCraftConfirm extends ContainerCraftConfirm { - - public ContainerNEWCraftConfirm(final InventoryPlayer inventory, final WirelessTerminalGuiObject terminal) { - super(inventory, terminal); - } - - @Override - public boolean canInteractWith(final EntityPlayer player) { - return true; - } - - @Override - public void startJob() { - if (!((Object) this instanceof AccessorContainerCraftConfirm accessor)) { - return; - } - if (this.getTarget() instanceof IActionHost host && host.getActionableNode() != null) { - final var grid = host.getActionableNode().getGrid(); - if (grid != null && accessor.getResult() != null && !this.isSimulation()) { - final ICraftingGrid crafting = grid.getCache(ICraftingGrid.class); - ICraftingCPU cpu = null; - if (this.getSelectedCpu() != -1) { - final Object record = accessor.getCpus().get(this.getSelectedCpu()); - if (record instanceof AccessorCraftingCPURecord recordAccessor) { - cpu = recordAccessor.getCpu(); - } - } - crafting.submitJob(accessor.getResult(), null, cpu, true, - new PlayerSource(this.getPlayerInv().player, host)); - } - } - final EntityPlayerMP player = (EntityPlayerMP) this.getPlayerInv().player; - final AutoCraftingQueue queue = AutoCraftingQueue.getQueue(player); - if (queue != null && !queue.executionQueue(player)) { - player.closeContainer(); - } - } -} diff --git a/src/main/java/github/kasuminova/novaeng/common/container/data/ECalculatorData.java b/src/main/java/github/kasuminova/novaeng/common/container/data/ECalculatorData.java index f8dd61af..716b87db 100644 --- a/src/main/java/github/kasuminova/novaeng/common/container/data/ECalculatorData.java +++ b/src/main/java/github/kasuminova/novaeng/common/container/data/ECalculatorData.java @@ -1,19 +1,19 @@ package github.kasuminova.novaeng.common.container.data; -import appeng.api.networking.crafting.ICraftingCPU; -import appeng.api.networking.crafting.ICraftingGrid; -import appeng.api.storage.data.IAEItemStack; -import appeng.me.GridAccessException; -import appeng.util.item.AEItemStack; +import ae2.api.networking.crafting.ICraftingCPU; +import ae2.api.networking.crafting.CraftingJobStatus; +import ae2.api.networking.crafting.ICraftingService; +import ae2.api.networking.IGridNode; +import ae2.api.stacks.GenericStack; import github.kasuminova.novaeng.common.block.ecotech.ecalculator.prop.Levels; import github.kasuminova.novaeng.common.ecalculator.ECPUCluster; import github.kasuminova.novaeng.common.tile.ecotech.ecalculator.ECalculatorController; import github.kasuminova.novaeng.common.tile.ecotech.ecalculator.ECalculatorMEChannel; import github.kasuminova.novaeng.common.tile.ecotech.ecalculator.ECalculatorThreadCore; import io.netty.buffer.ByteBuf; +import net.minecraft.network.PacketBuffer; import javax.annotation.Nonnull; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -50,26 +50,33 @@ private static List getEcpuData(final ECalculatorController controller return ecpuData; } - try { - final ICraftingGrid crafting = channel.getProxy().getCrafting(); - final List threadCores = controller.getThreadCores(); - for (ICraftingCPU cpu : crafting.getCpus()) { - if (!(cpu instanceof ECPUCluster ecpu)) { - continue; - } - - ECalculatorThreadCore core = ecpu.novaeng_ec$getController(); - if (core == null || !threadCores.contains(core)) { - continue; - } - - ecpuData.add(new ECPUData( - cpu.getFinalOutput(), cpu.getAvailableStorage(), ecpu.novaeng_ec$getUsedExtraStorage(), - ecpu.novaeng_ec$getParallelismRecorder().usedTimeAvg(), - ecpu.novaeng_ec$getTimeRecorder().usedTimeAvg() - )); + final IGridNode node = channel.getActionableNode(); + if (node == null || node.grid() == null) { + return ecpuData; + } + + final ICraftingService crafting = node.grid().getCraftingService(); + final List threadCores = controller.getThreadCores(); + for (ICraftingCPU cpu : crafting.getCpus()) { + if (!(cpu instanceof ECPUCluster ecpu)) { + continue; + } + + final ECalculatorThreadCore core = ecpu.novaeng_ec$getController(); + if (core == null || !threadCores.contains(core)) { + continue; + } + + final CraftingJobStatus status = cpu.getJobStatus(); + if (status == null || status.crafting() == null) { + continue; } - } catch (GridAccessException ignored) { + + ecpuData.add(new ECPUData( + status.crafting(), cpu.getAvailableStorage(), ecpu.novaeng_ec$getUsedExtraStorage(), + ecpu.novaeng_ec$getParallelismRecorder().usedTimeAvg(), + ecpu.novaeng_ec$getTimeRecorder().usedTimeAvg() + )); } return ecpuData; @@ -93,9 +100,10 @@ public static ECalculatorData read(final ByteBuf buf) { } byte ecpuSize = buf.readByte(); List ecpuList = new ArrayList<>(); + PacketBuffer packetBuffer = new PacketBuffer(buf); if (ecpuSize > 0) { for (byte i = 0; i < ecpuSize; i++) { - ecpuList.add(new ECPUData(AEItemStack.fromPacket(buf), buf.readLong(), buf.readLong(), buf.readInt(), buf.readInt())); + ecpuList.add(new ECPUData(GenericStack.readBuffer(packetBuffer), buf.readLong(), buf.readLong(), buf.readInt(), buf.readInt())); } } int cpuUsagePerSecond = buf.readInt(); @@ -115,11 +123,9 @@ public void write(final ByteBuf buf) { buf.writeByte(threadCore.maxHyperThreads); }); buf.writeByte(ecpuList.size()); + PacketBuffer packetBuffer = new PacketBuffer(buf); ecpuList.forEach(ecpu -> { - try { - ecpu.crafting.writeToPacket(buf); - } catch (IOException ignored) { - } + GenericStack.writeBuffer(ecpu.crafting, packetBuffer); buf.writeLong(ecpu.usedMemory); buf.writeLong(ecpu.usedExtraMemory); buf.writeInt(ecpu.parallelismPreSecond); @@ -128,7 +134,7 @@ public void write(final ByteBuf buf) { buf.writeInt(cpuUsagePerSecond); } - public record ECPUData(IAEItemStack crafting, long usedMemory, long usedExtraMemory, int parallelismPreSecond, + public record ECPUData(GenericStack crafting, long usedMemory, long usedExtraMemory, int parallelismPreSecond, int cpuUsagePerSecond) { } diff --git a/src/main/java/github/kasuminova/novaeng/common/container/data/EFabricatorPatternData.java b/src/main/java/github/kasuminova/novaeng/common/container/data/EFabricatorPatternData.java index 6df11571..50102e95 100644 --- a/src/main/java/github/kasuminova/novaeng/common/container/data/EFabricatorPatternData.java +++ b/src/main/java/github/kasuminova/novaeng/common/container/data/EFabricatorPatternData.java @@ -1,6 +1,6 @@ package github.kasuminova.novaeng.common.container.data; -import appeng.tile.inventory.AppEngInternalInventory; +import ae2.util.inv.AppEngInternalInventory; import github.kasuminova.novaeng.common.tile.ecotech.efabricator.EFabricatorController; import github.kasuminova.novaeng.common.tile.ecotech.efabricator.EFabricatorPatternBus; import github.kasuminova.novaeng.common.util.BlockPos2ValueMap; @@ -21,7 +21,7 @@ public static EFabricatorPatternData ofFull(final EFabricatorController efContro for (final EFabricatorPatternBus patternBus : efController.getPatternBuses()) { final AppEngInternalInventory patternInv = patternBus.getPatterns(); final BlockPos pos = patternBus.getPos(); - for (int i = 0; i < patternInv.getSlots(); i++) { + for (int i = 0; i < patternInv.size(); i++) { final ItemStack patternStack = patternInv.getStackInSlot(i); if (!patternStack.isEmpty()) { patterns.computeIfAbsent(pos, key -> new ObjectLinkedOpenHashSet<>()) diff --git a/src/main/java/github/kasuminova/novaeng/common/container/data/EStorageCellData.java b/src/main/java/github/kasuminova/novaeng/common/container/data/EStorageCellData.java index b95eee0b..cfb5de00 100644 --- a/src/main/java/github/kasuminova/novaeng/common/container/data/EStorageCellData.java +++ b/src/main/java/github/kasuminova/novaeng/common/container/data/EStorageCellData.java @@ -1,13 +1,11 @@ package github.kasuminova.novaeng.common.container.data; -import appeng.api.storage.ICellInventory; -import appeng.api.storage.ICellInventoryHandler; -import appeng.api.storage.data.IAEItemStack; -import appeng.tile.inventory.AppEngCellInventory; +import ae2.api.storage.StorageCells; +import ae2.api.storage.cells.StorageCell; +import ae2.api.storage.cells.StorageCellStatistics; +import ae2.util.inv.AppEngCellInventory; import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStorageLevel; import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStorageType; -import github.kasuminova.novaeng.common.estorage.ECellDriveWatcher; -import github.kasuminova.novaeng.common.estorage.EStorageCellHandler; import github.kasuminova.novaeng.common.item.estorage.EStorageCell; import github.kasuminova.novaeng.common.tile.ecotech.estorage.EStorageCellDrive; import net.minecraft.item.ItemStack; @@ -20,31 +18,17 @@ public static EStorageCellData from(final EStorageCellDrive drive) { if (stack.isEmpty()) { return null; } - EStorageCellHandler handler = EStorageCellHandler.getHandler(stack); - if (handler == null) { + StorageCell cellInventory = StorageCells.getCellInventory(stack, null); + if (!(cellInventory instanceof StorageCellStatistics statistics)) { return null; } - EStorageCell cell = (EStorageCell) stack.getItem(); + EStorageCell cell = (EStorageCell) stack.getItem(); DriveStorageType type = EStorageCellDrive.getCellType(cell); if (type == null) { return null; } DriveStorageLevel level = cell.getLevel(); - ECellDriveWatcher watcher = drive.getWatcher(); - if (watcher == null) { - return null; - } - ICellInventoryHandler cellInventory = (ICellInventoryHandler) watcher.getInternal(); - if (cellInventory == null) { - return null; - } - ICellInventory cellInv = cellInventory.getCellInv(); - if (cellInv == null) { - return null; - } - long storedTypes = cellInv.getStoredItemTypes(); - long usedBytes = cellInv.getUsedBytes(); - return new EStorageCellData(type, level, (int) storedTypes, usedBytes); + return new EStorageCellData(type, level, (int) statistics.getStoredTypes(), statistics.getUsedBytes()); } } diff --git a/src/main/java/github/kasuminova/novaeng/common/ecalculator/ECPUCluster.java b/src/main/java/github/kasuminova/novaeng/common/ecalculator/ECPUCluster.java index 981cb196..5bed0f05 100644 --- a/src/main/java/github/kasuminova/novaeng/common/ecalculator/ECPUCluster.java +++ b/src/main/java/github/kasuminova/novaeng/common/ecalculator/ECPUCluster.java @@ -1,6 +1,6 @@ package github.kasuminova.novaeng.common.ecalculator; -import appeng.me.cluster.implementations.CraftingCPUCluster; +import ae2.me.cluster.implementations.CraftingCPUCluster; import github.kasuminova.mmce.common.util.TimeRecorder; import github.kasuminova.novaeng.common.block.ecotech.ecalculator.prop.Levels; import github.kasuminova.novaeng.common.tile.ecotech.ecalculator.ECalculatorController; diff --git a/src/main/java/github/kasuminova/novaeng/common/estorage/ECellDriveWatcher.java b/src/main/java/github/kasuminova/novaeng/common/estorage/ECellDriveWatcher.java index 9a3e32b4..ebea2b54 100644 --- a/src/main/java/github/kasuminova/novaeng/common/estorage/ECellDriveWatcher.java +++ b/src/main/java/github/kasuminova/novaeng/common/estorage/ECellDriveWatcher.java @@ -1,81 +1,41 @@ package github.kasuminova.novaeng.common.estorage; -import appeng.api.config.Actionable; -import appeng.api.networking.security.IActionSource; -import appeng.api.storage.ICellInventoryHandler; -import appeng.api.storage.IMEInventory; -import appeng.api.storage.IStorageChannel; -import appeng.api.storage.data.IAEStack; -import appeng.me.GridAccessException; -import appeng.me.helpers.AENetworkProxy; -import appeng.me.storage.MEInventoryHandler; -import github.kasuminova.novaeng.NovaEngineeringCore; +import ae2.api.config.Actionable; +import ae2.api.networking.security.IActionSource; +import ae2.api.stacks.AEKey; +import ae2.api.storage.MEStorage; +import ae2.me.storage.MEInventoryHandler; import github.kasuminova.novaeng.common.tile.ecotech.estorage.EStorageCellDrive; -import github.kasuminova.novaeng.common.tile.ecotech.estorage.EStorageMEChannel; -import io.netty.util.internal.ThrowableUtil; -import java.util.Collections; -import java.util.List; - -public class ECellDriveWatcher> extends MEInventoryHandler { +public class ECellDriveWatcher extends MEInventoryHandler { protected final EStorageCellDrive drive; - public ECellDriveWatcher(final IMEInventory i, final IStorageChannel channel, final EStorageCellDrive drive) { - super(i, channel); + public ECellDriveWatcher(final MEStorage i, final EStorageCellDrive drive) { + super(i); this.drive = drive; } @Override - public T injectItems(final T input, final Actionable type, final IActionSource src) { - final long size = input.getStackSize(); - final T remainder = super.injectItems(input, type, src); + public long insert(final AEKey input, final long amount, final Actionable type, final IActionSource src) { + final long inserted = super.insert(input, amount, type, src); - if (type == Actionable.MODULATE && (remainder == null || remainder.getStackSize() != size)) { - EStorageMEChannel channel = this.drive.getController().getChannel(); - AENetworkProxy proxy = channel.getProxy(); - if (proxy.isActive()) { - try { - List changed = Collections.singletonList(input.copy().setStackSize(input.getStackSize() - (remainder == null ? 0 : remainder.getStackSize()))); - proxy.getStorage().postAlterationOfStoredItems(this.getChannel(), changed, channel.getSource()); - } catch (GridAccessException e) { - NovaEngineeringCore.log.warn(ThrowableUtil.stackTraceToString(e)); - } - } + if (type == Actionable.MODULATE && inserted > 0) { this.drive.onWriting(); } - return remainder; + return inserted; } @Override - public T extractItems(final T request, final Actionable type, final IActionSource src) { - final T extractable = super.extractItems(request, type, src); + public long extract(final AEKey request, final long amount, final Actionable type, final IActionSource src) { + final long extractable = super.extract(request, amount, type, src); - if (type == Actionable.MODULATE && extractable != null) { - EStorageMEChannel channel = this.drive.getController().getChannel(); - AENetworkProxy proxy = channel.getProxy(); - if (proxy.isActive()) { - try { - List changed = Collections.singletonList(request.copy().setStackSize(-extractable.getStackSize())); - proxy.getStorage().postAlterationOfStoredItems(this.getChannel(), changed, channel.getSource()); - } catch (GridAccessException e) { - NovaEngineeringCore.log.warn(ThrowableUtil.stackTraceToString(e)); - } - } + if (type == Actionable.MODULATE && extractable > 0) { this.drive.onWriting(); } return extractable; } - @Override - public boolean isSticky() { - if (this.getInternal() instanceof ICellInventoryHandler cellInventoryHandler) { - return cellInventoryHandler.isSticky(); - } - - return super.isSticky(); - } - } diff --git a/src/main/java/github/kasuminova/novaeng/common/estorage/EStorageCellHandler.java b/src/main/java/github/kasuminova/novaeng/common/estorage/EStorageCellHandler.java deleted file mode 100644 index 2f7b2aae..00000000 --- a/src/main/java/github/kasuminova/novaeng/common/estorage/EStorageCellHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package github.kasuminova.novaeng.common.estorage; - -import appeng.api.storage.ICellInventory; -import appeng.api.storage.ICellInventoryHandler; -import appeng.api.storage.ISaveProvider; -import appeng.api.storage.IStorageChannel; -import appeng.api.storage.data.IAEStack; -import appeng.core.features.registries.cell.BasicCellHandler; -import appeng.me.storage.BasicCellInventoryHandler; -import github.kasuminova.novaeng.common.item.estorage.EStorageCell; -import net.minecraft.item.ItemStack; - -public class EStorageCellHandler extends BasicCellHandler { - public static final EStorageCellHandler INSTANCE = new EStorageCellHandler(); - - public static EStorageCellHandler getHandler(final ItemStack cell) { - if (INSTANCE.isCell(cell)) { - return INSTANCE; - } - return null; - } - - @Override - public boolean isCell(final ItemStack is) { - return is.getItem() instanceof EStorageCell; - } - - @Override - public > ICellInventoryHandler getCellInventory(final ItemStack is, final ISaveProvider host, final IStorageChannel channel) { - final ICellInventory inv = EStorageCellInventory.createInventory(is, host); - if (inv == null || inv.getChannel() != channel) { - return null; - } - return new BasicCellInventoryHandler<>(inv, channel); - } - -} diff --git a/src/main/java/github/kasuminova/novaeng/common/estorage/EStorageCellInventory.java b/src/main/java/github/kasuminova/novaeng/common/estorage/EStorageCellInventory.java deleted file mode 100644 index fdb571ca..00000000 --- a/src/main/java/github/kasuminova/novaeng/common/estorage/EStorageCellInventory.java +++ /dev/null @@ -1,376 +0,0 @@ -package github.kasuminova.novaeng.common.estorage; - -import appeng.api.AEApi; -import appeng.api.config.Actionable; -import appeng.api.exceptions.AppEngException; -import appeng.api.implementations.items.IStorageCell; -import appeng.api.networking.security.IActionSource; -import appeng.api.storage.ICellInventory; -import appeng.api.storage.ICellInventoryHandler; -import appeng.api.storage.ISaveProvider; -import appeng.api.storage.IStorageChannel; -import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IAEStack; -import appeng.api.storage.data.IItemList; -import appeng.core.AEConfig; -import appeng.core.AELog; -import appeng.me.storage.AbstractCellInventory; -import github.kasuminova.novaeng.NovaEngineeringCore; -import github.kasuminova.novaeng.common.item.estorage.EStorageCell; -import github.kasuminova.novaeng.mixin.ae2.AccessorAbstractCellInventory; -import io.netty.util.internal.ThrowableUtil; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fml.relauncher.ReflectionHelper; - -public class EStorageCellInventory> extends AbstractCellInventory { - public static final String ITEM_SLOT = "#"; - public static final String ITEM_SLOT_COUNT = "@"; - public static final String ITEM_TYPE_TAG = "it"; - public static final String ITEM_COUNT_TAG = "ic"; - - private final EStorageCell cellType; - private final IStorageChannel channel; - - @SuppressWarnings("deprecation") - protected EStorageCellInventory(final EStorageCell cellType, final ItemStack o, final ISaveProvider container) { - super(cellType, o, container); - ReflectionHelper.setPrivateValue(AbstractCellInventory.class, this, cellType.getTotalTypes(o), "maxItemTypes", null); - this.cellType = cellType; - this.channel = cellType.getChannel(); - } - - @SuppressWarnings({"rawtypes"}) - public static > ICellInventory createInventory(final ItemStack o, final ISaveProvider container) { - try { - if (o == null) { - throw new AppEngException("ItemStack was used as a cell, but was not a cell!"); - } - - final Item type = o.getItem(); - if (!(type instanceof EStorageCell cellType)) { - throw new AppEngException("ItemStack was used as a cell, but was not a cell!"); - } - - if (!cellType.isStorageCell(o)) { - throw new AppEngException("ItemStack was used as a cell, but was not a cell!"); - } - - return new EStorageCellInventory(cellType, o, container); - } catch (final AppEngException e) { - NovaEngineeringCore.log.error(ThrowableUtil.stackTraceToString(e)); - return null; - } - } - - private static IStorageCell getStorageCell(final ItemStack input) { - if (input != null) { - final Item type = input.getItem(); - - if (type instanceof IStorageCell) { - return (IStorageCell) type; - } - } - - return null; - } - - @SuppressWarnings({"rawtypes"}) - private static boolean isCellEmpty(ICellInventory inv) { - if (inv != null) { - return inv.getAvailableItems(inv.getChannel().createList()).isEmpty(); - } - return true; - } - - private boolean isStorageCell(final T input) { - if (input instanceof final IAEItemStack stack) { - final IStorageCell type = getStorageCell(stack.getDefinition()); - - return type != null && !type.storableInStorageCell(); - } - - return false; - } - - protected IItemList getCellItems() { - if (this.cellItems == null) { - this.cellItems = this.channel.createList(); - this.loadCellItems(); - } - - return this.cellItems; - } - - private void loadCellItems() { - if (this.cellItems == null) { - this.cellItems = this.channel.createList(); - } - - this.cellItems.resetStatus(); // clears totals and stuff. - - final long types = this.getStoredItemTypes(); - boolean needsUpdate = false; - - AccessorAbstractCellInventory inv = (AccessorAbstractCellInventory) this; - for (int slot = 0; slot < types; slot++) { - NBTTagCompound compoundTag = inv.getTagCompound().getCompoundTag(ITEM_SLOT + slot); - long stackSize = inv.getTagCompound().getLong(ITEM_SLOT_COUNT + slot); - needsUpdate |= !this.loadCellItem(compoundTag, stackSize); - } - - if (needsUpdate) { - this.saveChanges(); - } - } - - @Override - public void persist() { - AccessorAbstractCellInventory inv = (AccessorAbstractCellInventory) this; - if (inv.getIsPersisted()) { - return; - } - NBTTagCompound tagCompound = inv.getTagCompound(); - - long itemCount = 0; - - // add new pretty stuff... - int x = 0; - for (final T v : this.cellItems) { - itemCount += v.getStackSize(); - - final NBTTagCompound g = new NBTTagCompound(); - v.writeToNBT(g); - tagCompound.setTag(ITEM_SLOT + x, g); - tagCompound.setLong(ITEM_SLOT_COUNT + x, v.getStackSize()); - - x++; - } - - final short oldStoredItems = inv.getStoredItemTypes(); - - inv.setStoredItemTypes((short) this.cellItems.size()); - - if (this.cellItems.isEmpty()) { - tagCompound.removeTag(ITEM_TYPE_TAG); - } else { - tagCompound.setShort(ITEM_TYPE_TAG, inv.getStoredItemTypes()); - } - - inv.setStoredItemCount(itemCount); - if (itemCount == 0) { - tagCompound.removeTag(ITEM_COUNT_TAG); - } else { - tagCompound.setLong(ITEM_COUNT_TAG, itemCount); - } - - // clean any old crusty stuff... - for (; x >= oldStoredItems && x < inv.getMaxItemTypes(); x++) { - tagCompound.removeTag(ITEM_SLOT + x); - tagCompound.removeTag(ITEM_SLOT_COUNT + x); - } - - inv.setIsPersisted(true); - } - - @Override - public T injectItems(T input, Actionable mode, IActionSource src) { - if (input == null) { - return null; - } - if (input.getStackSize() == 0) { - return null; - } - - if (this.cellType.isBlackListed(this.getItemStack(), input)) { - return input; - } - // This is slightly hacky as it expects a read-only access, but fine for now. - // TODO: Guarantee a read-only access. E.g. provide an isEmpty() method and ensure CellInventory does not write - // any NBT data for empty cells instead of relying on an empty IItemContainer - if (isStorageCell(input)) { - ItemStack cellStack = ((IAEItemStack) input).createItemStack(); - ICellInventoryHandler cellInvHandler = AEApi.instance().registries().cell().getCellInventory(cellStack, null, getStorageCell(cellStack).getChannel()); - if (cellInvHandler != null && !isCellEmpty(cellInvHandler.getCellInv())) { - return input; - } - } - - final T l = this.getCellItems().findPrecise(input); - if (l != null) { - final long remainingItemCount = this.getRemainingItemCount(); - if (remainingItemCount <= 0) { - return input; - } - - if (input.getStackSize() > remainingItemCount) { - final T r = input.copy(); - r.setStackSize(r.getStackSize() - remainingItemCount); - if (mode == Actionable.MODULATE) { - l.setStackSize(l.getStackSize() + remainingItemCount); - // Update Count. - AccessorAbstractCellInventory inv = (AccessorAbstractCellInventory) this; - inv.setStoredItemCount(inv.getStoredItemCount() + remainingItemCount); - this.saveChangesES(); - } - return r; - } else { - if (mode == Actionable.MODULATE) { - long prev = l.getStackSize(); - l.setStackSize(l.getStackSize() + input.getStackSize()); - // Update Count. - AccessorAbstractCellInventory inv = (AccessorAbstractCellInventory) this; - if (prev == 0) { - inv.setStoredItemTypes((short) (inv.getStoredItemTypes() + 1)); - } - inv.setStoredItemCount(inv.getStoredItemCount() + input.getStackSize()); - this.saveChangesES(); - } - return null; - } - } - - // room for new type, and for at least one item! - if (this.canHoldNewItem()) { - final long remainingItemCount = this.getRemainingItemCount() - (long) this.getBytesPerType() * this.itemsPerByte; - if (remainingItemCount > 0) { - if (input.getStackSize() > remainingItemCount) { - final T toReturn = input.copy(); - toReturn.setStackSize(input.getStackSize() - remainingItemCount); - if (mode == Actionable.MODULATE) { - final T toWrite = input.copy(); - toWrite.setStackSize(remainingItemCount); - - this.cellItems.add(toWrite); - - // Update Types and Counts. - AccessorAbstractCellInventory inv = (AccessorAbstractCellInventory) this; - inv.setStoredItemTypes((short) (inv.getStoredItemTypes() + 1)); - inv.setStoredItemCount(inv.getStoredItemCount() + remainingItemCount); - this.saveChangesES(); - } - return toReturn; - } - - if (mode == Actionable.MODULATE) { - this.cellItems.add(input); - - // Update Types and Counts. - AccessorAbstractCellInventory inv = (AccessorAbstractCellInventory) this; - inv.setStoredItemTypes((short) (inv.getStoredItemTypes() + 1)); - inv.setStoredItemCount(inv.getStoredItemCount() + input.getStackSize()); - this.saveChangesES(); - } - - return null; - } - } - - return input; - } - - @Override - public T extractItems(T request, Actionable mode, IActionSource src) { - if (request == null) { - return null; - } - - final long size = request.getStackSize(); - - T results = null; - - final T l = this.getCellItems().findPrecise(request); - if (l != null) { - results = l.copy(); - - if (l.getStackSize() <= size) { - results.setStackSize(l.getStackSize()); - if (mode == Actionable.MODULATE && l.getStackSize() > 0) { - l.setStackSize(0); - this.saveChanges(); - } - } else { - results.setStackSize(size); - if (mode == Actionable.MODULATE) { - l.setStackSize(l.getStackSize() - size); - // Update Count. - AccessorAbstractCellInventory inv = (AccessorAbstractCellInventory) this; - inv.setStoredItemCount(inv.getStoredItemCount() - size); - this.saveChangesES(); - } - } - } - - return results; - } - - @Override - public IStorageChannel getChannel() { - return this.channel; - } - - /** - * 类似 {@link AbstractCellInventory#saveChanges()},但是不对 cellItems 进行完全扫描。 - */ - protected void saveChangesES() { - if (this.container != null) { - ((AccessorAbstractCellInventory) this).setIsPersisted(false); - this.container.saveChanges(this); - } else { - saveChanges(); - } - } - - @Override - protected boolean loadCellItem(NBTTagCompound compoundTag, long stackSize) { - // Now load the item stack - final T t; - try { - t = this.channel.createFromNBT(compoundTag); - if (t == null) { - AELog.warn("Removing item " + compoundTag + " from storage cell because the associated item type couldn't be found."); - return false; - } - } catch (Throwable ex) { - if (AEConfig.instance().isRemoveCrashingItemsOnLoad()) { - AELog.warn(ex, "Removing item " + compoundTag + " from storage cell because loading the ItemStack crashed."); - return false; - } - throw ex; - } - - t.setStackSize(stackSize); - t.setCraftable(false); - - if (stackSize > 0) { - this.cellItems.add(t); - } - - return true; - } - - @Override - public long getUsedBytes() { - final long bytesForItemCount = (this.getStoredItemCount() + this.getUnusedItemCount()) / ((long) this.itemsPerByte * cellType.getByteMultiplier()); - return this.getStoredItemTypes() * this.getBytesPerType() + bytesForItemCount; - } - - @Override - public long getRemainingItemCount() { - final long remaining = this.getFreeBytes() * ((long) this.itemsPerByte * cellType.getByteMultiplier()) + this.getUnusedItemCount(); - return remaining > 0 ? remaining : 0; - } - - @Override - public int getUnusedItemCount() { - final int div = (int) (this.getStoredItemCount() % (8 * cellType.getByteMultiplier())); - - if (div == 0) { - return 0; - } - - return (this.itemsPerByte * cellType.getByteMultiplier()) - div; - } - -} diff --git a/src/main/java/github/kasuminova/novaeng/common/handler/ECalculatorEventHandler.java b/src/main/java/github/kasuminova/novaeng/common/handler/ECalculatorEventHandler.java index 8da3456a..c866d1d7 100644 --- a/src/main/java/github/kasuminova/novaeng/common/handler/ECalculatorEventHandler.java +++ b/src/main/java/github/kasuminova/novaeng/common/handler/ECalculatorEventHandler.java @@ -1,12 +1,10 @@ package github.kasuminova.novaeng.common.handler; -import appeng.api.config.SecurityPermissions; -import appeng.api.networking.IGrid; -import appeng.api.networking.IGridNode; -import appeng.api.networking.energy.IEnergyGrid; -import appeng.api.networking.security.ISecurityGrid; -import appeng.me.helpers.IGridProxyable; -import appeng.tile.inventory.AppEngInternalInventory; +import ae2.api.networking.IGridNode; +import ae2.api.networking.security.IActionHost; +import ae2.api.util.DimensionalBlockPos; +import ae2.util.Platform; +import ae2.util.inv.AppEngInternalInventory; import github.kasuminova.novaeng.NovaEngineeringCore; import github.kasuminova.novaeng.common.container.ContainerECalculatorController; import github.kasuminova.novaeng.common.item.ecalculator.ECalculatorCell; @@ -34,17 +32,15 @@ public class ECalculatorEventHandler { public static final int UPDATE_INTERVAL = 10; - private static boolean canInteract(final EntityPlayer player, final IGridProxyable proxyable) { - final IGridNode gn = proxyable.getProxy().getNode(); + private static boolean canInteract(final EntityPlayer player, + final TileEntity target, + final IActionHost actionHost) { + final IGridNode gn = actionHost.getActionableNode(); if (gn != null) { - final IGrid g = gn.getGrid(); - final IEnergyGrid eg = g.getCache(IEnergyGrid.class); - if (!eg.isNetworkPowered()) { + if (!gn.isPowered()) { return true; } - - final ISecurityGrid sg = g.getCache(ISecurityGrid.class); - return sg.hasPermission(player, SecurityPermissions.BUILD); + return Platform.hasPermissions(new DimensionalBlockPos(target), player); } return true; } @@ -95,7 +91,7 @@ public void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) { ECalculatorController controller = drive.getController(); if (controller != null) { ECalculatorMEChannel channel = controller.getChannel(); - if (channel != null && !canInteract(player, channel)) { + if (channel != null && !canInteract(player, drive, channel)) { player.sendMessage(new TextComponentTranslation("novaeng.ecalculator_cell_drive.player.no_permission")); event.setCanceled(true); return; diff --git a/src/main/java/github/kasuminova/novaeng/common/handler/EStorageEventHandler.java b/src/main/java/github/kasuminova/novaeng/common/handler/EStorageEventHandler.java index 31bb2f2e..08c22232 100644 --- a/src/main/java/github/kasuminova/novaeng/common/handler/EStorageEventHandler.java +++ b/src/main/java/github/kasuminova/novaeng/common/handler/EStorageEventHandler.java @@ -1,15 +1,13 @@ package github.kasuminova.novaeng.common.handler; -import appeng.api.config.SecurityPermissions; -import appeng.api.networking.IGrid; -import appeng.api.networking.IGridNode; -import appeng.api.networking.energy.IEnergyGrid; -import appeng.api.networking.security.ISecurityGrid; -import appeng.me.helpers.IGridProxyable; -import appeng.tile.inventory.AppEngCellInventory; +import ae2.api.networking.IGridNode; +import ae2.api.networking.security.IActionHost; +import ae2.api.storage.StorageCells; +import ae2.api.util.DimensionalBlockPos; +import ae2.util.inv.AppEngCellInventory; +import ae2.util.Platform; import github.kasuminova.novaeng.NovaEngineeringCore; import github.kasuminova.novaeng.common.container.ContainerEStorageController; -import github.kasuminova.novaeng.common.estorage.EStorageCellHandler; import github.kasuminova.novaeng.common.network.PktEStorageGUIData; import github.kasuminova.novaeng.common.tile.ecotech.estorage.EStorageCellDrive; import github.kasuminova.novaeng.common.tile.ecotech.estorage.EStorageController; @@ -33,17 +31,15 @@ public class EStorageEventHandler { public static final EStorageEventHandler INSTANCE = new EStorageEventHandler(); - private static boolean canInteract(final EntityPlayer player, final IGridProxyable proxyable) { - final IGridNode gn = proxyable.getProxy().getNode(); + private static boolean canInteract(final EntityPlayer player, + final TileEntity target, + final IActionHost actionHost) { + final IGridNode gn = actionHost.getActionableNode(); if (gn != null) { - final IGrid g = gn.getGrid(); - final IEnergyGrid eg = g.getCache(IEnergyGrid.class); - if (!eg.isNetworkPowered()) { + if (!gn.isPowered()) { return true; } - - final ISecurityGrid sg = g.getCache(ISecurityGrid.class); - return sg.hasPermission(player, SecurityPermissions.BUILD); + return Platform.hasPermissions(new DimensionalBlockPos(target), player); } return true; } @@ -73,7 +69,7 @@ public void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) { EStorageController controller = drive.getController(); if (controller != null) { EStorageMEChannel channel = controller.getChannel(); - if (channel != null && !canInteract(player, channel)) { + if (channel != null && !canInteract(player, drive, channel)) { player.sendMessage(new TextComponentTranslation("novaeng.estorage_cell_drive.player.no_permission")); event.setCanceled(true); return; @@ -85,7 +81,7 @@ public void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) { AppEngCellInventory inv = drive.getDriveInv(); ItemStack stackInSlot = inv.getStackInSlot(0); if (stackInSlot.isEmpty()) { - if (stackInHand.isEmpty() || EStorageCellHandler.getHandler(stackInHand) == null) { + if (stackInHand.isEmpty() || !StorageCells.isCellHandled(stackInHand)) { return; } player.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, inv.insertItem(0, stackInHand.copy(), false)); diff --git a/src/main/java/github/kasuminova/novaeng/common/handler/MachineAssemblyHandler.java b/src/main/java/github/kasuminova/novaeng/common/handler/MachineAssemblyHandler.java index fb180e56..39127990 100644 --- a/src/main/java/github/kasuminova/novaeng/common/handler/MachineAssemblyHandler.java +++ b/src/main/java/github/kasuminova/novaeng/common/handler/MachineAssemblyHandler.java @@ -3,7 +3,6 @@ import github.kasuminova.novaeng.NovaEngCoreConfig; import github.kasuminova.novaeng.client.util.NEWBlockArrayPreviewRenderHelper; import github.kasuminova.novaeng.common.item.ItemMachineAssemblyTool; -import github.kasuminova.novaeng.common.util.AutoCraftingQueue; import github.kasuminova.novaeng.common.util.NEWMachineAssemblyManager; import hellfirepvp.modularmachinery.client.ClientScheduler; import hellfirepvp.modularmachinery.client.util.DynamicMachineRenderContext; @@ -129,13 +128,11 @@ public void onPlayerTick(final TickEvent.PlayerTickEvent event) { @SubscribeEvent public void onPlayerLogOut(final PlayerEvent.PlayerLoggedOutEvent event) { - AutoCraftingQueue.removeQueue(event.player); NEWMachineAssemblyManager.removeMachineAssembly(event.player); } @SubscribeEvent public void onPlayerChangeDim(final PlayerEvent.PlayerChangedDimensionEvent event) { - AutoCraftingQueue.removeQueue(event.player); NEWMachineAssemblyManager.removeMachineAssembly(event.player); } } diff --git a/src/main/java/github/kasuminova/novaeng/common/handler/WorldCacheCleanupHandler.java b/src/main/java/github/kasuminova/novaeng/common/handler/WorldCacheCleanupHandler.java index fa854867..f4d7693b 100644 --- a/src/main/java/github/kasuminova/novaeng/common/handler/WorldCacheCleanupHandler.java +++ b/src/main/java/github/kasuminova/novaeng/common/handler/WorldCacheCleanupHandler.java @@ -7,7 +7,6 @@ import github.kasuminova.novaeng.common.performance.ClassResourceCacheCompactor; import github.kasuminova.novaeng.common.performance.MeteorWriteBatch; import github.kasuminova.novaeng.common.performance.SpawnCandidateList; -import github.kasuminova.novaeng.common.util.AutoCraftingQueue; import github.kasuminova.novaeng.common.util.MixinDecisions; import github.kasuminova.novaeng.mixin.rpsideas.AccessorItemBioticSensor; import hellfirepvp.modularmachinery.common.base.Mods; @@ -75,7 +74,6 @@ public void onWorldUnload(final WorldEvent.Unload event) { } HyperNetCaches.removeWorld(world); DreamEnergyCore.removeWorld(world); - AutoCraftingQueue.removeWorld(world); if (Mods.BM2.isPresent()) { MMAltar.removeWorld(world); } diff --git a/src/main/java/github/kasuminova/novaeng/common/integration/ae2/AeNetworkItemHandler.java b/src/main/java/github/kasuminova/novaeng/common/integration/ae2/AeNetworkItemHandler.java new file mode 100644 index 00000000..34fd6217 --- /dev/null +++ b/src/main/java/github/kasuminova/novaeng/common/integration/ae2/AeNetworkItemHandler.java @@ -0,0 +1,96 @@ +package github.kasuminova.novaeng.common.integration.ae2; + +import ae2.api.config.Actionable; +import ae2.api.networking.security.IActionSource; +import ae2.api.stacks.AEItemKey; +import ae2.api.storage.MEStorage; +import github.kasuminova.novaeng.common.performance.PerformanceMetrics; +import net.minecraft.item.ItemStack; +import net.minecraftforge.items.IItemHandler; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; + +public final class AeNetworkItemHandler implements IItemHandler { + + private static final int SLOTS = 1; + private static final int SLOT_LIMIT = 64; + + private final MEStorage storage; + private final IActionSource source; + private ItemStack lastDefinition; + private AEItemKey lastKey; + + public AeNetworkItemHandler(final MEStorage storage, final IActionSource source) { + this.storage = Objects.requireNonNull(storage, "storage"); + this.source = Objects.requireNonNull(source, "source"); + } + + @Override + public int getSlots() { + return SLOTS; + } + + @Override + public @NotNull ItemStack getStackInSlot(final int slot) { + return ItemStack.EMPTY; + } + + @Override + public @NotNull ItemStack insertItem(final int slot, final @NotNull ItemStack stack, final boolean simulate) { + if (slot != 0 || stack.isEmpty()) { + return stack; + } + + final AEItemKey key = this.keyOf(stack); + if (key == null) { + return stack; + } + + PerformanceMetrics.add(PerformanceMetrics.Counter.AE_OUTPUT_INSERTS, 1); + final long inserted = this.storage.insert(key, stack.getCount(), + simulate ? Actionable.SIMULATE : Actionable.MODULATE, this.source); + if (inserted <= 0) { + return stack; + } + if (inserted >= stack.getCount()) { + return ItemStack.EMPTY; + } + + final ItemStack remainder = stack.copy(); + remainder.setCount(stack.getCount() - (int) inserted); + return remainder; + } + + @Override + public @NotNull ItemStack extractItem(final int slot, final int amount, final boolean simulate) { + return ItemStack.EMPTY; + } + + @Override + public int getSlotLimit(final int slot) { + return SLOT_LIMIT; + } + + @Override + public boolean isItemValid(final int slot, final @NotNull ItemStack stack) { + return slot == 0 && !stack.isEmpty(); + } + + private AEItemKey keyOf(final ItemStack stack) { + final ItemStack last = this.lastDefinition; + if (last != null && ItemStack.areItemsEqual(last, stack) && ItemStack.areItemStackTagsEqual(last, stack)) { + return this.lastKey; + } + + final AEItemKey key = AEItemKey.of(stack); + if (key != null) { + final ItemStack definition = stack.copy(); + definition.setCount(1); + this.lastDefinition = definition; + this.lastKey = key; + } + return key; + } + +} diff --git a/src/main/java/github/kasuminova/novaeng/common/integration/theoneprobe/ECalculatorInfoProvider.java b/src/main/java/github/kasuminova/novaeng/common/integration/theoneprobe/ECalculatorInfoProvider.java index 9cb4ea1e..895ebfb2 100644 --- a/src/main/java/github/kasuminova/novaeng/common/integration/theoneprobe/ECalculatorInfoProvider.java +++ b/src/main/java/github/kasuminova/novaeng/common/integration/theoneprobe/ECalculatorInfoProvider.java @@ -1,7 +1,9 @@ package github.kasuminova.novaeng.common.integration.theoneprobe; -import appeng.api.storage.data.IAEItemStack; -import appeng.me.cluster.implementations.CraftingCPUCluster; +import ae2.api.networking.crafting.CraftingJobStatus; +import ae2.api.stacks.AEItemKey; +import ae2.api.stacks.GenericStack; +import ae2.me.cluster.implementations.CraftingCPUCluster; import github.kasuminova.novaeng.common.crafttweaker.util.NovaEngUtils; import github.kasuminova.novaeng.common.ecalculator.ECPUCluster; import github.kasuminova.novaeng.common.tile.ecotech.ecalculator.ECalculatorController; @@ -80,16 +82,17 @@ private static void processThreadCoreInfo(final IProbeInfo probeInfo, final ECal box = newBox(probeInfo).vertical(); box.text("{*top.ecalculator.thread_core.crafting*}"); for (final CraftingCPUCluster cpu : cpus) { - final IAEItemStack output = cpu.getFinalOutput(); - if (output == null) { + final CraftingJobStatus status = cpu.getJobStatus(); + if (status == null || status.crafting() == null || !(status.crafting().what() instanceof AEItemKey itemKey)) { continue; } final IProbeInfo taskBox = newBox(box).vertical(); IProbeInfo row = taskBox.horizontal(taskBox.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)); - final long count = output.getStackSize(); - final ItemStack stack = output.getCachedItemStack(1); + final GenericStack output = status.crafting(); + final long count = output.amount(); + final ItemStack stack = itemKey.toStack(1); row.item(stack); row.itemLabel(stack); row.text(" x " + count); diff --git a/src/main/java/github/kasuminova/novaeng/common/item/ItemBlockME.java b/src/main/java/github/kasuminova/novaeng/common/item/ItemBlockME.java index 95bf0310..e3d10c23 100644 --- a/src/main/java/github/kasuminova/novaeng/common/item/ItemBlockME.java +++ b/src/main/java/github/kasuminova/novaeng/common/item/ItemBlockME.java @@ -1,7 +1,6 @@ package github.kasuminova.novaeng.common.item; -import appeng.me.helpers.AENetworkProxy; -import appeng.me.helpers.IGridProxyable; +import ae2.me.helpers.IGridConnectedTile; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; @@ -32,9 +31,8 @@ public boolean placeBlockAt(@Nonnull final ItemStack stack, @Nonnull final IBlockState newState) { if (super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState)) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof IGridProxyable) { - AENetworkProxy proxy = ((IGridProxyable) tile).getProxy(); - proxy.setOwner(player); + if (tile instanceof IGridConnectedTile gridConnectedTile) { + gridConnectedTile.setOwner(player); } return true; } diff --git a/src/main/java/github/kasuminova/novaeng/common/item/ItemMachineAssemblyTool.java b/src/main/java/github/kasuminova/novaeng/common/item/ItemMachineAssemblyTool.java index 8ec475d5..2dc4f22f 100644 --- a/src/main/java/github/kasuminova/novaeng/common/item/ItemMachineAssemblyTool.java +++ b/src/main/java/github/kasuminova/novaeng/common/item/ItemMachineAssemblyTool.java @@ -1,20 +1,22 @@ package github.kasuminova.novaeng.common.item; -import appeng.api.networking.crafting.ICraftingGrid; -import appeng.util.item.AEItemStack; +import ae2.api.stacks.AEItemKey; +import ae2.container.implementations.ContainerCraftConfirm; +import ae2.container.interfaces.ICraftingGridContainer; +import ae2.core.gui.locator.GuiHostLocator; +import ae2.core.gui.locator.GuiHostLocators; +import ae2.helpers.WirelessTerminalGuiHost; +import baubles.api.BaublesApi; import com.brandon3055.draconicevolution.api.itemconfig.BooleanConfigField; import com.brandon3055.draconicevolution.api.itemconfig.IConfigurableItem; import com.brandon3055.draconicevolution.api.itemconfig.IItemConfigField; import com.brandon3055.draconicevolution.api.itemconfig.IntegerConfigField; import com.brandon3055.draconicevolution.api.itemconfig.ItemConfigFieldRegistry; import com.brandon3055.draconicevolution.api.itemconfig.ToolConfigHelper; -import com.circulation.random_complement.common.interfaces.RCCraftingGridCache; -import com.circulation.random_complement.common.util.MEHandler; import github.kasuminova.mmce.common.util.DynamicPattern; import github.kasuminova.novaeng.NovaEngineeringCore; import github.kasuminova.novaeng.common.CommonProxy; import github.kasuminova.novaeng.common.util.AssemblyBlockArray; -import github.kasuminova.novaeng.common.util.AutoCraftingQueue; import github.kasuminova.novaeng.common.util.NEWMachineAssemblyManager; import hellfirepvp.modularmachinery.common.block.BlockController; import hellfirepvp.modularmachinery.common.machine.DynamicMachine; @@ -22,9 +24,11 @@ import hellfirepvp.modularmachinery.common.tiles.base.TileMultiblockMachineController; import hellfirepvp.modularmachinery.common.util.BlockArrayCache; import ink.ikx.mmce.common.utils.StructureIngredient; +import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; @@ -34,12 +38,12 @@ import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; +import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.jspecify.annotations.NonNull; import javax.annotation.Nullable; -import java.util.ArrayDeque; import java.util.List; @SuppressWarnings("deprecation") @@ -206,22 +210,34 @@ public BooleanConfigField getNeedAllIngredientConfig() { final boolean autoCraft = usingAE && isAutoAECrafting(stack); final var missing = NEWMachineAssemblyManager.checkAllItems(player, ingredients, usingAE, autoCraft); final var requests = missing.list(); - if (autoCraft && !requests.isEmpty()) { - final var terminal = MEHandler.getTerminalGuiObject(player); - if (terminal != null && terminal.getActionableNode() != null && terminal.getActionableNode().getGrid() != null) { - final var grid = terminal.getActionableNode().getGrid(); - final RCCraftingGridCache crafting = grid.getCache(ICraftingGrid.class); - final var craftable = crafting.rc$getCraftableItems(); - final var queue = new ArrayDeque(); - for (final var alternatives : requests) { - for (final var item : alternatives) { - if (!item.isEmpty() && craftable.containsKey(AEItemStack.fromItemStack(item))) { - queue.add(item); - break; + if (autoCraft && !requests.isEmpty() && player instanceof EntityPlayerMP serverPlayer) { + final var locator = findWirelessTerminalLocator(player); + final var host = locator == null ? null : locator.locate(player, WirelessTerminalGuiHost.class); + if (locator != null && host != null) { + final var node = host.getActionableNode(); + final var grid = node == null ? null : node.grid(); + if (grid != null) { + final var craftables = grid.getCraftingService().getCraftables(AEItemKey.filter()); + final var toCraft = new ObjectArrayList(); + for (final var stacks : requests) { + for (final var item : stacks) { + if (item.isEmpty()) { + continue; + } + final var key = AEItemKey.of(item); + if (key == null) { + continue; + } + if (craftables.contains(key)) { + toCraft.add(new ICraftingGridContainer.AutoCraftEntry(key, item.getCount(), new IntArrayList())); + break; + } } } + if (!toCraft.isEmpty()) { + ContainerCraftConfirm.openWithCraftingList(host, serverPlayer, locator, toCraft); + } } - AutoCraftingQueue.setQueueAndStrat(queue, player); } } if (requests.isEmpty() || !isNeedAllIngredient(stack)) { @@ -261,6 +277,25 @@ public int getProfileCount(final ItemStack stack) { return 5; } + private static GuiHostLocator findWirelessTerminalLocator(final EntityPlayer player) { + for (int slot = 0; slot < player.inventory.getSizeInventory(); slot++) { + final GuiHostLocator locator = GuiHostLocators.forInventorySlot(slot); + if (locator.locate(player, WirelessTerminalGuiHost.class) != null) { + return locator; + } + } + if (Loader.isModLoaded("baubles")) { + final var handler = BaublesApi.getBaublesHandler(player); + for (int slot = 0; slot < handler.getSlots(); slot++) { + final GuiHostLocator locator = GuiHostLocators.forBaubleSlot(slot); + if (locator.locate(player, WirelessTerminalGuiHost.class) != null) { + return locator; + } + } + } + return null; + } + private static final class Configs { private static final BooleanConfigField USING_AE = new BooleanConfigField("UsingAE", false, description("UsingAE")); private static final BooleanConfigField IGNORE_FLUIDS = new BooleanConfigField("IgnoreFluids", false, description("IgnoreFluids")); diff --git a/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCell.java b/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCell.java index 5619f155..00f7ce32 100644 --- a/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCell.java +++ b/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCell.java @@ -1,29 +1,31 @@ package github.kasuminova.novaeng.common.item.estorage; -import appeng.api.AEApi; -import appeng.api.config.FuzzyMode; -import appeng.api.implementations.items.IStorageCell; -import appeng.api.storage.data.IAEStack; -import appeng.items.AEBaseItem; -import appeng.items.contents.CellConfig; -import appeng.items.contents.CellUpgrades; -import appeng.util.Platform; +import ae2.api.storage.cells.IBasicCellItem; +import ae2.api.stacks.AEKey; +import ae2.api.stacks.AEKeyType; +import ae2.api.config.FuzzyMode; +import ae2.api.upgrades.IUpgradeInventory; +import ae2.api.upgrades.UpgradeInventories; +import ae2.items.AEBaseItem; +import ae2.items.contents.CellConfig; +import ae2.util.ConfigInventory; +import ae2.util.Platform; import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStorageLevel; import github.kasuminova.novaeng.common.core.CreativeTabNovaEng; -import github.kasuminova.novaeng.common.estorage.EStorageCellHandler; import lombok.Getter; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.items.IItemHandler; import javax.annotation.Nonnull; import java.util.List; +import java.util.Set; -public abstract class EStorageCell> extends AEBaseItem implements IStorageCell { +public abstract class EStorageCell extends AEBaseItem implements IBasicCellItem { @Getter protected final DriveStorageLevel level; protected final int totalBytes; @@ -40,12 +42,9 @@ public EStorageCell(DriveStorageLevel level, final int millionBytes, final int b @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("DataFlowIssue") protected void addCheckedInformation(final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips) { super.addCheckedInformation(stack, world, lines, advancedTooltips); - AEApi.instance() - .client() - .addCellInformation(EStorageCellHandler.getHandler(stack).getCellInventory(stack, null, this.getChannel()), lines); + addCellInformationToTooltip(stack, lines); lines.add(I18n.format("novaeng.estorage_cell.insert.tip")); lines.add(I18n.format("novaeng.estorage_cell.extract.tip")); if (level == DriveStorageLevel.B) { @@ -67,43 +66,31 @@ public int getBytes(@Nonnull final ItemStack cellItem) { } @Override - public boolean isBlackListed(@Nonnull final ItemStack cellItem, @Nonnull final T requestedAddition) { + public boolean isBlackListed(@Nonnull final ItemStack cellItem, @Nonnull final AEKey requestedAddition) { return false; } + @Nonnull @Override - public boolean storableInStorageCell() { - return false; - } - - @Override - public boolean isStorageCell(@Nonnull final ItemStack i) { - return true; - } - - @Override - public boolean isEditable(final ItemStack is) { - return true; - } + public abstract AEKeyType getKeyType(); @Override - public IItemHandler getUpgradesInventory(final ItemStack is) { - return new CellUpgrades(is, 2); + public IUpgradeInventory getUpgrades(final ItemStack is) { + return UpgradeInventories.forItem(is, getKeyType() == AEKeyType.items() ? 4 : 3); } @Override - public IItemHandler getConfigInventory(final ItemStack is) { - return new CellConfig(is); + public ConfigInventory getConfigInventory(final ItemStack is) { + return CellConfig.create(Set.of(getKeyType()), is, getTotalTypes(is)); } @Override public FuzzyMode getFuzzyMode(final ItemStack is) { - final String fz = Platform.openNbtData(is).getString("FuzzyMode"); - try { - return FuzzyMode.valueOf(fz); - } catch (final Throwable t) { + final NBTTagCompound tag = is.getTagCompound(); + if (tag == null || !tag.hasKey("FuzzyMode", 8)) { return FuzzyMode.IGNORE_ALL; } + return FuzzyMode.valueOf(tag.getString("FuzzyMode")); } @Override diff --git a/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCellFluid.java b/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCellFluid.java index d3c358d6..4f132cd3 100644 --- a/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCellFluid.java +++ b/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCellFluid.java @@ -1,19 +1,14 @@ package github.kasuminova.novaeng.common.item.estorage; -import appeng.api.AEApi; -import appeng.api.storage.IStorageChannel; -import appeng.api.storage.channels.IFluidStorageChannel; -import appeng.api.storage.data.IAEFluidStack; -import appeng.fluids.helper.FluidCellConfig; +import ae2.api.stacks.AEKeyType; import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStorageLevel; import github.kasuminova.novaeng.novaeng_core.Tags; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.items.IItemHandler; import javax.annotation.Nonnull; -public class EStorageCellFluid extends EStorageCell { +public class EStorageCellFluid extends EStorageCell { public static final EStorageCellFluid LEVEL_A = new EStorageCellFluid(DriveStorageLevel.A, 16, 4); public static final EStorageCellFluid LEVEL_B = new EStorageCellFluid(DriveStorageLevel.B, 64, 16); @@ -35,14 +30,9 @@ public int getBytesPerType(@Nonnull final ItemStack cellItem) { return byteMultiplier * 1024; } - @Override - public IItemHandler getConfigInventory(final ItemStack is) { - return new FluidCellConfig(is); - } - @Nonnull @Override - public IStorageChannel getChannel() { - return AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class); + public AEKeyType getKeyType() { + return AEKeyType.fluids(); } } diff --git a/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCellGas.java b/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCellGas.java index e57918f9..ef3a9996 100644 --- a/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCellGas.java +++ b/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCellGas.java @@ -1,16 +1,14 @@ package github.kasuminova.novaeng.common.item.estorage; -import appeng.api.AEApi; -import appeng.api.storage.IStorageChannel; -import com.mekeng.github.common.me.data.IAEGasStack; -import com.mekeng.github.common.me.storage.IGasStorageChannel; -import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStorageLevel; +import ae2.api.stacks.AEKeyType; import github.kasuminova.novaeng.novaeng_core.Tags; +import me.ramidzkh.mekae2.ae2.AEGasKeyType; +import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStorageLevel; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.jetbrains.annotations.NotNull; -public class EStorageCellGas extends EStorageCell { +public class EStorageCellGas extends EStorageCell { public static final EStorageCellGas LEVEL_A = new EStorageCellGas(DriveStorageLevel.A, 16, 4); public static final EStorageCellGas LEVEL_B = new EStorageCellGas(DriveStorageLevel.B, 64, 16); @@ -35,7 +33,7 @@ public int getBytesPerType(@NotNull ItemStack itemStack) { @NotNull @Override - public IStorageChannel getChannel() { - return AEApi.instance().storage().getStorageChannel(IGasStorageChannel.class); + public AEKeyType getKeyType() { + return AEGasKeyType.TYPE; } } diff --git a/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCellItem.java b/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCellItem.java index b02132c8..d87c076d 100644 --- a/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCellItem.java +++ b/src/main/java/github/kasuminova/novaeng/common/item/estorage/EStorageCellItem.java @@ -1,9 +1,6 @@ package github.kasuminova.novaeng.common.item.estorage; -import appeng.api.AEApi; -import appeng.api.storage.IStorageChannel; -import appeng.api.storage.channels.IItemStorageChannel; -import appeng.api.storage.data.IAEItemStack; +import ae2.api.stacks.AEKeyType; import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStorageLevel; import github.kasuminova.novaeng.novaeng_core.Tags; import net.minecraft.item.ItemStack; @@ -11,7 +8,7 @@ import javax.annotation.Nonnull; -public class EStorageCellItem extends EStorageCell { +public class EStorageCellItem extends EStorageCell { public static final EStorageCellItem LEVEL_A = new EStorageCellItem(DriveStorageLevel.A, 16, 4); public static final EStorageCellItem LEVEL_B = new EStorageCellItem(DriveStorageLevel.B, 64, 16); @@ -35,7 +32,7 @@ public int getBytesPerType(@Nonnull final ItemStack cellItem) { @Nonnull @Override - public IStorageChannel getChannel() { - return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + public AEKeyType getKeyType() { + return AEKeyType.items(); } } diff --git a/src/main/java/github/kasuminova/novaeng/common/machine/BiogenicSimulationComputer.java b/src/main/java/github/kasuminova/novaeng/common/machine/BiogenicSimulationComputer.java index af8d0b45..f9ee1e2c 100644 --- a/src/main/java/github/kasuminova/novaeng/common/machine/BiogenicSimulationComputer.java +++ b/src/main/java/github/kasuminova/novaeng/common/machine/BiogenicSimulationComputer.java @@ -1,6 +1,6 @@ package github.kasuminova.novaeng.common.machine; -import appeng.util.Platform; +import ae2.util.Platform; import crafttweaker.CraftTweakerAPI; import crafttweaker.api.item.IItemStack; import crafttweaker.api.minecraft.CraftTweakerMC; diff --git a/src/main/java/github/kasuminova/novaeng/common/mod/Mods.java b/src/main/java/github/kasuminova/novaeng/common/mod/Mods.java index 5b0cafb8..5ececcab 100644 --- a/src/main/java/github/kasuminova/novaeng/common/mod/Mods.java +++ b/src/main/java/github/kasuminova/novaeng/common/mod/Mods.java @@ -4,25 +4,7 @@ public enum Mods { - AE2("appliedenergistics2"), - AE2EL("appliedenergistics2") { - @Override - public boolean loaded() { - if (this.initialized) { - return this.loaded; - } - this.initialized = true; - if (!super.loaded()) { - return this.loaded = false; - } - try { - Class.forName("appeng.core.AE2ELCore"); - return this.loaded = true; - } catch (Exception e) { - return this.loaded = false; - } - } - }, + AE2("ae2"), IC2("ic2"), MEK("mekanism"), MEKCEU("mekanism") { diff --git a/src/main/java/github/kasuminova/novaeng/common/network/ParallelNetworkManager.java b/src/main/java/github/kasuminova/novaeng/common/network/ParallelNetworkManager.java index de066c95..e26d8bf5 100644 --- a/src/main/java/github/kasuminova/novaeng/common/network/ParallelNetworkManager.java +++ b/src/main/java/github/kasuminova/novaeng/common/network/ParallelNetworkManager.java @@ -1,18 +1,13 @@ package github.kasuminova.novaeng.common.network; -import appeng.core.sync.network.NetworkHandler; import github.kasuminova.mmce.common.util.concurrent.Action; import github.kasuminova.mmce.common.util.concurrent.ActionExecutor; -import github.kasuminova.novaeng.NovaEngineeringCore; import github.kasuminova.novaeng.common.mod.Mods; import hellfirepvp.modularmachinery.ModularMachinery; -import ic2.core.network.NetworkManager; import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; import it.unimi.dsi.fastutil.objects.ReferenceSet; import mekanism.common.Mekanism; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.common.Optional; -import net.minecraftforge.fml.common.network.FMLEventChannel; import java.util.Map; import java.util.PriorityQueue; @@ -25,41 +20,11 @@ public class ParallelNetworkManager { private final ReferenceSet blacklistChannels = new ReferenceOpenHashSet<>(); public void init() { - if (Mods.IC2.loaded()) { - initializeIC2Blacklist(); - } - if (Mods.AE2.loaded()) { - initializeAE2Blacklist(); - } if (Mods.MEKCEU.loaded()) { initializeMekanismCEuBlacklist(); } } - @Optional.Method(modid = "ic2") - private void initializeIC2Blacklist() { - try { - FMLEventChannel channel = ObfuscationReflectionHelper.getPrivateValue(NetworkManager.class, null, "channel"); - if (channel != null) { - addBlacklistChannel(channel); - } - } catch (Throwable e) { - NovaEngineeringCore.log.warn(e); - } - } - - @Optional.Method(modid = "appliedenergistics2") - private void initializeAE2Blacklist() { - try { - FMLEventChannel ec = ObfuscationReflectionHelper.getPrivateValue(NetworkHandler.class, NetworkHandler.instance(), "ec"); - if (ec != null) { - addBlacklistChannel(ec); - } - } catch (Throwable e) { - NovaEngineeringCore.log.warn(e); - } - } - /** * MekCEu is async, so we dont need proxy that. */ diff --git a/src/main/java/github/kasuminova/novaeng/common/network/PktAutoCraftConfirm.java b/src/main/java/github/kasuminova/novaeng/common/network/PktAutoCraftConfirm.java deleted file mode 100644 index b4071c3a..00000000 --- a/src/main/java/github/kasuminova/novaeng/common/network/PktAutoCraftConfirm.java +++ /dev/null @@ -1,33 +0,0 @@ -package github.kasuminova.novaeng.common.network; - -import github.kasuminova.novaeng.common.container.ContainerNEWCraftConfirm; -import github.kasuminova.novaeng.common.util.AutoCraftingQueue; -import io.netty.buffer.ByteBuf; -import net.minecraftforge.fml.common.network.simpleimpl.IMessage; -import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; - -public final class PktAutoCraftConfirm implements IMessage, IMessageHandler { - - @Override - public void fromBytes(final ByteBuf buf) { - } - - @Override - public void toBytes(final ByteBuf buf) { - } - - @Override - public IMessage onMessage(final PktAutoCraftConfirm message, final MessageContext ctx) { - final var player = ctx.getServerHandler().player; - player.getServerWorld().addScheduledTask(() -> { - if (player.openContainer instanceof ContainerNEWCraftConfirm) { - final AutoCraftingQueue queue = AutoCraftingQueue.getQueue(player); - if (queue != null && !queue.executionQueue(player)) { - player.closeContainer(); - } - } - }); - return null; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/common/network/PktEFabricatorPatternSearchGUIAction.java b/src/main/java/github/kasuminova/novaeng/common/network/PktEFabricatorPatternSearchGUIAction.java index 06aa5b3c..309ffdb0 100644 --- a/src/main/java/github/kasuminova/novaeng/common/network/PktEFabricatorPatternSearchGUIAction.java +++ b/src/main/java/github/kasuminova/novaeng/common/network/PktEFabricatorPatternSearchGUIAction.java @@ -1,6 +1,6 @@ package github.kasuminova.novaeng.common.network; -import appeng.tile.inventory.AppEngInternalInventory; +import ae2.util.inv.AppEngInternalInventory; import github.kasuminova.novaeng.NovaEngineeringCore; import github.kasuminova.novaeng.common.container.ContainerEFabricatorPatternSearch; import github.kasuminova.novaeng.common.tile.ecotech.efabricator.EFabricatorController; diff --git a/src/main/java/github/kasuminova/novaeng/common/network/PktEStorageGUIData.java b/src/main/java/github/kasuminova/novaeng/common/network/PktEStorageGUIData.java index 4f5a659c..bb055e13 100644 --- a/src/main/java/github/kasuminova/novaeng/common/network/PktEStorageGUIData.java +++ b/src/main/java/github/kasuminova/novaeng/common/network/PktEStorageGUIData.java @@ -32,7 +32,7 @@ public PktEStorageGUIData() { public PktEStorageGUIData(final EStorageController controller) { List drives = controller.getCellDrives(); for (EStorageCellDrive drive : drives) { - if (!(drive.getDriveInv().getStackInSlot(0).getItem() instanceof EStorageCell cell) + if (!(drive.getDriveInv().getStackInSlot(0).getItem() instanceof EStorageCell cell) || !drive.isCellSupported(cell.getLevel())) continue; EStorageCellData data = EStorageCellData.from(drive); if (data != null) dataList.add(data); diff --git a/src/main/java/github/kasuminova/novaeng/common/network/PktPatternTermUploadPattern.java b/src/main/java/github/kasuminova/novaeng/common/network/PktPatternTermUploadPattern.java index 9ae5741c..b4a19032 100644 --- a/src/main/java/github/kasuminova/novaeng/common/network/PktPatternTermUploadPattern.java +++ b/src/main/java/github/kasuminova/novaeng/common/network/PktPatternTermUploadPattern.java @@ -1,16 +1,12 @@ package github.kasuminova.novaeng.common.network; -import appeng.api.AEApi; -import appeng.api.networking.IGridNode; -import appeng.api.networking.crafting.ICraftingPatternDetails; -import appeng.api.networking.security.IActionHost; -import appeng.api.storage.data.IAEItemStack; -import appeng.container.implementations.ContainerPatternEncoder; -import appeng.items.misc.ItemEncodedPattern; -import appeng.me.GridAccessException; -import com.glodblock.github.util.FluidCraftingPatternDetails; +import ae2.api.crafting.IPatternDetails; +import ae2.api.crafting.PatternDetailsHelper; +import ae2.api.networking.security.IActionHost; +import ae2.container.SlotSemantics; +import ae2.container.me.patternencode.ContainerPatternEncodingTerm; +import ae2.core.definitions.AEItems; import github.kasuminova.novaeng.common.tile.ecotech.efabricator.EFabricatorMEChannel; -import github.kasuminova.novaeng.mixin.ae2.AccessorContainerPatternEncoder; import hellfirepvp.modularmachinery.ModularMachinery; import io.netty.buffer.ByteBuf; import net.minecraft.item.ItemStack; @@ -33,56 +29,52 @@ public void toBytes(final ByteBuf buffer) { public IMessage onMessage(final PktPatternTermUploadPattern message, final MessageContext context) { final var player = context.getServerHandler().player; ModularMachinery.EXECUTE_MANAGER.addSyncTask(() -> { - if (!(player.openContainer instanceof ContainerPatternEncoder container)) { + if (!(player.openContainer instanceof ContainerPatternEncodingTerm container)) { return; } - final var accessor = (AccessorContainerPatternEncoder) container; - final var slot = accessor.getPatternSlotOUT(); - final ItemStack stack = slot.getStack(); - if (stack.isEmpty()) { + final ItemStack patternStack = container.getSlots(SlotSemantics.ENCODED_PATTERN).stream() + .findFirst().map(net.minecraft.inventory.Slot::getStack).orElse(ItemStack.EMPTY); + if (patternStack.isEmpty()) { return; } - final var part = container.getPart(); - final var itemObject = accessor.getIGuiItemObject(); - final Iterable nodes; - if (part != null) { - try { - nodes = part.getProxy().getGrid().getMachines(EFabricatorMEChannel.class); - } catch (final GridAccessException ignored) { - return; - } - } else if (itemObject instanceof IActionHost host) { - nodes = host.getActionableNode().getGrid().getMachines(EFabricatorMEChannel.class); - } else { + if (!(container.getTarget() instanceof IActionHost itemObject)) { + return; + } + final var node = itemObject.getActionableNode(); + if (node == null) { + return; + } + final var grid = node.grid(); + if (grid == null) { return; } - if (!nodes.iterator().hasNext() || !(stack.getItem() instanceof ItemEncodedPattern item)) { + final var channelNodes = grid.getMachines(EFabricatorMEChannel.class); + if (channelNodes.isEmpty()) { return; } - final ICraftingPatternDetails pattern = item.getPatternForItem(stack, player.world); - if (!pattern.isCraftable() && !(pattern instanceof FluidCraftingPatternDetails)) { + final IPatternDetails pattern = PatternDetailsHelper.decodePattern(patternStack, player.world); + if (pattern == null || pattern.getPrimaryOutput() == null) { return; } - final IAEItemStack output = pattern.getCondensedOutputs()[0]; - for (final IGridNode node : nodes) { - final var channel = (EFabricatorMEChannel) node.getMachine(); + final var out = pattern.getPrimaryOutput().what(); + for (final EFabricatorMEChannel channel : channelNodes) { final var controller = channel.getController(); if (controller == null) { continue; } for (final var bus : controller.getPatternBuses()) { - if (bus.getAePatterns().contains(output)) { + if (bus.getAePatterns().contains(out)) { player.sendMessage(new TextComponentTranslation("novaeng.efabricator_parallel_proc.tooltip.0")); - player.inventory.placeItemBackInInventory(player.world, AEApi.instance().definitions().materials() - .blankPattern().maybeStack(slot.getStack().getCount()).orElse(ItemStack.EMPTY)); - slot.putStack(ItemStack.EMPTY); + player.inventory.placeItemBackInInventory(player.world, + new ItemStack(AEItems.BLANK_PATTERN.item(), patternStack.getCount())); + container.clear(); return; } } } - for (final IGridNode node : nodes) { - if (((EFabricatorMEChannel) node.getMachine()).insertPattern(stack)) { - slot.putStack(ItemStack.EMPTY); + for (final EFabricatorMEChannel channel : channelNodes) { + if (channel.insertPattern(patternStack)) { + container.clear(); break; } } diff --git a/src/main/java/github/kasuminova/novaeng/common/performance/AeOutputPreparation.java b/src/main/java/github/kasuminova/novaeng/common/performance/AeOutputPreparation.java deleted file mode 100644 index 858d2526..00000000 --- a/src/main/java/github/kasuminova/novaeng/common/performance/AeOutputPreparation.java +++ /dev/null @@ -1,51 +0,0 @@ -package github.kasuminova.novaeng.common.performance; - -import appeng.util.item.AEItemStack; -import net.minecraft.item.ItemStack; - -import java.util.Objects; - -/** Reuses item conversion only. Network, permission, slot and notification code still runs for each insert. */ -public final class AeOutputPreparation { - private static final ThreadLocal> SCOPES = new ThreadLocal<>(); - - private AeOutputPreparation() { - } - - public static void enter() { - OperationCache cache = SCOPES.get(); - if (cache == null) { - cache = new OperationCache<>(); - SCOPES.set(cache); - } - cache.enter(); - } - - public static void leave() { - SCOPES.get().leave(); - } - - public static AEItemStack convert(final ItemStack stack) { - PerformanceMetrics.add(PerformanceMetrics.Counter.AE_OUTPUT_INSERTS, 1); - final OperationCache cache = SCOPES.get(); - if (cache == null || !cache.active() || stack.isEmpty()) { - return AEItemStack.fromItemStack(stack); - } - AEItemStack template = cache.get(stack); - if (template != null) { - final ItemStack definition = template.getDefinition(); - if (!ItemStack.areItemsEqual(definition, stack) || !ItemStack.areItemStackTagsEqual(definition, stack) - || !definition.areCapsCompatible(stack)) { - template = null; - } - } - if (template == null) { - template = AEItemStack.fromItemStack(stack); - cache.put(stack, template); - } - // injectItems may mutate its input. The cached canonical definition never escapes. - final AEItemStack converted = (AEItemStack) Objects.requireNonNull(template).copy(); - converted.setStackSize(stack.getCount()); - return converted; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/common/performance/AeOutputTarget.java b/src/main/java/github/kasuminova/novaeng/common/performance/AeOutputTarget.java deleted file mode 100644 index f33d2212..00000000 --- a/src/main/java/github/kasuminova/novaeng/common/performance/AeOutputTarget.java +++ /dev/null @@ -1,5 +0,0 @@ -package github.kasuminova.novaeng.common.performance; - -/** Marker for the supported direct-to-network AE item handler; arbitrary handlers remain unchanged. */ -public interface AeOutputTarget { -} diff --git a/src/main/java/github/kasuminova/novaeng/common/performance/AvailableStackIteration.java b/src/main/java/github/kasuminova/novaeng/common/performance/AvailableStackIteration.java deleted file mode 100644 index e9691556..00000000 --- a/src/main/java/github/kasuminova/novaeng/common/performance/AvailableStackIteration.java +++ /dev/null @@ -1,9 +0,0 @@ -package github.kasuminova.novaeng.common.performance; - -import appeng.api.storage.data.IAEStack; - -import java.util.function.Consumer; - -public interface AvailableStackIteration> { - void nova$forEachAvailable(Consumer consumer); -} diff --git a/src/main/java/github/kasuminova/novaeng/common/performance/OperationCache.java b/src/main/java/github/kasuminova/novaeng/common/performance/OperationCache.java deleted file mode 100644 index 977c5727..00000000 --- a/src/main/java/github/kasuminova/novaeng/common/performance/OperationCache.java +++ /dev/null @@ -1,40 +0,0 @@ -package github.kasuminova.novaeng.common.performance; - -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; - -/** Owner-thread reusable frames; nested callbacks cannot read another operation's preparation. */ -public final class OperationCache { - private final ObjectArrayList> frames = new ObjectArrayList<>(); - private int depth; - - public void enter() { - if (depth == frames.size()) { - frames.add(new Reference2ObjectOpenHashMap<>()); - } - depth++; - } - - public void leave() { - if (depth == 0) { - throw new IllegalStateException("Unbalanced operation scope"); - } - frames.get(--depth).clear(); - } - - public boolean active() { return depth != 0; } - - public V get(final K key) { - return depth == 0 ? null : frames.get(depth - 1).get(key); - } - - public void put(final K key, final V value) { - if (depth == 0) { - throw new IllegalStateException("No active operation"); - } - final Reference2ObjectOpenHashMap frame = frames.get(depth - 1); - if (frame.size() < 512 || frame.containsKey(key)) { - frame.put(key, value); - } - } -} diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/TileCustomControllerME.java b/src/main/java/github/kasuminova/novaeng/common/tile/TileCustomControllerME.java index e2de4c2c..40b978c1 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/TileCustomControllerME.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/TileCustomControllerME.java @@ -1,37 +1,50 @@ package github.kasuminova.novaeng.common.tile; -import appeng.api.networking.GridFlags; -import appeng.api.networking.IGridNode; -import appeng.api.networking.events.MENetworkChannelsChanged; -import appeng.api.networking.events.MENetworkEventSubscribe; -import appeng.api.networking.events.MENetworkPowerStatusChange; -import appeng.api.networking.security.IActionHost; -import appeng.api.networking.security.IActionSource; -import appeng.api.networking.ticking.IGridTickable; -import appeng.api.util.AECableType; -import appeng.api.util.AEPartLocation; -import appeng.api.util.DimensionalCoord; -import appeng.me.GridAccessException; -import appeng.me.helpers.AENetworkProxy; -import appeng.me.helpers.IGridProxyable; -import appeng.me.helpers.MachineSource; -import appeng.util.Platform; +import ae2.api.AECapabilities; +import ae2.api.networking.GridFlags; +import ae2.api.networking.IGridNode; +import ae2.api.networking.IGridNodeListener; +import ae2.api.networking.IManagedGridNode; +import ae2.api.networking.security.IActionSource; +import ae2.api.util.AECableType; +import ae2.me.ManagedGridNode; +import ae2.me.helpers.IGridConnectedTile; +import ae2.me.helpers.MachineSource; +import ae2.util.Platform; import hellfirepvp.modularmachinery.ModularMachinery; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; import javax.annotation.Nonnull; import javax.annotation.Nullable; -public abstract class TileCustomControllerME extends TileCustomController implements IActionHost, IGridProxyable, IGridTickable { - protected final AENetworkProxy proxy = new AENetworkProxy(this, "aeProxy", getVisualItemStack(), true); +public abstract class TileCustomControllerME extends TileCustomController implements IGridConnectedTile { + private static final IGridNodeListener NODE_LISTENER = new IGridNodeListener<>() { + @Override + public void onSaveChanges(final TileCustomControllerME nodeOwner, final IGridNode node) { + nodeOwner.saveChanges(); + } + + @Override + public void onStateChanged(final TileCustomControllerME nodeOwner, + final IGridNode node, + final State state) { + nodeOwner.onMainNodeStateChanged(state); + } + }; + + protected final IManagedGridNode mainNode = new ManagedGridNode(this, NODE_LISTENER) + .setVisualRepresentation(getVisualItemStack()) + .setInWorldNode(true) + .setTagName("aeProxy"); protected final IActionSource source; public TileCustomControllerME() { this.source = new MachineSource(this); - this.proxy.setIdlePowerUsage(0.0D); - this.proxy.setFlags(GridFlags.REQUIRE_CHANNEL); + this.mainNode.setIdlePowerUsage(0.0D); + this.mainNode.setFlags(GridFlags.REQUIRE_CHANNEL); } public abstract ItemStack getVisualItemStack(); @@ -39,98 +52,95 @@ public TileCustomControllerME() { @Override public void readCustomNBT(final NBTTagCompound compound) { super.readCustomNBT(compound); - if (FMLCommonHandler.instance().getSide().isServer()) { - proxy.readFromNBT(compound); - } + mainNode.loadFromNBT(compound); } @Override public void writeCustomNBT(final NBTTagCompound compound) { super.writeCustomNBT(compound); - proxy.writeToNBT(compound); - } - - // AppEng Compat - - @MENetworkEventSubscribe - public void stateChange(final MENetworkChannelsChanged change) { - this.notifyNeighbors(); + mainNode.saveToNBT(compound); } - @MENetworkEventSubscribe - public void stateChange(final MENetworkPowerStatusChange change) { - this.notifyNeighbors(); + @Override + public void onMainNodeStateChanged(final IGridNodeListener.State reason) { + notifyNeighbors(); } private void notifyNeighbors() { - if (this.proxy.isActive()) { - try { - this.proxy.getTick().wakeDevice(this.proxy.getNode()); - } catch (GridAccessException e) { - // :P - } - Platform.notifyBlocksOfNeighbors(this.getWorld(), this.getPos()); + if (!mainNode.isActive()) { + return; } + mainNode.ifPresent((grid, node) -> grid.getTickManager().wakeDevice(node)); + Platform.notifyBlocksOfNeighbors(this.getWorld(), this.getPos()); } @Override - public void gridChanged() { - - } - - @Nonnull - @Override + @Nullable public IGridNode getActionableNode() { - return proxy.getNode(); + return mainNode.getNode(); } @Nonnull @Override - public AENetworkProxy getProxy() { - return proxy; + public IManagedGridNode getMainNode() { + return mainNode; } - @Nonnull @Override - public DimensionalCoord getLocation() { - return new DimensionalCoord(this); + public void saveChanges() { + markDirty(); } @Nullable @Override - public IGridNode getGridNode(@Nonnull final AEPartLocation dir) { - return proxy.getNode(); + public IGridNode getGridNode(@Nonnull final EnumFacing dir) { + return mainNode.getNode(); } @Nonnull @Override - public AECableType getCableConnectionType(@Nonnull final AEPartLocation dir) { + public AECableType getCableConnectionType(@Nonnull final EnumFacing dir) { return AECableType.SMART; } @Override - public void securityBreak() { - getWorld().destroyBlock(getPos(), true); + public boolean hasCapability(@Nonnull final Capability capability, @Nullable final EnumFacing facing) { + if (capability == AECapabilities.IN_WORLD_GRID_NODE_HOST) { + return true; + } + return super.hasCapability(capability, facing); + } + + @Nullable + @Override + public T getCapability(@Nonnull final Capability capability, @Nullable final EnumFacing facing) { + if (capability == AECapabilities.IN_WORLD_GRID_NODE_HOST) { + return AECapabilities.IN_WORLD_GRID_NODE_HOST.cast(this); + } + return super.getCapability(capability, facing); } @Override public void onChunkUnload() { super.onChunkUnload(); - proxy.onChunkUnload(); + mainNode.destroy(); } @Override public void invalidate() { super.invalidate(); - proxy.invalidate(); + mainNode.destroy(); } @Override public void validate() { super.validate(); if (!getWorld().isRemote) { - ModularMachinery.EXECUTE_MANAGER.addSyncTask(proxy::onReady); + ModularMachinery.EXECUTE_MANAGER.addSyncTask(() -> { + if (!mainNode.isReady()) { + mainNode.create(getWorld(), getPos()); + } + }); } } - } diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorCellDrive.java b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorCellDrive.java index a21dcef4..87e44153 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorCellDrive.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorCellDrive.java @@ -1,10 +1,9 @@ package github.kasuminova.novaeng.common.tile.ecotech.ecalculator; -import appeng.tile.inventory.AppEngInternalInventory; -import appeng.util.helpers.ItemHandlerUtil; -import appeng.util.inv.IAEAppEngInventory; -import appeng.util.inv.InvOperation; -import appeng.util.inv.filter.IAEItemFilter; +import ae2.api.inventories.InternalInventory; +import ae2.util.inv.AppEngInternalInventory; +import ae2.util.inv.InternalInventoryHost; +import ae2.util.inv.filter.IAEItemFilter; import github.kasuminova.novaeng.common.block.ecotech.ecalculator.prop.DriveStorageLevel; import github.kasuminova.novaeng.common.block.ecotech.ecalculator.prop.Levels; import github.kasuminova.novaeng.common.item.ecalculator.ECalculatorCell; @@ -14,15 +13,11 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.IItemHandler; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import static appeng.helpers.ItemStackHelper.stackFromNBT; -import static appeng.helpers.ItemStackHelper.stackWriteToNBT; - -public class ECalculatorCellDrive extends ECalculatorPart implements IAEAppEngInventory { +public class ECalculatorCellDrive extends ECalculatorPart implements InternalInventoryHost { protected final AppEngInternalInventory driveInv = new AppEngInternalInventory(this, 1); protected EnumFacing connectedSide = null; @@ -32,7 +27,7 @@ public ECalculatorCellDrive() { } @Override - public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack) { + public void onChangeInventory(final AppEngInternalInventory inv, final int slot) { disconnectTransmitter(); final ECalculatorController controller = getController(); if (controller != null) { @@ -42,6 +37,16 @@ public void onChangeInventory(final IItemHandler inv, final int slot, final InvO this.markForUpdateSync(); } + @Override + public void saveChangedInventory(final AppEngInternalInventory inv) { + markDirty(); + } + + @Override + public boolean isClientSide() { + return world != null && world.isRemote; + } + public long getSuppliedBytes() { final ItemStack stackInSlot = driveInv.getStackInSlot(0); if (stackInSlot.isEmpty()) { @@ -134,7 +139,7 @@ public boolean hasCapability(@Nonnull final Capability capability, @Nullable @Override public T getCapability(@Nonnull final Capability capability, @Nullable final EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { - return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(driveInv); + return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(driveInv.toItemHandler()); } return super.getCapability(capability, facing); } @@ -144,9 +149,9 @@ public void readCustomNBT(final NBTTagCompound tag) { super.readCustomNBT(tag); final NBTTagCompound opt = tag.getCompoundTag("driveInv"); - for (int x = 0; x < driveInv.getSlots(); x++) { + for (int x = 0; x < driveInv.size(); x++) { final NBTTagCompound item = opt.getCompoundTag("item" + x); - ItemHandlerUtil.setStackInSlot(driveInv, x, stackFromNBT(item)); + driveInv.setItemDirect(x, item.hasKey("id", 8) ? new ItemStack(item) : ItemStack.EMPTY); } if (tag.hasKey("connectedSide")) { this.connectedSide = EnumFacing.VALUES[tag.getByte("connectedSide")]; @@ -164,11 +169,11 @@ public void writeCustomNBT(final NBTTagCompound tag) { super.writeCustomNBT(tag); final NBTTagCompound opt = new NBTTagCompound(); - for (int x = 0; x < driveInv.getSlots(); x++) { + for (int x = 0; x < driveInv.size(); x++) { final NBTTagCompound itemNBT = new NBTTagCompound(); final ItemStack is = driveInv.getStackInSlot(x); if (!is.isEmpty()) { - stackWriteToNBT(is, itemNBT); + is.writeToNBT(itemNBT); } opt.setTag("item" + x, itemNBT); } @@ -179,11 +184,6 @@ public void writeCustomNBT(final NBTTagCompound tag) { } } - @Override - public void saveChanges() { - markDirty(); - } - @Override public void notifyUpdate() { super.notifyUpdate(); @@ -203,12 +203,7 @@ private static class CellInvFilter implements IAEItemFilter { private static final CellInvFilter INSTANCE = new CellInvFilter(); @Override - public boolean allowExtract(IItemHandler inv, int slot, int amount) { - return true; - } - - @Override - public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + public boolean allowInsert(InternalInventory inv, int slot, ItemStack stack) { return !stack.isEmpty() && stack.getItem() instanceof ECalculatorCell; } diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorController.java b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorController.java index b51a63f0..f14bfea9 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorController.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorController.java @@ -1,7 +1,6 @@ package github.kasuminova.novaeng.common.tile.ecotech.ecalculator; -import appeng.api.util.WorldCoord; -import appeng.me.cluster.implementations.CraftingCPUCluster; +import ae2.me.cluster.implementations.CraftingCPUCluster; import github.kasuminova.mmce.common.helper.IDynamicPatternInfo; import github.kasuminova.mmce.common.util.DynamicPattern; import github.kasuminova.novaeng.NovaEngineeringCore; @@ -224,7 +223,7 @@ public void createVirtualCPU() { return; } - WorldCoord pos = new WorldCoord(getPos()); + BlockPos pos = getPos(); this.virtualCPU = new CraftingCPUCluster(pos, pos); ECPUCluster eCluster = ECPUCluster.from(this.virtualCPU); eCluster.novaeng_ec$setVirtualCPUOwner(this); diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorMEChannel.java b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorMEChannel.java index 71ec6878..1af50bbc 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorMEChannel.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorMEChannel.java @@ -1,42 +1,62 @@ package github.kasuminova.novaeng.common.tile.ecotech.ecalculator; -import appeng.api.networking.GridFlags; -import appeng.api.networking.IGridNode; -import appeng.api.networking.events.MENetworkChannelsChanged; -import appeng.api.networking.events.MENetworkCraftingCpuChange; -import appeng.api.networking.events.MENetworkEventSubscribe; -import appeng.api.networking.events.MENetworkPowerStatusChange; -import appeng.api.networking.security.IActionHost; -import appeng.api.networking.security.IActionSource; -import appeng.api.util.AECableType; -import appeng.api.util.AEPartLocation; -import appeng.api.util.DimensionalCoord; -import appeng.me.GridAccessException; -import appeng.me.cluster.implementations.CraftingCPUCluster; -import appeng.me.helpers.AENetworkProxy; -import appeng.me.helpers.IGridProxyable; -import appeng.me.helpers.MachineSource; +import ae2.api.AECapabilities; +import ae2.api.networking.GridFlags; +import ae2.api.networking.IGridNode; +import ae2.api.networking.IGridNodeListener; +import ae2.api.networking.IManagedGridNode; +import ae2.api.networking.events.GridCraftingCpuChange; +import ae2.api.networking.security.IActionSource; +import ae2.api.util.AECableType; +import ae2.me.ManagedGridNode; +import ae2.me.cluster.implementations.CraftingCPUCluster; +import ae2.me.helpers.IGridConnectedTile; +import ae2.me.helpers.MachineSource; import github.kasuminova.novaeng.common.block.ecotech.ecalculator.BlockECalculatorMEChannel; import hellfirepvp.modularmachinery.ModularMachinery; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Collections; import java.util.List; -public class ECalculatorMEChannel extends ECalculatorPart implements IActionHost, IGridProxyable { +public class ECalculatorMEChannel extends ECalculatorPart implements IGridConnectedTile { - protected final AENetworkProxy proxy = new AENetworkProxy(this, "channel", getVisualItemStack(), true); + private static final IGridNodeListener NODE_LISTENER = new IGridNodeListener<>() { + @Override + public void onSaveChanges(final ECalculatorMEChannel nodeOwner, final IGridNode node) { + nodeOwner.saveChanges(); + } + + @Override + public void onStateChanged(final ECalculatorMEChannel nodeOwner, + final IGridNode node, + final State state) { + nodeOwner.onMainNodeStateChanged(state); + } + }; + + protected IManagedGridNode mainNode; protected final IActionSource source = new MachineSource(this); private boolean wasActive = false; public ECalculatorMEChannel() { - this.proxy.setIdlePowerUsage(1.0D); - this.proxy.setFlags(GridFlags.REQUIRE_CHANNEL, GridFlags.DENSE_CAPACITY); + this.mainNode = createMainNode(); + } + + private IManagedGridNode createMainNode() { + return new ManagedGridNode(this, NODE_LISTENER) + .setIdlePowerUsage(1.0D) + .setFlags(GridFlags.REQUIRE_CHANNEL, GridFlags.DENSE_CAPACITY) + .setVisualRepresentation(getVisualItemStack()) + .setInWorldNode(true) + .setTagName("channel"); } public IActionSource getSource() { @@ -48,18 +68,9 @@ public ItemStack getVisualItemStack() { return new ItemStack(Item.getItemFromBlock(controller == null ? BlockECalculatorMEChannel.INSTANCE : controller.getParentController()), 1, 0); } - @MENetworkEventSubscribe - public void stateChange(final MENetworkPowerStatusChange c) { - final boolean currentActive = this.proxy.isActive(); - if (this.wasActive != currentActive) { - this.wasActive = currentActive; - postCPUClusterChangeEvent(); - } - } - - @MENetworkEventSubscribe - public void stateChange(final MENetworkChannelsChanged c) { - final boolean currentActive = this.proxy.isActive(); + @Override + public void onMainNodeStateChanged(final IGridNodeListener.State reason) { + final boolean currentActive = this.mainNode.isActive(); if (this.wasActive != currentActive) { this.wasActive = currentActive; postCPUClusterChangeEvent(); @@ -67,18 +78,15 @@ public void stateChange(final MENetworkChannelsChanged c) { } protected void postCPUClusterChangeEvent() { - if (this.proxy.isActive()) { - try { - this.proxy.getGrid().postEvent(new MENetworkCraftingCpuChange(this.proxy.getNode())); - } catch (final GridAccessException ignored) { - } + if (this.mainNode.isActive()) { + this.mainNode.ifPresent((grid, node) -> grid.postEvent(new GridCraftingCpuChange(node))); } } // Clusters public List getCPUs() { - final boolean currentActive = this.proxy.isActive(); + final boolean currentActive = this.mainNode.isActive(); if (!currentActive || !isAssembled()) { return Collections.emptyList(); } @@ -91,81 +99,103 @@ public List getCPUs() { // Misc - @Nonnull + @Nullable @Override public IGridNode getActionableNode() { - return proxy.getNode(); + return mainNode.getNode(); } - @Nonnull - @Override - public AENetworkProxy getProxy() { - return proxy; - } - - @Nonnull @Override - public DimensionalCoord getLocation() { - return new DimensionalCoord(this); + public IManagedGridNode getMainNode() { + return mainNode; } @Override - public void gridChanged() { + public void saveChanges() { + markDirty(); } @Nullable @Override - public IGridNode getGridNode(@Nonnull final AEPartLocation dir) { - return proxy.getNode(); + public IGridNode getGridNode(@Nonnull final EnumFacing dir) { + return mainNode.getNode(); } @Nonnull @Override - public AECableType getCableConnectionType(@Nonnull final AEPartLocation dir) { + public AECableType getCableConnectionType(@Nonnull final EnumFacing dir) { return AECableType.DENSE_SMART; } @Override - public void securityBreak() { - getWorld().destroyBlock(getPos(), true); + public boolean hasCapability(@Nonnull final Capability capability, @Nullable final EnumFacing facing) { + if (capability == AECapabilities.IN_WORLD_GRID_NODE_HOST) { + return true; + } + return super.hasCapability(capability, facing); + } + + @Nullable + @Override + public T getCapability(@Nonnull final Capability capability, @Nullable final EnumFacing facing) { + if (capability == AECapabilities.IN_WORLD_GRID_NODE_HOST) { + return AECapabilities.IN_WORLD_GRID_NODE_HOST.cast(this); + } + return super.getCapability(capability, facing); } @Override public void readCustomNBT(final NBTTagCompound compound) { super.readCustomNBT(compound); - proxy.readFromNBT(compound); + mainNode.loadFromNBT(compound); } @Override public void writeCustomNBT(final NBTTagCompound compound) { super.writeCustomNBT(compound); - proxy.writeToNBT(compound); + mainNode.saveToNBT(compound); } @Override public void onChunkUnload() { super.onChunkUnload(); - proxy.onChunkUnload(); + mainNode.destroy(); } @Override public void invalidate() { super.invalidate(); - proxy.invalidate(); + mainNode.destroy(); } @Override public void onAssembled() { super.onAssembled(); - proxy.setVisualRepresentation(getVisualItemStack()); - ModularMachinery.EXECUTE_MANAGER.addSyncTask(proxy::onReady); + mainNode.setVisualRepresentation(getVisualItemStack()); + final IManagedGridNode node = mainNode; + ModularMachinery.EXECUTE_MANAGER.addSyncTask(() -> { + if (mainNode == node && !node.isReady() && !getWorld().isRemote) { + node.create(getWorld(), getPos()); + } + }); } @Override public void onDisassembled() { super.onDisassembled(); - proxy.setVisualRepresentation(getVisualItemStack()); - proxy.invalidate(); + int ownerId = -1; + if (mainNode.isReady()) { + final IGridNode node = mainNode.getNode(); + if (node != null) { + ownerId = node.getOwningPlayerId(); + } + } + mainNode.destroy(); + mainNode = createMainNode(); + if (ownerId >= 0) { + mainNode.setOwningPlayerId(ownerId); + } + wasActive = false; } diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorThreadCore.java b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorThreadCore.java index 62924dfe..6b36e19a 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorThreadCore.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/ecalculator/ECalculatorThreadCore.java @@ -1,13 +1,13 @@ package github.kasuminova.novaeng.common.tile.ecotech.ecalculator; -import appeng.api.util.WorldCoord; -import appeng.me.cluster.implementations.CraftingCPUCluster; +import ae2.me.cluster.implementations.CraftingCPUCluster; import github.kasuminova.mmce.common.util.Sides; import github.kasuminova.novaeng.common.ecalculator.ECPUCluster; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.play.server.SPacketUpdateTileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.util.Constants; import javax.annotation.Nonnull; @@ -155,7 +155,7 @@ public void readCPUNBT(final NBTTagCompound compound) { for (int i = 0; i < clustersTag.tagCount(); i++) { NBTTagCompound clusterTag = clustersTag.getCompoundTagAt(i); - WorldCoord coord = new WorldCoord(getPos()); + BlockPos coord = getPos(); CraftingCPUCluster cluster = new CraftingCPUCluster(coord, coord); ECPUCluster eCluster = ECPUCluster.from(cluster); diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorController.java b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorController.java index 41b1bd25..aea7de9c 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorController.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorController.java @@ -1,16 +1,11 @@ package github.kasuminova.novaeng.common.tile.ecotech.efabricator; -import appeng.api.AEApi; -import appeng.api.config.Actionable; -import appeng.api.config.PowerMultiplier; -import appeng.api.networking.energy.IEnergyGrid; -import appeng.api.storage.channels.IItemStorageChannel; -import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IItemList; -import appeng.me.GridAccessException; -import appeng.util.Platform; -import appeng.util.item.ItemList; -import github.kasuminova.mmce.client.util.ItemStackUtils; +import ae2.api.config.Actionable; +import ae2.api.config.PowerMultiplier; +import ae2.api.networking.energy.IEnergyService; +import ae2.api.storage.StorageHelper; +import ae2.api.stacks.KeyCounter; +import ae2.api.stacks.GenericStack; import github.kasuminova.novaeng.NovaEngineeringCore; import github.kasuminova.novaeng.client.util.BlockModelHider; import github.kasuminova.novaeng.common.block.ecotech.efabricator.BlockEFabricatorController; @@ -48,8 +43,7 @@ public final class EFabricatorController extends EPartController coolantInputHandlers = new ObjectArrayList<>(); private final ObjectArrayList coolantOutputHandlers = new ObjectArrayList<>(); - private final IItemStorageChannel itemChannel = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); - private IItemList outputBuffer = new ItemList(); + private KeyCounter outputBuffer = new KeyCounter(); private double energyConsumePerTick = 64.0; private EFabricatorMEChannel channel; private int length; @@ -108,15 +102,11 @@ public ObjectArrayList getCoolantOutputHandlers() { return this.coolantOutputHandlers; } - public IItemStorageChannel getItemChannel() { - return this.itemChannel; - } - - public IItemList getOutputBuffer() { + public KeyCounter getOutputBuffer() { return this.outputBuffer; } - public void setOutputBuffer(final IItemList buffer) { + public void setOutputBuffer(final KeyCounter buffer) { this.outputBuffer = buffer; } @@ -249,7 +239,7 @@ public void setGuiDataDirty(final boolean dirty) { @Override public boolean onSyncTick() { - if (this.channel == null || !this.channel.getProxy().isActive()) { + if (this.channel == null || !this.channel.getMainNode().isActive()) { this.tickExecutor = null; return false; } @@ -331,12 +321,11 @@ public void supplyCoolantCache() { } public void supplyWorkerPower() { - final IEnergyGrid energy; - try { - energy = this.channel.getProxy().getEnergy(); - } catch (final GridAccessException ignored) { + final var node = this.channel.getMainNode().getNode(); + if (node == null) { return; } + final IEnergyService energy = node.grid().getEnergyService(); for (final var worker : this.getWorkers()) { if (worker.getEnergyCache() < worker.getMaxEnergyCache()) { worker.supplyEnergy((int) energy.extractAEPower(worker.getMaxEnergyCache() - worker.getEnergyCache(), @@ -346,14 +335,15 @@ public void supplyWorkerPower() { } public void clearOutputBuffer() { - try { - final var proxy = this.channel.getProxy(); - final var inventory = proxy.getStorage().getInventory(this.itemChannel); - for (final var stack : this.outputBuffer) { - final var remainder = Platform.poweredInsert(proxy.getEnergy(), inventory, stack.copy(), this.channel.getSource()); - stack.setStackSize(remainder == null ? 0 : remainder.getStackSize()); - } - } catch (final GridAccessException ignored) { + final var node = this.channel.getMainNode().getNode(); + if (node == null) { + return; + } + final var energy = node.grid().getEnergyService(); + final var inventory = node.grid().getStorageService().getInventory(); + for (final var stack : this.outputBuffer) { + final var inserted = StorageHelper.poweredInsert(energy, inventory, stack.getKey(), stack.getLongValue(), channel.getSource()); + outputBuffer.set(stack.getKey(), stack.getLongValue() - inserted); } } @@ -454,7 +444,7 @@ public void recalculateEnergyUsage() { if (this.energyConsumePerTick != drain) { this.energyConsumePerTick = drain; if (this.channel != null) { - this.channel.getProxy().setIdlePowerUsage(drain); + this.channel.getMainNode().setIdlePowerUsage(drain); } } } @@ -462,9 +452,9 @@ public void recalculateEnergyUsage() { public boolean insertPattern(final ItemStack stack) { for (final var bus : this.getPatternBuses()) { final var inventory = bus.getPatterns(); - for (int i = 0; i < inventory.getSlots(); i++) { + for (int i = 0; i < inventory.size(); i++) { if (inventory.getStackInSlot(i).isEmpty()) { - inventory.setStackInSlot(i, ItemUtils.copyStackWithSize(stack, 1)); + inventory.setItemDirect(i, ItemUtils.copyStackWithSize(stack, 1)); return true; } } @@ -638,10 +628,12 @@ public void readCustomNBT(final NBTTagCompound tag) { this.setOverclocked(tag.getBoolean("overclock")); this.setActiveCooling(tag.getBoolean("activeCooling")); this.coolantCache = tag.getInteger("coolantCache"); - this.outputBuffer = new ItemList(); + this.outputBuffer = new KeyCounter(); final NBTTagList items = tag.getTagList("outputBuffer", Constants.NBT.TAG_COMPOUND); - for (int i = 0; i < items.tagCount(); i++) { - this.outputBuffer.add(this.itemChannel.createStack(ItemStackUtils.readNBTOversize(items.getCompoundTagAt(i)))); + for (GenericStack stack : GenericStack.readList(items)) { + if (stack != null) { + this.outputBuffer.add(stack.what(), stack.amount()); + } } this.loaded = previouslyLoaded; if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { @@ -656,12 +648,12 @@ public void writeCustomNBT(final NBTTagCompound tag) { tag.setBoolean("overclock", this.overclocked); tag.setBoolean("activeCooling", this.activeCooling); tag.setInteger("coolantCache", this.coolantCache); - final NBTTagList items = new NBTTagList(); synchronized (this.outputBuffer) { + final List stacks = new ObjectArrayList<>(); for (final var stack : this.outputBuffer) { - items.appendTag(ItemStackUtils.writeNBTOversize(stack.getCachedItemStack(stack.getStackSize()))); + stacks.add(new GenericStack(stack.getKey(), stack.getLongValue())); } + tag.setTag("outputBuffer", GenericStack.writeList(stacks)); } - tag.setTag("outputBuffer", items); } } diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorMEChannel.java b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorMEChannel.java index 25dbd79b..b299a678 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorMEChannel.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorMEChannel.java @@ -1,49 +1,64 @@ package github.kasuminova.novaeng.common.tile.ecotech.efabricator; -import appeng.api.networking.GridFlags; -import appeng.api.networking.IGridNode; -import appeng.api.networking.crafting.ICraftingPatternDetails; -import appeng.api.networking.crafting.ICraftingProvider; -import appeng.api.networking.crafting.ICraftingProviderHelper; -import appeng.api.networking.events.MENetworkChannelsChanged; -import appeng.api.networking.events.MENetworkCraftingPatternChange; -import appeng.api.networking.events.MENetworkEventSubscribe; -import appeng.api.networking.events.MENetworkPowerStatusChange; -import appeng.api.networking.security.IActionHost; -import appeng.api.networking.security.IActionSource; -import appeng.api.util.AECableType; -import appeng.api.util.AEPartLocation; -import appeng.api.util.DimensionalCoord; -import appeng.me.GridAccessException; -import appeng.me.helpers.AENetworkProxy; -import appeng.me.helpers.IGridProxyable; -import appeng.me.helpers.MachineSource; -import com.glodblock.github.common.item.ItemFluidPacket; -import com.glodblock.github.common.item.fake.FakeItemRegister; -import com.glodblock.github.util.FluidCraftingPatternDetails; -import github.kasuminova.mmce.common.util.PatternItemFilter; +import ae2.api.AECapabilities; +import ae2.api.crafting.IPatternDetails; +import ae2.api.crafting.PatternDetailsHelper; +import ae2.api.networking.GridFlags; +import ae2.api.networking.IGridNode; +import ae2.api.networking.IGridNodeListener; +import ae2.api.networking.IManagedGridNode; +import ae2.api.networking.crafting.ICraftingProvider; +import ae2.api.stacks.AEItemKey; +import ae2.api.stacks.KeyCounter; +import ae2.api.networking.security.IActionSource; +import ae2.api.util.AECableType; +import ae2.me.ManagedGridNode; +import ae2.me.helpers.IGridConnectedTile; +import ae2.me.helpers.MachineSource; +import com.google.common.primitives.Ints; import github.kasuminova.novaeng.common.block.ecotech.efabricator.BlockEFabricatorMEChannel; import github.kasuminova.novaeng.common.tile.ecotech.efabricator.EFabricatorWorker.CraftWork; import hellfirepvp.modularmachinery.ModularMachinery; -import net.minecraft.inventory.InventoryCrafting; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; +import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Arrays; +import java.util.Collections; +import java.util.List; import java.util.Objects; -public final class EFabricatorMEChannel extends EFabricatorPart implements ICraftingProvider, IActionHost, IGridProxyable { +public final class EFabricatorMEChannel extends EFabricatorPart implements ICraftingProvider, IGridConnectedTile { - private final AENetworkProxy aEProxy = new AENetworkProxy(this, "channel", this.getVisualItemStack(), true); + private final IGridNodeListener nodeListener = new IGridNodeListener<>() { + @Override + public void onSaveChanges(EFabricatorMEChannel nodeOwner, IGridNode node) { + nodeOwner.saveChanges(); + } + + @Override + public void onStateChanged(EFabricatorMEChannel nodeOwner, IGridNode node, State state) { + nodeOwner.postPatternChangeEvent(); + } + }; + private final ItemStack visualItemStack; + private final IManagedGridNode mainNode = new ManagedGridNode(this, nodeListener); private final IActionSource source = new MachineSource(this); private boolean wasActive; public EFabricatorMEChannel() { - this.aEProxy.setIdlePowerUsage(1.0); - this.aEProxy.setFlags(GridFlags.REQUIRE_CHANNEL, GridFlags.DENSE_CAPACITY); + var controller = getController(); + visualItemStack = controller == null ? new ItemStack(BlockEFabricatorMEChannel.INSTANCE) : new ItemStack(Objects.requireNonNull(controller.getParentController())); + mainNode.setIdlePowerUsage(1.0) + .setFlags(GridFlags.REQUIRE_CHANNEL, GridFlags.DENSE_CAPACITY) + .setVisualRepresentation(this.visualItemStack) + .setInWorldNode(true) + .setTagName("channel"); } private static ItemStack getContainerItem(@Nullable final ItemStack stack) { @@ -76,96 +91,74 @@ public ItemStack getVisualItemStack() { : new ItemStack(Objects.requireNonNull(controller.getParentController())); } - @MENetworkEventSubscribe - public void stateChange(final MENetworkPowerStatusChange event) { - this.postPatternChangeEvent(); - } - - @MENetworkEventSubscribe - public void stateChange(final MENetworkChannelsChanged event) { - this.postPatternChangeEvent(); - } - private void postPatternChangeEvent() { - final boolean active = this.aEProxy.isActive(); + final boolean active = this.mainNode.isActive(); if (this.wasActive != active) { this.wasActive = active; - try { - this.aEProxy.getGrid().postEvent(new MENetworkCraftingPatternChange(this, this.aEProxy.getNode())); - } catch (final GridAccessException ignored) { - } + ICraftingProvider.requestUpdate(mainNode); } } @Override - public void provideCrafting(final ICraftingProviderHelper tracker) { + public List getAvailablePatterns() { final EFabricatorController controller = this.getController(); if (controller == null) { - return; + return Collections.emptyList(); } + + final var patternBuses = controller.getPatternBuses(); + if (patternBuses == null) { + return Collections.emptyList(); + } + + final List details = new ObjectArrayList<>(); for (final var bus : controller.getPatternBuses()) { - bus.provideCrafting(this, tracker); + details.addAll(bus.getDetails()); } + return details; } @Override - public boolean pushPattern(final ICraftingPatternDetails pattern, final InventoryCrafting table) { + public boolean pushPattern(final IPatternDetails pattern, final KeyCounter[] inputHolder, final int multiplier) { if (this.isBusy()) { return false; } - if (!pattern.isCraftable()) { - return pattern instanceof FluidCraftingPatternDetails fluid && this.pushFluidPattern(fluid, table); + + if (!(pattern.getPrimaryOutput().what() instanceof AEItemKey outputKey)) { + return false; } - final ItemStack output = pattern.getOutput(table, this.getWorld()); - if (output.isEmpty()) { + if (inputHolder.length > 9 || multiplier <= 0) { return false; } + final ItemStack[] remaining = new ItemStack[9]; Arrays.fill(remaining, ItemStack.EMPTY); - int size = 0; - for (int i = 0; i < Math.min(table.getSizeInventory(), 9); i++) { - final ItemStack item = table.getStackInSlot(i); - if (!item.isEmpty()) { - if (size == 0) { - size = item.getCount(); - } - remaining[i] = getContainerItem(item); + for (int i = 0; i < inputHolder.length; i++) { + final var entry = inputHolder[i].getFirstEntry(); + if (entry == null) { + return false; } + final long value = entry.getLongValue(); + if (!(entry.getKey() instanceof AEItemKey key)) { + return false; + } + remaining[i] = getContainerItem(key.toStack(Ints.saturatedCast(value))); } - output.setCount(output.getCount() * size); - return this.partController.offerWork(new CraftWork(remaining, output, size)); - } - - private boolean pushFluidPattern(final FluidCraftingPatternDetails pattern, final InventoryCrafting table) { - final var outputs = pattern.getOutputs(); - final ItemStack output = outputs[0] == null ? ItemStack.EMPTY : outputs[0].getCachedItemStack(outputs[0].getStackSize()); - if (output.isEmpty()) { + final var outputAmount = Math.multiplyExact(pattern.getPrimaryOutput().amount(), multiplier); + if (outputAmount > Integer.MAX_VALUE) { return false; } - final ItemStack[] remaining = new ItemStack[9]; - Arrays.fill(remaining, ItemStack.EMPTY); - int size = 0; - for (int i = 0; i < Math.min(table.getSizeInventory(), 9); i++) { - final ItemStack item = table.getStackInSlot(i); - if (!item.isEmpty()) { - if (size == 0) { - size = item.getCount(); - if (item.getItem() instanceof ItemFluidPacket) { - final int amount = ((FluidStack) FakeItemRegister.getStack(item)).amount; - final int patternAmount = ((FluidStack) FakeItemRegister.getStack(pattern.getInputs()[i])).amount; - size = amount / patternAmount; - } - } - remaining[i] = getContainerItem(item); - } - } - output.setCount(output.getCount() * size); - return this.partController.offerWork(new CraftWork(remaining, output, size)); + return this.partController.offerWork(new CraftWork(remaining, outputKey.toStack(Ints.saturatedCast(outputAmount)), multiplier)); } public boolean insertPattern(final ItemStack stack) { - return PatternItemFilter.INSTANCE.allowInsert(null, -1, stack) - && this.partController != null && this.partController.insertPattern(stack); + if (!PatternDetailsHelper.isEncodedPattern(stack)) { + return false; + } + if (partController != null) { + return partController.insertPattern(stack); + } + return false; } @Override @@ -175,73 +168,42 @@ public boolean isBusy() { @Override @Nonnull - public IGridNode getActionableNode() { - return this.aEProxy.getNode(); - } - - @Override - @Nonnull - public AENetworkProxy getProxy() { - return this.aEProxy; - } - - @Override - @Nonnull - public DimensionalCoord getLocation() { - return new DimensionalCoord(this); - } - - @Override - public void gridChanged() { - } - - @Override - @Nullable - public IGridNode getGridNode(@Nonnull final AEPartLocation direction) { - return this.aEProxy.getNode(); - } - - @Override - @Nonnull - public AECableType getCableConnectionType(@Nonnull final AEPartLocation direction) { - return AECableType.DENSE_SMART; - } - - @Override - public void securityBreak() { - this.getWorld().destroyBlock(this.getPos(), true); + public IManagedGridNode getMainNode() { + return this.mainNode; } @Override public void readCustomNBT(final NBTTagCompound tag) { super.readCustomNBT(tag); - this.aEProxy.readFromNBT(tag); + this.mainNode.loadFromNBT(tag); } @Override public void writeCustomNBT(final NBTTagCompound tag) { super.writeCustomNBT(tag); - this.aEProxy.writeToNBT(tag); + this.mainNode.saveToNBT(tag); } @Override public void onChunkUnload() { super.onChunkUnload(); - this.aEProxy.onChunkUnload(); + this.mainNode.destroy(); } @Override public void invalidate() { super.invalidate(); - this.aEProxy.invalidate(); + this.mainNode.destroy(); } @Override public void onAssembled() { super.onAssembled(); - this.aEProxy.setVisualRepresentation(this.getVisualItemStack()); + this.mainNode.setVisualRepresentation(this.getVisualItemStack()); ModularMachinery.EXECUTE_MANAGER.addSyncTask(() -> { - this.aEProxy.onReady(); + if (!mainNode.isReady() && !getWorld().isRemote) { + this.mainNode.create(getWorld(), getPos()); + } this.partController.recalculateEnergyUsage(); }); } @@ -249,7 +211,30 @@ public void onAssembled() { @Override public void onDisassembled() { super.onDisassembled(); - this.aEProxy.setVisualRepresentation(this.getVisualItemStack()); - this.aEProxy.invalidate(); + this.mainNode.setVisualRepresentation(this.getVisualItemStack()); + this.mainNode.destroy(); + } + + @Override + public void saveChanges() { + this.markDirty(); + } + + @Override + public AECableType getCableConnectionType(EnumFacing dir) { + return AECableType.DENSE_SMART; + } + + @Override + public boolean hasCapability(@NotNull Capability capability, @Nullable EnumFacing facing) { + return capability == AECapabilities.IN_WORLD_GRID_NODE_HOST || super.hasCapability(capability, facing); + } + + @Override + public @Nullable T getCapability(@NotNull Capability capability, @Nullable EnumFacing facing) { + if (capability == AECapabilities.IN_WORLD_GRID_NODE_HOST) { + return AECapabilities.IN_WORLD_GRID_NODE_HOST.cast(this); + } + return super.getCapability(capability, facing); } } diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorPatternBus.java b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorPatternBus.java index e94f0147..fe591f09 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorPatternBus.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorPatternBus.java @@ -1,19 +1,12 @@ package github.kasuminova.novaeng.common.tile.ecotech.efabricator; -import appeng.api.implementations.ICraftingPatternItem; -import appeng.api.networking.crafting.ICraftingPatternDetails; -import appeng.api.networking.crafting.ICraftingProvider; -import appeng.api.networking.crafting.ICraftingProviderHelper; -import appeng.api.networking.events.MENetworkCraftingPatternChange; -import appeng.api.storage.data.IAEItemStack; -import appeng.items.misc.ItemEncodedPattern; -import appeng.me.GridAccessException; -import appeng.tile.inventory.AppEngInternalInventory; -import appeng.util.inv.IAEAppEngInventory; -import appeng.util.inv.InvOperation; -import com.glodblock.github.util.FluidCraftingPatternDetails; -import com.glodblock.github.util.FluidPatternDetails; -import github.kasuminova.mmce.common.util.PatternItemFilter; +import ae2.api.crafting.IPatternDetails; +import ae2.api.crafting.PatternDetailsHelper; +import ae2.api.networking.crafting.ICraftingProvider; +import ae2.api.stacks.AEKey; +import ae2.api.stacks.GenericStack; +import ae2.util.inv.AppEngInternalInventory; +import ae2.util.inv.InternalInventoryHost; import github.kasuminova.novaeng.NovaEngineeringCore; import github.kasuminova.novaeng.common.container.ContainerEFabricatorPatternSearch; import github.kasuminova.novaeng.common.container.data.EFabricatorPatternData; @@ -29,27 +22,25 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.IItemHandler; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.List; import java.util.Set; -public final class EFabricatorPatternBus extends EFabricatorPart implements IAEAppEngInventory { +public final class EFabricatorPatternBus extends EFabricatorPart implements InternalInventoryHost { public static final int PATTERN_SLOTS = 72; - private final Set aePatterns = new ObjectOpenHashSet<>(); - private final AppEngInternalInventory patterns = new AppEngInternalInventory(this, PATTERN_SLOTS, 1, PatternItemFilter.INSTANCE); - private final ObjectArrayList details = new ObjectArrayList<>(PATTERN_SLOTS); + private final Set aePatterns = new ObjectOpenHashSet<>(); + private final AppEngInternalInventory patterns = new AppEngInternalInventory(this, PATTERN_SLOTS, 1); + private final ObjectArrayList details = new ObjectArrayList<>(PATTERN_SLOTS); private int validPatterns; - private ICraftingPatternDetails[] detailsSnapshot; public EFabricatorPatternBus() { this.details.size(PATTERN_SLOTS); } - public Set getAePatterns() { + public Set getAePatterns() { return this.aePatterns; } @@ -61,28 +52,21 @@ private void refreshPatterns() { for (int i = 0; i < PATTERN_SLOTS; i++) { this.refreshPattern(i); } + this.refreshPatternOutputs(); this.notifyPatternChanged(); } private void refreshPattern(final int slot) { - this.detailsSnapshot = null; - if (this.details.set(slot, null) != null) { - this.validPatterns--; - } + details.set(slot, null); final ItemStack pattern = this.patterns.getStackInSlot(slot); - if (pattern.isEmpty() || !(pattern.getItem() instanceof ICraftingPatternItem item)) { + if (pattern.isEmpty()) { return; } - final var detail = item.getPatternForItem(pattern, this.getWorld()); - if (detail != null && (detail.isCraftable() || detail instanceof FluidCraftingPatternDetails)) { - this.details.set(slot, detail); - this.validPatterns++; - this.detailsSnapshot = null; - } + this.details.set(slot, PatternDetailsHelper.decodePattern(pattern, getWorld())); } - public List getDetails() { - final List result = new ObjectArrayList<>(this.validPatterns); + public List getDetails() { + final List result = new ObjectArrayList<>(this.validPatterns); for (final var detail : this.details) { if (detail != null) { result.add(detail); @@ -95,61 +79,39 @@ public int getValidPatterns() { return this.validPatterns; } - void provideCrafting(final ICraftingProvider provider, final ICraftingProviderHelper tracker) { - ICraftingPatternDetails[] snapshot = this.detailsSnapshot; - if (snapshot == null) { - snapshot = new ICraftingPatternDetails[this.validPatterns]; - int index = 0; - for (final ICraftingPatternDetails detail : this.details) { - if (detail != null) { - snapshot[index++] = detail; - } - } - this.detailsSnapshot = snapshot; - } - for (final ICraftingPatternDetails detail : snapshot) { - if (detail.isCraftable() || detail instanceof FluidCraftingPatternDetails) { - tracker.addCraftingOption(provider, detail); - } - } - } - @Override - public void saveChanges() { + public void saveChangedInventory(AppEngInternalInventory inv) { this.markNoUpdateSync(); } @Override - public void onChangeInventory(final IItemHandler inventory, final int slot, final InvOperation operation, - final ItemStack removed, final ItemStack added) { + public void onChangeInventory(final AppEngInternalInventory inventory, final int slot) { this.refreshPattern(slot); - this.notifyPatternChanged(); this.sendPatternSearchGUIUpdateToClient(slot); - switch (operation) { - case EXTRACT -> this.removePattern(removed); - case INSERT -> this.addPattern(added); - case SET -> { - this.removePattern(removed); - this.addPattern(added); - } - } + this.refreshPatternOutputs(); + this.notifyPatternChanged(); } - private void addPattern(final ItemStack stack) { - if (stack.getItem() instanceof ItemEncodedPattern item) { - final var pattern = item.getPatternForItem(stack, this.world); - if (pattern != null && (pattern.isCraftable() || pattern instanceof FluidPatternDetails)) { - this.aePatterns.add(pattern.getCondensedOutputs()[0]); - } - } + @Override + public boolean isClientSide() { + return world != null && world.isRemote; } - private void removePattern(final ItemStack stack) { - if (stack.getItem() instanceof ItemEncodedPattern item) { - final var pattern = item.getPatternForItem(stack, this.world); - if (pattern != null && (pattern.isCraftable() || pattern instanceof FluidPatternDetails)) { - this.aePatterns.remove(pattern.getCondensedOutputs()[0]); + private void refreshPatternOutputs() { + aePatterns.clear(); + for (IPatternDetails detail : details) { + if (detail == null) { + return; + } + final GenericStack stack = detail.getPrimaryOutput(); + if (stack == null) { + return; } + final AEKey key = stack.what(); + if (key == null) { + return; + } + aePatterns.add(key); } } @@ -157,12 +119,13 @@ private void notifyPatternChanged() { if (this.partController == null) { return; } - try { - final var channel = this.partController.getChannel(); - if (channel != null && channel.getProxy().isActive()) { - channel.getProxy().getGrid().postEvent(new MENetworkCraftingPatternChange(channel, channel.getProxy().getNode())); - } - } catch (final GridAccessException ignored) { + final var channel = this.partController.getChannel(); + if (channel == null) { + return; + } + final var mainNode = channel.getMainNode(); + if (mainNode.isActive()) { + ICraftingProvider.requestUpdate(mainNode); } this.partController.recalculateEnergyUsage(); } @@ -213,10 +176,8 @@ public T getCapability(@Nonnull final Capability capability, @Nullable fi @Override public void readCustomNBT(final NBTTagCompound tag) { super.readCustomNBT(tag); - this.patterns.readFromNBT(tag.getCompoundTag("patterns")); - for (final ItemStack stack : this.patterns) { - this.addPattern(stack); - } + this.patterns.readFromNBT(tag, "patterns"); + refreshPatterns(); } @Override diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorWorker.java b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorWorker.java index 0d57a431..1899e9bf 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorWorker.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/efabricator/EFabricatorWorker.java @@ -1,11 +1,11 @@ package github.kasuminova.novaeng.common.tile.ecotech.efabricator; -import appeng.api.config.Actionable; -import appeng.api.networking.energy.IEnergyGrid; -import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IItemList; -import appeng.me.GridAccessException; -import appeng.util.item.AEItemStack; +import ae2.api.config.Actionable; +import ae2.api.networking.IGrid; +import ae2.api.networking.IGridNode; +import ae2.api.networking.energy.IEnergyService; +import ae2.api.stacks.AEItemKey; +import ae2.api.stacks.KeyCounter; import github.kasuminova.novaeng.NovaEngineeringCore; import github.kasuminova.novaeng.common.block.ecotech.efabricator.prop.WorkerStatus; import github.kasuminova.novaeng.common.network.PktEFabricatorWorkerStatusUpdate; @@ -92,13 +92,16 @@ public synchronized int doWork() { final int usage = controller.getOverclocked() && !controller.getActiveCooling() ? controller.getLevel().applyOverclockEnergyUsage(ENERGY_USAGE) : ENERGY_USAGE; double energy = this.energyCache; - IEnergyGrid grid = null; + IEnergyService grid = null; final var channel = controller.getChannel(); if (channel != null) { - try { - grid = channel.getProxy().getGrid().getCache(IEnergyGrid.class); - energy += grid.getStoredPower(); - } catch (final GridAccessException ignored) { + IGridNode node = channel.getMainNode().getNode(); + if (node != null) { + IGrid igrid = node.grid(); + if (igrid != null) { + grid = igrid.getEnergyService(); + energy += grid.getStoredPower(); + } } } int parallelism = (int) Math.min(Math.max(controller.getAvailableParallelism(), 1), energy / usage); @@ -106,7 +109,7 @@ public synchronized int doWork() { parallelism = Math.min(parallelism, coolant / COOLANT_USAGE); } int completed = 0; - final IItemList output = controller.getOutputBuffer(); + final KeyCounter output = controller.getOutputBuffer(); synchronized (output) { while (parallelism > completed && !this.queue.isEmpty()) { final CraftWork work = this.queue.poll(); @@ -120,10 +123,16 @@ public synchronized int doWork() { } for (final ItemStack remaining : finished.remaining) { if (!remaining.isEmpty()) { - output.add(AEItemStack.fromItemStack(remaining)); + final var key = AEItemKey.of(remaining); + if (key != null) { + output.add(key, remaining.getCount()); + } } } - output.add(AEItemStack.fromItemStack(finished.output)); + final var key = AEItemKey.of(finished.output); + if (key != null) { + output.add(key, finished.output.getCount()); + } completed += finished.size; } } diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageCellDrive.java b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageCellDrive.java index 6a184771..6c951528 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageCellDrive.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageCellDrive.java @@ -1,25 +1,15 @@ package github.kasuminova.novaeng.common.tile.ecotech.estorage; -import appeng.api.AEApi; -import appeng.api.networking.events.MENetworkCellArrayUpdate; -import appeng.api.networking.security.IActionSource; -import appeng.api.networking.storage.IStorageGrid; -import appeng.api.storage.ICellInventory; -import appeng.api.storage.ICellInventoryHandler; -import appeng.api.storage.IMEInventory; -import appeng.api.storage.IMEInventoryHandler; -import appeng.api.storage.ISaveProvider; -import appeng.api.storage.IStorageChannel; -import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IAEStack; -import appeng.api.storage.data.IItemList; -import appeng.me.GridAccessException; -import appeng.me.helpers.AENetworkProxy; -import appeng.tile.inventory.AppEngCellInventory; -import appeng.util.helpers.ItemHandlerUtil; -import appeng.util.inv.IAEAppEngInventory; -import appeng.util.inv.InvOperation; -import appeng.util.inv.filter.IAEItemFilter; +import ae2.api.inventories.InternalInventory; +import ae2.api.stacks.AEKeyType; +import ae2.api.storage.StorageCells; +import ae2.api.storage.cells.ISaveProvider; +import ae2.api.storage.cells.StorageCell; +import ae2.api.storage.cells.StorageCellStatistics; +import ae2.util.inv.AppEngCellInventory; +import ae2.util.inv.AppEngInternalInventory; +import ae2.util.inv.InternalInventoryHost; +import ae2.util.inv.filter.IAEItemFilter; import github.kasuminova.novaeng.NovaEngineeringCore; import github.kasuminova.novaeng.common.block.ecotech.estorage.BlockEStorageController; import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStorageCapacity; @@ -27,7 +17,6 @@ import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.DriveStorageType; import github.kasuminova.novaeng.common.container.data.EStorageCellData; import github.kasuminova.novaeng.common.estorage.ECellDriveWatcher; -import github.kasuminova.novaeng.common.estorage.EStorageCellHandler; import github.kasuminova.novaeng.common.item.estorage.EStorageCell; import github.kasuminova.novaeng.common.item.estorage.EStorageCellFluid; import github.kasuminova.novaeng.common.item.estorage.EStorageCellGas; @@ -45,26 +34,21 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.IItemHandler; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.Collection; import java.util.Map; -import static appeng.helpers.ItemStackHelper.stackFromNBT; -import static appeng.helpers.ItemStackHelper.stackWriteToNBT; - -@SuppressWarnings("rawtypes") -public class EStorageCellDrive extends EStoragePart implements ISaveProvider, IAEAppEngInventory { +public class EStorageCellDrive extends EStoragePart implements ISaveProvider, InternalInventoryHost { @Getter protected final AppEngCellInventory driveInv = new AppEngCellInventory(this, 1); - protected final Map>, IMEInventoryHandler> inventoryHandlers = new Reference2ObjectOpenHashMap<>(); + protected final Map inventoryHandlers = new Reference2ObjectOpenHashMap<>(); - protected EStorageCellHandler cellHandler = null; @Getter - protected ECellDriveWatcher watcher = null; + protected StorageCell cellHandler = null; + @Getter + protected ECellDriveWatcher watcher = null; protected boolean isCached = false; @@ -112,34 +96,29 @@ public static long getMaxBytes(final EStorageCellData data) { }; } - public static DriveStorageType getCellType(final EStorageCell cell) { + public static DriveStorageType getCellType(final EStorageCell cell) { DriveStorageType type; - if (cell instanceof EStorageCellItem) { - type = DriveStorageType.ITEM; - } else if (cell instanceof EStorageCellFluid) { - type = DriveStorageType.FLUID; - } else if (Mods.MEKENG.isPresent() && cell instanceof EStorageCellGas) { - type = DriveStorageType.GAS; - } else { - return null; + switch (cell) { + case EStorageCellItem _ -> type = DriveStorageType.ITEM; + case EStorageCellFluid _ -> type = DriveStorageType.FLUID; + case EStorageCellGas _ when Mods.MEKENG.isPresent() -> type = DriveStorageType.GAS; + case null, default -> { + return null; + } } return type; } - public static DriveStorageCapacity getCapacity(final ICellInventoryHandler cellInvHandler) { - if (cellInvHandler == null) { + public static DriveStorageCapacity getCapacity(final StorageCell cellInventory) { + if (!(cellInventory instanceof StorageCellStatistics statistics)) { return DriveStorageCapacity.EMPTY; } - ICellInventory cellInv = cellInvHandler.getCellInv(); - if (cellInv == null) { - return DriveStorageCapacity.EMPTY; - } - long totalTypes = cellInv.getTotalItemTypes(); - long storedTypes = cellInv.getStoredItemTypes(); + long totalTypes = statistics.getTotalTypes(); + long storedTypes = statistics.getStoredTypes(); if (storedTypes == 0) { return DriveStorageCapacity.EMPTY; } - if (cellInv.getFreeBytes() <= 0) { + if (statistics.getUsedBytes() >= statistics.getTotalBytes()) { return DriveStorageCapacity.FULL; } if (storedTypes >= totalTypes) { @@ -193,28 +172,18 @@ protected void updateHandler(final boolean refreshState) { cellHandler = null; inventoryHandlers.clear(); isCached = true; + driveInv.setHandler(0, null); ItemStack stack = driveInv.getStackInSlot(0); if (stack.isEmpty()) { updateDriveBlockState(); return; } - if ((cellHandler = EStorageCellHandler.getHandler(stack)) == null) { - return; - } - ICellInventoryHandler cellInventory = null; - final Collection>> storageChannels = AEApi.instance().storage().storageChannels(); - for (final IStorageChannel> channel : storageChannels) { - cellInventory = cellHandler.getCellInventory(stack, this, channel); - if (cellInventory == null) { - continue; - } + StorageCell cellInventory = StorageCells.getCellInventory(stack, this); + if (cellInventory != null && stack.getItem() instanceof EStorageCell cell) { + cellHandler = cellInventory; driveInv.setHandler(0, cellInventory); - watcher = new ECellDriveWatcher<>(cellInventory, channel, this); - if (partController != null) { - watcher.setPriority(partController.getChannel().getPriority()); - } - inventoryHandlers.put(channel, watcher); - break; + watcher = new ECellDriveWatcher(cellInventory, this); + inventoryHandlers.put(cell.getKeyType(), watcher); } if (partController != null) { partController.recalculateEnergyUsage(); @@ -252,98 +221,35 @@ public void updateDriveBlockState() { markForUpdate(); } - public > IMEInventoryHandler getHandler(final IStorageChannel channel) { + public ECellDriveWatcher getHandler(final AEKeyType channel) { updateHandler(false); - if (driveInv.getStackInSlot(0).getItem() instanceof EStorageCell cell && isCellSupported(cell.getLevel())) { - IMEInventoryHandler handler = inventoryHandlers.get(channel); - return handler == null ? null : (IMEInventoryHandler) handler; + if (driveInv.getStackInSlot(0).getItem() instanceof EStorageCell cell && isCellSupported(cell.getLevel())) { + return inventoryHandlers.get(channel); } return null; } @Override - public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added) { + public void onChangeInventory(final AppEngInternalInventory inv, final int slot) { this.isCached = false; // recalculate the storage cell. this.updateHandler(true); this.markForUpdateSync(); + } - EStorageController controller = getController(); - if (controller == null) { - return; - } - - EStorageMEChannel channel = controller.getChannel(); - AENetworkProxy proxy = channel.getProxy(); - IActionSource source = channel.getSource(); - - try { - if (proxy.isActive()) { - final IStorageGrid gs = proxy.getStorage(); - postChanges(gs, removed, added, source); - } - proxy.getGrid().postEvent(new MENetworkCellArrayUpdate()); - } catch (final GridAccessException ignored) { - } - + @Override + public void saveChangedInventory(final AppEngInternalInventory inv) { + saveChanges(); } @Override - public void onAssembled() { - super.onAssembled(); - if (watcher != null) { - watcher.setPriority(partController.getChannel().getPriority()); - } + public boolean isClientSide() { + return world.isRemote; } @Override public void onDisassembled() { super.onDisassembled(); - EStorageController controller = getController(); - if (controller == null) { - return; - } - EStorageMEChannel channel = controller.getChannel(); - if (channel == null) { - return; - } - AENetworkProxy proxy = channel.getProxy(); - IActionSource source = channel.getSource(); - - try { - if (proxy.isActive()) { - ItemStack removed = driveInv.getStackInSlot(0); - final IStorageGrid gs = proxy.getStorage(); - postChanges(gs, removed, ItemStack.EMPTY, source); - } - proxy.getGrid().postEvent(new MENetworkCellArrayUpdate()); - } catch (final GridAccessException ignored) { - } - } - - public void postChanges(final IStorageGrid gs, final ItemStack removed, final ItemStack added, final IActionSource src) { - if (cellHandler == null) { - return; - } - for (final IStorageChannel chan : AEApi.instance().storage().storageChannels()) { - final IItemList myChanges = chan.createList(); - - if (!removed.isEmpty()) { - final IMEInventory myInv = cellHandler.getCellInventory(removed, null, chan); - if (myInv != null) { - myInv.getAvailableItems(myChanges); - for (final IAEStack is : myChanges) { - is.setStackSize(-is.getStackSize()); - } - } - } - if (!added.isEmpty()) { - final IMEInventory myInv = cellHandler.getCellInventory(added, null, chan); - if (myInv != null) { - myInv.getAvailableItems(myChanges); - } - } - gs.postAlterationOfStoredItems(chan, myChanges, src); - } + driveInv.persist(); } public void onWriting() { @@ -362,7 +268,7 @@ public boolean hasCapability(@Nonnull final Capability capability, @Nullable @Override public T getCapability(@Nonnull final Capability capability, @Nullable final EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { - return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(driveInv); + return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(driveInv.toItemHandler()); } return super.getCapability(capability, facing); } @@ -372,9 +278,9 @@ public void readCustomNBT(final NBTTagCompound tag) { super.readCustomNBT(tag); final NBTTagCompound opt = tag.getCompoundTag("driveInv"); - for (int x = 0; x < driveInv.getSlots(); x++) { + for (int x = 0; x < driveInv.size(); x++) { final NBTTagCompound item = opt.getCompoundTag("item" + x); - ItemHandlerUtil.setStackInSlot(driveInv, x, stackFromNBT(item)); + driveInv.setItemDirect(x, item.hasKey("id", 8) ? new ItemStack(item) : ItemStack.EMPTY); } if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { @@ -387,22 +293,17 @@ public void writeCustomNBT(final NBTTagCompound tag) { super.writeCustomNBT(tag); final NBTTagCompound opt = new NBTTagCompound(); - for (int x = 0; x < driveInv.getSlots(); x++) { + for (int x = 0; x < driveInv.size(); x++) { final NBTTagCompound itemNBT = new NBTTagCompound(); final ItemStack is = driveInv.getStackInSlot(x); if (!is.isEmpty()) { - stackWriteToNBT(is, itemNBT); + is.writeToNBT(itemNBT); } opt.setTag("item" + x, itemNBT); } tag.setTag("driveInv", opt); } - @Override - public void saveChanges(@Nullable final ICellInventory cellInventory) { - saveChanges(); - } - @Override public void saveChanges() { markDirty(); @@ -418,13 +319,10 @@ private static class CellInvFilter implements IAEItemFilter { private static final CellInvFilter INSTANCE = new CellInvFilter(); @Override - public boolean allowExtract(IItemHandler inv, int slot, int amount) { - return true; - } - - @Override - public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { - return !stack.isEmpty() && EStorageCellHandler.getHandler(stack) != null; + public boolean allowInsert(InternalInventory inv, int slot, ItemStack stack) { + return !stack.isEmpty() + && stack.getItem() instanceof EStorageCell + && StorageCells.isCellHandled(stack); } } diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageController.java b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageController.java index f173c950..7b4dacfa 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageController.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageController.java @@ -1,12 +1,10 @@ package github.kasuminova.novaeng.common.tile.ecotech.estorage; -import appeng.api.config.Actionable; -import appeng.api.storage.ICellInventory; -import appeng.api.storage.ICellInventoryHandler; -import appeng.api.storage.data.IAEItemStack; +import ae2.api.config.Actionable; +import ae2.api.storage.IStorageProvider; +import ae2.api.storage.cells.StorageCell; import github.kasuminova.novaeng.client.util.BlockModelHider; import github.kasuminova.novaeng.common.block.ecotech.estorage.BlockEStorageController; -import github.kasuminova.novaeng.common.estorage.ECellDriveWatcher; import github.kasuminova.novaeng.common.tile.ecotech.EPartController; import github.kasuminova.novaeng.common.tile.ecotech.estorage.bus.EStorageBus; import github.kasuminova.novaeng.novaeng_core.Tags; @@ -174,23 +172,15 @@ public double extractPower(final double amt, final Actionable mode) { public void recalculateEnergyUsage() { double newIdleDrain = 64; for (final EStorageCellDrive drive : getCellDrives()) { - ECellDriveWatcher watcher = drive.getWatcher(); - if (watcher == null) { + StorageCell cell = drive.getCellHandler(); + if (cell == null) { continue; } - ICellInventoryHandler cellInventory = (ICellInventoryHandler) watcher.getInternal(); - if (cellInventory == null) { - continue; - } - ICellInventory cellInv = cellInventory.getCellInv(); - if (cellInv == null) { - continue; - } - newIdleDrain += cellInv.getIdleDrain(); + newIdleDrain += cell.getIdleDrain(); } this.idleDrain = newIdleDrain; - if (this.channel != null) { - this.channel.getProxy().setIdlePowerUsage(idleDrain); + if (channel != null) { + IStorageProvider.requestUpdate(channel.getMainNode()); } } diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageEnergyCell.java b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageEnergyCell.java index e7f4f4e9..79f6d9c5 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageEnergyCell.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageEnergyCell.java @@ -1,6 +1,6 @@ package github.kasuminova.novaeng.common.tile.ecotech.estorage; -import appeng.api.config.Actionable; +import ae2.api.config.Actionable; import github.kasuminova.novaeng.common.block.ecotech.estorage.BlockEStorageEnergyCell; import github.kasuminova.novaeng.common.block.ecotech.estorage.prop.EnergyCellStatus; import lombok.Getter; diff --git a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageMEChannel.java b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageMEChannel.java index ec40c5de..2a0bf12b 100644 --- a/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageMEChannel.java +++ b/src/main/java/github/kasuminova/novaeng/common/tile/ecotech/estorage/EStorageMEChannel.java @@ -1,52 +1,73 @@ package github.kasuminova.novaeng.common.tile.ecotech.estorage; -import appeng.api.config.AccessRestriction; -import appeng.api.config.Actionable; -import appeng.api.config.PowerMultiplier; -import appeng.api.networking.GridFlags; -import appeng.api.networking.IGridNode; -import appeng.api.networking.energy.IAEPowerStorage; -import appeng.api.networking.events.MENetworkCellArrayUpdate; -import appeng.api.networking.events.MENetworkChannelsChanged; -import appeng.api.networking.events.MENetworkEventSubscribe; -import appeng.api.networking.events.MENetworkPowerStatusChange; -import appeng.api.networking.events.MENetworkPowerStorage; -import appeng.api.networking.security.IActionHost; -import appeng.api.networking.security.IActionSource; -import appeng.api.storage.ICellContainer; -import appeng.api.storage.ICellInventory; -import appeng.api.storage.IMEInventoryHandler; -import appeng.api.storage.IStorageChannel; -import appeng.api.util.AECableType; -import appeng.api.util.AEPartLocation; -import appeng.api.util.DimensionalCoord; -import appeng.me.GridAccessException; -import appeng.me.helpers.AENetworkProxy; -import appeng.me.helpers.IGridProxyable; -import appeng.me.helpers.MachineSource; +import ae2.api.AECapabilities; +import ae2.api.config.AccessRestriction; +import ae2.api.config.Actionable; +import ae2.api.config.PowerMultiplier; +import ae2.api.networking.GridFlags; +import ae2.api.networking.GridHelper; +import ae2.api.networking.IGridNode; +import ae2.api.networking.IGridNodeListener; +import ae2.api.networking.IManagedGridNode; +import ae2.api.networking.events.GridPowerStorageStateChanged; +import ae2.api.networking.energy.IAEPowerStorage; +import ae2.api.networking.security.IActionSource; +import ae2.api.storage.IStorageMounts; +import ae2.api.storage.IStorageProvider; +import ae2.api.storage.MEStorage; +import ae2.api.storage.MEStorageChangeListener; +import ae2.api.storage.MEStorageMonitor; +import ae2.api.storage.cells.StorageCell; +import ae2.api.stacks.AEKey; +import ae2.api.stacks.AEKeyType; +import ae2.api.stacks.AEKeyTypes; +import ae2.api.stacks.KeyCounter; +import ae2.api.util.AECableType; +import ae2.me.helpers.IGridConnectedTile; +import ae2.me.helpers.MachineSource; +import github.kasuminova.novaeng.common.estorage.ECellDriveWatcher; import github.kasuminova.novaeng.common.block.ecotech.efabricator.BlockEFabricatorMEChannel; import hellfirepvp.modularmachinery.ModularMachinery; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.Collections; -import java.util.List; -import java.util.ArrayList; -public class EStorageMEChannel extends EStoragePart implements ICellContainer, IActionHost, IGridProxyable, IAEPowerStorage { +public class EStorageMEChannel extends EStoragePart implements IGridConnectedTile, IStorageProvider, IAEPowerStorage { - protected final AENetworkProxy proxy = new AENetworkProxy(this, "channel", getVisualItemStack(), true); + private static final IGridNodeListener NODE_LISTENER = new IGridNodeListener<>() { + @Override + public void onSaveChanges(final EStorageMEChannel nodeOwner, final IGridNode node) { + nodeOwner.saveChanges(); + } + + @Override + public void onStateChanged(final EStorageMEChannel nodeOwner, + final IGridNode node, + final State state) { + nodeOwner.onMainNodeStateChanged(state); + } + }; + + protected IManagedGridNode mainNode = createMainNode(); protected final IActionSource source = new MachineSource(this); protected int priority = 0; private boolean wasActive = false; - public EStorageMEChannel() { - this.proxy.setIdlePowerUsage(1.0D); - this.proxy.setFlags(GridFlags.REQUIRE_CHANNEL, GridFlags.DENSE_CAPACITY); + private IManagedGridNode createMainNode() { + return GridHelper.createManagedNode(this, NODE_LISTENER) + .setIdlePowerUsage(1.0D) + .setFlags(GridFlags.REQUIRE_CHANNEL, GridFlags.DENSE_CAPACITY) + .setVisualRepresentation(getVisualItemStack()) + .setInWorldNode(true) + .setTagName("channel") + .addService(IStorageProvider.class, this) + .addService(IAEPowerStorage.class, this); } public IActionSource getSource() { @@ -54,17 +75,31 @@ public IActionSource getSource() { } @Override - @SuppressWarnings("rawtypes") - public List getCellArray(final IStorageChannel channel) { - if (partController != null) { - final List handlers = new ArrayList<>(); - for (EStorageCellDrive drive : partController.getCellDrives()) { - final IMEInventoryHandler handler = drive.getHandler(channel); - if (handler != null) handlers.add(handler); + public void mountInventories(final IStorageMounts mounts) { + if (partController == null) { + return; + } + + for (final EStorageCellDrive drive : partController.getCellDrives()) { + for (final AEKeyType keyType : AEKeyTypes.getAll()) { + mountDrive(mounts, drive, keyType); } - return handlers; } - return Collections.emptyList(); + } + + private void mountDrive(final IStorageMounts mounts, + final EStorageCellDrive drive, + final AEKeyType keyType) { + final ECellDriveWatcher handler = drive.getHandler(keyType); + if (handler == null) { + return; + } + + final StorageCell cell = drive.getCellHandler(); + if (cell == null) { + throw new IllegalStateException("Storage drive returned a handler without a cell"); + } + mounts.mount(new DriveStorageMonitor(handler, cell), priority); } @Override @@ -73,76 +108,61 @@ public int getPriority() { } public ItemStack getVisualItemStack() { - EStorageController controller = getController(); - return new ItemStack(Item.getItemFromBlock(controller == null ? BlockEFabricatorMEChannel.INSTANCE : controller.getParentController()), 1, 0); + final EStorageController controller = getController(); + return new ItemStack(Item.getItemFromBlock( + controller == null ? BlockEFabricatorMEChannel.INSTANCE : controller.getParentController()), 1, 0); } - @MENetworkEventSubscribe - public void stateChange(final MENetworkPowerStatusChange c) { - postCellArrayUpdateEvent(); - } - - @MENetworkEventSubscribe - public void stateChange(final MENetworkChannelsChanged c) { - postCellArrayUpdateEvent(); - } - - protected void postCellArrayUpdateEvent() { - final boolean currentActive = this.proxy.isActive(); - if (this.wasActive != currentActive) { - this.wasActive = currentActive; - try { - this.proxy.getGrid().postEvent(new MENetworkCellArrayUpdate()); - } catch (final GridAccessException ignored) { - } + @Override + public void onMainNodeStateChanged(final IGridNodeListener.State reason) { + final boolean currentActive = mainNode.isActive(); + if (wasActive != currentActive) { + wasActive = currentActive; + IStorageProvider.requestUpdate(mainNode); } } @Override public double injectAEPower(final double amt, @Nonnull final Actionable mode) { - if (partController == null) { + if (partController == null || amt < 0.000001D) { return 0; } - if (amt < 0.000001) { - return 0; - } - if (mode == Actionable.MODULATE && this.getAECurrentPower() < 0.01 && amt > 0) { - this.proxy.getNode().getGrid().postEvent(new MENetworkPowerStorage(this, MENetworkPowerStorage.PowerEventType.PROVIDE_POWER)); + if (mode == Actionable.MODULATE && getAECurrentPower() < 0.01D && amt > 0) { + postPowerStorageStateChanged(GridPowerStorageStateChanged.PowerEventType.PROVIDE_POWER); } return partController.injectPower(amt, mode); } @Override - public double extractAEPower(final double amt, @Nonnull final Actionable mode, @Nonnull final PowerMultiplier multiplier) { + public double extractAEPower(final double amt, + @Nonnull final Actionable mode, + @Nonnull final PowerMultiplier multiplier) { if (partController == null) { return 0; } - if (mode == Actionable.MODULATE) { - final boolean wasFull = this.getAECurrentPower() >= this.getAEMaxPower() - 0.001; - if (wasFull && amt > 0) { - try { - this.proxy.getGrid().postEvent(new MENetworkPowerStorage(this, MENetworkPowerStorage.PowerEventType.REQUEST_POWER)); - } catch (final GridAccessException ignored) { - } - } + if (mode == Actionable.MODULATE + && getAECurrentPower() >= getAEMaxPower() - 0.001D + && amt > 0) { + postPowerStorageStateChanged(GridPowerStorageStateChanged.PowerEventType.RECEIVE_POWER); } return multiplier.divide(partController.extractPower(multiplier.multiply(amt), mode)); } + private void postPowerStorageStateChanged(final GridPowerStorageStateChanged.PowerEventType type) { + final IGridNode node = mainNode.getNode(); + if (node != null) { + node.grid().postEvent(new GridPowerStorageStateChanged(this, type)); + } + } + @Override public double getAEMaxPower() { - if (this.partController == null) { - return 0; - } - return this.partController.getMaxEnergyStore(); + return partController == null ? 0 : partController.getMaxEnergyStore(); } @Override public double getAECurrentPower() { - if (this.partController == null) { - return 0; - } - return this.partController.getEnergyStored(); + return partController == null ? 0 : partController.getEnergyStored(); } @Override @@ -156,101 +176,162 @@ public AccessRestriction getPowerFlow() { return AccessRestriction.READ_WRITE; } - @Nonnull + @Nullable @Override public IGridNode getActionableNode() { - return proxy.getNode(); + return mainNode.getNode(); } - @Nonnull @Override - public AENetworkProxy getProxy() { - return proxy; + public IManagedGridNode getMainNode() { + return mainNode; } - @Nonnull + @Nullable @Override - public DimensionalCoord getLocation() { - return new DimensionalCoord(this); + public IGridNode getGridNode(@Nonnull final EnumFacing dir) { + return mainNode.getNode(); } + @Nonnull @Override - public void gridChanged() { - + public AECableType getCableConnectionType(@Nonnull final EnumFacing dir) { + return AECableType.DENSE_SMART; } - @Nullable @Override - public IGridNode getGridNode(@Nonnull final AEPartLocation dir) { - return proxy.getNode(); + public void saveChanges() { + markDirty(); + } + + public void securityBreak() { + getWorld().destroyBlock(getPos(), true); } - @Nonnull @Override - public AECableType getCableConnectionType(@Nonnull final AEPartLocation dir) { - return AECableType.DENSE_SMART; + public boolean hasCapability(@Nonnull final Capability capability, @Nullable final EnumFacing facing) { + if (capability == AECapabilities.IN_WORLD_GRID_NODE_HOST) { + return true; + } + return super.hasCapability(capability, facing); } + @Nullable @Override - public void securityBreak() { - getWorld().destroyBlock(getPos(), true); + public T getCapability(@Nonnull final Capability capability, @Nullable final EnumFacing facing) { + if (capability == AECapabilities.IN_WORLD_GRID_NODE_HOST) { + return AECapabilities.IN_WORLD_GRID_NODE_HOST.cast(this); + } + return super.getCapability(capability, facing); } @Override public void readCustomNBT(final NBTTagCompound compound) { super.readCustomNBT(compound); - proxy.readFromNBT(compound); + mainNode.loadFromNBT(compound); } @Override public void writeCustomNBT(final NBTTagCompound compound) { super.writeCustomNBT(compound); - proxy.writeToNBT(compound); + mainNode.saveToNBT(compound); } @Override public void onChunkUnload() { super.onChunkUnload(); - proxy.onChunkUnload(); + mainNode.destroy(); } @Override public void invalidate() { super.invalidate(); - proxy.invalidate(); + mainNode.destroy(); } @Override public void onAssembled() { super.onAssembled(); - proxy.setVisualRepresentation(getVisualItemStack()); + mainNode.setVisualRepresentation(getVisualItemStack()); + final IManagedGridNode node = mainNode; ModularMachinery.EXECUTE_MANAGER.addSyncTask(() -> { - proxy.onReady(); - partController.recalculateEnergyUsage(); - List cellDrives = partController.getCellDrives(); - if (!cellDrives.isEmpty()) { - try { - proxy.getGrid().postEvent(new MENetworkCellArrayUpdate()); - } catch (GridAccessException ignored) { - } + if (mainNode == node && !node.isReady() && !getWorld().isRemote) { + node.create(getWorld(), getPos()); } + partController.recalculateEnergyUsage(); }); } @Override public void onDisassembled() { super.onDisassembled(); - proxy.setVisualRepresentation(getVisualItemStack()); - proxy.invalidate(); + int ownerId = -1; + if (mainNode.isReady()) { + final IGridNode node = mainNode.getNode(); + if (node != null) { + ownerId = node.getOwningPlayerId(); + } + } + mainNode.destroy(); + mainNode = createMainNode(); + if (ownerId >= 0) { + mainNode.setOwningPlayerId(ownerId); + } + wasActive = false; } - // noop + private static final class DriveStorageMonitor implements MEStorageMonitor { + private final MEStorage handler; + private final StorageCell monitor; - @Override - public void blinkCell(final int slot) { - } + private DriveStorageMonitor(final MEStorage handler, final StorageCell monitor) { + this.handler = handler; + this.monitor = monitor; + } - @Override - public void saveChanges(@Nullable final ICellInventory cellInventory) { + @Override + public void addListener(final MEStorageChangeListener listener, final Object verificationToken) { + monitor.addListener(listener, verificationToken); + } + + @Override + public void removeListener(final MEStorageChangeListener listener) { + monitor.removeListener(listener); + } + + @Override + public boolean isPreferredStorageFor(final AEKey what, final IActionSource source) { + return handler.isPreferredStorageFor(what, source); + } + + @Override + public boolean isStickyStorageFor(final AEKey what, final IActionSource source) { + return handler.isStickyStorageFor(what, source); + } + + @Override + public long insert(final AEKey what, final long amount, final Actionable mode, final IActionSource source) { + return handler.insert(what, amount, mode, source); + } + + @Override + public long extract(final AEKey what, final long amount, final Actionable mode, final IActionSource source) { + return handler.extract(what, amount, mode, source); + } + + @Override + public void getAvailableStacks(final KeyCounter out) { + handler.getAvailableStacks(out); + } + + @Override + public KeyCounter getAvailableStacks() { + return handler.getAvailableStacks(); + } + + @Override + public net.minecraft.util.text.ITextComponent getDescription() { + return handler.getDescription(); + } } } diff --git a/src/main/java/github/kasuminova/novaeng/common/util/AEItemStackSet.java b/src/main/java/github/kasuminova/novaeng/common/util/AEItemStackSet.java index a9def05c..2925bb70 100644 --- a/src/main/java/github/kasuminova/novaeng/common/util/AEItemStackSet.java +++ b/src/main/java/github/kasuminova/novaeng/common/util/AEItemStackSet.java @@ -1,57 +1,56 @@ package github.kasuminova.novaeng.common.util; -import appeng.api.storage.data.IAEItemStack; -import appeng.util.item.AEItemStack; +import ae2.api.stacks.AEItemKey; import io.netty.buffer.ByteBuf; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.List; import java.util.Map; +import net.minecraft.network.PacketBuffer; public class AEItemStackSet { private final Map entries = new Object2ObjectOpenHashMap<>(); private final List entryList = new ObjectArrayList<>(); - public int add(IAEItemStack stack) { + public int add(AEItemKey stack) { Entry entry = entries.get(new Entry(stack, -1)); if (entry == null) { - entry = new Entry(stack.copy().setStackSize(1), entryList.size()); + entry = new Entry(stack, entryList.size()); entries.put(entry, entry); entryList.add(entry); } return entry.id(); } - protected void addInternal(IAEItemStack stack) { + protected void addInternal(AEItemKey stack) { Entry entry = new Entry(stack, entryList.size()); entryList.add(entry); entries.put(entry, entry); } - public IAEItemStack get(int id) { - return entryList.get(id).stack().copy(); + public AEItemKey get(int id) { + return entryList.get(id).stack(); } public void writeToBuffer(final ByteBuf buf) { buf.writeInt(entryList.size()); + PacketBuffer packetBuffer = new PacketBuffer(buf); for (Entry entry : entryList) { - try { - entry.stack().writeToPacket(buf); - } catch (Throwable ignored) { - } + entry.stack().writeToPacket(packetBuffer); } } public void fromBuffer(final ByteBuf buf) { int size = buf.readInt(); + PacketBuffer packetBuffer = new PacketBuffer(buf); for (int i = 0; i < size; i++) { - addInternal(AEItemStack.fromPacket(buf)); + addInternal(AEItemKey.fromPacket(packetBuffer)); } } - private record Entry(IAEItemStack stack, int id) { + private record Entry(AEItemKey stack, int id) { @Override public int hashCode() { diff --git a/src/main/java/github/kasuminova/novaeng/common/util/AssemblyBlockArray.java b/src/main/java/github/kasuminova/novaeng/common/util/AssemblyBlockArray.java index c7045f4a..73c34b09 100644 --- a/src/main/java/github/kasuminova/novaeng/common/util/AssemblyBlockArray.java +++ b/src/main/java/github/kasuminova/novaeng/common/util/AssemblyBlockArray.java @@ -1,16 +1,10 @@ package github.kasuminova.novaeng.common.util; -import appeng.api.AEApi; -import appeng.api.config.Actionable; -import appeng.api.networking.storage.IStorageGrid; -import appeng.api.storage.IMEMonitor; -import appeng.api.storage.channels.IFluidStorageChannel; -import appeng.api.storage.channels.IItemStorageChannel; -import appeng.api.storage.data.IAEFluidStack; -import appeng.api.storage.data.IAEItemStack; -import appeng.helpers.WirelessTerminalGuiObject; -import appeng.me.helpers.PlayerSource; -import com.circulation.random_complement.common.util.MEHandler; +import ae2.api.config.Actionable; +import ae2.api.networking.security.IActionHost; +import ae2.container.AEBaseContainer; +import ae2.api.storage.MEStorage; +import ae2.me.helpers.PlayerSource; import github.kasuminova.novaeng.common.util.NEWMachineAssemblyManager.Ingredient; import github.kasuminova.novaeng.common.util.NEWMachineAssemblyManager.OperatingStatus; import hellfirepvp.modularmachinery.common.util.BlockArray; @@ -256,15 +250,16 @@ public OperatingStatus assemblyBlock(final World world, final EntityPlayerMP pla } } final var materials = getMaterialList(info); - WirelessTerminalGuiObject terminal = null; - IMEMonitor items = null; - IMEMonitor fluids = null; + boolean hasAE = false; + IActionHost terminal = null; + MEStorage storage = null; if (this.usingAE) { - terminal = MEHandler.getTerminalGuiObject(player); - if (terminal != null && terminal.getActionableNode() != null && terminal.getActionableNode().getGrid() != null) { - final IStorageGrid storage = terminal.getActionableNode().getGrid().getCache(IStorageGrid.class); - items = storage.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); - fluids = storage.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); + if (player.openContainer instanceof AEBaseContainer c) { + terminal = (IActionHost) c.getTarget(); + } + if (terminal != null && terminal.getActionableNode() != null && terminal.getActionableNode().grid() != null) { + storage = terminal.getActionableNode().grid().getStorageService().getInventory(); + hasAE = true; } } final var inventory = player.inventory.mainInventory; @@ -284,23 +279,28 @@ public OperatingStatus assemblyBlock(final World world, final EntityPlayerMP pla return OperatingStatus.SUCCESS; } } - if (items != null) { + if (hasAE) { for (final var pair : materials) { final var ingredient = pair.getFirst(); if (ingredient.isItem()) { if (ingredient.getItemStack().isEmpty()) { continue; } - final var extracted = items.extractItems(ingredient.getAEItemStack(), Actionable.MODULATE, new PlayerSource(player, terminal)); - if (extracted == null || extracted.getStackSize() == 0) { + final var key = ingredient.getAEItemStack(); + if (key == null) { + continue; + } + final var extracted = storage.extract(key, ingredient.getItemStack().getCount(), Actionable.MODULATE, new PlayerSource(player, terminal)); + if (extracted == 0) { continue; } } else { - final var extracted = fluids.extractItems(ingredient.getAEFluidStack(), Actionable.SIMULATE, new PlayerSource(player, terminal)); - if (extracted == null || extracted.getStackSize() < 1000) { + final var key = ingredient.getAEFluidStack(); + final var extracted = storage.extract(key, 1000, Actionable.SIMULATE, new PlayerSource(player, terminal)); + if (extracted < 1000) { continue; } - fluids.extractItems(ingredient.getAEFluidStack(), Actionable.MODULATE, new PlayerSource(player, terminal)); + storage.extract(key, 1000, Actionable.MODULATE, new PlayerSource(player, terminal)); } this.placeBlock(player, world, pos, pair.getSecond()); return OperatingStatus.SUCCESS; diff --git a/src/main/java/github/kasuminova/novaeng/common/util/AutoCraftingQueue.java b/src/main/java/github/kasuminova/novaeng/common/util/AutoCraftingQueue.java deleted file mode 100644 index d78acb83..00000000 --- a/src/main/java/github/kasuminova/novaeng/common/util/AutoCraftingQueue.java +++ /dev/null @@ -1,113 +0,0 @@ -package github.kasuminova.novaeng.common.util; - -import appeng.api.networking.crafting.ICraftingGrid; -import appeng.api.networking.crafting.ICraftingJob; -import appeng.api.util.AEPartLocation; -import appeng.container.ContainerOpenContext; -import appeng.core.AELog; -import appeng.me.helpers.PlayerSource; -import appeng.util.item.AEItemStack; -import com.circulation.random_complement.common.util.MEHandler; -import github.kasuminova.novaeng.NovaEngineeringCore; -import github.kasuminova.novaeng.common.CommonProxy; -import github.kasuminova.novaeng.common.container.ContainerNEWCraftConfirm; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import javax.annotation.Nullable; -import java.util.Map; -import java.util.Queue; -import java.util.concurrent.Future; - -public final class AutoCraftingQueue { - - private static final Map QUEUES = new Object2ObjectOpenHashMap<>(); - private Queue queue = EmptyQueue.empty(); - - public static void setQueueAndStrat(final Queue items, final EntityPlayer player) { - final AutoCraftingQueue queue = QUEUES.computeIfAbsent(player, ignored -> new AutoCraftingQueue()); - queue.queue = items; - queue.executionQueue(player); - } - - @Nullable - public static AutoCraftingQueue getQueue(final EntityPlayer player) { - return QUEUES.get(player); - } - - public static void removeQueue(final EntityPlayer player) { - final AutoCraftingQueue queue = QUEUES.remove(player); - if (queue != null) { - queue.queue.clear(); - queue.queue = EmptyQueue.empty(); - } - } - - public static void removeWorld(final World world) { - final var entries = QUEUES.entrySet().iterator(); - while (entries.hasNext()) { - final var entry = entries.next(); - if (entry.getKey().world == world) { - entry.getValue().queue.clear(); - entry.getValue().queue = EmptyQueue.empty(); - entries.remove(); - } - } - } - - public static void clearAll() { - for (final AutoCraftingQueue queue : QUEUES.values()) { - queue.queue.clear(); - queue.queue = EmptyQueue.empty(); - } - QUEUES.clear(); - } - - public void clearQueue() { - this.queue.clear(); - this.queue = EmptyQueue.empty(); - QUEUES.values().removeIf(existing -> existing == this); - } - - public boolean executionQueue(final EntityPlayer player) { - final ItemStack item = this.queue.poll(); - if (item == null) { - this.clearQueue(); - return false; - } - Future future = null; - try { - final var terminal = MEHandler.getTerminalGuiObject(player); - final var node = terminal == null ? null : terminal.getActionableNode(); - final var grid = node == null ? null : node.getGrid(); - if (grid == null) { - this.clearQueue(); - return false; - } - final ICraftingGrid crafting = grid.getCache(ICraftingGrid.class); - final AEItemStack request = AEItemStack.fromItemStack(item); - future = crafting.beginCraftingJob(player.world, grid, new PlayerSource(player, terminal), - request == null ? null : request.setStackSize(item.getCount()), null); - player.openGui(NovaEngineeringCore.instance, CommonProxy.GuiType.AUTO_CRAFTGUI.ordinal(), player.world, - terminal.getInventorySlot(), terminal.isBaubleSlot() ? 1 : 0, Integer.MIN_VALUE); - if (player.openContainer instanceof ContainerNEWCraftConfirm confirm) { - final ContainerOpenContext context = new ContainerOpenContext(null); - context.setSide(AEPartLocation.INTERNAL); - confirm.setOpenContext(context); - confirm.setAutoStart(false); - confirm.setJob(future); - confirm.detectAndSendChanges(); - } - return true; - } catch (final Throwable failure) { - if (future != null) { - future.cancel(true); - } - this.clearQueue(); - AELog.debug(failure); - return false; - } - } -} diff --git a/src/main/java/github/kasuminova/novaeng/common/util/EmptyQueue.java b/src/main/java/github/kasuminova/novaeng/common/util/EmptyQueue.java deleted file mode 100644 index 32b00090..00000000 --- a/src/main/java/github/kasuminova/novaeng/common/util/EmptyQueue.java +++ /dev/null @@ -1,99 +0,0 @@ -package github.kasuminova.novaeng.common.util; - -import it.unimi.dsi.fastutil.objects.ObjectIterators; - -import java.util.AbstractQueue; -import java.util.Collection; -import java.util.Iterator; - -public final class EmptyQueue extends AbstractQueue { - - private static final EmptyQueue EMPTY = new EmptyQueue<>(); - - private EmptyQueue() { - } - - @SuppressWarnings("unchecked") - public static EmptyQueue empty() { - return (EmptyQueue) EMPTY; - } - - @Override - public boolean add(final E value) { - return false; - } - - @Override - public boolean offer(final E value) { - return false; - } - - @Override - public E remove() { - return null; - } - - @Override - public E poll() { - return null; - } - - @Override - public E element() { - return null; - } - - @Override - public E peek() { - return null; - } - - @Override - public Iterator iterator() { - return ObjectIterators.emptyIterator(); - } - - @Override - public boolean remove(final Object value) { - return false; - } - - @Override - public boolean addAll(final Collection values) { - return false; - } - - @Override - public boolean removeAll(final Collection values) { - return false; - } - - @Override - public boolean retainAll(final Collection values) { - return false; - } - - @Override - public void clear() { - } - - @Override - public int size() { - return 0; - } - - @Override - public boolean isEmpty() { - return true; - } - - @Override - public boolean contains(final Object value) { - return false; - } - - @Override - public boolean containsAll(final Collection values) { - return false; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/common/util/MixinDecisions.java b/src/main/java/github/kasuminova/novaeng/common/util/MixinDecisions.java index ec86265b..fcef7a14 100644 --- a/src/main/java/github/kasuminova/novaeng/common/util/MixinDecisions.java +++ b/src/main/java/github/kasuminova/novaeng/common/util/MixinDecisions.java @@ -5,7 +5,7 @@ public final class MixinDecisions { - public static final boolean ae2Loaded = isPresent("appliedenergistics2"); + public static final boolean ae2Loaded = isPresent("ae2"); public static final boolean actiniumLoaded = isPresent("actinium"); public static final boolean arLoaded = isPresent("advancedrocketry"); public static final boolean enderioLoaded = isPresent("enderio"); @@ -44,7 +44,7 @@ public static boolean recipeContextPoolEnabled() { return mmceLoaded && NovaEngCoreConfig.PERFORMANCE.boundedRecipeContexts; } - public static boolean aeOutputPreparationEnabled() { + public static boolean aeOutputInsertionEnabled() { return mmceLoaded && ae2Loaded && NovaEngCoreConfig.PERFORMANCE.batchAe2Outputs; } @@ -222,8 +222,7 @@ private static boolean isOptimizationEnabled(final String mixinName) { "actinium.MixinBuildOutputBudgetRelease", "actinium.MixinSortOutputBudgetRelease", "actinium.MixinRenderSectionMemoryBudget" -> NovaEngCoreConfig.PERFORMANCE.chunkBuildMemoryBudget; - case "mmce.InvokerItemOutputBus", "mmce.MixinItemOutputPreparation", - "ae2.MixinNetworkInventoryOutputPreparation" -> aeOutputPreparationEnabled(); + case "mmce.MixinItemOutputBusNetworkTarget" -> aeOutputInsertionEnabled(); case "mmce.MixinTileNotificationGeneration", "mmce.MixinTaskExecutorNotifications" -> NovaEngCoreConfig.PERFORMANCE.coalesceMmceNotifications; case "minecraft.MixinClassInheritanceMultiMapLazy" -> NovaEngCoreConfig.PERFORMANCE.lazyEntityClassIndexes; @@ -436,7 +435,6 @@ private static boolean isOptimizationEnabled(final String mixinName) { case "minecraft.MixinEntityDataManagerLookup" -> NovaEngCoreConfig.SERVER.optimizeEntityDataManagerLookup; case "minecraft.MixinBiome", "minecraft.forge.MixinForgeRegistry" -> NovaEngCoreConfig.SERVER.optimizeBiomeIdLookup; - case "ae2.MixinItemListCapacity" -> NovaEngCoreConfig.SERVER.optimizeAe2ItemListCapacity; case "universaltweaks.MixinUTEntityDesync" -> NovaEngCoreConfig.SERVER.optimizeUniversalTweaksEntityBlacklist; default -> true; }; diff --git a/src/main/java/github/kasuminova/novaeng/common/util/NEWMachineAssemblyManager.java b/src/main/java/github/kasuminova/novaeng/common/util/NEWMachineAssemblyManager.java index 1ae68417..a93c5ebc 100644 --- a/src/main/java/github/kasuminova/novaeng/common/util/NEWMachineAssemblyManager.java +++ b/src/main/java/github/kasuminova/novaeng/common/util/NEWMachineAssemblyManager.java @@ -1,18 +1,15 @@ package github.kasuminova.novaeng.common.util; -import appeng.api.AEApi; -import appeng.api.config.Actionable; -import appeng.api.networking.storage.IStorageGrid; -import appeng.api.storage.channels.IFluidStorageChannel; -import appeng.api.storage.channels.IItemStorageChannel; -import appeng.api.storage.data.IAEFluidStack; -import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IAEStack; -import appeng.fluids.util.AEFluidStack; -import appeng.me.helpers.PlayerSource; -import appeng.util.item.AEItemStack; -import com.circulation.random_complement.common.util.MEHandler; -import com.glodblock.github.common.item.fake.FakeFluids; +import ae2.api.config.Actionable; +import ae2.api.networking.security.IActionHost; +import ae2.api.storage.MEStorage; +import ae2.container.AEBaseContainer; +import ae2.api.stacks.AEFluidKey; +import ae2.api.stacks.GenericStack; +import ae2.api.stacks.AEItemKey; +import ae2.api.stacks.AEKey; +import ae2.me.helpers.PlayerSource; +import com.google.common.primitives.Ints; import github.kasuminova.novaeng.NovaEngineeringCore; import hellfirepvp.modularmachinery.ModularMachinery; import hellfirepvp.modularmachinery.common.integration.ModIntegrationJEI; @@ -116,43 +113,47 @@ public static Miss2ListPair checkAllItems(final EntityPlayer player, final Struc final var items = getItemStackIngList(itemIngredients); final var fluids = getFluidStackIngList(fluidIngredients); if (usingAE) { - final var terminal = MEHandler.getTerminalGuiObject(player); + final IActionHost terminal = player.openContainer instanceof AEBaseContainer c ? (IActionHost) c.getTarget() : null; if (terminal != null && terminal.getActionableNode() != null) { - final var grid = terminal.getActionableNode().getGrid(); + final var grid = terminal.getActionableNode().grid(); if (grid != null) { - final IStorageGrid storage = grid.getCache(IStorageGrid.class); - final var itemInventory = storage.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); - final var fluidInventory = storage.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); + final MEStorage storage = grid.getStorageService().getInventory(); final var source = new PlayerSource(player, terminal); for (final var stacks : new ReferenceArrayList<>(items)) { for (final var stack : stacks) { - final var extracted = itemInventory.extractItems(AEItemStack.fromItemStack(stack), Actionable.SIMULATE, source); - if (extracted == null) { + var key = AEItemKey.of(stack); + if (key == null) { continue; } - final int size = (int) extracted.getStackSize(); - if (stack.getCount() <= size) { + final var extracted = storage.extract(key, stack.getCount(), Actionable.SIMULATE, source); + if (extracted == 0) { + continue; + } + if (stack.getCount() <= extracted) { items.remove(stacks); break; } for (final var alternative : stacks) { - alternative.shrink(size); + alternative.shrink(Ints.saturatedCast(extracted)); } } } for (final var stacks : new ReferenceArrayList<>(fluids)) { for (final var stack : stacks) { - final var extracted = fluidInventory.extractItems(AEFluidStack.fromFluidStack(stack), Actionable.SIMULATE, source); - if (extracted == null) { + var key = AEFluidKey.of(stack); + if (key == null) { + continue; + } + final var extracted = storage.extract(key, stack.amount, Actionable.SIMULATE, source); + if (extracted == 0) { continue; } - final int size = (int) extracted.getStackSize(); - if (stack.amount <= size) { + if (stack.amount <= extracted) { fluids.remove(stacks); break; } for (final var alternative : stacks) { - alternative.amount -= size; + alternative.amount -= Ints.saturatedCast(extracted); } } } @@ -184,9 +185,9 @@ public static Miss2ListPair checkAllItems(final EntityPlayer player, final Struc for (final var stacks : fluids) { final List packed = new ObjectArrayList<>(); for (final var stack : stacks) { - final var drops = FakeFluids.packFluid2Drops(stack); - drops.setCount(stack.amount); - packed.add(drops); + var key = AEFluidKey.of(stack); + if (key == null) continue; + packed.add(GenericStack.wrapInItemStack(key, stack.amount)); } result.add(packed); } @@ -288,18 +289,18 @@ public List> getList() { public static final class Ingredient { private final Object ingredient; private final boolean item; - private final IAEStack aeStack; + private final AEKey aeStack; public Ingredient(final ItemStack stack) { this.ingredient = stack; this.item = true; - this.aeStack = AEItemStack.fromItemStack(stack); + this.aeStack = AEItemKey.of(stack); } public Ingredient(final FluidStack stack) { this.ingredient = stack; this.item = false; - this.aeStack = AEFluidStack.fromFluidStack(stack); + this.aeStack = AEFluidKey.of(stack); } public Object getIngredient() { @@ -310,7 +311,7 @@ public boolean isItem() { return this.item; } - public IAEStack getAeStack() { + public AEKey getAeStack() { return this.aeStack; } @@ -318,16 +319,16 @@ public ItemStack getItemStack() { return (ItemStack) this.ingredient; } - public IAEItemStack getAEItemStack() { - return this.aeStack instanceof IAEItemStack stack ? stack : null; + public AEItemKey getAEItemStack() { + return this.aeStack instanceof AEItemKey stack ? stack : null; } public FluidStack getFluidStack() { return (FluidStack) this.ingredient; } - public IAEFluidStack getAEFluidStack() { - return this.aeStack instanceof IAEFluidStack stack ? stack : null; + public AEFluidKey getAEFluidStack() { + return this.aeStack instanceof AEFluidKey stack ? stack : null; } @Override diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorAbstractCellInventory.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorAbstractCellInventory.java deleted file mode 100644 index d0e45f8e..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorAbstractCellInventory.java +++ /dev/null @@ -1,35 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.me.storage.AbstractCellInventory; -import net.minecraft.nbt.NBTTagCompound; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(value = AbstractCellInventory.class, remap = false) -public interface AccessorAbstractCellInventory { - - @Accessor - NBTTagCompound getTagCompound(); - - @Accessor - int getMaxItemTypes(); - - @Accessor - short getStoredItemTypes(); - - @Accessor - void setStoredItemTypes(short storedItemTypes); - - @Accessor - long getStoredItemCount(); - - @Accessor - void setStoredItemCount(long storedItemCount); - - @Accessor - boolean getIsPersisted(); - - @Accessor - void setIsPersisted(boolean isPersisted); - -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorCellRegistry.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorCellRegistry.java deleted file mode 100644 index e69d6da5..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorCellRegistry.java +++ /dev/null @@ -1,16 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.storage.ICellHandler; -import appeng.core.features.registries.cell.CellRegistry; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.List; - -@Mixin(CellRegistry.class) -public interface AccessorCellRegistry { - - @Accessor(remap = false) - List getHandlers(); - -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorContainerCraftConfirm.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorContainerCraftConfirm.java deleted file mode 100644 index 20246dab..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorContainerCraftConfirm.java +++ /dev/null @@ -1,19 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.networking.crafting.ICraftingJob; -import appeng.container.implementations.ContainerCraftConfirm; -import appeng.container.implementations.CraftingCPURecord; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.ArrayList; - -@Mixin(value = ContainerCraftConfirm.class, remap = false) -public interface AccessorContainerCraftConfirm { - - @Accessor("result") - ICraftingJob getResult(); - - @Accessor("cpus") - ArrayList getCpus(); -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorContainerPatternEncoder.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorContainerPatternEncoder.java deleted file mode 100644 index 471a1d53..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorContainerPatternEncoder.java +++ /dev/null @@ -1,18 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.implementations.guiobjects.IGuiItemObject; -import appeng.container.implementations.ContainerPatternEncoder; -import appeng.container.slot.SlotRestrictedInput; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(value = ContainerPatternEncoder.class, remap = false) -public interface AccessorContainerPatternEncoder { - - @Accessor - SlotRestrictedInput getPatternSlotOUT(); - - @Accessor - IGuiItemObject getIGuiItemObject(); - -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorCraftingCPURecord.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorCraftingCPURecord.java deleted file mode 100644 index 7fdd439a..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorCraftingCPURecord.java +++ /dev/null @@ -1,13 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.networking.crafting.ICraftingCPU; -import appeng.container.implementations.CraftingCPURecord; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(value = CraftingCPURecord.class, remap = false) -public interface AccessorCraftingCPURecord { - - @Accessor("cpu") - ICraftingCPU getCpu(); -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorGuiCraftConfirm.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorGuiCraftConfirm.java deleted file mode 100644 index 78fe6555..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorGuiCraftConfirm.java +++ /dev/null @@ -1,16 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.client.gui.implementations.GuiCraftConfirm; -import net.minecraft.client.gui.GuiButton; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(value = GuiCraftConfirm.class, remap = false) -public interface AccessorGuiCraftConfirm { - - @Accessor("cancel") - GuiButton getCancel(); - - @Accessor("start") - GuiButton getStart(); -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorItemVariantRecords.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorItemVariantRecords.java deleted file mode 100644 index 3d085bb1..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/AccessorItemVariantRecords.java +++ /dev/null @@ -1,14 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.storage.data.IAEItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -import java.util.Map; - -// ItemVariantList is package-private; its concrete subclasses retain their existing maps. -@Mixin(targets = "appeng.util.item.ItemVariantList", remap = false) -public interface AccessorItemVariantRecords { - @Invoker("getRecords") - Map nova$records(); -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinAEBaseGui.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinAEBaseGui.java deleted file mode 100644 index 9879f369..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinAEBaseGui.java +++ /dev/null @@ -1,15 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.client.gui.AEBaseGui; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(AEBaseGui.class) -public class MixinAEBaseGui { - - @Redirect(method = "drawScreen", at = @At(value = "INVOKE", target = "Lappeng/util/Platform;isModLoaded(Ljava/lang/String;)Z", remap = false)) - private boolean hei(String modid) { - return false; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinAppEngClientPacketHandler.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinAppEngClientPacketHandler.java deleted file mode 100644 index 5a065d07..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinAppEngClientPacketHandler.java +++ /dev/null @@ -1,29 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.core.sync.AppEngPacket; -import appeng.core.sync.PacketCallState; -import appeng.core.sync.network.AppEngClientPacketHandler; -import github.kasuminova.novaeng.common.profiler.CPacketProfiler; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(AppEngClientPacketHandler.class) -public class MixinAppEngClientPacketHandler { - - @SuppressWarnings("MethodMayBeStatic") - @Redirect( - method = "onPacketData", - at = @At( - value = "INVOKE", - target = "Lappeng/core/sync/AppEngPacket;setCallParam(Lappeng/core/sync/PacketCallState;)V", - remap = false - ), - remap = false - ) - private void redirectParsePacket(AppEngPacket instance, PacketCallState call) { - CPacketProfiler.onPacketReceived(instance, instance.getPacketID()); - instance.setCallParam(call); - } - -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinAppEngServerPacketHandler.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinAppEngServerPacketHandler.java deleted file mode 100644 index 7c641374..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinAppEngServerPacketHandler.java +++ /dev/null @@ -1,34 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.core.sync.AppEngPacket; -import appeng.core.sync.PacketCallState; -import appeng.core.sync.network.AppEngServerPacketHandler; -import com.llamalad7.mixinextras.sugar.Local; -import github.kasuminova.novaeng.common.profiler.SPacketProfiler; -import net.minecraft.entity.player.EntityPlayer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(AppEngServerPacketHandler.class) -public class MixinAppEngServerPacketHandler { - - @SuppressWarnings("MethodMayBeStatic") - @Redirect( - method = "onPacketData", - at = @At( - value = "INVOKE", - target = "Lappeng/core/sync/AppEngPacket;setCallParam(Lappeng/core/sync/PacketCallState;)V", - remap = false - ), - remap = false - ) - private void redirectParsePacket(AppEngPacket instance, PacketCallState call, - @Local(name = "player") EntityPlayer player) { - if (player != null) { - SPacketProfiler.onPacketReceived(player, instance); - } - instance.setCallParam(call); - } - -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCompassReaderRegions.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCompassReaderRegions.java deleted file mode 100644 index 25724dc7..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCompassReaderRegions.java +++ /dev/null @@ -1,59 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.services.compass.CompassReader; -import appeng.services.compass.CompassRegion; -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.io.File; -import java.util.Map; - -@Mixin(value = CompassReader.class, remap = false) -public abstract class MixinCompassReaderRegions { - - @Shadow - @Final - @Mutable - private Map regions; - - @Shadow - @Final - private int dimensionId; - - @Shadow - @Final - private File worldCompassFolder; - - @Inject(method = "(ILjava/io/File;)V", at = @At("RETURN"), require = 1) - private void nova$primitiveRegions(final int dimensionId, final File worldCompassFolder, final CallbackInfo ci) { - final Long2ObjectMap primitive = new Long2ObjectOpenHashMap<>(Math.max(4, this.regions.size())); - primitive.putAll(this.regions); - this.regions = primitive; - } - - /** - * @author circulation - * @reason Use the region coordinate directly as a long key without changing the original signed packing. - */ - @Overwrite - private CompassRegion getRegion(final int chunkX, final int chunkZ) { - long key = chunkX >> 10; - key <<= 32; - key |= chunkZ >> 10; - final Long2ObjectMap regions = (Long2ObjectMap) this.regions; - CompassRegion region = regions.get(key); - if (region == null) { - region = new CompassRegion(chunkX, chunkZ, this.dimensionId, this.worldCompassFolder); - regions.put(key, region); - } - return region; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingCPUCluster.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingCPUCluster.java index 04f965e0..ace95949 100644 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingCPUCluster.java +++ b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingCPUCluster.java @@ -1,19 +1,10 @@ package github.kasuminova.novaeng.mixin.ae2; -import appeng.api.networking.IGrid; -import appeng.api.networking.IGridNode; -import appeng.api.networking.crafting.ICraftingJob; -import appeng.api.networking.crafting.ICraftingLink; -import appeng.api.networking.crafting.ICraftingRequester; -import appeng.api.networking.energy.IEnergyGrid; -import appeng.api.networking.security.IActionSource; -import appeng.crafting.MECraftingInventory; -import appeng.me.cache.CraftingGridCache; -import appeng.me.cluster.implementations.CraftingCPUCluster; -import appeng.me.helpers.MachineSource; -import appeng.tile.crafting.TileCraftingTile; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import ae2.api.networking.IGrid; +import ae2.api.networking.IGridNode; +import ae2.me.cluster.implementations.CraftingCPUCluster; +import ae2.me.helpers.MachineSource; +import ae2.tile.crafting.ICraftingCPUTileEntity; import github.kasuminova.mmce.common.util.TimeRecorder; import github.kasuminova.novaeng.common.block.ecotech.ecalculator.prop.Levels; import github.kasuminova.novaeng.common.ecalculator.ECPUCluster; @@ -21,7 +12,7 @@ import github.kasuminova.novaeng.common.tile.ecotech.ecalculator.ECalculatorMEChannel; import github.kasuminova.novaeng.common.tile.ecotech.ecalculator.ECalculatorThreadCore; import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Final; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -30,8 +21,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import javax.annotation.Nullable; - @Mixin(value = CraftingCPUCluster.class, remap = false) public abstract class MixinCraftingCPUCluster implements ECPUCluster { @@ -40,170 +29,72 @@ public abstract class MixinCraftingCPUCluster implements ECPUCluster { @Unique private final TimeRecorder novaeng_ec$parallelismRecorder = new TimeRecorder(); @Unique - private ECalculatorThreadCore novaeng_ec$core = null; + private ECalculatorThreadCore novaeng_ec$core; @Unique - private ECalculatorController novaeng_ec$virtualCPUOwner = null; + private ECalculatorController novaeng_ec$virtualCPUOwner; @Unique - private long novaeng_ec$usedExtraStorage = 0; - @Shadow - private long availableStorage; + private long novaeng_ec$usedExtraStorage; @Shadow - private boolean isDestroyed; - - @Shadow - private int accelerator; - - @Shadow - private MECraftingInventory inventory; - - @Shadow - private boolean isComplete; - + protected long storage; @Shadow - private ICraftingLink myLastLink; - + protected int accelerator; @Shadow - private MachineSource machineSrc; - @Final + protected boolean destroyed; @Shadow - private int[] usedOps; + protected MachineSource machineSrc; @Shadow - public abstract void destroy(); + public abstract IGrid getGrid(); @Shadow - public abstract void cancel(); - - @Inject(method = "submitJob", at = @At(value = "INVOKE", target = "Lappeng/api/networking/crafting/ICraftingJob;getOutput()Lappeng/api/storage/data/IAEItemStack;")) - private void injectSubmitJob(final IGrid g, final ICraftingJob job, final IActionSource src, final ICraftingRequester requestingMachine, final CallbackInfoReturnable cir) { - if (this.novaeng_ec$virtualCPUOwner == null) { - return; - } - this.novaeng_ec$virtualCPUOwner.onVirtualCPUSubmitJob(job.getByteTotal()); - } - - @Inject(method = "cancel", at = @At("RETURN")) - private void injectCancel(final CallbackInfo ci) { - if (this.novaeng_ec$core == null) { - return; - } - // Ensure inventory is empty - if (this.inventory.getItemList().isEmpty()) { - this.destroy(); - } - } - - @Inject(method = "updateCraftingLogic", at = @At("HEAD"), cancellable = true) - private void injectUpdateCraftingLogicStoreItems(final IGrid grid, final IEnergyGrid eg, final CraftingGridCache cc, final CallbackInfo ci) { - if (this.novaeng_ec$core == null) { - return; - } - if (this.myLastLink != null) { - if (this.myLastLink.isCanceled()) { - this.myLastLink = null; - this.cancel(); - } - } - if (this.isComplete) { - // Ensure inventory is empty - if (this.inventory.getItemList().isEmpty()) { - this.destroy(); - ci.cancel(); - } - } - } - - @Inject(method = "updateCraftingLogic", at = @At("TAIL")) - private void injectUpdateCraftingLogicTail(final IGrid grid, final IEnergyGrid eg, final CraftingGridCache cc, final CallbackInfo ci) { - int currentParallelism = this.usedOps[0]; - this.novaeng_ec$parallelismRecorder.addUsedTime(currentParallelism); - } + public abstract World getLevel(); - @WrapOperation( - method = "updateCraftingLogic", - at = @At( - value = "INVOKE", - target = "Lappeng/tile/crafting/TileCraftingTile;isActive()Z" - ) - ) - private boolean redirectUpdateCraftingLogicIsActive(final TileCraftingTile instance, final Operation original) { - if (this.novaeng_ec$core != null) { - ECalculatorController controller = this.novaeng_ec$core.getController(); - return controller != null && controller.getChannel() != null && controller.getChannel().getProxy().isActive(); - } - if (this.novaeng_ec$virtualCPUOwner != null) { - ECalculatorController controller = this.novaeng_ec$virtualCPUOwner; - return controller.getChannel() != null && controller.getChannel().getProxy().isActive(); - } - return original.call(instance); - } - - @Inject(method = "destroy", at = @At("HEAD"), cancellable = true) + @Inject(method = "destroy", at = @At("HEAD")) private void injectDestroy(final CallbackInfo ci) { - if (this.novaeng_ec$core == null) { - return; - } - if (this.isDestroyed) { - ci.cancel(); - return; + if (!this.destroyed && this.novaeng_ec$core != null) { + this.novaeng_ec$core.onCPUDestroyed((CraftingCPUCluster) (Object) this); } - this.novaeng_ec$core.onCPUDestroyed((CraftingCPUCluster) (Object) this); } @Inject(method = "isActive", at = @At("HEAD"), cancellable = true) private void injectIsActive(final CallbackInfoReturnable cir) { - if (this.novaeng_ec$core == null && this.novaeng_ec$virtualCPUOwner == null) { - return; - } - if (this.novaeng_ec$core != null) { - ECalculatorController controller = this.novaeng_ec$core.getController(); - cir.setReturnValue(controller != null && controller.getChannel() != null && controller.getChannel().getProxy().isActive()); - } - if (this.novaeng_ec$virtualCPUOwner != null) { - ECalculatorController controller = this.novaeng_ec$virtualCPUOwner; - cir.setReturnValue(controller.getChannel() != null && controller.getChannel().getProxy().isActive()); + ECalculatorController controller = this.novaeng_ec$getOwner(); + if (controller != null) { + ECalculatorMEChannel channel = controller.getChannel(); + cir.setReturnValue(channel != null && channel.getMainNode().isActive()); } } @Inject(method = "getGrid", at = @At("HEAD"), cancellable = true) private void injectGetGrid(final CallbackInfoReturnable cir) { - if (this.novaeng_ec$core != null) { - final ECalculatorController controller = this.novaeng_ec$core.getController(); - if (controller == null) { - return; - } - final ECalculatorMEChannel channel = controller.getChannel(); - if (channel == null) { - return; - } - IGridNode node = channel.getProxy().getNode(); - cir.setReturnValue(node == null ? null : node.getGrid()); + ECalculatorController controller = this.novaeng_ec$getOwner(); + if (controller == null) { + return; } - if (this.novaeng_ec$virtualCPUOwner != null) { - final ECalculatorMEChannel channel = this.novaeng_ec$virtualCPUOwner.getChannel(); - if (channel == null) { - return; - } - IGridNode node = channel.getProxy().getNode(); - cir.setReturnValue(node == null ? null : node.getGrid()); + + ECalculatorMEChannel channel = controller.getChannel(); + if (channel == null) { + cir.setReturnValue(null); + return; } + + IGridNode node = channel.getMainNode().getNode(); + cir.setReturnValue(node == null ? null : node.grid()); } @Inject(method = "getCore", at = @At("HEAD"), cancellable = true) - private void injectGetCore(final CallbackInfoReturnable cir) { - if (this.novaeng_ec$core != null || this.novaeng_ec$virtualCPUOwner != null) { + private void injectGetCore(final CallbackInfoReturnable cir) { + if (this.novaeng_ec$getOwner() != null) { cir.setReturnValue(null); } } - @Inject(method = "getWorld", at = @At("HEAD"), cancellable = true) - private void injectGetWorld(final CallbackInfoReturnable cir) { - if (this.novaeng_ec$core != null) { - cir.setReturnValue(this.novaeng_ec$core.getWorld()); - } - if (this.novaeng_ec$virtualCPUOwner != null) { - cir.setReturnValue(this.novaeng_ec$virtualCPUOwner.getWorld()); + @Inject(method = "getLevel", at = @At("HEAD"), cancellable = true) + private void injectGetLevel(final CallbackInfoReturnable cir) { + ECalculatorController controller = this.novaeng_ec$getOwner(); + if (controller != null) { + cir.setReturnValue(controller.getWorld()); } } @@ -212,17 +103,24 @@ private void injectMarkDirty(final CallbackInfo ci) { if (this.novaeng_ec$core != null) { this.novaeng_ec$core.markNoUpdateSync(); ci.cancel(); - } - if (this.novaeng_ec$virtualCPUOwner != null) { + } else if (this.novaeng_ec$virtualCPUOwner != null) { this.novaeng_ec$virtualCPUOwner.markNoUpdateSync(); ci.cancel(); } } + @Unique + private ECalculatorController novaeng_ec$getOwner() { + if (this.novaeng_ec$core != null) { + return this.novaeng_ec$core.getController(); + } + return this.novaeng_ec$virtualCPUOwner; + } + @Unique @Override public void novaeng_ec$setAvailableStorage(final long availableStorage) { - this.availableStorage = availableStorage; + this.storage = availableStorage; } @Unique @@ -241,14 +139,9 @@ private void injectMarkDirty(final CallbackInfo ci) { @Override public void novaeng_ec$setThreadCore(final ECalculatorThreadCore threadCore) { this.novaeng_ec$core = threadCore; - - final ECalculatorController controller = threadCore.getController(); - if (controller == null) { - return; - } - final ECalculatorMEChannel channel = controller.getChannel(); - if (channel != null) { - this.machineSrc = new MachineSource(channel); + ECalculatorController controller = threadCore.getController(); + if (controller != null && controller.getChannel() != null) { + this.machineSrc = new MachineSource(controller.getChannel()); } } @@ -256,32 +149,16 @@ private void injectMarkDirty(final CallbackInfo ci) { @Override public void novaeng_ec$setVirtualCPUOwner(@Nullable final ECalculatorController virtualCPUOwner) { this.novaeng_ec$virtualCPUOwner = virtualCPUOwner; - if (virtualCPUOwner == null) { - return; - } - - final ECalculatorMEChannel channel = virtualCPUOwner.getChannel(); - if (channel != null) { - this.machineSrc = new MachineSource(channel); + if (virtualCPUOwner != null && virtualCPUOwner.getChannel() != null) { + this.machineSrc = new MachineSource(virtualCPUOwner.getChannel()); } } @Unique @Override public Levels novaeng_ec$getControllerLevel() { - final ECalculatorController controller; - if (this.novaeng_ec$core != null) { - controller = this.novaeng_ec$core.getController(); - } else if (this.novaeng_ec$virtualCPUOwner != null) { - controller = this.novaeng_ec$virtualCPUOwner; - } else { - return null; - } - - if (controller != null) { - return controller.getLevel(); - } - return null; + ECalculatorController controller = this.novaeng_ec$getOwner(); + return controller == null ? null : controller.getLevel(); } @Unique @@ -299,8 +176,7 @@ private void injectMarkDirty(final CallbackInfo ci) { @Unique @Override public void novaeng_ec$markDestroyed() { - this.isDestroyed = true; - this.isComplete = true; + this.destroyed = true; } @Unique diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingCPUClusterTwo.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingCPUClusterTwo.java deleted file mode 100644 index 867aa78d..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingCPUClusterTwo.java +++ /dev/null @@ -1,504 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.config.Actionable; -import appeng.api.config.FuzzyMode; -import appeng.api.config.PowerMultiplier; -import appeng.api.config.Settings; -import appeng.api.config.YesNo; -import appeng.api.networking.crafting.ICraftingMedium; -import appeng.api.networking.crafting.ICraftingPatternDetails; -import appeng.api.networking.energy.IEnergyGrid; -import appeng.api.networking.security.IActionSource; -import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IItemList; -import appeng.container.ContainerNull; -import appeng.crafting.CraftingLink; -import appeng.crafting.MECraftingInventory; -import appeng.helpers.DualityInterface; -import appeng.me.cache.CraftingGridCache; -import appeng.me.cluster.implementations.CraftingCPUCluster; -import appeng.me.helpers.MachineSource; -import appeng.util.Platform; -import appeng.util.item.AEItemStack; -import co.neeve.nae2.common.crafting.patterntransform.PatternTransformWrapper; -import co.neeve.nae2.common.helpers.VirtualPatternDetails; -import co.neeve.nae2.common.interfaces.ICancellingCraftingMedium; -import com.circulation.random_complement.client.RCSettings; -import com.circulation.random_complement.client.buttonsetting.IntelligentBlocking; -import com.circulation.random_complement.common.interfaces.RCIConfigurableObject; -import com.glodblock.github.coremod.CoreModHooks; -import com.glodblock.github.integration.mek.FCGasItems; -import com.glodblock.github.loader.FCItems; -import com.glodblock.github.util.FluidCraftingPatternDetails; -import com.glodblock.github.util.ModAndClassUtil; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import github.kasuminova.mmce.common.tile.MEPatternProvider; -import github.kasuminova.novaeng.common.tile.MEPatternProviderNova; -import github.kasuminova.novaeng.common.tile.ecotech.efabricator.EFabricatorMEChannel; -import github.kasuminova.novaeng.common.tile.ecotech.efabricator.EFabricatorWorker; -import github.kasuminova.novaeng.common.util.MediumType; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import it.unimi.dsi.fastutil.objects.ObjectLists; -import lombok.val; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.Loader; -import org.jetbrains.annotations.NotNull; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.injection.At; -import thelm.packagingprovider.util.MixinHooks; - -import java.util.ArrayDeque; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Queue; - -@Mixin(value = CraftingCPUCluster.class, remap = false, priority = 0) -public abstract class MixinCraftingCPUClusterTwo { - - @Shadow - private int remainingOperations; - @Shadow - private MachineSource machineSrc; - @Shadow - private MECraftingInventory inventory; - @Shadow - @Final - private Map tasks; - @Shadow - @Final - private Map> visitedMediums; - @Shadow - private boolean somethingChanged; - @Shadow - private IItemList waitingFor; - @Unique - private boolean r$IgnoreParallel = false; - @Unique - private long r$craftingFrequency = 0; - @Unique - private boolean r$nae2$ghostInjecting; - - @Unique - private static double n$getSum(IAEItemStack[] input) { - double sum = 0; - for (IAEItemStack anInput : input) { - if (anInput != null) { - if (anInput.getItem() == FCItems.FLUID_DROP) { - sum += Math.max((double) anInput.getStackSize() / (double) 1000.0F, 1.0F); - continue; - } - - if (ModAndClassUtil.GAS && anInput.getItem() == FCGasItems.GAS_DROP) { - sum += Math.max((double) anInput.getStackSize() / (double) 4000.0F, 1.0F); - continue; - } - sum += anInput.getStackSize(); - } - } - return sum; - } - - @Unique - private static long n$getCraftingAmount(IAEItemStack stack) { - ItemStack definition = stack.getDefinition(); - if (definition != null && !definition.isEmpty()) { - if (definition.getItem() == FCItems.FLUID_DROP) { - return (long) Math.max((double) stack.getStackSize() / 1000.0d, 1.0d); - } - if (ModAndClassUtil.GAS && definition.getItem() == FCGasItems.GAS_DROP) { - return (long) Math.max((double) stack.getStackSize() / 4000.0d, 1.0d); - } - } - return stack.getStackSize(); - } - - @Shadow - protected abstract void postChange(IAEItemStack diff, IActionSource src); - - @Shadow - protected abstract void postCraftingStatusChange(IAEItemStack diff); - - @Shadow - protected abstract boolean canCraft(ICraftingPatternDetails details, IAEItemStack[] condensedInputs); - - @Shadow - protected abstract World getWorld(); - - @Shadow - protected abstract void markDirty(); - - @Shadow - public abstract void cancel(); - - @Shadow - protected abstract void completeJob(); - - @Shadow - public abstract IAEItemStack injectItems(IAEItemStack input, Actionable type, IActionSource src); - - /** - * @author circulation - * @reason 完全覆写样板发配方法 - */ - @Overwrite - private void executeCrafting(IEnergyGrid eg, CraftingGridCache cc) { - val voidSet = new ObjectArrayList(); - Iterator> i = this.tasks.entrySet().iterator(); - - while (i.hasNext()) { - Map.Entry e = i.next(); - val value = e.getValue(); - if (value.getValue() <= 0L) { - i.remove(); - } else { - val key = e.getKey(); - - long max = 0; - val list = (key.isCraftable() || key instanceof FluidCraftingPatternDetails) ? key.getCondensedOutputs() : key.getCondensedInputs(); - for (IAEItemStack stack1 : list) { - long size = n$getCraftingAmount(stack1); - if (size > max) max = size; - } - - if (this.canCraft(key, key.getCondensedInputs())) { - if (key instanceof VirtualPatternDetails) { - this.completeJob(); - this.cancel(); - return; - } - - boolean didPatternCraft; - doWhileCraftingLoop: - do { - this.r$craftingFrequency = e.getValue().getValue(); - if (max * this.r$craftingFrequency > Integer.MAX_VALUE) { - this.r$craftingFrequency = Integer.MAX_VALUE / max; - } - - InventoryCrafting ic = null; - didPatternCraft = false; - - Queue mediums = this.visitedMediums.get(key); - if (mediums == null || mediums.isEmpty()) { - mediums = new ArrayDeque<>(); - for (ICraftingMedium availableMedium : cc.getMediums(key)) { - if (availableMedium != null) { - mediums.add(availableMedium); - } - } - this.visitedMediums.put(key, mediums); - } - - while (!mediums.isEmpty()) { - ICraftingMedium m = mediums.poll(); - if (value.getValue() > 0L && m != null && !m.isBusy()) { - MediumType mediumType = this.r$specialMediumTreatment(m, key); - if (ic == null) { - IAEItemStack[] input = key.getInputs(); - final var sum = n$getSum(input); - double energy; - long s = this.r$craftingFrequency; - if (mediumType != MediumType.NULL) { - double sum1 = sum * s; - double o = eg.extractAEPower(sum1, Actionable.SIMULATE, PowerMultiplier.CONFIG); - if (o < sum1 - 0.01) { - this.r$craftingFrequency = (long) (o / sum1 * this.r$craftingFrequency); - s = Math.max(s, this.r$craftingFrequency); - } - } - energy = eg.extractAEPower(sum * s, Actionable.MODULATE, PowerMultiplier.CONFIG); - - if (energy < sum - 0.01) { - continue; - } - - val l = key.isCraftable() ? 3 : 10; - ic = CoreModHooks.wrapCraftingBuffer(new ContainerNull(), l, l); - if (!key.isCraftable() && Loader.isModLoaded("packagingprovider")) { - ic = MixinHooks.INSTANCE.getCraftingInventory(input.length); - } - - boolean found = false; - - for (int x = 0; x < input.length; ++x) { - if (input[x] != null) { - found = false; - if (key.isCraftable()) { - Collection itemList; - if (key.canSubstitute()) { - List substitutes = key.getSubstituteInputs(x); - itemList = new ObjectArrayList<>(substitutes.size()); - - for (IAEItemStack stack : substitutes) { - itemList.addAll(this.inventory.getItemList().findFuzzy(stack, FuzzyMode.IGNORE_ALL)); - } - } else { - IAEItemStack item = this.inventory.getItemList().findPrecise(input[x]); - if (item != null) { - itemList = ObjectLists.singleton(item); - } else if (input[x].getItem().isDamageable()) { - itemList = this.inventory.getItemList().findFuzzy(input[x], FuzzyMode.IGNORE_ALL); - } else { - itemList = ObjectLists.emptyList(); - } - } - - for (IAEItemStack fuzz : itemList) { - fuzz = fuzz.copy(); - fuzz.setStackSize(input[x].getStackSize()); - if (key.isValidItemForSlot(x, fuzz.createItemStack(), this.getWorld())) { - IAEItemStack ais = this.r$extractItemsR(this.inventory, fuzz, Actionable.MODULATE, this.machineSrc, mediumType); - ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack(); - if (!is.isEmpty()) { - IAEItemStack receiver = ais.copy(); - this.postChange(receiver, this.machineSrc); - ic.setInventorySlotContents(x, is); - found = true; - break; - } - } - } - } else { - IAEItemStack ais = this.r$extractItemsR(this.inventory, input[x].copy(), Actionable.MODULATE, this.machineSrc, mediumType); - ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack(); - if (!is.isEmpty()) { - IAEItemStack receiver = input[x]; - if (mediumType != MediumType.NULL) - receiver = receiver.copy().setStackSize(receiver.getStackSize() * this.r$craftingFrequency); - this.postChange(receiver, this.machineSrc); - ic.setInventorySlotContents(x, is); - - var count = is.getCount(); - if (mediumType != MediumType.NULL) - count /= (int) this.r$craftingFrequency; - if (count == input[x].getStackSize()) { - found = true; - continue; - } - } - } - - if (!found) { - break; - } - } - } - - if (!found) { - for (int x = 0; x < ic.getSizeInventory(); ++x) { - ItemStack is = CoreModHooks.removeFluidPackets(ic, x); - if (!is.isEmpty()) { - this.inventory.injectItems( - CoreModHooks.wrapFluidPacketStack( - AEItemStack.fromItemStack(is) - ), - Actionable.MODULATE, - this.machineSrc - ); - } - } - - ic = null; - break; - } - } - - ICraftingPatternDetails newDetails; - if (key instanceof PatternTransformWrapper wrapper) { - newDetails = wrapper.getDelegate(); - } else { - newDetails = key; - } - if (m.pushPattern(newDetails, ic)) { - this.somethingChanged = true; - if (mediumType != MediumType.NULL && !this.r$IgnoreParallel) { - this.remainingOperations -= (int) this.r$craftingFrequency; - } else --this.remainingOperations; - - val outputs = key.getCondensedOutputs(); - if (m instanceof ICancellingCraftingMedium medium) { - if (medium.shouldAutoComplete()) { - Collections.addAll(voidSet, outputs); - } - } - - for (IAEItemStack out : outputs) { - val iaeStack = out.copy(); - if (mediumType != MediumType.NULL) - iaeStack.setStackSize(iaeStack.getStackSize() * this.r$craftingFrequency); - this.r$postProcessing(iaeStack); - } - - if (key.isCraftable()) { - for (int x = 0; x < ic.getSizeInventory(); ++x) { - ItemStack output = Platform.getContainerItem(CoreModHooks.removeFluidPackets(ic, x)); - if (!output.isEmpty()) { - IAEItemStack cItem = AEItemStack.fromItemStack(output); - if (mediumType == MediumType.EF) - cItem.setStackSize(cItem.getStackSize() * this.r$craftingFrequency); - this.r$postProcessing(cItem); - } - } - } - - ic = null; - didPatternCraft = true; - this.markDirty(); - if (mediumType == MediumType.NULL) { - value.setValue(value.getValue() - 1); - } else { - value.setValue(value.getValue() - (this.r$craftingFrequency)); - } - - if (value.getValue() <= 0) { - break doWhileCraftingLoop; - } - - if (value.getValue() > 0L && this.remainingOperations == 0) { - for (IAEItemStack output : voidSet) { - this.r$nae2$ghostInject(output); - } - return; - } - - if (m instanceof DualityInterface di && - (di.getConfigManager().getSetting(Settings.BLOCK) == YesNo.YES && ((RCIConfigurableObject) di).r$getConfigManager().getSetting(RCSettings.IntelligentBlocking) == IntelligentBlocking.CLOSE) - ) - break; - } - } - } - - if (ic != null) { - for (int x = 0; x < ic.getSizeInventory(); ++x) { - ItemStack is = CoreModHooks.removeFluidPackets(ic, x); - if (!is.isEmpty()) { - this.inventory.injectItems(CoreModHooks.wrapFluidPacketStack(AEItemStack.fromItemStack(is)), Actionable.MODULATE, this.machineSrc); - } - } - } - } while (didPatternCraft); - } - } - } - for (IAEItemStack output : voidSet) { - this.r$nae2$ghostInject(output); - } - } - - @Unique - private void r$postProcessing(IAEItemStack cItem) { - this.postChange(cItem, this.machineSrc); - this.waitingFor.add(cItem); - this.postCraftingStatusChange(cItem); - } - - @Unique - @NotNull - private MediumType r$specialMediumTreatment(ICraftingMedium m, ICraftingPatternDetails details) { - if (m instanceof MEPatternProviderNova mep) { - if (mep.getWorkMode() != MEPatternProvider.WorkModeSetting.BLOCKING_MODE - && mep.getWorkMode() != MEPatternProvider.WorkModeSetting.CRAFTING_LOCK_MODE) { - - for (IAEItemStack input : details.getCondensedInputs()) { - long size = input.getStackSize() * this.r$craftingFrequency; - val item = this.inventory.extractItems(input.copy().setStackSize(size), Actionable.SIMULATE, this.machineSrc); - if (item == null) continue; - if (item.getStackSize() < size) { - this.r$craftingFrequency = Math.max(1, item.getStackSize() / input.getStackSize()); - } - } - - if (mep.r$isIgnoreParallel()) { - this.r$IgnoreParallel = true; - } else { - this.r$IgnoreParallel = false; - this.r$craftingFrequency = Math.min(this.remainingOperations, this.r$craftingFrequency); - } - return MediumType.MEPatternProvider; - } else - return MediumType.NULL; - } else if (m instanceof EFabricatorMEChannel ef) { - var max = 0; - for (EFabricatorWorker worker : ef.getController().getWorkers()) { - max += worker.getRemainingSpace(); - } - for (IAEItemStack input : details.getInputs()) { - if (input == null) continue; - long size = this.r$craftingFrequency; - val item = this.inventory.extractItems(input.copy().setStackSize(size), Actionable.SIMULATE, this.machineSrc); - if (item == null) continue; - if (item.getStackSize() < size) { - long size0 = item.getStackSize() / input.getStackSize(); - if (size0 < 2) { - this.r$craftingFrequency = 1; - } else { - this.r$craftingFrequency = size0; - } - } - } - this.r$craftingFrequency = Math.min(max, this.r$craftingFrequency); - return MediumType.EF; - } else - return MediumType.NULL; - } - - @Unique - private IAEItemStack r$extractItemsR(MECraftingInventory instance, IAEItemStack receiver, Actionable mode, IActionSource src, MediumType mediumType) { - if (mediumType != MediumType.NULL) - receiver.setStackSize(receiver.getStackSize() * this.r$craftingFrequency); - return instance.extractItems(receiver, mode, src); - } - - @Unique - protected void r$nae2$ghostInject(IAEItemStack output) { - this.r$nae2$ghostInjecting = true; - try { - this.injectItems(output, Actionable.MODULATE, this.machineSrc); - } finally { - this.r$nae2$ghostInjecting = false; - } - } - - @WrapOperation( - method = "injectItems", - at = @At( - value = "INVOKE", - target = "Lappeng/crafting/CraftingLink;injectItems(Lappeng/api/storage/data/IAEItemStack;Lappeng/api/config/Actionable;)Lappeng/api/storage/data/IAEItemStack;" - ) - ) - protected IAEItemStack wrapInjectItems(CraftingLink link, IAEItemStack input, Actionable mode, Operation operation) { - return this.r$nae2$ghostInjecting ? null : operation.call(link, input, mode); - } - - @WrapOperation( - method = "injectItems", - at = @At( - value = "INVOKE", - target = "Lappeng/crafting/MECraftingInventory;injectItems(Lappeng/api/storage/data/IAEItemStack;Lappeng/api/config/Actionable;Lappeng/api/networking/security/IActionSource;)Lappeng/api/storage/data/IAEItemStack;" - ) - ) - protected IAEItemStack wrapInjectItems(MECraftingInventory link, IAEItemStack input, Actionable mode, IActionSource src, Operation operation) { - return this.r$nae2$ghostInjecting ? null : operation.call(link, input, mode, src); - } - - @Mixin(targets = "appeng.me.cluster.implementations.CraftingCPUCluster$TaskProgress", remap = false) - public interface AccessorTaskProgress { - @Accessor - long getValue(); - - @Accessor - void setValue(long value); - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingCPUStatus.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingCPUStatus.java deleted file mode 100644 index e133fdf8..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingCPUStatus.java +++ /dev/null @@ -1,48 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.networking.crafting.ICraftingCPU; -import appeng.container.implementations.CraftingCPUStatus; -import github.kasuminova.novaeng.common.block.ecotech.ecalculator.prop.Levels; -import github.kasuminova.novaeng.common.ecalculator.ECPUCluster; -import github.kasuminova.novaeng.common.ecalculator.ECPUStatus; -import net.minecraft.nbt.NBTTagCompound; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(value = CraftingCPUStatus.class, remap = false) -public class MixinCraftingCPUStatus implements ECPUStatus { - - @Unique - private Levels novaeng_ec$ecLevel; - - @Inject(method = "(Lappeng/api/networking/crafting/ICraftingCPU;I)V", at = @At("RETURN")) - private void injectInit(final ICraftingCPU cluster, final int serial, final CallbackInfo ci) { - if (cluster instanceof ECPUCluster ecpuCluster) { - this.novaeng_ec$ecLevel = ecpuCluster.novaeng_ec$getControllerLevel(); - } - } - - @Inject(method = "(Lnet/minecraft/nbt/NBTTagCompound;)V", at = @At("RETURN")) - private void injectInit(final NBTTagCompound i, final CallbackInfo ci) { - if (i.hasKey("ecLevel")) { - this.novaeng_ec$ecLevel = Levels.BY_ORDINAL[i.getByte("ecLevel")]; - } - } - - @Inject(method = "writeToNBT", at = @At("RETURN")) - private void injectWriteToNBT(final NBTTagCompound i, final CallbackInfo ci) { - if (novaeng_ec$ecLevel == null) { - return; - } - i.setByte("ecLevel", (byte) novaeng_ec$ecLevel.ordinal()); - } - - @Override - public Levels novaeng_ec$getLevel() { - return novaeng_ec$ecLevel; - } - -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingGridCache.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingGridCache.java deleted file mode 100644 index 7807c280..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinCraftingGridCache.java +++ /dev/null @@ -1,68 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.networking.IGrid; -import appeng.api.networking.IGridNode; -import appeng.api.networking.energy.IEnergyGrid; -import appeng.crafting.CraftingLink; -import appeng.me.cache.CraftingGridCache; -import appeng.me.cluster.implementations.CraftingCPUCluster; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import github.kasuminova.mmce.common.util.TimeRecorder; -import github.kasuminova.novaeng.common.ecalculator.ECPUCluster; -import github.kasuminova.novaeng.common.tile.ecotech.ecalculator.ECalculatorMEChannel; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.List; -import java.util.Set; - -@SuppressWarnings("MethodMayBeStatic") -@Mixin(value = CraftingGridCache.class, remap = false) -public abstract class MixinCraftingGridCache { - - @Shadow - @Final - private IGrid grid; - - @Shadow - @Final - private Set craftingCPUClusters; - - @Shadow - public abstract void addLink(final CraftingLink link); - - @Inject(method = "updateCPUClusters()V", at = @At("RETURN")) - private void injectUpdateCPUClusters(final CallbackInfo ci) { - for (final IGridNode ecNode : grid.getMachines(ECalculatorMEChannel.class)) { - final ECalculatorMEChannel ec = (ECalculatorMEChannel) ecNode.getMachine(); - final List cpus = ec.getCPUs(); - - for (CraftingCPUCluster cpu : cpus) { - this.craftingCPUClusters.add(cpu); - - if (cpu.getLastCraftingLink() != null) { - this.addLink((CraftingLink) cpu.getLastCraftingLink()); - } - } - } - } - - @WrapOperation(method = "onUpdateTick", at = @At(value = "INVOKE", target = "Lappeng/me/cluster/implementations/CraftingCPUCluster;updateCraftingLogic(Lappeng/api/networking/IGrid;Lappeng/api/networking/energy/IEnergyGrid;Lappeng/me/cache/CraftingGridCache;)V")) - private void wrapOnUpdateTick(final CraftingCPUCluster instance, final IGrid grid, final IEnergyGrid eg, final CraftingGridCache cc, final Operation original) { - ECPUCluster ec = ECPUCluster.from(instance); - if (ec.novaeng_ec$getController() != null) { - TimeRecorder recorder = ec.novaeng_ec$getTimeRecorder(); - final long start = System.nanoTime() / 1000; - original.call(instance, grid, eg, cc); - recorder.addUsedTime((int) (System.nanoTime() / 1000 - start)); - } else { - original.call(instance, grid, eg, cc); - } - } - -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinGridStorageCache.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinGridStorageCache.java deleted file mode 100644 index 724e48af..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinGridStorageCache.java +++ /dev/null @@ -1,31 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.storage.IStorageChannel; -import appeng.api.storage.data.IAEStack; -import appeng.me.cache.GridStorageCache; -import appeng.me.cache.NetworkMonitor; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.Map; - -@Mixin(value = GridStorageCache.class, remap = false) -public class MixinGridStorageCache { - - @Shadow - @Final - private Map>, NetworkMonitor> storageMonitors; - - @SuppressWarnings({"MixinAnnotationTarget", "rawtypes"}) - @Redirect(method = "*", at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;")) - private Object fixNPE(Map instance, Object o) { - var i = instance.get(o); - if (instance == storageMonitors && i == null) { - storageMonitors.put((IStorageChannel) o, (NetworkMonitor) (i = new NetworkMonitor((GridStorageCache) (Object) this, (IStorageChannel) o))); - } - return i; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinGuiCraftConfirm.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinGuiCraftConfirm.java deleted file mode 100644 index 9dd2c224..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinGuiCraftConfirm.java +++ /dev/null @@ -1,10 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.client.gui.implementations.GuiCraftConfirm; -import github.kasuminova.novaeng.client.util.RCGuiCraftConfirm; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(GuiCraftConfirm.class) -public class MixinGuiCraftConfirm implements RCGuiCraftConfirm { - -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinGuiCraftingStatus.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinGuiCraftingStatus.java deleted file mode 100644 index aa145960..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinGuiCraftingStatus.java +++ /dev/null @@ -1,163 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.storage.data.IAEItemStack; -import appeng.client.gui.AEBaseGui; -import appeng.client.gui.implementations.GuiCraftingStatus; -import appeng.client.gui.widgets.GuiScrollbar; -import appeng.container.implementations.ContainerCraftingStatus; -import appeng.container.implementations.CraftingCPUStatus; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import github.kasuminova.mmce.client.gui.util.RenderPos; -import github.kasuminova.mmce.client.gui.util.TextureProperties; -import github.kasuminova.novaeng.common.block.ecotech.ecalculator.prop.Levels; -import github.kasuminova.novaeng.common.ecalculator.ECPUStatus; -import github.kasuminova.novaeng.novaeng_core.Tags; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextFormatting; -import org.lwjgl.opengl.GL11; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; - -import java.util.List; - -@SuppressWarnings({"StaticVariableMayNotBeInitialized", "NonConstantFieldWithUpperCaseName"}) -@Mixin(value = GuiCraftingStatus.class, remap = false) -public abstract class MixinGuiCraftingStatus extends AEBaseGui { - - @Unique - private static final ResourceLocation novaeng_ec$TEXTURE = new ResourceLocation(Tags.MOD_ID, "textures/gui/ecalculator_gui_2.png"); - @Unique - private static final TextureProperties novaeng_ec$L4 = TextureProperties.of(novaeng_ec$TEXTURE, 1, 1, 67, 22); - @Unique - private static final TextureProperties novaeng_ec$L4_CELL = TextureProperties.of(novaeng_ec$TEXTURE, 0, 124, 16, 16); - @Unique - private static final TextureProperties novaeng_ec$L6 = TextureProperties.of(novaeng_ec$TEXTURE, 1, 26, 67, 22); - @Unique - private static final TextureProperties novaeng_ec$L6_CELL = TextureProperties.of(novaeng_ec$TEXTURE, 34, 124, 16, 16); - @Unique - private static final TextureProperties novaeng_ec$L9 = TextureProperties.of(novaeng_ec$TEXTURE, 1, 51, 67, 22); - @Unique - private static final TextureProperties novaeng_ec$L9_CELL = TextureProperties.of(novaeng_ec$TEXTURE, 17, 124, 16, 16); - @Unique - private static final TextureProperties novaeng_ec$L11 = TextureProperties.of(novaeng_ec$TEXTURE, 1, 76, 67, 22); - @Shadow - @Final - private static int CPU_TABLE_WIDTH; - @Shadow - @Final - private static int CPU_TABLE_SLOT_HEIGHT; - @Shadow - @Final - private static int CPU_TABLE_SLOT_XOFF; - @Shadow - @Final - private static int CPU_TABLE_SLOT_YOFF; - @Shadow - @Final - private static int CPU_TABLE_SLOT_WIDTH; - @Shadow - @Final - private ContainerCraftingStatus status; - @Shadow - private GuiScrollbar cpuScrollbar; - - public MixinGuiCraftingStatus() { - super(null); - } - - @WrapOperation(method = "drawFG", at = @At(value = "INVOKE", target = "Ljava/util/List;get(I)Ljava/lang/Object;")) - private Object redirectDrawFG(final List instance, final int i, final Operation original, @Local(name = "hoveredCpu") final CraftingCPUStatus hoveredCpu) { - CraftingCPUStatus status = original.call(instance, i); - ECPUStatus ecpuStatus = (ECPUStatus) status; - if (ecpuStatus.novaeng_ec$getLevel() != null) { - novaeng_ec$renderECPUStatus(status, ecpuStatus.novaeng_ec$getLevel(), i, this.cpuScrollbar.getCurrentScroll(), hoveredCpu); - return null; - } - return status; - } - - @Unique - @SuppressWarnings({"RedundantCast"}) - private void novaeng_ec$renderECPUStatus(final CraftingCPUStatus cpu, final Levels ecLevel, final int i, final int firstCpu, final CraftingCPUStatus hoveredCpu) { - final FontRenderer font = fontRenderer; - final int textColor = 0x202020; - int x = -CPU_TABLE_WIDTH + 9; - int y = 19 + (i - firstCpu) * CPU_TABLE_SLOT_HEIGHT; - if (cpu.getSerial() == this.status.selectedCpuSerial) { - GL11.glColor4f(0.0F, 0.8352F, 1.0F, 1.0F); - } else if (hoveredCpu != null && hoveredCpu.getSerial() == cpu.getSerial()) { - GL11.glColor4f(0.65F, 0.9F, 1.0F, 1.0F); - } else { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - } - this.bindTexture("guis/cpu_selector.png"); - this.drawTexturedModalRect(x, y, CPU_TABLE_SLOT_XOFF, CPU_TABLE_SLOT_YOFF, CPU_TABLE_SLOT_WIDTH, CPU_TABLE_SLOT_HEIGHT); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - TextFormatting color = TextFormatting.WHITE; - if (ecLevel == Levels.L4) { - novaeng_ec$L4.render(new RenderPos(x, y), (AEBaseGui) (Object) this); - color = TextFormatting.AQUA; - } else if (ecLevel == Levels.L6) { - novaeng_ec$L6.render(new RenderPos(x, y), (AEBaseGui) (Object) this); - color = TextFormatting.GOLD; - } else if (ecLevel == Levels.L9) { - novaeng_ec$L9.render(new RenderPos(x, y), (AEBaseGui) (Object) this); - color = TextFormatting.DARK_PURPLE; - } else if (ecLevel == Levels.L11) { - novaeng_ec$L11.render(new RenderPos(x, y), (AEBaseGui) (Object) this); - color = TextFormatting.RED; - } - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - String name = cpu.getName(); - if (name == null || name.isEmpty()) { - name = color + "#" + cpu.getSerial() + TextFormatting.RESET; - } - if (name.replaceAll("§.", "").length() > 8) { - name = name.substring(0, 7) + ".."; - } - GL11.glPushMatrix(); - GL11.glTranslatef(x + (3 + 8), y + 3, 0); - GL11.glScalef(0.8f, 0.8f, 1.0f); - font.drawString(name, 0, 0, textColor); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glTranslatef(x + 3, y + 11, 0); - final IAEItemStack craftingStack = cpu.getCrafting(); - GL11.glScalef(0.5f, 0.5f, 1.0f); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - if (ecLevel == Levels.L4) { - novaeng_ec$L4_CELL.render(new RenderPos(2, 0), (AEBaseGui) (Object) this); - } else if (ecLevel == Levels.L6) { - novaeng_ec$L6_CELL.render(new RenderPos(2, 0), (AEBaseGui) (Object) this); - } else if (ecLevel == Levels.L9) { - novaeng_ec$L9_CELL.render(new RenderPos(2, 0), (AEBaseGui) (Object) this); - } - GL11.glTranslatef(18.0f, 3.5f, 0.0f); - if (craftingStack != null) { - String amount = Long.toString(craftingStack.getStackSize()); - if (amount.length() > 9) { - amount = amount.substring(0, 9) + ".."; - } - GL11.glScalef(1.5f, 1.5f, 1.0f); - font.drawString(amount, 0, 0, 0x009000); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glTranslatef(x + CPU_TABLE_SLOT_WIDTH - (19 + 4), y + 3, 0); - this.drawItem(0, 0, craftingStack.createItemStack()); - } else { - GL11.glScalef(1.5f, 1.5f, 1.0f); - font.drawString(cpu.formatStorage(), 0, 0, textColor); - } - GL11.glPopMatrix(); - } - -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinGuiPatternTerm.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinGuiPatternTerm.java deleted file mode 100644 index 17497d83..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinGuiPatternTerm.java +++ /dev/null @@ -1,58 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.client.gui.implementations.GuiMEMonitorable; -import appeng.client.gui.implementations.GuiPatternTerm; -import appeng.client.gui.widgets.GuiTabButton; -import appeng.container.implementations.ContainerPatternEncoder; -import github.kasuminova.novaeng.NovaEngineeringCore; -import github.kasuminova.novaeng.common.block.ecotech.efabricator.BlockEFabricatorController; -import github.kasuminova.novaeng.common.network.PktPatternTermUploadPattern; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(GuiPatternTerm.class) -public class MixinGuiPatternTerm extends GuiMEMonitorable { - - @Final - @Shadow(remap = false) - private ContainerPatternEncoder container; - - @Unique - private GuiTabButton novaeng_core$uploadPatternButton; - - @SuppressWarnings("DataFlowIssue") - public MixinGuiPatternTerm() { - super(null, null); - } - - @Inject(method = "initGui", at = @At("RETURN")) - private void injectInitGui(final CallbackInfo ci) { - this.novaeng_core$uploadPatternButton = new GuiTabButton( - this.guiLeft + 173, this.guiTop + this.ySize - 155, - new ItemStack(BlockEFabricatorController.L4), I18n.format("gui.efabricator.button.upload_pattern"), this.itemRender - ); - this.buttonList.add(this.novaeng_core$uploadPatternButton); - } - - @Inject(method = "actionPerformed", at = @At("HEAD"), cancellable = true) - private void injectActionPerformed(final GuiButton btn, final CallbackInfo ci) { - if (btn == this.novaeng_core$uploadPatternButton) { - NovaEngineeringCore.NET_CHANNEL.sendToServer(new PktPatternTermUploadPattern()); - ci.cancel(); - } - } - - @Inject(method = "drawFG", at = @At("HEAD"), remap = false) - private void injectDrawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, final CallbackInfo ci) { - this.novaeng_core$uploadPatternButton.visible = this.container.isCraftingMode(); - } - -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinItemListBulkIteration.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinItemListBulkIteration.java deleted file mode 100644 index 536be6a1..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinItemListBulkIteration.java +++ /dev/null @@ -1,35 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.storage.data.IAEItemStack; -import appeng.util.item.ItemList; -import github.kasuminova.novaeng.common.performance.AvailableStackIteration; -import it.unimi.dsi.fastutil.objects.Reference2ObjectMap; -import net.minecraft.item.Item; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import java.util.ConcurrentModificationException; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Consumer; - -@Mixin(value = ItemList.class, remap = false) -public abstract class MixinItemListBulkIteration implements AvailableStackIteration { - @Shadow - @Final - private Reference2ObjectMap records; - @Shadow - @Final - private AtomicInteger version; - - @Override - public void nova$forEachAvailable(final Consumer consumer) { - final int expected = version.get(); - final Consumer available = stack -> { - if (!stack.isMeaningful()) return; - if (version.get() != expected) throw new ConcurrentModificationException(); - consumer.accept(stack); - }; - records.values().forEach(record -> ((AccessorItemVariantRecords) record).nova$records().values().forEach(available)); - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinItemListIgnoreCraftingCopies.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinItemListIgnoreCraftingCopies.java deleted file mode 100644 index d606add8..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinItemListIgnoreCraftingCopies.java +++ /dev/null @@ -1,50 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.storage.data.IAEStack; -import appeng.api.storage.data.IItemList; -import appeng.util.inv.ItemListIgnoreCrafting; -import appeng.util.item.ItemList; -import github.kasuminova.novaeng.common.performance.AvailableStackIteration; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -import java.util.function.Consumer; - -@Mixin(value = ItemListIgnoreCrafting.class, remap = false) -public abstract class MixinItemListIgnoreCraftingCopies> implements AvailableStackIteration { - @Shadow - @Final - private IItemList target; - - /** - * @author NovaEngineering - * @reason Clear crafting on ItemList's owned copy instead of making an intermediate stack copy. - */ - @Overwrite - public void add(T option) { - if (option != null && option.isCraftable()) { - if (target.getClass() == ItemList.class) { - final T previous = target.findPrecise(option); - final boolean craftable = previous != null && previous.isCraftable(); - target.add(option); - target.findPrecise(option).setCraftable(craftable); - return; - } - option = option.copy(); - option.setCraftable(false); - } - target.add(option); - } - - @Override - @SuppressWarnings("unchecked") - public void nova$forEachAvailable(final Consumer consumer) { - if (target instanceof AvailableStackIteration iteration) { - ((AvailableStackIteration) iteration).nova$forEachAvailable(consumer); - } else { - for (final T stack : target) consumer.accept(stack); - } - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinMECraftingInventoryIteration.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinMECraftingInventoryIteration.java deleted file mode 100644 index f640de9a..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinMECraftingInventoryIteration.java +++ /dev/null @@ -1,32 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IItemList; -import appeng.crafting.MECraftingInventory; -import github.kasuminova.novaeng.common.performance.AvailableStackIteration; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = MECraftingInventory.class, remap = false) -public abstract class MixinMECraftingInventoryIteration { - @Shadow - @Final - private IItemList localCache; - - /** - * @author NovaEngineering - * @reason Scan owned records without allocating two iterators per item variant; output still owns its copies. - */ - @Overwrite - @SuppressWarnings("unchecked") - public IItemList getAvailableItems(final IItemList out) { - if (localCache instanceof AvailableStackIteration iteration) { - ((AvailableStackIteration) iteration).nova$forEachAvailable(out::add); - } else { - for (final IAEItemStack stack : localCache) out.add(stack); - } - return out; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinMeteorDataNameEncoder.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinMeteorDataNameEncoder.java deleted file mode 100644 index 60cf6598..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinMeteorDataNameEncoder.java +++ /dev/null @@ -1,38 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.core.worlddata.MeteorDataNameEncoder; -import github.kasuminova.novaeng.common.performance.MeteorDataFilename; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = MeteorDataNameEncoder.class, remap = false) -public abstract class MixinMeteorDataNameEncoder { - - @Shadow - @Final - private char dataSeparator; - - @Shadow - @Final - private String fileExtension; - - @Shadow - @Final - private char baseExtSeparator; - - @Shadow - @Final - private int bitScale; - - /** - * @author circulation - * @reason Build decimal region filenames without Formatter's parsing and varargs on ASCII-digit locales. - */ - @Overwrite - public String encode(final int dimension, final int chunkX, final int chunkZ) { - return MeteorDataFilename.encode(dimension, chunkX, chunkZ, this.bitScale, - this.dataSeparator, this.baseExtSeparator, this.fileExtension); - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinMeteorWriteBatch.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinMeteorWriteBatch.java deleted file mode 100644 index 1e84e57d..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinMeteorWriteBatch.java +++ /dev/null @@ -1,37 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.core.AELog; -import appeng.hooks.TickHandler; -import appeng.util.IWorldCallable; -import com.google.common.base.Stopwatch; -import github.kasuminova.novaeng.common.performance.MeteorWriteBatch; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - -import java.util.Queue; -import java.util.concurrent.TimeUnit; - -@Mixin(value = TickHandler.class, remap = false) -public abstract class MixinMeteorWriteBatch { - /** - * @author NovaEngineering - * @reason Coalesce meteor region writes within the existing queue budget and flush on all exits. - */ - @Overwrite - private void processQueue(final Queue> queue, final World world) { - if (queue == null) return; - final Stopwatch stopwatch = Stopwatch.createStarted(); - try (final MeteorWriteBatch batch = MeteorWriteBatch.open()) { - IWorldCallable callable; - while ((callable = queue.poll()) != null) { - try { - callable.call(world); - if (stopwatch.elapsed(TimeUnit.MILLISECONDS) > 50L) break; - } catch (final Exception failure) { - AELog.debug(failure); - } - } - } - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinNetworkInventoryOutputPreparation.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinNetworkInventoryOutputPreparation.java deleted file mode 100644 index 1f588c4a..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinNetworkInventoryOutputPreparation.java +++ /dev/null @@ -1,19 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.tile.inventory.AppEngNetworkInventory; -import appeng.util.item.AEItemStack; -import github.kasuminova.novaeng.common.performance.AeOutputPreparation; -import github.kasuminova.novaeng.common.performance.AeOutputTarget; -import net.minecraft.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(value = AppEngNetworkInventory.class, remap = false) -public abstract class MixinNetworkInventoryOutputPreparation implements AeOutputTarget { - @Redirect(method = "insertItem", at = @At(value = "INVOKE", - target = "Lappeng/util/item/AEItemStack;fromItemStack(Lnet/minecraft/item/ItemStack;)Lappeng/util/item/AEItemStack;"), require = 1) - private AEItemStack nova$reuseConversion(final ItemStack stack) { - return AeOutputPreparation.convert(stack); - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinPacketInventoryAction.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinPacketInventoryAction.java deleted file mode 100644 index 1176c5ab..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinPacketInventoryAction.java +++ /dev/null @@ -1,39 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.container.AEBaseContainer; -import appeng.core.sync.AppEngPacket; -import appeng.core.sync.network.INetworkInfo; -import appeng.core.sync.packets.PacketInventoryAction; -import appeng.helpers.InventoryAction; -import github.kasuminova.novaeng.common.handler.AEPktInvActionSpamHandler; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(PacketInventoryAction.class) -public class MixinPacketInventoryAction { - - @Shadow(remap = false) - @Final - private InventoryAction action; - - @Inject(method = "serverPacketData", at = @At("HEAD"), cancellable = true, remap = false) - private void injectServerPacketData(final INetworkInfo manager, final AppEngPacket packet, final EntityPlayer player, final CallbackInfo ci) { - final EntityPlayerMP sender = (EntityPlayerMP) player; - if (!(sender.openContainer instanceof AEBaseContainer)) { - return; - } - if (this.action == InventoryAction.MOVE_REGION && AEPktInvActionSpamHandler.receivePacketAndCheckSpam(sender)) { - sender.connection.disconnect(new TextComponentString("[NovaEng-Core]" + TextFormatting.RED + " Disconnected by AE2 Packet Spam.")); - ci.cancel(); - } - } - -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinSpawnDataInput.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinSpawnDataInput.java deleted file mode 100644 index 34b97989..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinSpawnDataInput.java +++ /dev/null @@ -1,51 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import com.llamalad7.mixinextras.sugar.Local; -import github.kasuminova.novaeng.common.performance.MeteorRegionCache; -import github.kasuminova.novaeng.common.performance.MeteorSpawnDataInput; -import net.minecraft.nbt.NBTTagCompound; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - -@Mixin(targets = "appeng.core.worlddata.SpawnData", remap = false) -public abstract class MixinSpawnDataInput { - - @Unique - private final MeteorRegionCache nova$regions = new MeteorRegionCache(getClass()); - - @Inject(method = "loadSpawnData", at = @At(value = "INVOKE", target = "Ljava/io/File;isFile()Z"), - cancellable = true, require = 1) - private void nova$readCachedRegion(final int dimension, final int x, final int z, - final CallbackInfoReturnable cir, @Local final File file) { - final NBTTagCompound cached = nova$regions.get(file); - if (cached != null) cir.setReturnValue(cached); - } - - @Redirect(method = "loadSpawnData", at = @At(value = "INVOKE", - target = "Lnet/minecraft/nbt/CompressedStreamTools;readCompressed(Ljava/io/InputStream;)Lnet/minecraft/nbt/NBTTagCompound;", remap = true), require = 1) - private NBTTagCompound nova$bufferCompressedFile(final InputStream is, @Local final File file) throws IOException { - final NBTTagCompound data = MeteorSpawnDataInput.read(is); - nova$regions.completeRead(file, data); - return data; - } - - @Inject(method = "writeSpawnData", at = @At(value = "NEW", target = "java/io/FileOutputStream"), - cancellable = true, require = 1) - private void nova$prepareRegionWrite(final int dimension, final int x, final int z, final NBTTagCompound data, - final CallbackInfo ci, @Local final File file) throws IOException { - // An identical successful write has no dirty interval to flush or lose at shutdown. - if (!nova$regions.containsUnchanged(file, data) && !nova$regions.stage(file, data)) { - nova$regions.writeThrough(file, data); - } - ci.cancel(); - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinTileChestFilter.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinTileChestFilter.java index 0cd956d3..b7abae5c 100644 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinTileChestFilter.java +++ b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinTileChestFilter.java @@ -1,23 +1,22 @@ package github.kasuminova.novaeng.mixin.ae2; +import ae2.api.inventories.InternalInventory; import github.kasuminova.novaeng.common.item.estorage.EStorageCell; import net.minecraft.item.ItemStack; -import net.minecraftforge.items.IItemHandler; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@SuppressWarnings("MethodMayBeStatic") -@Mixin(targets = "appeng.tile.storage.TileChest$CellInventoryFilter") +@Mixin(targets = "ae2.tile.storage.TileMEChest$CellInventoryFilter", remap = false) public class MixinTileChestFilter { /** * 不是,那么大个驱动器怎么塞得下那么大个硬盘? */ @Inject(method = "allowInsert", at = @At("HEAD"), cancellable = true, remap = false) - private void injectEStorageCellCheck(final IItemHandler inv, final int slot, final ItemStack stack, final CallbackInfoReturnable cir) { - if (stack.getItem() instanceof EStorageCell) { + private void injectEStorageCellCheck(final InternalInventory inv, final int slot, final ItemStack stack, final CallbackInfoReturnable cir) { + if (stack.getItem() instanceof EStorageCell) { cir.setReturnValue(false); } } diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinTileDriveFilter.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinTileDriveFilter.java index 0caf0269..1fee0120 100644 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinTileDriveFilter.java +++ b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinTileDriveFilter.java @@ -1,23 +1,22 @@ package github.kasuminova.novaeng.mixin.ae2; +import ae2.api.inventories.InternalInventory; import github.kasuminova.novaeng.common.item.estorage.EStorageCell; import net.minecraft.item.ItemStack; -import net.minecraftforge.items.IItemHandler; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@SuppressWarnings("MethodMayBeStatic") -@Mixin(targets = "appeng.tile.storage.TileDrive$CellValidInventoryFilter") +@Mixin(targets = "ae2.tile.storage.TileDrive$CellValidInventoryFilter", remap = false) public class MixinTileDriveFilter { /** * 不是,那么大个驱动器怎么塞得下那么大个硬盘? */ @Inject(method = "allowInsert", at = @At("HEAD"), cancellable = true, remap = false) - private void injectEStorageCellCheck(final IItemHandler inv, final int slot, final ItemStack stack, final CallbackInfoReturnable cir) { - if (stack.getItem() instanceof EStorageCell) { + private void injectEStorageCellCheck(final InternalInventory inv, final int slot, final ItemStack stack, final CallbackInfoReturnable cir) { + if (stack.getItem() instanceof EStorageCell) { cir.setReturnValue(false); } } diff --git a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinUVLModelLoader.java b/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinUVLModelLoader.java deleted file mode 100644 index 3fd1cfcb..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/ae2/MixinUVLModelLoader.java +++ /dev/null @@ -1,35 +0,0 @@ -package github.kasuminova.novaeng.mixin.ae2; - -import appeng.client.render.model.UVLModelLoader; -import github.kasuminova.novaeng.client.resource.ModelJsonMetadataIndex; -import github.kasuminova.novaeng.client.resource.ModelJsonMetadataIndexImpl; -import net.minecraft.util.ResourceLocation; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -/** - * Answers AE2 UVL marker probes from the same parsed model metadata used by other loaders. - */ -@Mixin(value = UVLModelLoader.class, priority = 2000, remap = false) -public abstract class MixinUVLModelLoader { - - @Inject(method = "accepts", at = @At("HEAD"), cancellable = true, - remap = false, require = 1) - private void nova$readSharedUvlMarker(final ResourceLocation modelLocation, - final CallbackInfoReturnable cir) { - final ModelJsonMetadataIndex metadata = ModelJsonMetadataIndexImpl.instance(); - if (!metadata.isActive()) { - return; - } - - String modelPath = modelLocation.getPath(); - if (modelPath.startsWith("models/")) { - modelPath = modelPath.substring("models/".length()); - } - final ResourceLocation jsonLocation = new ResourceLocation( - modelLocation.getNamespace(), "models/" + modelPath + ".json"); - cir.setReturnValue(metadata.hasUvlMarker(jsonLocation)); - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/bettermeteor/MixinCompassTargetScan.java b/src/main/java/github/kasuminova/novaeng/mixin/bettermeteor/MixinCompassTargetScan.java deleted file mode 100644 index 675d936d..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/bettermeteor/MixinCompassTargetScan.java +++ /dev/null @@ -1,123 +0,0 @@ -package github.kasuminova.novaeng.mixin.bettermeteor; - -import appeng.services.CompassService; - -import com.circulation.better_meteorite.BMConfig; -import com.circulation.better_meteorite.util.Function; - -import github.kasuminova.novaeng.common.performance.MeteorCompassMetadata; - -import it.unimi.dsi.fastutil.objects.ObjectArrayList; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; - -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -/** - * Runs before BetterMeteorite's HEAD callback, retaining its configured target semantics. - */ -@Mixin(value = CompassService.class, remap = false, priority = 2000) -public abstract class MixinCompassTargetScan { - @Shadow - @Final - private static int CHUNK_SIZE; - @Unique - private static volatile MeteorCompassMetadata nova$targets; - @Unique - private static MethodHandle nova$updatePostConstructor; - @Shadow - @Final - private ExecutorService executor; - - @Unique - private static synchronized MeteorCompassMetadata nova$initializeTargets() - throws ReflectiveOperationException { - if (nova$targets != null) return nova$targets; - final var lookup = - MethodHandles.privateLookupIn(CompassService.class, MethodHandles.lookup()); - final Class type = lookup.findClass("appeng.services.CompassService$CMUpdatePost"); - nova$updatePostConstructor = - MethodHandles.privateLookupIn(type, lookup) - .findConstructor( - type, - MethodType.methodType( - void.class, - CompassService.class, - World.class, - int.class, - int.class, - int.class, - boolean.class)) - .asType( - MethodType.methodType( - Runnable.class, - CompassService.class, - World.class, - int.class, - int.class, - int.class, - boolean.class)); - final ObjectArrayList states = new ObjectArrayList<>(); - for (final String target : BMConfig.MeteoriteCompassTarget) { - final IBlockState state = Function.getBlockFromName(target); - if (state != null) states.add(state); - } - final MeteorCompassMetadata matcher = new MeteorCompassMetadata(states); - nova$targets = matcher; - return matcher; - } - - @Inject( - method = "updateArea(Lnet/minecraft/world/World;III)Ljava/util/concurrent/Future;", - at = @At("HEAD"), - cancellable = true, - require = 1) - private void nova$scanConfiguredTargets( - final World world, - final int x, - final int y, - final int z, - final CallbackInfoReturnable> result) - throws Throwable { - final int chunkX = x >> 4; - final int chunkZ = z >> 4; - final int band = y >> 5; - final Chunk chunk = world.getChunk(chunkX, chunkZ); - MeteorCompassMetadata targets = nova$targets; - if (targets == null) targets = nova$initializeTargets(); - final MeteorCompassMetadata.Scan scan = targets.scan(); - boolean found = false; - if (!targets.isEmpty()) { - search: - for (int blockX = 0; blockX < CHUNK_SIZE; blockX++) { - for (int blockZ = 0; blockZ < CHUNK_SIZE; blockZ++) { - for (int blockY = band << 5, endY = blockY + 32; blockY < endY; blockY++) { - if (scan.matches(chunk.getBlockState(blockX, blockY, blockZ))) { - found = true; - break search; - } - } - } - } - } - final Runnable update = - (Runnable) - nova$updatePostConstructor.invokeExact( - (CompassService) (Object) this, world, chunkX, chunkZ, band, found); - result.setReturnValue(executor.submit(update)); - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/betterp2p/MixinServerLinkP2PHandler.java b/src/main/java/github/kasuminova/novaeng/mixin/betterp2p/MixinServerLinkP2PHandler.java deleted file mode 100644 index b2d3028d..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/betterp2p/MixinServerLinkP2PHandler.java +++ /dev/null @@ -1,47 +0,0 @@ -package github.kasuminova.novaeng.mixin.betterp2p; - -import com.projecturanus.betterp2p.network.packet.C2SLinkP2P; -import com.projecturanus.betterp2p.network.packet.ServerLinkP2PHandler; -import net.minecraftforge.fml.common.network.simpleimpl.IMessage; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.Objects; - -@Mixin(value = ServerLinkP2PHandler.class, remap = false) -public abstract class MixinServerLinkP2PHandler { - - @Unique - private static final ThreadLocal NOVA$SERVER_DISPATCH = new ThreadLocal<>(); - - @Inject(method = "onMessage(Lcom/projecturanus/betterp2p/network/packet/C2SLinkP2P;Lnet/minecraftforge/fml/common/network/simpleimpl/MessageContext;)Lnet/minecraftforge/fml/common/network/simpleimpl/IMessage;", - at = @At("HEAD"), cancellable = true, remap = false, require = 1) - private void nova$linkOnServerThread(final C2SLinkP2P message, final MessageContext ctx, - final CallbackInfoReturnable cir) { - if (NOVA$SERVER_DISPATCH.get() == message) { - return; - } - if (message.getInput() == null || message.getOutput() == null) { - cir.setReturnValue(null); - return; - } - Objects.requireNonNull(ctx.getServerHandler().player.getServer()).addScheduledTask(() -> { - final C2SLinkP2P previous = NOVA$SERVER_DISPATCH.get(); - NOVA$SERVER_DISPATCH.set(message); - try { - ((ServerLinkP2PHandler) (Object) this).onMessage(message, ctx); - } finally { - if (previous == null) { - NOVA$SERVER_DISPATCH.remove(); - } else { - NOVA$SERVER_DISPATCH.set(previous); - } - } - }); - cir.setReturnValue(null); - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/betterp2p/MixinServerUnlinkP2PHandler.java b/src/main/java/github/kasuminova/novaeng/mixin/betterp2p/MixinServerUnlinkP2PHandler.java deleted file mode 100644 index 484edcb9..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/betterp2p/MixinServerUnlinkP2PHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -package github.kasuminova.novaeng.mixin.betterp2p; - -import com.projecturanus.betterp2p.network.ModNetwork; -import com.projecturanus.betterp2p.network.packet.C2SUnlinkP2P; -import com.projecturanus.betterp2p.network.packet.S2COpenGui; -import com.projecturanus.betterp2p.network.packet.ServerUnlinkP2PHandler; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - -@Mixin(value = ServerUnlinkP2PHandler.class, remap = false) -public class MixinServerUnlinkP2PHandler { - - /** - * @author circulation - * @reason Fix CME caused by updating ME network in non-server thread. - */ - @Overwrite - @Nullable - public S2COpenGui onMessage(C2SUnlinkP2P message, MessageContext ctx) { - if (message.getP2p() == null) { - return null; - } - - var player = ctx.getServerHandler().player; - var cache = ModNetwork.INSTANCE.getPlayerState().get(player.getUniqueID()); - if (cache == null) { - return null; - } - player.getServer().addScheduledTask(() -> { - cache.getGridCache().unlinkP2P(message.getP2p()); - ModNetwork.INSTANCE.requestP2PUpdate(player); - }); - - return null; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/ae2ctl/MixinBackground.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/ae2ctl/MixinBackground.java deleted file mode 100644 index 48d4cfcd..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/ae2ctl/MixinBackground.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.ae2ctl; - -import github.kasuminova.ae2ctl.client.gui.widget.impl.craftingtree.Background; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = Background.class, remap = false) -public abstract class MixinBackground { - - @Shadow - @Final - private static Background[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static Background[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/ae2ctl/MixinGuiType.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/ae2ctl/MixinGuiType.java deleted file mode 100644 index 8bfcf5ad..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/ae2ctl/MixinGuiType.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.ae2ctl; - -import github.kasuminova.ae2ctl.common.CommonProxy.GuiType; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = GuiType.class, remap = false) -public abstract class MixinGuiType { - - @Shadow - @Final - private static GuiType[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static GuiType[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/betterp2p/MixinBetterMemoryCardModes.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/betterp2p/MixinBetterMemoryCardModes.java deleted file mode 100644 index d9e1bb4a..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/betterp2p/MixinBetterMemoryCardModes.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.betterp2p; - -import com.projecturanus.betterp2p.item.BetterMemoryCardModes; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = BetterMemoryCardModes.class, remap = false) -public abstract class MixinBetterMemoryCardModes { - - @Shadow - @Final - private static BetterMemoryCardModes[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static BetterMemoryCardModes[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/betterp2p/MixinGuiScale.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/betterp2p/MixinGuiScale.java deleted file mode 100644 index f2b31147..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/betterp2p/MixinGuiScale.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.betterp2p; - -import com.projecturanus.betterp2p.client.gui.widget.GuiScale; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = GuiScale.class, remap = false) -public abstract class MixinGuiScale { - - @Shadow - @Final - private static GuiScale[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static GuiScale[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/mekeng/MixinGuiMode.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/mekeng/MixinGuiMode.java deleted file mode 100644 index dfcfc7e6..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/mekeng/MixinGuiMode.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.mekeng; - -import com.mekeng.github.common.container.handler.GuiFactory.GuiMode; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = GuiMode.class, remap = false) -public abstract class MixinGuiMode { - - @Shadow - @Final - private static GuiMode[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static GuiMode[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/mekeng/MixinPT.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/mekeng/MixinPT.java deleted file mode 100644 index cd986b39..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/mekeng/MixinPT.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.mekeng; - -import com.mekeng.github.network.packet.sync.ParaSerializer.PT; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = PT.class, remap = false) -public abstract class MixinPT { - - @Shadow - @Final - private static PT[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static PT[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/neenergistics/MixinIngredientMergeMode.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/neenergistics/MixinIngredientMergeMode.java deleted file mode 100644 index 2faa2612..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/neenergistics/MixinIngredientMergeMode.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.neenergistics; - -import com.github.vfyjxf.nee.config.IngredientMergeMode; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = IngredientMergeMode.class, remap = false) -public abstract class MixinIngredientMergeMode { - - @Shadow - @Final - private static IngredientMergeMode[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static IngredientMergeMode[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/neenergistics/MixinPlayerAction.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/neenergistics/MixinPlayerAction.java deleted file mode 100644 index b7271c6f..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/neenergistics/MixinPlayerAction.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.neenergistics; - -import com.github.vfyjxf.nee.network.PlayerAction; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = PlayerAction.class, remap = false) -public abstract class MixinPlayerAction { - - @Shadow - @Final - private static PlayerAction[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static PlayerAction[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/neenergistics/MixinSyncAction.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/neenergistics/MixinSyncAction.java deleted file mode 100644 index b0968cf7..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/neenergistics/MixinSyncAction.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.neenergistics; - -import com.github.vfyjxf.nee.network.SyncAction; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = SyncAction.class, remap = false) -public abstract class MixinSyncAction { - - @Shadow - @Final - private static SyncAction[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static SyncAction[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/threng/MixinBasicIO.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/threng/MixinBasicIO.java deleted file mode 100644 index c3407816..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/threng/MixinBasicIO.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.threng; - -import io.github.phantamanta44.threng.util.SlotType.BasicIO; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = BasicIO.class, remap = false) -public abstract class MixinBasicIO { - - @Shadow - @Final - private static BasicIO[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static BasicIO[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/threng/MixinBlockBigAssemblerType.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/threng/MixinBlockBigAssemblerType.java deleted file mode 100644 index 44438232..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/threng/MixinBlockBigAssemblerType.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.threng; - -import io.github.phantamanta44.threng.block.BlockBigAssembler.Type; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = Type.class, remap = false) -public abstract class MixinBlockBigAssemblerType { - - @Shadow - @Final - private static Type[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static Type[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/threng/MixinBlockMachineType.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/threng/MixinBlockMachineType.java deleted file mode 100644 index 92bc181b..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/threng/MixinBlockMachineType.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.threng; - -import io.github.phantamanta44.threng.block.BlockMachine.Type; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = Type.class, remap = false) -public abstract class MixinBlockMachineType { - - @Shadow - @Final - private static Type[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static Type[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/threng/MixinItemMaterialType.java b/src/main/java/github/kasuminova/novaeng/mixin/enumcache/threng/MixinItemMaterialType.java deleted file mode 100644 index 8b17141c..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/enumcache/threng/MixinItemMaterialType.java +++ /dev/null @@ -1,24 +0,0 @@ -package github.kasuminova.novaeng.mixin.enumcache.threng; - -import io.github.phantamanta44.threng.item.ItemMaterial.Type; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = Type.class, remap = false) -public abstract class MixinItemMaterialType { - - @Shadow - @Final - private static Type[] $VALUES; - - /** - * @author circulation - * @reason Return $VALUES instead of its clone. - */ - @Overwrite(remap = false) - public static Type[] values() { - return $VALUES; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/mmce/InvokerItemOutputBus.java b/src/main/java/github/kasuminova/novaeng/mixin/mmce/InvokerItemOutputBus.java deleted file mode 100644 index e6014302..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/mmce/InvokerItemOutputBus.java +++ /dev/null @@ -1,12 +0,0 @@ -package github.kasuminova.novaeng.mixin.mmce; - -import hellfirepvp.modularmachinery.common.tiles.TileItemOutputBus; -import net.minecraftforge.items.IItemHandler; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(value = TileItemOutputBus.class, remap = false) -public interface InvokerItemOutputBus { - @Invoker("outputToExternal") - void nova$invokeOutput(IItemHandler external); -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/mmce/MixinItemOutputBusNetworkTarget.java b/src/main/java/github/kasuminova/novaeng/mixin/mmce/MixinItemOutputBusNetworkTarget.java new file mode 100644 index 00000000..cf88c1ad --- /dev/null +++ b/src/main/java/github/kasuminova/novaeng/mixin/mmce/MixinItemOutputBusNetworkTarget.java @@ -0,0 +1,36 @@ +package github.kasuminova.novaeng.mixin.mmce; + +import ae2.api.AECapabilities; +import ae2.api.networking.security.IActionSource; +import ae2.api.storage.MEStorage; +import github.kasuminova.novaeng.common.integration.ae2.AeNetworkItemHandler; +import hellfirepvp.modularmachinery.common.tiles.TileItemOutputBus; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.items.CapabilityItemHandler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(value = TileItemOutputBus.class, remap = false) +public abstract class MixinItemOutputBusNetworkTarget { + + @Redirect(method = "doRestrictedTick", at = @At(value = "INVOKE", + target = "Lnet/minecraft/tileentity/TileEntity;getCapability(Lnet/minecraftforge/common/capabilities/Capability;Lnet/minecraft/util/EnumFacing;)Ljava/lang/Object;", + remap = false), require = 1) + private Object nova$resolveNetworkTarget(final TileEntity target, final Capability capability, + final EnumFacing side) { + final Object resolved = target.getCapability(capability, side); + if (resolved != null || capability != CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return resolved; + } + if (AECapabilities.ME_STORAGE == null) { + return null; + } + + final MEStorage storage = target.getCapability(AECapabilities.ME_STORAGE, side); + return storage == null ? null : new AeNetworkItemHandler(storage, IActionSource.empty()); + } + +} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/mmce/MixinItemOutputPreparation.java b/src/main/java/github/kasuminova/novaeng/mixin/mmce/MixinItemOutputPreparation.java deleted file mode 100644 index 9dac8a8f..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/mmce/MixinItemOutputPreparation.java +++ /dev/null @@ -1,27 +0,0 @@ -package github.kasuminova.novaeng.mixin.mmce; - -import github.kasuminova.novaeng.common.performance.AeOutputPreparation; -import github.kasuminova.novaeng.common.performance.AeOutputTarget; -import hellfirepvp.modularmachinery.common.tiles.TileItemOutputBus; -import net.minecraftforge.items.IItemHandler; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(value = TileItemOutputBus.class, remap = false) -public abstract class MixinItemOutputPreparation { - @Redirect(method = "doRestrictedTick", at = @At(value = "INVOKE", - target = "Lhellfirepvp/modularmachinery/common/tiles/TileItemOutputBus;outputToExternal(Lnet/minecraftforge/items/IItemHandler;)V"), require = 1) - private void nova$prepareSupportedOutput(final TileItemOutputBus bus, final IItemHandler external) { - if (!(external instanceof AeOutputTarget)) { - ((InvokerItemOutputBus) bus).nova$invokeOutput(external); - return; - } - AeOutputPreparation.enter(); - try { - ((InvokerItemOutputBus) bus).nova$invokeOutput(external); - } finally { - AeOutputPreparation.leave(); - } - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/mmce/MixinMEPatternProvider.java b/src/main/java/github/kasuminova/novaeng/mixin/mmce/MixinMEPatternProvider.java deleted file mode 100644 index 3b39b48b..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/mmce/MixinMEPatternProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -package github.kasuminova.novaeng.mixin.mmce; - -import github.kasuminova.mmce.common.tile.MEPatternProvider; -import github.kasuminova.mmce.common.tile.base.MEMachineComponent; -import github.kasuminova.novaeng.common.tile.MEPatternProviderNova; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; - -@Mixin(value = MEPatternProvider.class, remap = false) -public abstract class MixinMEPatternProvider extends MEMachineComponent implements MEPatternProviderNova { - @Unique - public boolean novaEngineering_Core$ignoreParallel = false; - - @Shadow - public abstract MEPatternProvider.WorkModeSetting getWorkMode(); - - public boolean r$isIgnoreParallel() { - return novaEngineering_Core$ignoreParallel; - } - - public void r$IgnoreParallel() { - novaEngineering_Core$ignoreParallel = true; - } -} diff --git a/src/main/java/github/kasuminova/novaeng/mixin/nae2/MixinJEICellCategory.java b/src/main/java/github/kasuminova/novaeng/mixin/nae2/MixinJEICellCategory.java deleted file mode 100644 index 73868544..00000000 --- a/src/main/java/github/kasuminova/novaeng/mixin/nae2/MixinJEICellCategory.java +++ /dev/null @@ -1,33 +0,0 @@ -package github.kasuminova.novaeng.mixin.nae2; - -import appeng.api.AEApi; -import appeng.api.storage.ICellHandler; -import appeng.api.storage.ICellRegistry; -import co.neeve.nae2.common.integration.jei.JEICellCategory; -import github.kasuminova.novaeng.common.estorage.EStorageCellHandler; -import net.minecraft.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(JEICellCategory.class) -public class MixinJEICellCategory { - - @Redirect( - method = "getCellInfo", - at = @At( - value = "INVOKE", - target = "Lappeng/api/storage/ICellRegistry;getHandler(Lnet/minecraft/item/ItemStack;)Lappeng/api/storage/ICellHandler;", - remap = false - ), - remap = false - ) - private static ICellHandler redirectGetEStorageCellHandler(final ICellRegistry instance, final ItemStack stack) { - EStorageCellHandler handler = EStorageCellHandler.getHandler(stack); - if (handler != null) { - return handler; - } - return AEApi.instance().registries().cell().getHandler(stack); - } - -} diff --git a/src/main/resources/novaeng_core.mixin.json b/src/main/resources/novaeng_core.mixin.json index 5a1ca4f5..3a84ff11 100644 --- a/src/main/resources/novaeng_core.mixin.json +++ b/src/main/resources/novaeng_core.mixin.json @@ -13,27 +13,7 @@ "actuallyadditions.MixinLushCaveAllocation", "actuallyadditions.MixinTileEntityPhantomface", "actuallyadditions.MixinWorldgenOreFactory", - "ae2.AccessorAbstractCellInventory", - "ae2.AccessorCellRegistry", - "ae2.AccessorContainerCraftConfirm", - "ae2.AccessorContainerPatternEncoder", - "ae2.AccessorCraftingCPURecord", - "ae2.AccessorItemVariantRecords", - "ae2.MixinAppEngServerPacketHandler", - "ae2.MixinCompassReaderRegions", "ae2.MixinCraftingCPUCluster", - "ae2.MixinCraftingCPUClusterTwo", - "ae2.MixinCraftingCPUClusterTwo$AccessorTaskProgress", - "ae2.MixinCraftingCPUStatus", - "ae2.MixinCraftingGridCache", - "ae2.MixinGridStorageCache", - "ae2.MixinItemListBulkIteration", - "ae2.MixinItemListIgnoreCraftingCopies", - "ae2.MixinMECraftingInventoryIteration", - "ae2.MixinMeteorDataNameEncoder", - "ae2.MixinMeteorWriteBatch", - "ae2.MixinNetworkInventoryOutputPreparation", - "ae2.MixinSpawnDataInput", "ae2.MixinTileChestFilter", "ae2.MixinTileDriveFilter", "alfheim.MixinDeduplicatedLongQueue", @@ -61,10 +41,6 @@ "athenaeum.MixinEnchantmentHelper", "avaritia.MixinAvaritiaFactoryProbe", "base.MixinMaterialUserPrimitiveBiMap", - "bettermeteor.MixinCompassTargetScan", - "bettermineshafts.MixinBiomeTypes", - "betterp2p.MixinServerLinkP2PHandler", - "betterp2p.MixinServerUnlinkP2PHandler", "biomesoplenty.MixinAIWaspRandomFly", "biomesoplenty.MixinGenerationStages", "biomesoplenty.MixinGeneratorStageRevision", @@ -146,8 +122,6 @@ "enumcache.advancedrocketry.MixinMODES", "enumcache.advancedrocketry.MixinTemps", "enumcache.advancedrocketry.MixinType", - "enumcache.ae2ctl.MixinBackground", - "enumcache.ae2ctl.MixinGuiType", "enumcache.ae2exttable.MixinAE2ExtendedGUIs", "enumcache.ae2exttable.MixinKeyBindings", "enumcache.ae2exttable.MixinPacketTypes", @@ -260,8 +234,6 @@ "enumcache.betterbuilderswands.MixinEnumLock", "enumcache.bettermineshafts.MixinOreType", "enumcache.bettermineshafts.MixinTurnDirection", - "enumcache.betterp2p.MixinBetterMemoryCardModes", - "enumcache.betterp2p.MixinGuiScale", "enumcache.bibliocraft.MixinEnumBiblioPaintings", "enumcache.bibliocraft.MixinEnumColor", "enumcache.bibliocraft.MixinEnumMetalType", @@ -710,8 +682,6 @@ "enumcache.mekanism.MixinTubeTier", "enumcache.mekanism.MixinUpgrade", "enumcache.mekanism.MixinWrenches", - "enumcache.mekeng.MixinGuiMode", - "enumcache.mekeng.MixinPT", "enumcache.mets.MixinFabricatorType", "enumcache.mets.MixinMetsBlockWithTileEntity", "enumcache.minecraft.MixinActionType", @@ -980,9 +950,6 @@ "enumcache.modularui.MixinScreenOrientation", "enumcache.more_flux_storage.MixinFluxGuiActionType", "enumcache.moreoverlays.MixinRenderMode", - "enumcache.neenergistics.MixinIngredientMergeMode", - "enumcache.neenergistics.MixinPlayerAction", - "enumcache.neenergistics.MixinSyncAction", "enumcache.nuclearcraft.MixinBasicType", "enumcache.nuclearcraft.MixinBlockQuantumComputerCodeGeneratorType", "enumcache.nuclearcraft.MixinControlType", @@ -1153,10 +1120,6 @@ "enumcache.thermalfoundation.MixinPacketTypes", "enumcache.thermalfoundation.MixinToolSet", "enumcache.thermalfoundation.MixinToolSetVanilla", - "enumcache.threng.MixinBasicIO", - "enumcache.threng.MixinBlockBigAssemblerType", - "enumcache.threng.MixinBlockMachineType", - "enumcache.threng.MixinItemMaterialType", "enumcache.tinymobfarm.MixinEnumMobFarm", "enumcache.topalldependents.MixinEnumChip", "enumcache.torchmaster.MixinGuiType", @@ -1298,7 +1261,6 @@ "minecraft.forge.MixinPotentialSpawnsAllocation", "minecraft.forge.MixinTerrainGenPrimerOres", "mmce.AccessorAbstractMachine", - "mmce.InvokerItemOutputBus", "mmce.MixinBlockArrayCache", "mmce.MixinBlockArrayIngredients", "mmce.MixinBlockArrayPreviewRenderHelper", @@ -1308,10 +1270,9 @@ "mmce.MixinCommonProxy", "mmce.MixinCraftingCheckResultAllocation", "mmce.MixinDynamicMachineRenderContext", - "mmce.MixinItemOutputPreparation", + "mmce.MixinItemOutputBusNetworkTarget", "mmce.MixinMachineRecipe", "mmce.MixinMachineRegistry", - "mmce.MixinMEPatternProvider", "mmce.MixinOredictCache", "mmce.MixinRecipeAdapterBuilder", "mmce.MixinRecipeCraftingContextMemory", @@ -1322,7 +1283,6 @@ "mmce.MixinTileMultiblockMachineController", "mmce.MixinTileNotificationGeneration", "mmce.MixinWorldSceneRendererWidget", - "nae2.MixinJEICellCategory", "nco.MixinFluidTileWrapper", "nco.MixinITileGui", "nco.MixinNCPFWriter", @@ -1387,13 +1347,6 @@ "actinium.MixinSortOutputBudgetRelease", "actinium.MixinVintageScratchMemory", "actinium.MixinWorldClient", - "ae2.AccessorGuiCraftConfirm", - "ae2.MixinAEBaseGui", - "ae2.MixinAppEngClientPacketHandler", - "ae2.MixinGuiCraftConfirm", - "ae2.MixinGuiCraftingStatus", - "ae2.MixinGuiPatternTerm", - "ae2.MixinUVLModelLoader", "alfheim.MixinLightingEngine", "ar.MixinWavefrontSyntax", "architecturecraft.MixinBlockModelResourceProviderPrimitiveBiMap", @@ -1527,7 +1480,6 @@ "thermaldynamics.MixinModelHelperFaceFilter" ], "server": [ - "ae2.MixinPacketInventoryAction", "astralsorcery.AccessorResearchManager", "astralsorcery.InvokerPerkEffectHelper", "astralsorcery.MixinPlayerProgress",