mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-09-04 19:37:55 +00:00
Ignore enchantments/attributes on the original item
Turtle tools were not equippable, as we considered the stack enchanted due to the item's base attribute modifiers. We now only check the component patch for enchantments/attribute modifiers. This also removes the craftItem property of tools - this hasn't worked since we added support for enchanted tools! Fixes #1810
This commit is contained in:
@@ -58,7 +58,7 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
|
||||
*/
|
||||
public final class ToolBuilder {
|
||||
private final ResourceLocation id;
|
||||
private final Item toolItem;
|
||||
private final Item item;
|
||||
private Component adjective;
|
||||
private @Nullable Item craftingItem;
|
||||
private float damageMultiplier = TurtleToolSpec.DEFAULT_DAMAGE_MULTIPLIER;
|
||||
@@ -66,15 +66,15 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
|
||||
private boolean allowEnchantments = false;
|
||||
private TurtleToolDurability consumeDurability = TurtleToolDurability.NEVER;
|
||||
|
||||
ToolBuilder(ResourceLocation id, Item toolItem) {
|
||||
ToolBuilder(ResourceLocation id, Item item) {
|
||||
this.id = id;
|
||||
adjective = Component.translatable(UpgradeBase.getDefaultAdjective(id));
|
||||
this.toolItem = toolItem;
|
||||
this.item = item;
|
||||
craftingItem = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a custom adjective for this tool. By default this takes its adjective from the tool item.
|
||||
* Specify a custom adjective for this tool. By default this takes its adjective from the upgrade id.
|
||||
*
|
||||
* @param adjective The new adjective to use.
|
||||
* @return The tool builder, for further use.
|
||||
@@ -84,18 +84,6 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a custom item which is used to craft this upgrade. By default this is the same as the provided tool
|
||||
* item, but you may wish to override it.
|
||||
*
|
||||
* @param craftingItem The item used to craft this upgrade.
|
||||
* @return The tool builder, for further use.
|
||||
*/
|
||||
public ToolBuilder craftingItem(Item craftingItem) {
|
||||
this.craftingItem = craftingItem;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The amount of damage a swing of this tool will do. This is multiplied by {@link Attributes#ATTACK_DAMAGE} to
|
||||
* get the final damage.
|
||||
@@ -152,8 +140,7 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
|
||||
public void add(Consumer<Upgrade<ITurtleUpgrade>> add) {
|
||||
upgrade(id, ComputerCraftAPIService.get().createTurtleTool(new TurtleToolSpec(
|
||||
adjective,
|
||||
Optional.ofNullable(craftingItem),
|
||||
toolItem,
|
||||
item,
|
||||
damageMultiplier,
|
||||
allowEnchantments,
|
||||
consumeDurability,
|
||||
|
@@ -22,8 +22,7 @@ import java.util.Optional;
|
||||
* The template for a turtle tool.
|
||||
*
|
||||
* @param adjective The adjective for this tool.
|
||||
* @param craftItem The item used to craft this tool.
|
||||
* @param toolItem The actual tool used.
|
||||
* @param item The tool used.
|
||||
* @param damageMultiplier The damage multiplier for this tool.
|
||||
* @param allowEnchantments Whether to allow enchantments.
|
||||
* @param consumeDurability When to consume durability.
|
||||
@@ -31,8 +30,7 @@ import java.util.Optional;
|
||||
*/
|
||||
public record TurtleToolSpec(
|
||||
Component adjective,
|
||||
Optional<Item> craftItem,
|
||||
Item toolItem,
|
||||
Item item,
|
||||
float damageMultiplier,
|
||||
boolean allowEnchantments,
|
||||
TurtleToolDurability consumeDurability,
|
||||
@@ -42,8 +40,7 @@ public record TurtleToolSpec(
|
||||
|
||||
public static final MapCodec<TurtleToolSpec> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(
|
||||
ComponentSerialization.CODEC.fieldOf("adjective").forGetter(TurtleToolSpec::adjective),
|
||||
BuiltInRegistries.ITEM.byNameCodec().optionalFieldOf("craftingItem").forGetter(TurtleToolSpec::craftItem),
|
||||
BuiltInRegistries.ITEM.byNameCodec().fieldOf("item").forGetter(TurtleToolSpec::toolItem),
|
||||
BuiltInRegistries.ITEM.byNameCodec().fieldOf("item").forGetter(TurtleToolSpec::item),
|
||||
Codec.FLOAT.optionalFieldOf("damageMultiplier", DEFAULT_DAMAGE_MULTIPLIER).forGetter(TurtleToolSpec::damageMultiplier),
|
||||
Codec.BOOL.optionalFieldOf("allowEnchantments", false).forGetter(TurtleToolSpec::allowEnchantments),
|
||||
TurtleToolDurability.CODEC.optionalFieldOf("consumeDurability", TurtleToolDurability.NEVER).forGetter(TurtleToolSpec::consumeDurability),
|
||||
|
Reference in New Issue
Block a user