-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add recipes for clearing facades #1452
base: master-1.19-lts
Are you sure you want to change the base?
Add recipes for clearing facades #1452
Conversation
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
@@ -61,6 +61,11 @@ public ItemStack assemble(Container inv) { | |||
return this.outputItems.get(0).getIngredientFirst().copy(); | |||
} | |||
|
|||
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.
"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.
Also here.
c82a47f
to
390704c
Compare
accidentally pushed a local utility script
had forgotten to change the recipe type when copy pasting the indentation from the mechanical squeezer facade recipe
remove unnecessary set NBT to null
Adds the squeezer facade recipes as mentioned in #1424