Careful Deploying

- Added the option to have held items not be consumed in deploying recipes
This commit is contained in:
simibubi 2021-09-26 20:45:24 +02:00
parent b1047bb542
commit 994fe29021
20 changed files with 131 additions and 41 deletions

View file

@ -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

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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é",

View file

@ -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",

View file

@ -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": "極度の加熱が必要",

View file

@ -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": "초고온 가열됨",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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": "Перегрето",

View file

@ -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": "超级加热",

View file

@ -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": "超級加熱",

View file

@ -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<DeployerApplicationRecipe> {
@ -53,7 +55,18 @@ public class DeployingCategory extends CreateRecipeCategory<DeployerApplicationR
.getItems()));
itemStacks.init(2, false, 131, 50);
itemStacks.set(2, recipe.getResultItem());
if (recipe.shouldKeepHeldItem()) {
itemStacks.addTooltipCallback((slotIndex, input, ingredient, tooltip) -> {
if (!input)
return;
if (slotIndex != 1)
return;
tooltip.add(1, Lang.translate("recipe.deploying.not_consumed")
.withStyle(TextFormatting.GOLD));
});
}
addStochasticTooltip(itemStacks, recipe.getRollableResults(), 2);
}

View file

@ -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;
}

View file

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

View file

@ -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<RecipeWrapper> 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<RecipeWrapper> 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<RecipeWrapper> i
public static List<DeployerApplicationRecipe> convert(List<IRecipe<?>> 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<RecipeWrapper> 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() {

View file

@ -90,7 +90,9 @@ public class ProcessingRecipeSerializer<T extends ProcessingRecipe<?>> 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<T extends ProcessingRecipe<?>> 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<T extends ProcessingRecipe<?>> 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) {

View file

@ -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",