From 994fe290215a77f3cb163ef1e97c2e47d960dd0b Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sun, 26 Sep 2021 20:45:24 +0200 Subject: [PATCH] Careful Deploying - Added the option to have held items not be consumed in deploying recipes --- src/generated/resources/.cache/cache | 26 +++++----- .../resources/assets/create/lang/en_us.json | 1 + .../assets/create/lang/unfinished/de_de.json | 3 +- .../assets/create/lang/unfinished/es_es.json | 3 +- .../assets/create/lang/unfinished/fr_fr.json | 3 +- .../assets/create/lang/unfinished/it_it.json | 3 +- .../assets/create/lang/unfinished/ja_jp.json | 3 +- .../assets/create/lang/unfinished/ko_kr.json | 3 +- .../assets/create/lang/unfinished/nl_nl.json | 3 +- .../assets/create/lang/unfinished/pl_pl.json | 3 +- .../assets/create/lang/unfinished/pt_br.json | 3 +- .../assets/create/lang/unfinished/ru_ru.json | 3 +- .../assets/create/lang/unfinished/zh_cn.json | 3 +- .../assets/create/lang/unfinished/zh_tw.json | 3 +- .../jei/category/DeployingCategory.java | 15 +++++- .../SequencedAssemblySubCategory.java | 17 +++++++ .../deployer/BeltDeployerCallbacks.java | 11 +++-- .../deployer/DeployerApplicationRecipe.java | 49 ++++++++++++++++--- .../ProcessingRecipeSerializer.java | 16 ++++-- .../assets/create/lang/default/messages.json | 1 + 20 files changed, 131 insertions(+), 41 deletions(-) diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 28f03b4a8..a5943c70d 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -426,19 +426,19 @@ a3a11524cd3515fc01d905767b4b7ea782adaf03 assets/create/blockstates/yellow_seat.j 7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json fb760b12b4bc8114744d3acc6a597b2fad88d988 assets/create/lang/en_ud.json -66e8ae18a98d86c66393c908ab51eae5060b8e04 assets/create/lang/en_us.json -9e94c2420840c516e24dfd7968aaad61da24b5a2 assets/create/lang/unfinished/de_de.json -f1a6ed9a5812c89e7c7152c9abf2b64c133fd27d assets/create/lang/unfinished/es_es.json -23a46ae0bc7b2181f26eeed70801714a254d2587 assets/create/lang/unfinished/fr_fr.json -5e95153e640edc367b963489df8c92c459badcd3 assets/create/lang/unfinished/it_it.json -a951315b2591051dad6c53739fe554fe78595250 assets/create/lang/unfinished/ja_jp.json -419a1fc9af7d7ea0ccd612847df74e0b45380864 assets/create/lang/unfinished/ko_kr.json -dbc823d8cb38598e75871a2187b2a58d7f77f86a assets/create/lang/unfinished/nl_nl.json -ac609477c295be1705d3efc07848ffe6779fd397 assets/create/lang/unfinished/pl_pl.json -95e17b968103e0ef62411489e699d39ac7ff0b64 assets/create/lang/unfinished/pt_br.json -b37f50f613b0df44032fe5d618a5ce7227be8087 assets/create/lang/unfinished/ru_ru.json -fa465cd2c595bcd71449ad432a1908e27897177a assets/create/lang/unfinished/zh_cn.json -6192a7ede669ae6b6f8de6701b8a924d6a756c4a assets/create/lang/unfinished/zh_tw.json +fcd58b47e3fbe4039ea684dadd08d36bd0beaa7d assets/create/lang/en_us.json +2047ce757fe7b7d279b72c5d4d8d6f111e478b2f assets/create/lang/unfinished/de_de.json +3cb5a941527ad3981a094cb2599a28aa654c15b3 assets/create/lang/unfinished/es_es.json +008a67a90fc7d6d59d98c3ac4f4cd45cb47fbcc2 assets/create/lang/unfinished/fr_fr.json +80091dc7ed4ed81a18bce6e9fa0b5fc870a70c89 assets/create/lang/unfinished/it_it.json +a12b0fabb18a0bc7e50ad4e6760aa0a3f222edaf assets/create/lang/unfinished/ja_jp.json +e49e3d4cfcd43194e3904c94a167bc98179b40ff assets/create/lang/unfinished/ko_kr.json +47fa6e25a19d0f8c86178954da4b50aaec247ef4 assets/create/lang/unfinished/nl_nl.json +64581657991641f49c5888e379157939cb5bdc3c assets/create/lang/unfinished/pl_pl.json +d3f22a7ee26461f1369f100001098b9f165b7cb5 assets/create/lang/unfinished/pt_br.json +c2b821bd4c0b09ba0f255c40bcd379b9ad864f10 assets/create/lang/unfinished/ru_ru.json +c43f76c83bbd9c7ac9cd8ac7f82fa1b98347771b assets/create/lang/unfinished/zh_cn.json +e797c8d5e89b9ecc6bf82858a1c905f8b905da16 assets/create/lang/unfinished/zh_tw.json 487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json 3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json diff --git a/src/generated/resources/assets/create/lang/en_us.json b/src/generated/resources/assets/create/lang/en_us.json index 268153180..3b240d38c 100644 --- a/src/generated/resources/assets/create/lang/en_us.json +++ b/src/generated/resources/assets/create/lang/en_us.json @@ -752,6 +752,7 @@ "create.recipe.assembly.repeat": "Repeat Sequence %1$s Times", "create.recipe.assembly.junk": "Random salvage", "create.recipe.processing.chance": "%1$s%% Chance", + "create.recipe.deploying.not_consumed": "Not Consumed", "create.recipe.heat_requirement.none": "No Heating Required", "create.recipe.heat_requirement.heated": "Heated", "create.recipe.heat_requirement.superheated": "Super-Heated", diff --git a/src/generated/resources/assets/create/lang/unfinished/de_de.json b/src/generated/resources/assets/create/lang/unfinished/de_de.json index ce55f9519..fd2077686 100644 --- a/src/generated/resources/assets/create/lang/unfinished/de_de.json +++ b/src/generated/resources/assets/create/lang/unfinished/de_de.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1134", + "_": "Missing Localizations: 1135", "_": "->------------------------] Game Elements [------------------------<-", @@ -753,6 +753,7 @@ "create.recipe.assembly.repeat": "UNLOCALIZED: Repeat Sequence %1$s Times", "create.recipe.assembly.junk": "UNLOCALIZED: Random salvage", "create.recipe.processing.chance": "Chance: %1$s%%", + "create.recipe.deploying.not_consumed": "UNLOCALIZED: Not Consumed", "create.recipe.heat_requirement.none": "Keine Hitze benötigt", "create.recipe.heat_requirement.heated": "Wenig Hitze benötigt", "create.recipe.heat_requirement.superheated": "Viel Hitze benötigt", diff --git a/src/generated/resources/assets/create/lang/unfinished/es_es.json b/src/generated/resources/assets/create/lang/unfinished/es_es.json index 79a683627..6e7652f4d 100644 --- a/src/generated/resources/assets/create/lang/unfinished/es_es.json +++ b/src/generated/resources/assets/create/lang/unfinished/es_es.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 0", + "_": "Missing Localizations: 1", "_": "->------------------------] Game Elements [------------------------<-", @@ -753,6 +753,7 @@ "create.recipe.assembly.repeat": "Repetir la secuencia %1$s veces", "create.recipe.assembly.junk": "Basura aleatoria", "create.recipe.processing.chance": "%1$s%% Chance", + "create.recipe.deploying.not_consumed": "UNLOCALIZED: Not Consumed", "create.recipe.heat_requirement.none": "No es necesario calentar", "create.recipe.heat_requirement.heated": "Calentado", "create.recipe.heat_requirement.superheated": "Súper-Calentado", diff --git a/src/generated/resources/assets/create/lang/unfinished/fr_fr.json b/src/generated/resources/assets/create/lang/unfinished/fr_fr.json index 2e0c26dd4..73fadc258 100644 --- a/src/generated/resources/assets/create/lang/unfinished/fr_fr.json +++ b/src/generated/resources/assets/create/lang/unfinished/fr_fr.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1386", + "_": "Missing Localizations: 1387", "_": "->------------------------] Game Elements [------------------------<-", @@ -753,6 +753,7 @@ "create.recipe.assembly.repeat": "UNLOCALIZED: Repeat Sequence %1$s Times", "create.recipe.assembly.junk": "UNLOCALIZED: Random salvage", "create.recipe.processing.chance": "%1$s%% de chance", + "create.recipe.deploying.not_consumed": "UNLOCALIZED: Not Consumed", "create.recipe.heat_requirement.none": "Pas de chauffage requis", "create.recipe.heat_requirement.heated": "Chauffé", "create.recipe.heat_requirement.superheated": "Surchauffé", diff --git a/src/generated/resources/assets/create/lang/unfinished/it_it.json b/src/generated/resources/assets/create/lang/unfinished/it_it.json index 8108827f1..e6df80ea8 100644 --- a/src/generated/resources/assets/create/lang/unfinished/it_it.json +++ b/src/generated/resources/assets/create/lang/unfinished/it_it.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 914", + "_": "Missing Localizations: 915", "_": "->------------------------] Game Elements [------------------------<-", @@ -753,6 +753,7 @@ "create.recipe.assembly.repeat": "UNLOCALIZED: Repeat Sequence %1$s Times", "create.recipe.assembly.junk": "UNLOCALIZED: Random salvage", "create.recipe.processing.chance": "%1$s%% di probabilità", + "create.recipe.deploying.not_consumed": "UNLOCALIZED: Not Consumed", "create.recipe.heat_requirement.none": "Nessun riscaldamento", "create.recipe.heat_requirement.heated": "Riscaldamento", "create.recipe.heat_requirement.superheated": "Super riscaldamento", diff --git a/src/generated/resources/assets/create/lang/unfinished/ja_jp.json b/src/generated/resources/assets/create/lang/unfinished/ja_jp.json index 5650fe7dd..e6269480a 100644 --- a/src/generated/resources/assets/create/lang/unfinished/ja_jp.json +++ b/src/generated/resources/assets/create/lang/unfinished/ja_jp.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 9", + "_": "Missing Localizations: 10", "_": "->------------------------] Game Elements [------------------------<-", @@ -753,6 +753,7 @@ "create.recipe.assembly.repeat": "%1$s回繰り返す", "create.recipe.assembly.junk": "ランダムな仕損品", "create.recipe.processing.chance": "%1$s%%チャンス", + "create.recipe.deploying.not_consumed": "UNLOCALIZED: Not Consumed", "create.recipe.heat_requirement.none": "加熱不要", "create.recipe.heat_requirement.heated": "加熱が必要", "create.recipe.heat_requirement.superheated": "極度の加熱が必要", diff --git a/src/generated/resources/assets/create/lang/unfinished/ko_kr.json b/src/generated/resources/assets/create/lang/unfinished/ko_kr.json index b45ee1cfb..2cdccc02e 100644 --- a/src/generated/resources/assets/create/lang/unfinished/ko_kr.json +++ b/src/generated/resources/assets/create/lang/unfinished/ko_kr.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 24", + "_": "Missing Localizations: 25", "_": "->------------------------] Game Elements [------------------------<-", @@ -753,6 +753,7 @@ "create.recipe.assembly.repeat": "%1$s번 반복하기", "create.recipe.assembly.junk": "조립 실패한 조각들", "create.recipe.processing.chance": "%1$s%% 확률", + "create.recipe.deploying.not_consumed": "UNLOCALIZED: Not Consumed", "create.recipe.heat_requirement.none": "열이 필요하지 않음", "create.recipe.heat_requirement.heated": "가열됨", "create.recipe.heat_requirement.superheated": "초고온 가열됨", diff --git a/src/generated/resources/assets/create/lang/unfinished/nl_nl.json b/src/generated/resources/assets/create/lang/unfinished/nl_nl.json index 2a8d48fd3..cb8d8972e 100644 --- a/src/generated/resources/assets/create/lang/unfinished/nl_nl.json +++ b/src/generated/resources/assets/create/lang/unfinished/nl_nl.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1766", + "_": "Missing Localizations: 1767", "_": "->------------------------] Game Elements [------------------------<-", @@ -753,6 +753,7 @@ "create.recipe.assembly.repeat": "UNLOCALIZED: Repeat Sequence %1$s Times", "create.recipe.assembly.junk": "UNLOCALIZED: Random salvage", "create.recipe.processing.chance": "%1$s%% Kans", + "create.recipe.deploying.not_consumed": "UNLOCALIZED: Not Consumed", "create.recipe.heat_requirement.none": "UNLOCALIZED: No Heating Required", "create.recipe.heat_requirement.heated": "UNLOCALIZED: Heated", "create.recipe.heat_requirement.superheated": "UNLOCALIZED: Super-Heated", diff --git a/src/generated/resources/assets/create/lang/unfinished/pl_pl.json b/src/generated/resources/assets/create/lang/unfinished/pl_pl.json index 010fcaa58..727fa23c9 100644 --- a/src/generated/resources/assets/create/lang/unfinished/pl_pl.json +++ b/src/generated/resources/assets/create/lang/unfinished/pl_pl.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 256", + "_": "Missing Localizations: 257", "_": "->------------------------] Game Elements [------------------------<-", @@ -753,6 +753,7 @@ "create.recipe.assembly.repeat": "UNLOCALIZED: Repeat Sequence %1$s Times", "create.recipe.assembly.junk": "UNLOCALIZED: Random salvage", "create.recipe.processing.chance": "%1$s%% szans", + "create.recipe.deploying.not_consumed": "UNLOCALIZED: Not Consumed", "create.recipe.heat_requirement.none": "Nie wymaga podgrzewania", "create.recipe.heat_requirement.heated": "Podrzewane", "create.recipe.heat_requirement.superheated": "Silnie podgrzewane", diff --git a/src/generated/resources/assets/create/lang/unfinished/pt_br.json b/src/generated/resources/assets/create/lang/unfinished/pt_br.json index 6d34e640a..13fd43cbc 100644 --- a/src/generated/resources/assets/create/lang/unfinished/pt_br.json +++ b/src/generated/resources/assets/create/lang/unfinished/pt_br.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1807", + "_": "Missing Localizations: 1808", "_": "->------------------------] Game Elements [------------------------<-", @@ -753,6 +753,7 @@ "create.recipe.assembly.repeat": "UNLOCALIZED: Repeat Sequence %1$s Times", "create.recipe.assembly.junk": "UNLOCALIZED: Random salvage", "create.recipe.processing.chance": "%1$s%% de chance", + "create.recipe.deploying.not_consumed": "UNLOCALIZED: Not Consumed", "create.recipe.heat_requirement.none": "UNLOCALIZED: No Heating Required", "create.recipe.heat_requirement.heated": "UNLOCALIZED: Heated", "create.recipe.heat_requirement.superheated": "UNLOCALIZED: Super-Heated", diff --git a/src/generated/resources/assets/create/lang/unfinished/ru_ru.json b/src/generated/resources/assets/create/lang/unfinished/ru_ru.json index 35b858bb2..b5c391ad7 100644 --- a/src/generated/resources/assets/create/lang/unfinished/ru_ru.json +++ b/src/generated/resources/assets/create/lang/unfinished/ru_ru.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 5", + "_": "Missing Localizations: 6", "_": "->------------------------] Game Elements [------------------------<-", @@ -753,6 +753,7 @@ "create.recipe.assembly.repeat": "Повторите последовательность %1$s раз", "create.recipe.assembly.junk": "Случайный мусор", "create.recipe.processing.chance": "%1$s%% шанса", + "create.recipe.deploying.not_consumed": "UNLOCALIZED: Not Consumed", "create.recipe.heat_requirement.none": "Не требует нагрева", "create.recipe.heat_requirement.heated": "Нагрето", "create.recipe.heat_requirement.superheated": "Перегрето", diff --git a/src/generated/resources/assets/create/lang/unfinished/zh_cn.json b/src/generated/resources/assets/create/lang/unfinished/zh_cn.json index 0d0f8f5bc..35a44fa56 100644 --- a/src/generated/resources/assets/create/lang/unfinished/zh_cn.json +++ b/src/generated/resources/assets/create/lang/unfinished/zh_cn.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 4", + "_": "Missing Localizations: 5", "_": "->------------------------] Game Elements [------------------------<-", @@ -753,6 +753,7 @@ "create.recipe.assembly.repeat": "该序列需要重复 %1$s 次", "create.recipe.assembly.junk": "随机废料", "create.recipe.processing.chance": "%1$s%%概率", + "create.recipe.deploying.not_consumed": "UNLOCALIZED: Not Consumed", "create.recipe.heat_requirement.none": "无需加热", "create.recipe.heat_requirement.heated": "加热", "create.recipe.heat_requirement.superheated": "超级加热", diff --git a/src/generated/resources/assets/create/lang/unfinished/zh_tw.json b/src/generated/resources/assets/create/lang/unfinished/zh_tw.json index 9ec60092a..28e21eea1 100644 --- a/src/generated/resources/assets/create/lang/unfinished/zh_tw.json +++ b/src/generated/resources/assets/create/lang/unfinished/zh_tw.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 19", + "_": "Missing Localizations: 20", "_": "->------------------------] Game Elements [------------------------<-", @@ -753,6 +753,7 @@ "create.recipe.assembly.repeat": "重複 %1$s 次", "create.recipe.assembly.junk": "有機率得到垃圾", "create.recipe.processing.chance": "%1$s%%概率", + "create.recipe.deploying.not_consumed": "UNLOCALIZED: Not Consumed", "create.recipe.heat_requirement.none": "不需要加熱", "create.recipe.heat_requirement.heated": "普通加熱", "create.recipe.heat_requirement.superheated": "超級加熱", diff --git a/src/main/java/com/simibubi/create/compat/jei/category/DeployingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/DeployingCategory.java index f3fc6ee9e..4e88e2ca2 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/DeployingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/DeployingCategory.java @@ -9,11 +9,13 @@ import com.simibubi.create.compat.jei.category.animations.AnimatedDeployer; import com.simibubi.create.content.contraptions.components.deployer.DeployerApplicationRecipe; import com.simibubi.create.foundation.fluid.FluidIngredient; import com.simibubi.create.foundation.gui.AllGuiTextures; +import com.simibubi.create.foundation.utility.Lang; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredients; +import net.minecraft.util.text.TextFormatting; public class DeployingCategory extends CreateRecipeCategory { @@ -53,7 +55,18 @@ public class DeployingCategory extends CreateRecipeCategory { + if (!input) + return; + if (slotIndex != 1) + return; + tooltip.add(1, Lang.translate("recipe.deploying.not_consumed") + .withStyle(TextFormatting.GOLD)); + }); + } + addStochasticTooltip(itemStacks, recipe.getRollableResults(), 2); } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/sequencedAssembly/SequencedAssemblySubCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/sequencedAssembly/SequencedAssemblySubCategory.java index 99810a1e1..bf4345225 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/sequencedAssembly/SequencedAssemblySubCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/sequencedAssembly/SequencedAssemblySubCategory.java @@ -10,12 +10,16 @@ import com.simibubi.create.compat.jei.category.animations.AnimatedDeployer; import com.simibubi.create.compat.jei.category.animations.AnimatedPress; import com.simibubi.create.compat.jei.category.animations.AnimatedSaw; import com.simibubi.create.compat.jei.category.animations.AnimatedSpout; +import com.simibubi.create.content.contraptions.components.deployer.DeployerApplicationRecipe; +import com.simibubi.create.content.contraptions.itemAssembly.IAssemblyRecipe; import com.simibubi.create.content.contraptions.itemAssembly.SequencedRecipe; import com.simibubi.create.foundation.fluid.FluidIngredient; import com.simibubi.create.foundation.gui.AllGuiTextures; +import com.simibubi.create.foundation.utility.Lang; import mezz.jei.api.gui.ingredient.IGuiFluidStackGroup; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; +import net.minecraft.util.text.TextFormatting; public abstract class SequencedAssemblySubCategory { @@ -115,6 +119,19 @@ public abstract class SequencedAssemblySubCategory { .getIngredients() .get(1) .getItems())); + + IAssemblyRecipe contained = recipe.getAsAssemblyRecipe(); + if (contained instanceof DeployerApplicationRecipe && ((DeployerApplicationRecipe) contained).shouldKeepHeldItem()) { + itemStacks.addTooltipCallback((slotIndex, input, ingredient, tooltip) -> { + if (!input) + return; + if (slotIndex != index) + return; + tooltip.add(1, Lang.translate("recipe.deploying.not_consumed") + .withStyle(TextFormatting.GOLD)); + }); + } + return 1; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/BeltDeployerCallbacks.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/BeltDeployerCallbacks.java index b0900e2be..dfe84ba54 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/BeltDeployerCallbacks.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/BeltDeployerCallbacks.java @@ -104,10 +104,13 @@ public class BeltDeployerCallbacks { handler.handleProcessingOnItem(transported, TransportedResult.convertToAndLeaveHeld(collect, left)); ItemStack heldItem = deployerTileEntity.player.getMainHandItem(); - if (heldItem.isDamageableItem()) - heldItem.hurtAndBreak(1, deployerTileEntity.player, s -> s.broadcastBreakEvent(Hand.MAIN_HAND)); - else - heldItem.shrink(1); + if (!(recipe instanceof DeployerApplicationRecipe) + || !((DeployerApplicationRecipe) recipe).shouldKeepHeldItem()) { + if (heldItem.isDamageableItem()) + heldItem.hurtAndBreak(1, deployerTileEntity.player, s -> s.broadcastBreakEvent(Hand.MAIN_HAND)); + else + heldItem.shrink(1); + } BlockPos pos = deployerTileEntity.getBlockPos(); World world = deployerTileEntity.getLevel(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerApplicationRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerApplicationRecipe.java index 3fb54e05f..aabfa2846 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerApplicationRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerApplicationRecipe.java @@ -5,6 +5,7 @@ import java.util.Set; import java.util.function.Supplier; import java.util.stream.Collectors; +import com.google.gson.JsonObject; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.AllTags.AllItemTags; @@ -18,7 +19,9 @@ import com.simibubi.create.foundation.utility.Lang; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.Ingredient; +import net.minecraft.network.PacketBuffer; import net.minecraft.util.IItemProvider; +import net.minecraft.util.JSONUtils; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; @@ -30,8 +33,11 @@ import net.minecraftforge.items.wrapper.RecipeWrapper; public class DeployerApplicationRecipe extends ProcessingRecipe implements IAssemblyRecipe { + private boolean keepHeldItem; + public DeployerApplicationRecipe(ProcessingRecipeParams params) { super(AllRecipeTypes.DEPLOYING, params); + keepHeldItem = false; } @Override @@ -52,6 +58,10 @@ public class DeployerApplicationRecipe extends ProcessingRecipe i return 2; } + public boolean shouldKeepHeldItem() { + return keepHeldItem; + } + public Ingredient getRequiredHeldItem() { if (ingredients.isEmpty()) throw new IllegalStateException("Deploying Recipe: " + id.toString() + " has no tool!"); @@ -66,12 +76,14 @@ public class DeployerApplicationRecipe extends ProcessingRecipe i public static List convert(List> sandpaperRecipes) { return sandpaperRecipes.stream() - .map(r -> new ProcessingRecipeBuilder<>(DeployerApplicationRecipe::new, new ResourceLocation(r.getId().getNamespace(), r.getId() - .getPath() + "_using_deployer")).require(r.getIngredients() - .get(0)) - .require(AllItemTags.SANDPAPER.tag) - .output(r.getResultItem()) - .build()) + .map(r -> new ProcessingRecipeBuilder<>(DeployerApplicationRecipe::new, new ResourceLocation(r.getId() + .getNamespace(), + r.getId() + .getPath() + "_using_deployer")).require(r.getIngredients() + .get(0)) + .require(AllItemTags.SANDPAPER.tag) + .output(r.getResultItem()) + .build()) .collect(Collectors.toList()); } @@ -80,6 +92,31 @@ public class DeployerApplicationRecipe extends ProcessingRecipe i list.add(ingredients.get(1)); } + @Override + public void readAdditional(JsonObject json) { + super.readAdditional(json); + keepHeldItem = JSONUtils.getAsBoolean(json, "keepHeldItem", false); + } + + @Override + public void writeAdditional(JsonObject json) { + super.writeAdditional(json); + if (keepHeldItem) + json.addProperty("keepHeldItem", keepHeldItem); + } + + @Override + public void readAdditional(PacketBuffer buffer) { + super.readAdditional(buffer); + keepHeldItem = buffer.readBoolean(); + } + + @Override + public void writeAdditional(PacketBuffer buffer) { + super.writeAdditional(buffer); + buffer.writeBoolean(keepHeldItem); + } + @Override @OnlyIn(Dist.CLIENT) public ITextComponent getDescriptionForAssembly() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeSerializer.java b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeSerializer.java index 9d83395c3..38404346b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeSerializer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeSerializer.java @@ -90,7 +90,9 @@ public class ProcessingRecipeSerializer> extends F if (JSONUtils.isValidNode(json, "heatRequirement")) builder.requiresHeat(HeatCondition.deserialize(JSONUtils.getAsString(json, "heatRequirement"))); - return builder.build(); + T recipe = builder.build(); + recipe.readAdditional(json); + return recipe; } protected void writeToBuffer(PacketBuffer buffer, T recipe) { @@ -112,6 +114,8 @@ public class ProcessingRecipeSerializer> extends F buffer.writeVarInt(recipe.getProcessingDuration()); buffer.writeVarInt(recipe.getRequiredHeat() .ordinal()); + + recipe.writeAdditional(buffer); } protected T readFromBuffer(ResourceLocation recipeId, PacketBuffer buffer) { @@ -123,26 +127,28 @@ public class ProcessingRecipeSerializer> extends F int size = buffer.readVarInt(); for (int i = 0; i < size; i++) ingredients.add(Ingredient.fromNetwork(buffer)); - + size = buffer.readVarInt(); for (int i = 0; i < size; i++) fluidIngredients.add(FluidIngredient.read(buffer)); - + size = buffer.readVarInt(); for (int i = 0; i < size; i++) results.add(ProcessingOutput.read(buffer)); - + size = buffer.readVarInt(); for (int i = 0; i < size; i++) fluidResults.add(FluidStack.readFromPacket(buffer)); - return new ProcessingRecipeBuilder<>(factory, recipeId).withItemIngredients(ingredients) + T recipe = new ProcessingRecipeBuilder<>(factory, recipeId).withItemIngredients(ingredients) .withItemOutputs(results) .withFluidIngredients(fluidIngredients) .withFluidOutputs(fluidResults) .duration(buffer.readVarInt()) .requiresHeat(HeatCondition.values()[buffer.readVarInt()]) .build(); + recipe.readAdditional(buffer); + return recipe; } public final void write(JsonObject json, T recipe) { diff --git a/src/main/resources/assets/create/lang/default/messages.json b/src/main/resources/assets/create/lang/default/messages.json index 1df9899de..f67843698 100644 --- a/src/main/resources/assets/create/lang/default/messages.json +++ b/src/main/resources/assets/create/lang/default/messages.json @@ -65,6 +65,7 @@ "create.recipe.assembly.junk": "Random salvage", "create.recipe.processing.chance": "%1$s%% Chance", + "create.recipe.deploying.not_consumed": "Not Consumed", "create.recipe.heat_requirement.none": "No Heating Required", "create.recipe.heat_requirement.heated": "Heated", "create.recipe.heat_requirement.superheated": "Super-Heated",