DevOnTheRocks / RockyTweaks

A Minecraft Forge mod that adds additional functionality to other mods.
GNU General Public License v3.0
5 stars 2 forks source link

Add ability to remove anvil "recipes" #5

Closed stohun01 closed 5 years ago

Mohron commented 6 years ago

The vanilla anvil does not have recipes in the same sense as the crafting table or furnace do. It supports repairing repairable items, putting enchantments on enchantable items and naming items. The "recipes" added by RockyCore's CraftTweaker capability are just special handling of the anvil event and aren't really recipes at all. This is why I did not add removal capability since there is no anvil recipe registry to remove recipes from.

That being said, it may still be able to block certain inputs and/or outputs from generating effectively removing a "recipe" but there's a lot less consistency to anvil crafting due to repair material values and equipment damage varying as well as enchantments supporting multiple levels and multiple enchantments per book.

TLDR: Anvils don't have recipes, though prevention of a specific outcome is possible.

stohun01 commented 6 years ago

I use the term recipe loosely here. What I'm looking for is the ability to disable repairing completely but keep the renaming and adding of enchantments features. It would also be good if items could be blacklisted so they couldn't be repaired or enchanted in an anvil, and hopefully have these changes reflected in JEI. I'm making a mod pack focused around Better With Mods, which by default completely disables the vanilla anvil. In doing so you lose the ability to use name tags and enchanted books are useless.

Guinaro commented 6 years ago

I need this aswell for my modpack. I need to be able to remove certain items to be able to be enchanted. E.g. My modpack leans on Tinker's Construct, and removes full functionality of all standard minecraft tools like wooden shovel, iron pickaxe, ... I like to be able to remove those items from the anvil "recipes".

Mohron commented 6 years ago

How about this?

import mods.rockycore.Anvil;

Anvil.remove([<minecraft:diamond_pickaxe>]);

Mohron commented 6 years ago

If you'd like to try this out to see if you can do what you're lucking to do, that would be great!

# Anvil Removal
# Anvil.remove([input]) - Remove a single input (either side)
# Anvil.remove([input, input]) - Remove a combination of inputs (opposite sides)
# Anvil.remove(output) - Remove an output

## Blacklist Mending Enchant (input)
Anvil.remove([<minecraft:enchanted_book>.withTag({StoredEnchantments: [{lvl: 1 as short, id: 70 as short}]})]);

## Blacklist Diamond Hoe (input)
Anvil.remove([<minecraft:diamond_hoe>]);

## Blacklist Sharpness V on a Diamond Sword (inputs)
Anvil.remove([<minecraft:diamond_sword>, <minecraft:enchanted_book>.withTag({StoredEnchantments: [{lvl: 5 as short, id: 16 as short}]})]);

## Blacklist Enchanted Books (output)
Anvil.remove(<minecraft:enchanted_book>);

Test Build (rename from .zip to .jar) rockycore-1.12.2-0.4.0.zip

Guinaro commented 6 years ago

I just tested out: mods.rockycore.Anvil.remove([<minecraft:iron_shovel>]); Which indeed prevents the shovel from being enchanted by means of a book. However JEI Anvil doesn't reflect the recipe removal. Do not know if that it is possible due to the programmatic way that the anvil probably works.

mods.rockycore.Anvil.remove(<minecraft:iron_shovel>); Or mods.rockycore.Anvil.remove(<minecraft:iron_shovel>.withTag({ench: [{lvl: 1 as short, id: 32 as short}], RepairCost: 1})); Doesn't prevent the creation of an enchanted iron shovel.

In any case: thank you for the new functionality. Slowly getting to a cleaner modpack.

Guinaro commented 6 years ago

I did another test with mods.rockycore.Anvil.remove([<minecraft:iron_shovel>,<minecraft:enchanted_book>.withTag({StoredEnchantments: [{lvl: 1 as short, id: 32 as short}]})]); I cannot enchant with Efficiency I as expected, and can do it with Fortune I. And then I encountered possibly a bug in Minecraft anvil mechanics: When first putting the shovel + Fortune I book in the anvil it allows crafting as expected. If I switch the book to Efficiency I, and then craft/pickup the enchanted shovel out of the Anvil. I get a shovel with Fortune I as enchantment and a consumed Efficiency I book. Would need to test more but lack the time currently. Just noting an observation. This would be an easy way to only creating a single high level book, and never consuming the original book, but using cheap level 1 throw aways.

Wolf68k commented 5 years ago

So when I first followed the example....

// ## Blacklist Diamond Hoe (input)
Anvil.remove([<minecraft:diamond_hoe>]); //.....but I used <minecraft:wooden_shovel>

It was my interpretation that it meant it prevent placing the item into the anvil completely, but that's not the case. I was still able to place the item into the anvil. I however could not combine with a book. Then of course is the loophole, if the item is damaged then you can repair it and/or add a book. You have to add .anyDamage() to the item; .anyDamage() It would be better of course it completely prevented you from being able to place the item in the anvil.

Renari commented 5 years ago

This is exactly what I was looking for, trying to make it so enderio armor can't be empowered.

Renari commented 5 years ago

Unfortunately I was unable to get this to work.

import mods.rockycore.Anvil;

## remove all dark steel empowered upgrades
Anvil.remove([<enderio:item_dark_steel_helmet>.withTag({"enderio.darksteel.upgrade.energyUpgrade": {level: 0}}).anyDamage()]);
Anvil.remove([<enderio:item_dark_steel_helmet>.withTag({"enderio.darksteel.upgrade.energyUpgrade": {level: 1}}).anyDamage()]);
Anvil.remove([<enderio:item_dark_steel_helmet>.withTag({"enderio.darksteel.upgrade.energyUpgrade": {level: 2}}).anyDamage()]);
Anvil.remove([<enderio:item_dark_steel_helmet>.withTag({"enderio.darksteel.upgrade.energyUpgrade": {level: 3}}).anyDamage()]);

image

Mohron commented 5 years ago

@Renari can you put your crafttweaker log on pastebin/gist and link it here.

Renari commented 5 years ago

https://gist.github.com/Renari/e674d9ff8dd592ce14dd212e11756966

Mohron commented 5 years ago

@Renari try installing https://minecraft.curseforge.com/projects/mtlib

Renari commented 5 years ago

Thanks the script doesn't error now however the below entry still doesn't function.

Anvil.remove([<enderio:item_dark_steel_helmet>.withTag({"enderio.darksteel.upgrade.energyUpgrade": {level: 0}}).anyDamage()]);

# I also tried these but these product syntax errors
Anvil.remove([<enderio:item_dark_steel_helmet.anyDamage()>.withTag({"enderio.darksteel.upgrade.energyUpgrade": {level: 0}})]);

var helmet = <enderio:item_dark_steel_helmet>.anyDamage()
Anvil.remove([helmet.withTag({"enderio.darksteel.upgrade.energyUpgrade": {level: 0}})]);

Anvil.remove([<enderio:item_dark_steel_helmet>.anyDamage().withTag({"enderio.darksteel.upgrade.energyUpgrade": {level: 0}})]);

image

I tried to blacklist the input next and that seems to be working though.

Anvil.remove([<enderio:item_dark_steel_helmet>.anyDamage(), <enderio:item_material:15>]);

image

The recipe still shows in JEI which is a bummer, I'll look around and see if there's a way to remove it there.

Mohron commented 5 years ago

@Renari remove the square brackets if you want to remove an output.

https://crafttweaker.readthedocs.io/en/latest/#Mods/RockyCore/Anvil/

Mohron commented 5 years ago

This should have been closed here 7cc5927ba5eba6c32835274a6c0429996fada24f