-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement] Proposed solution to how to increment DME data model NBT in the Simulation Supercomputer + addtional problems and their (proposed) solutions #19
Comments
There is one change I would make from this: Instead of modifying the DME Models at the end of a recipe, modify it at the beginning. This solves the first problem. Hopefully, there is some method that we can use to modify the recipe ingredients. This would remove the need for expensive checks in [Edit]: Probably Every tick, it probably handles energy check as well. |
If you want to model the Simulation Supercomputer's processing behavior exactly on how the DME Simulation Chamber singleblock does it, the data model's NBT increment has to be done at the end of the process. I would make a mockup RecipeLogic class for you, but I have a uni exam in the near future and can't spare any time to code it. (Please don't quote me on this, I'm not an expert on DME's API!) Regarding interacting with multiblock inputs: As far as I can tell, If we want to register recipes for the multiblock that take the data model's tier into account when calculating the chance for pristine matter: I believe the only way to make that happen in a way that wouldn't require rewriting GTCEu Oh yeah, the corrected formula for the percent chance of pristine matter based upon model tier is as follows: Incidentally, does your team have a multiblock version of the DME Loot Fabricator defined? I saw a controller that might be that while puttering around this codebase. If you don't, would you like one? I also think I saw that GCYM doesn't add a multiblock version of the Gas Collector; would you like one of those too? They will take me some time to complete, so I can only do them after my uni exam, but it is possible. |
I understand that the singleblock iterates the level at the end, but after thought, doing it at the start seems much more appropriate. |
As for the other multiblocks, they are not needed. Thank you for your consideration. |
Alright, I'll leave those multiblocks for my own instance of Nomi-Ceu then. Ok, so if you want to increment your model's sim and data counts at the start of the process instead of at the end, override |
I was thinking on running on This would work better, working even if we for some reason reverted DME Simulation Supercomputer to use Non-Distinct. |
Excellent idea. Edit: I just realized that incrementing the data model's sim and data counts at the start of the process instead of at the end could be exploited by players to farm data model progress very quickly at the cost of pulsating polymer clay and forsaking pristine or living matter; by simply alternating putting the model in the input bus's inventory, then taking it out again and waiting for the recipe to fail completely, the recipe is started and the data model's NBT is incremented over and over again. Is this exploit desired/does it matter if this exploit is used by players? |
Since I don't have much else to say on this matter I will close this issue thread with this comment. The archived file included in this comment is a recipe populator script written in Groovy, to automate populating the Sim Chamber multiblock's RecipeMap with simulation recipes. I hope it will help you and your team further. |
I will leave this as open until we implement this. Your assistance was very helpful. |
They would have to break the controller, but it is a possible idea. However, it should be fine. Will consider this. |
Implemented in bc138df. |
If your interested, the implemented groovy script for recipes can be seen here. |
As I made my way through your team's codebase for this mod, I noticed that you haven't yet implemented a way to increase DME data models' kill/simulation counts in the Simulation Supercomputer yet. I propose the following solution to this issue:
tl;dr: Custom
MultiblockRecipeLogic
class, look through the input buses for the data model then use DME's implementation to increment the model's NBT data. I also found and listed additional problems and possible solutions.Long and thorough explanation:
The
MultiblockRecipeLogic
class in Gregtech CEu exposes aprotected
method by the name ofgetInputBuses()
. This is for distinct-bus multiblocks; the Simulation Supercomputer is one of these. This method returns a List, a list which contains the inventories of all the input buses on the multiblock. Iterate through these inventories until you have located the ItemStack representing the DME data model.The
MultiblockRecipeLogic
class also exposes theprotected void
methodcompleteRecipe()
, which (as you can probably guess) handles the logic that is to be done at the end of each completed recipe (actuates Muffler output, places products in the output buses, resets the processing time, etc.)But wait, there's more. Let's examine DME's implementation of this process, to see if we can implement the same or similar here.
The
DataModelHelper
class in DME is a helper class wrapping a number of methods and functions useful for manipulating DME data model items and their NBT metadata. It contains thepublic static void
methodaddSimulation(Itemstack dataModel)
, which adds 1 to the passed data model's data count (tracks progress to the next data model tier), adds 1 to the passed data model's sim count (tracks nothing relevant for us) and also automatically tiers up the model if it has a data count exceeding the amount necessary to achieve the next tier. The only thing it does not do is first verify if the ItemStack it recieves as a parameter is, indeed, a DME data model. Note that it directly modifies the data model's ItemStack's NBT data, and does not remove or edit anything else about the data model ItemStack.My solution is as such:
Write a custom
RecipeLogic
class (DMESimChamberRecipeLogic
would be a good, although long, name) extendingMultiblockRecipeLogic
. OverridecompleteRecipe()
and inside of it, comb through the Simulation Supercomputer's input buses' inventories fromgetInputBuses()
using a finder algorithm of your choice to find the data model's ItemStack and verify that it is actually a data model. After verification succeeds, use the previously-importedDataModelHelper.addSimulation(Itemstack dataModel)
to increase the data model's counts.Additional possible problems and my proposed solutions:
P: The DME Simulation Chamber singleblock machine automatically cancels a running simulation if the player removes the data model from its slot. If we want/need to, how do we replicate this behaviour in the multiblock?
A: The
MultiblockRecipeLogic
class exposes thecanProgressRecipe()
method, aprotected
method returning a boolean that confirms if the recipe can continue being processed. Override this method inDMESimChamberRecipeLogic
and insert an additional check to see if the data model is still in one of the input buses, once again usinggetInputBuses()
. If it is not (means it has either been consumed as recipe input, which is impossible according to the registered recipes for the Simulation Supercomputer, or was removed from the bus by the player), then return false. This will make the recipe reverse if the data model is ever removed while the recipe is in progress, until the data model is placed back in the bus. Please note that thecanProgressRecipe()
method runs once every recipe progress update, so the finder algorithm must be performant (cache the bus the model is in to ease repeated reference, perhaps?)P: The DME Simulation Chamber singleblock machine only has space for one data model to be simulated at a time. If we want/need to, how do we replicate this behaviour in the multiblock?
A: The
MultiblockRecipeLogic
class exposes thecanWorkWithInputs()
method, aprotected
method that returns a boolean that confirms if a multiblock can work with the items in its input buses. (Notably, this method returning true is one of the prerequisites to begin recipe lookup to start processing.) Override this method inDMESimChamberRecipeLogic
and count up the number of data models in the input buses usinggetInputBuses()
. If there's more than one, return false. This will prevent recipe lookup from happening, and the multiblock will not start processing at all. Could also implement similar incanProgressRecipe()
to prevent recipe from progressing while more than one datamodel is in the input buses, if a player happens to insert a second data model while the first is being simulated (caching data model input bus may also be of use here).If you are going to implement either of these additional fixes, I would recommend writing (an) appropriate warning message(s) to the display in the multiblock's right-click interface with
addWarningText(List<ITextComponent> textList)
for player QoL.The text was updated successfully, but these errors were encountered: