Skip to content
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

Open
wants to merge 5 commits into
base: master-1.19-lts
Choose a base branch
from

Conversation

kirjorjos
Copy link
Contributor

Adds the squeezer facade recipes as mentioned in #1424

Copy link
Member

@rubensworks rubensworks left a 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()) {
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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.

Copy link
Contributor Author

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();
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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();
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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": [
{
Copy link
Member

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": [
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here.

@kirjorjos kirjorjos force-pushed the squeeze-facade-recipes branch from c82a47f to 390704c Compare January 1, 2025 23:31
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants