From 2c43f6b0a3f0f81d6d3a373ee8f59f53d2c88f4f Mon Sep 17 00:00:00 2001 From: trinsdar <30245301+Trinsdar@users.noreply.github.com> Date: Sun, 26 Nov 2023 14:25:44 -0500 Subject: [PATCH] made rock cutter use tool type methds and made the item class exend the class in gt core --- .../java/trinsdar/gt4r/data/ToolTypes.java | 25 +------------------ .../gt4r/items/MaterialRockCutter.java | 16 +++++++++--- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/common/src/main/java/trinsdar/gt4r/data/ToolTypes.java b/common/src/main/java/trinsdar/gt4r/data/ToolTypes.java index 203b7339..48e2dd87 100644 --- a/common/src/main/java/trinsdar/gt4r/data/ToolTypes.java +++ b/common/src/main/java/trinsdar/gt4r/data/ToolTypes.java @@ -68,7 +68,7 @@ public Map getFromResult(@Nonnull ItemStack stack) { return ImmutableMap.of(); } }); - public static AntimatterToolType ROCK_CUTTER = AntimatterAPI.register(AntimatterToolType.class, new RockCutterToolType(GT4RRef.ID, "rock_cutter", 1, 1, 1, -1.0F, -3.0F)).setPowered(100000L, 1).setRepairability(false).setOverlayLayers(2).addEffectiveMaterials(ICE_SOLID, METAL, STONE, HEAVY_METAL, PISTON).setBrokenItems(ImmutableMap.of("rock_cutter", i -> getBrokenItem(i, RockCutterPowerUnit))); + public static AntimatterToolType ROCK_CUTTER = AntimatterAPI.register(AntimatterToolType.class, new AntimatterToolType(GT4RRef.ID, "rock_cutter", 1, 1, 1, -1.0F, -3.0F, false)).setPowered(100000L, 1).setRepairable(false).setOverlayLayers(2).addEffectiveMaterials(ICE_SOLID, METAL, STONE, HEAVY_METAL, PISTON).setBrokenItems(ImmutableMap.of("rock_cutter", i -> getBrokenItem(i, RockCutterPowerUnit))).setType(AntimatterDefaultTools.PICKAXE).setToolSupplier((domain, toolType, tier, properties) -> new MaterialRockCutter(domain, toolType, properties, 1)); static { PropertyIngredient.addGetter(CustomTags.BATTERIES_RE.location(), ToolTypes::getEnergy); @@ -125,27 +125,4 @@ public static Tuple> getEnergyAndMat(ItemStack stack } return null; } - - public static class RockCutterToolType extends AntimatterToolType{ - - public RockCutterToolType(String domain, String id, int useDurability, int attackDurability, int craftingDurability, float baseAttackDamage, float baseAttackSpeed) { - super(domain, id, useDurability, attackDurability, craftingDurability, baseAttackDamage, baseAttackSpeed, false); - setType(AntimatterDefaultTools.PICKAXE); - } - - @Override - public List instantiatePoweredTools(String domain) { - List poweredTools = new ObjectArrayList<>(); - Item.Properties properties = prepareInstantiation(domain); - poweredTools.add(new MaterialRockCutter(domain, this, properties, 1)); - return poweredTools; - } - - @Override - public List instantiatePoweredTools(String domain, Supplier properties) { - List poweredTools = new ObjectArrayList<>(); - poweredTools.add(new MaterialRockCutter(domain, this, properties.get(), 1)); - return poweredTools; - } - } } diff --git a/common/src/main/java/trinsdar/gt4r/items/MaterialRockCutter.java b/common/src/main/java/trinsdar/gt4r/items/MaterialRockCutter.java index c9c74771..4c77fec1 100644 --- a/common/src/main/java/trinsdar/gt4r/items/MaterialRockCutter.java +++ b/common/src/main/java/trinsdar/gt4r/items/MaterialRockCutter.java @@ -1,5 +1,6 @@ package trinsdar.gt4r.items; +import io.github.gregtechintergalactical.gtcore.data.GTCoreTools; import muramasa.antimatter.material.Material; import muramasa.antimatter.material.MaterialTags; import muramasa.antimatter.tool.AntimatterItemTier; @@ -14,6 +15,7 @@ import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import tesseract.TesseractCapUtils; import tesseract.api.gt.IEnergyHandler; @@ -26,7 +28,7 @@ import static muramasa.antimatter.data.AntimatterMaterials.Diamond; import static trinsdar.gt4r.data.Materials.Titanium; -public class MaterialRockCutter extends MaterialTool { +public class MaterialRockCutter extends GTCoreTools.PoweredTool { public MaterialRockCutter(String domain, AntimatterToolType type, Properties properties, int energyTier) { super(domain, type, AntimatterItemTier.NULL, properties, energyTier); } @@ -36,6 +38,12 @@ public String getId() { return type.getId(); } + @Override + public int getItemColor(ItemStack stack, @org.jetbrains.annotations.Nullable Block block, int i) { + if (i == 1) return Titanium.getRGB(); + return super.getItemColor(stack, block, i); + } + @Override public void onGenericFillItemGroup(CreativeModeTab group, NonNullList list, long maxEnergy) { if (this.allowdedIn(group)){ @@ -54,11 +62,11 @@ public void onGenericFillItemGroup(CreativeModeTab group, NonNullList @Override public ItemStack resolveStack(Material primary, Material secondary, long startingEnergy, long maxEnergy) { ItemStack stack = super.resolveStack(primary, secondary, startingEnergy, maxEnergy); - if (!primary.has(MaterialTags.TOOLS) || !secondary.has(MaterialTags.HANDLE)){ + if (!primary.has(MaterialTags.TOOLS)){ return stack; } - Map mainEnchants = MaterialTags.TOOLS.get(primary).toolEnchantment(), handleEnchants = MaterialTags.HANDLE.get(secondary).toolEnchantment(); - if (!mainEnchants.containsKey(Enchantments.SILK_TOUCH) && !handleEnchants.containsKey(Enchantments.SILK_TOUCH)) { + Map mainEnchants = MaterialTags.TOOLS.get(primary).toolEnchantment(); + if (!mainEnchants.containsKey(Enchantments.SILK_TOUCH)) { stack.enchant(Enchantments.SILK_TOUCH, 1); } return stack;