-
-
Notifications
You must be signed in to change notification settings - Fork 76
Add recipes for clearing facades #1452
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
base: master-1.19-lts
Are you sure you want to change the base?
Add recipes for clearing facades #1452
Conversation
rubensworks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kirjorjos!
| for (RecipeSqueezer.IngredientChance itemStackChance : recipe.getOutputItems()) { | ||
| if (itemStackChance.getChance() == 1.0F || itemStackChance.getChance() >= level.random.nextFloat()) { | ||
| for (RecipeSqueezer.IngredientChance itemStackChance : recipe.assemble(oldItem)) { | ||
| if (itemStackChance.getChance() == 1.0F || itemStackChance.getChance() >= level.random.nextFloat()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation seems to be wrong here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely missed that, I'll fix that indentation and the JSON file indentations
| public static NonNullList<IngredientChance> getOutputItems(ItemStack inputItem) { | ||
| ItemStack facadeItemStack = new ItemStack(RegistryEntries.ITEM_FACADE); | ||
|
|
||
| facadeItemStack.setTag(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially, my testing was giving back facades with empty NBT which didn't stack with the ones already in world and from the other recipes, but testing now, it is in fact unnecessary so I'll remove it.
| Either<ItemStack, ItemStackFromIngredient> facadeEither = Either.left(facadeItemStack); | ||
| IngredientChance facade = new IngredientChance(facadeEither, 1.0F); | ||
|
|
||
| CompoundTag nbt = inputItem.getOrCreateTag(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, the following lines attempt to check if the item is a block?
If so, you could just check if item is instanceof ItemBlock. That would simplify this code quite a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not trying to check if it's a block anywhere, just grab the assumed block from the NBT, letting it be an empty ItemStack if malformed or missing NBT as that would be the case in squeezing a blank facade
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably use this one then: https://github.com/CyclopsMC/IntegratedDynamics/blob/master-1.21-lts/src/main/java/org/cyclops/integrateddynamics/item/ItemFacade.java#L41
| } | ||
|
|
||
| public NonNullList<IngredientChance> assemble(ItemStack inputItem) { | ||
| if (!inputItem.is(RegistryEntries.ITEM_FACADE.asItem())) return getOutputItems(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think it is possible to create a custom recipe serializer type so that we don't have to hardcode things like this.
Concretely, the serializer could provide a subclass of RecipeSqueezer that just overrides this assemble method.
The "type" entry in the recipe JSON would then refer to this new serializer, e.g. integrateddynamics:squeezer_facade_unwrap.
The problem with your current approach is that things become more difficult to maintain like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The helper function in FacadeSqueezeCalculator could then be moved to that serializer class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine moving the method from the FacadeSqueezeCalculator to a separate serializer, but I thought the type key in the JSON object referenced the recipe type, not the serializer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type refers to the serializer. For example, the clear_part.json recipe refers to the integrateddynamics:crafting_special_nbt_clear serializer, which is of the crafting recipe type.
| "item": "integrateddynamics:facade", | ||
| "result": { | ||
| "items": [ | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation seems a bit off in this file.
src/main/resources/data/integrateddynamics/recipes/squeezer/convenience/facade_squeeze.json
Outdated
Show resolved
Hide resolved
c82a47f to
390704c
Compare
|
I'm not sure if there's a certain way I should let you know that I believe I've addressed everything you mentioned, but I had pushed 3 commits on February 3rd that for some reason are showing grouped with the ones from December. Apologies if you had noticed and hadn't gotten to it yet, but wanted to say something as it has been a bit. |
|
There should be a button to re-request a review from someone. Somewhere on the top-right of this page. |
rubensworks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is the direction I had in mind as well :-)
...ta/integrateddynamics/recipes/mechanical_squeezer/convenience/mechanical_facade_squeeze.json
Outdated
Show resolved
Hide resolved
src/main/resources/data/integrateddynamics/recipes/squeezer/convenience/facade_squeeze.json
Outdated
Show resolved
Hide resolved
src/main/java/org/cyclops/integrateddynamics/core/recipe/type/RecipeFacadeSqueeze.java
Outdated
Show resolved
Hide resolved
src/main/java/org/cyclops/integrateddynamics/core/recipe/type/RecipeFacadeSqueeze.java
Outdated
Show resolved
Hide resolved
...main/java/org/cyclops/integrateddynamics/core/recipe/type/RecipeFacadeSqueezeMechanical.java
Show resolved
Hide resolved
...main/java/org/cyclops/integrateddynamics/core/recipe/type/RecipeSerializerFacadeSqueeze.java
Outdated
Show resolved
Hide resolved
...main/java/org/cyclops/integrateddynamics/core/recipe/type/RecipeSerializerFacadeSqueeze.java
Outdated
Show resolved
Hide resolved
src/main/java/org/cyclops/integrateddynamics/core/recipe/type/RecipeFacadeSqueeze.java
Show resolved
Hide resolved
...main/java/org/cyclops/integrateddynamics/core/recipe/type/RecipeFacadeSqueezeMechanical.java
Show resolved
Hide resolved
...ta/integrateddynamics/recipes/mechanical_squeezer/convenience/mechanical_facade_squeeze.json
Outdated
Show resolved
Hide resolved
src/main/resources/data/integrateddynamics/recipes/squeezer/convenience/facade_squeeze.json
Outdated
Show resolved
Hide resolved
...main/java/org/cyclops/integrateddynamics/core/recipe/type/RecipeFacadeSqueezeMechanical.java
Show resolved
Hide resolved
|
Rebasing on master may be required as well, as there seem to be merge conflicts. |
the thing says this:
but right above that it says this instead:
(deepest nested exception) |
If I'm not mistaking, I believe that's because the github action doesn't have an auth key. |
I agree that github is acting weird with it as it isn't even seeing I changed half the files I changed looking now, I haven't really heard of rebasing before, but I'll do some research and give it a try. |
fixed crash with squeezing empty facade by adding check for a null facadeBlockItem, outputs blank facade only now
accidentally pushed a local utility script
Reset file when rebasing
… Recipe[Serializer]Squeeze[Mechanical]
Added a static method in RecipeFacadeSqueeze that both class's assemble methods' call
Update JSON file when rebasing
I'm pretty sure I managed to rebase, but I guess if I did something wrong with it, I can try some more. |
0327bec to
1aa0620
Compare
|
Playing around in game, I am noticing a bug that this PR brings to light: If the facaded item has NBT, that NBT is lost when making the facade. I think the best way to resolve this would be storing the NBT with the facade, maybe something like |
src/main/resources/data/integrateddynamics/recipes/special/facade_clear.json
Outdated
Show resolved
Hide resolved
This issue existed before this PR already, right? Besides my other comment above, this should be good to go. |
It did exist before this PR, but it wasn't particularly an issue before this PR as there was no normal instance where the player would see something related to the NBT. Assuming you still want to make a new issue for this though, I'm good to let you test and merge. If I'm not mistaking, it should be |
|
The |
|
I can explicitly disable empty -> empty if you want, the empty -> empty is more of a byproduct of allowing any data facade -> empty plus the block if there is one to also handle the case for invalid data. (Eg. If a mod got removed so the block that used to be facaded doesn't exist) |
|
Removing invalid data makes sense indeed. But if the facade is really just empty, I think we should disallow it. |
|
Unless I'm missing something, it looks like I would need to update the [Mechanical]Squeezer block entity class as |
Are you sure? That's not how recipes are handled based on my recollection.
The match method should be a good place indeed. |
|
I had thought i remembered matches being called on every run, but it didn't seem to be called when testing with a changed matches, so I launched in debug mode, set a break point, and confirmed it's not called once the world is loaded. |
Probably because of the cache. |
|
Testing some more, it seems you are right that cache is making my tests behave weirdly. To confirm, the cache should reset when I leave the world and rejoin? |
|
I'm thinking I must be missing something as from a complete MC restart, after loading into the world, before trying any recipes (so the cache should be empty), I'm debugging matched on FacadeSqueeze, it returns false, but still gets processed. I also tried using the mechanical squeezer from a fresh MC restart and can't seem to catch inside the matches call in SqueezeFacadeMechanical to see why it's not working. |
|
Testing some more, it seems like it's only calling the matches method in RecipeSqueezer and RecipeMechanicalSqueezer, and unless I'm missing something (very possible), it looks to me like the logic for which method to call is inside Cyclopscore? |
Not sure actually. It will reset in any case on a game restart.
I don't remember the precise mechanics myself tbh. I'd have to dive into the code myself. |
|
I guess for right now, do you want me to push what I'm 99% sure should work with a patched cyclopscore, or did you want to look at it first or...? Sorry, I'm just unsure what I should be doing here right now. |
|
I suspect not changes should be needed in CC. But if you think there must be, feel free to open a PR. |
Adds the squeezer facade recipes as mentioned in #1424