Skip to content

Commit

Permalink
made rock cutter use tool type methds and made the item class exend t…
Browse files Browse the repository at this point in the history
…he class in gt core
  • Loading branch information
Trinsdar committed Nov 26, 2023
1 parent fc3970e commit 2c43f6b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 28 deletions.
25 changes: 1 addition & 24 deletions common/src/main/java/trinsdar/gt4r/data/ToolTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Map<String, Object> 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);
Expand Down Expand Up @@ -125,27 +125,4 @@ public static Tuple<Long, Tuple<Long, Material>> 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<IAntimatterTool> instantiatePoweredTools(String domain) {
List<IAntimatterTool> poweredTools = new ObjectArrayList<>();
Item.Properties properties = prepareInstantiation(domain);
poweredTools.add(new MaterialRockCutter(domain, this, properties, 1));
return poweredTools;
}

@Override
public List<IAntimatterTool> instantiatePoweredTools(String domain, Supplier<Item.Properties> properties) {
List<IAntimatterTool> poweredTools = new ObjectArrayList<>();
poweredTools.add(new MaterialRockCutter(domain, this, properties.get(), 1));
return poweredTools;
}
}
}
16 changes: 12 additions & 4 deletions common/src/main/java/trinsdar/gt4r/items/MaterialRockCutter.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
Expand All @@ -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<ItemStack> list, long maxEnergy) {
if (this.allowdedIn(group)){
Expand All @@ -54,11 +62,11 @@ public void onGenericFillItemGroup(CreativeModeTab group, NonNullList<ItemStack>
@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<Enchantment, Integer> mainEnchants = MaterialTags.TOOLS.get(primary).toolEnchantment(), handleEnchants = MaterialTags.HANDLE.get(secondary).toolEnchantment();
if (!mainEnchants.containsKey(Enchantments.SILK_TOUCH) && !handleEnchants.containsKey(Enchantments.SILK_TOUCH)) {
Map<Enchantment, Integer> mainEnchants = MaterialTags.TOOLS.get(primary).toolEnchantment();
if (!mainEnchants.containsKey(Enchantments.SILK_TOUCH)) {
stack.enchant(Enchantments.SILK_TOUCH, 1);
}
return stack;
Expand Down

0 comments on commit 2c43f6b

Please sign in to comment.