-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: š Fixed vanilla shulker box to sophisticated shulker box upgradeā¦
ā¦ recipe to transfer the vanilla shulker boxes contents
- Loading branch information
Showing
22 changed files
with
117 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/generated/resources/data/minecraft/recipes/shulker_box_from_vanilla_shulker_box.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rated/resources/data/sophisticatedstorage/recipes/black_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...erated/resources/data/sophisticatedstorage/recipes/blue_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rated/resources/data/sophisticatedstorage/recipes/brown_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...erated/resources/data/sophisticatedstorage/recipes/cyan_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...erated/resources/data/sophisticatedstorage/recipes/gray_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rated/resources/data/sophisticatedstorage/recipes/green_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../resources/data/sophisticatedstorage/recipes/light_blue_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../resources/data/sophisticatedstorage/recipes/light_gray_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...erated/resources/data/sophisticatedstorage/recipes/lime_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ted/resources/data/sophisticatedstorage/recipes/magenta_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ated/resources/data/sophisticatedstorage/recipes/orange_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...erated/resources/data/sophisticatedstorage/recipes/pink_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ated/resources/data/sophisticatedstorage/recipes/purple_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nerated/resources/data/sophisticatedstorage/recipes/red_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rated/resources/data/sophisticatedstorage/recipes/white_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ated/resources/data/sophisticatedstorage/recipes/yellow_shulker_box_to_sophisticated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...ava/net/p3pp3rf1y/sophisticatedstorage/crafting/ShulkerBoxFromVanillaShapelessRecipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package net.p3pp3rf1y.sophisticatedstorage.crafting; | ||
|
||
import net.minecraft.core.RegistryAccess; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.inventory.CraftingContainer; | ||
import net.minecraft.world.item.BlockItem; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.crafting.RecipeSerializer; | ||
import net.minecraft.world.item.crafting.ShapelessRecipe; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraftforge.common.capabilities.ForgeCapabilities; | ||
import net.p3pp3rf1y.sophisticatedcore.crafting.IWrapperRecipe; | ||
import net.p3pp3rf1y.sophisticatedcore.crafting.RecipeWrapperSerializer; | ||
import net.p3pp3rf1y.sophisticatedcore.util.InventoryHelper; | ||
import net.p3pp3rf1y.sophisticatedstorage.init.ModBlocks; | ||
import net.p3pp3rf1y.sophisticatedstorage.item.CapabilityStorageWrapper; | ||
import net.p3pp3rf1y.sophisticatedstorage.item.WoodStorageBlockItem; | ||
|
||
import java.util.LinkedHashSet; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
public class ShulkerBoxFromVanillaShapelessRecipe extends ShapelessRecipe implements IWrapperRecipe<ShapelessRecipe> { | ||
public static final Set<ResourceLocation> REGISTERED_RECIPES = new LinkedHashSet<>(); | ||
private final ShapelessRecipe compose; | ||
|
||
public ShulkerBoxFromVanillaShapelessRecipe(ShapelessRecipe compose) { | ||
super(compose.getId(), compose.getGroup(), compose.category(), compose.result, compose.getIngredients()); | ||
this.compose = compose; | ||
REGISTERED_RECIPES.add(compose.getId()); | ||
} | ||
|
||
@Override | ||
public boolean matches(CraftingContainer inventory, Level level) { | ||
return super.matches(inventory, level) && getVanillaShulkerBox(inventory).map(storage -> !(storage.getItem() instanceof WoodStorageBlockItem) || !WoodStorageBlockItem.isPacked(storage)).orElse(false); | ||
} | ||
|
||
@Override | ||
public ShapelessRecipe getCompose() { | ||
return compose; | ||
} | ||
|
||
@Override | ||
public ItemStack assemble(CraftingContainer input, RegistryAccess registries) { | ||
ItemStack upgradedStorage = super.assemble(input, registries); | ||
getVanillaShulkerBox(input).ifPresent(vanillaShulkerBox -> { | ||
|
||
vanillaShulkerBox.getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(itemCap -> { | ||
upgradedStorage.getCapability(CapabilityStorageWrapper.getCapabilityInstance()).ifPresent(wrapper -> { | ||
InventoryHelper.iterate(itemCap, (slot, stack) -> { | ||
if (!stack.isEmpty()) { | ||
wrapper.getInventoryHandler().insertItem(stack, false); | ||
} | ||
}); | ||
}); | ||
}); | ||
}); | ||
return upgradedStorage; | ||
} | ||
|
||
@Override | ||
public boolean isSpecial() { | ||
return true; | ||
} | ||
|
||
private Optional<ItemStack> getVanillaShulkerBox(CraftingContainer input) { | ||
for (int slot = 0; slot < input.getContainerSize(); slot++) { | ||
ItemStack slotStack = input.getItem(slot); | ||
if (slotStack.getItem() instanceof BlockItem blockItem && blockItem.getBlock() instanceof net.minecraft.world.level.block.ShulkerBoxBlock) { | ||
return Optional.of(slotStack); | ||
} | ||
} | ||
|
||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public RecipeSerializer<?> getSerializer() { | ||
return ModBlocks.SHULKER_BOX_FROM_VANILLA_SHAPELESS_RECIPE_SERIALIZER.get(); | ||
} | ||
|
||
public static class Serializer extends RecipeWrapperSerializer<ShapelessRecipe, ShulkerBoxFromVanillaShapelessRecipe> { | ||
public Serializer() { | ||
super(ShulkerBoxFromVanillaShapelessRecipe::new, RecipeSerializer.SHAPELESS_RECIPE); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters