Use custom tool materials (#2631)
* Use custom tool materials * Separate jackhammer materials
This commit is contained in:
parent
ce18aab73d
commit
7d9fb6d414
12 changed files with 94 additions and 18 deletions
|
@ -34,7 +34,6 @@ import net.minecraft.item.ToolMaterials;
|
|||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import reborncore.RebornRegistry;
|
||||
import reborncore.common.powerSystem.RcEnergyTier;
|
||||
import reborncore.common.powerSystem.RcEnergyTier;
|
||||
import team.reborn.energy.api.EnergyStorage;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.blockentity.cable.CableBlockEntity;
|
||||
|
@ -187,13 +186,13 @@ public class ModRegistry {
|
|||
RebornRegistry.registerItem(TRContent.WRENCH = InitUtils.setup(new WrenchItem(), "wrench"));
|
||||
RebornRegistry.registerItem(TRContent.PAINTING_TOOL = InitUtils.setup(new PaintingToolItem(), "painting_tool"));
|
||||
|
||||
RebornRegistry.registerItem(TRContent.BASIC_DRILL = InitUtils.setup(new DrillItem(ToolMaterials.IRON, TechRebornConfig.basicDrillCharge, RcEnergyTier.MEDIUM, TechRebornConfig.basicDrillCost, 6F, -.5F, MiningLevel.IRON), "basic_drill"));
|
||||
RebornRegistry.registerItem(TRContent.BASIC_CHAINSAW = InitUtils.setup(new ChainsawItem(ToolMaterials.IRON, TechRebornConfig.basicChainsawCharge, RcEnergyTier.MEDIUM, TechRebornConfig.basicChainsawCost, 20F, 0.5F, Items.IRON_AXE), "basic_chainsaw"));
|
||||
RebornRegistry.registerItem(TRContent.BASIC_JACKHAMMER = InitUtils.setup(new JackhammerItem(TechRebornConfig.basicJackhammerCharge, RcEnergyTier.MEDIUM, TechRebornConfig.basicJackhammerCost), "basic_jackhammer"));
|
||||
RebornRegistry.registerItem(TRContent.BASIC_DRILL = InitUtils.setup(new DrillItem(TRToolMaterials.BASIC_DRILL, TechRebornConfig.basicDrillCharge, RcEnergyTier.MEDIUM, TechRebornConfig.basicDrillCost, 6F, -.5F, MiningLevel.IRON), "basic_drill"));
|
||||
RebornRegistry.registerItem(TRContent.BASIC_CHAINSAW = InitUtils.setup(new ChainsawItem(TRToolMaterials.BASIC_CHAINSAW, TechRebornConfig.basicChainsawCharge, RcEnergyTier.MEDIUM, TechRebornConfig.basicChainsawCost, 20F, 0.5F, Items.IRON_AXE), "basic_chainsaw"));
|
||||
RebornRegistry.registerItem(TRContent.BASIC_JACKHAMMER = InitUtils.setup(new JackhammerItem(TRToolMaterials.BASIC_JACKHAMMER, TechRebornConfig.basicJackhammerCharge, RcEnergyTier.MEDIUM, TechRebornConfig.basicJackhammerCost), "basic_jackhammer"));
|
||||
RebornRegistry.registerItem(TRContent.ELECTRIC_TREE_TAP = InitUtils.setup(new ElectricTreetapItem(), "electric_treetap"));
|
||||
|
||||
RebornRegistry.registerItem(TRContent.ADVANCED_DRILL = InitUtils.setup(new DrillItem(ToolMaterials.DIAMOND, TechRebornConfig.advancedDrillCharge, RcEnergyTier.EXTREME, TechRebornConfig.advancedDrillCost, 12F, 0.2F, MiningLevel.DIAMOND), "advanced_drill"));
|
||||
RebornRegistry.registerItem(TRContent.ADVANCED_CHAINSAW = InitUtils.setup(new ChainsawItem(ToolMaterials.DIAMOND, TechRebornConfig.advancedChainsawCharge, RcEnergyTier.EXTREME, TechRebornConfig.advancedChainsawCost, 20F, 1.0F, Items.DIAMOND_AXE), "advanced_chainsaw"));
|
||||
RebornRegistry.registerItem(TRContent.ADVANCED_DRILL = InitUtils.setup(new DrillItem(TRToolMaterials.ADVANCED_DRILL, TechRebornConfig.advancedDrillCharge, RcEnergyTier.EXTREME, TechRebornConfig.advancedDrillCost, 12F, 0.2F, MiningLevel.DIAMOND), "advanced_drill"));
|
||||
RebornRegistry.registerItem(TRContent.ADVANCED_CHAINSAW = InitUtils.setup(new ChainsawItem(TRToolMaterials.ADVANCED_CHAINSAW, TechRebornConfig.advancedChainsawCharge, RcEnergyTier.EXTREME, TechRebornConfig.advancedChainsawCost, 20F, 1.0F, Items.DIAMOND_AXE), "advanced_chainsaw"));
|
||||
RebornRegistry.registerItem(TRContent.ADVANCED_JACKHAMMER = InitUtils.setup(new AdvancedJackhammerItem(), "advanced_jackhammer"));
|
||||
RebornRegistry.registerItem(TRContent.ROCK_CUTTER = InitUtils.setup(new RockCutterItem(), "rock_cutter"));
|
||||
|
||||
|
|
69
src/main/java/techreborn/init/TRToolMaterials.java
Normal file
69
src/main/java/techreborn/init/TRToolMaterials.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
package techreborn.init;
|
||||
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.item.ToolMaterials;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import techreborn.TechReborn;
|
||||
|
||||
import static net.minecraft.item.ToolMaterials.*;
|
||||
|
||||
/**
|
||||
* We use custom materials to allow LevelZ to tweak the mining level of our tools.
|
||||
*/
|
||||
public class TRToolMaterials {
|
||||
public static final ToolMaterial BASIC_CHAINSAW = copy(IRON, "basic_chainsaw");
|
||||
public static final ToolMaterial BASIC_DRILL = copy(IRON, "basic_drill");
|
||||
public static final ToolMaterial BASIC_JACKHAMMER = copy(DIAMOND, "basic_jackhammer");
|
||||
|
||||
public static final ToolMaterial ADVANCED_CHAINSAW = copy(DIAMOND, "advanced_chainsaw");
|
||||
public static final ToolMaterial ADVANCED_DRILL = copy(DIAMOND, "advanced_drill");
|
||||
public static final ToolMaterial ADVANCED_JACKHAMMER = copy(DIAMOND, "advanced_jackhammer");
|
||||
|
||||
public static final ToolMaterial INDUSTRIAL_CHAINSAW = copy(DIAMOND, "industrial_chainsaw");
|
||||
public static final ToolMaterial INDUSTRIAL_DRILL = copy(DIAMOND, "industrial_drill");
|
||||
public static final ToolMaterial INDUSTRIAL_JACKHAMMER = copy(DIAMOND, "industrial_jackhammer");
|
||||
|
||||
public static final ToolMaterial ROCK_CUTTER = copy(DIAMOND, "rock_cutter");
|
||||
public static final ToolMaterial NANOSABER = copy(DIAMOND, "nanosaber");
|
||||
public static final ToolMaterial OMNI_TOOL = copy(DIAMOND, "omni_tool");
|
||||
|
||||
public static ToolMaterial copy(ToolMaterial material, String id) {
|
||||
return new ToolMaterial() {
|
||||
@Override
|
||||
public int getDurability() {
|
||||
return material.getDurability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMiningSpeedMultiplier() {
|
||||
return material.getMiningSpeedMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAttackDamage() {
|
||||
return material.getAttackDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMiningLevel() {
|
||||
return material.getMiningLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability() {
|
||||
return material.getEnchantability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairIngredient() {
|
||||
return material.getRepairIngredient();
|
||||
}
|
||||
|
||||
// This allows LevelZ to identify the material.
|
||||
@Override
|
||||
public String toString() {
|
||||
return TechReborn.MOD_ID + ":" + id;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@ public class ChainsawItem extends AxeItem implements RcEnergyItem {
|
|||
public final Item referenceTool;
|
||||
public final RcEnergyTier tier;
|
||||
|
||||
public ChainsawItem(ToolMaterials material, int energyCapacity, RcEnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, Item referenceTool) {
|
||||
public ChainsawItem(ToolMaterial material, int energyCapacity, RcEnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, Item referenceTool) {
|
||||
// combat stats same as for diamond axe. Fix for #2468
|
||||
super(material, 5.0F, -3.0F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||
this.maxCharge = energyCapacity;
|
||||
|
|
|
@ -51,7 +51,7 @@ public class DrillItem extends PickaxeItem implements RcEnergyItem, DynamicAttri
|
|||
public final int miningLevel;
|
||||
public final RcEnergyTier tier;
|
||||
|
||||
public DrillItem(ToolMaterials material, int energyCapacity, RcEnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, MiningLevel miningLevel) {
|
||||
public DrillItem(ToolMaterial material, int energyCapacity, RcEnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, MiningLevel miningLevel) {
|
||||
// combat stats same as for diamond pickaxe. Fix for #2468
|
||||
super(material, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||
this.maxCharge = energyCapacity;
|
||||
|
|
|
@ -41,6 +41,7 @@ import reborncore.common.powerSystem.RcEnergyItem;
|
|||
import reborncore.common.powerSystem.RcEnergyTier;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.init.TRToolMaterials;
|
||||
import techreborn.utils.InitUtils;
|
||||
import techreborn.utils.ToolsUtil;
|
||||
|
||||
|
@ -53,9 +54,9 @@ public class JackhammerItem extends PickaxeItem implements RcEnergyItem, Dynamic
|
|||
public final int cost;
|
||||
protected final float unpoweredSpeed = 0.5F;
|
||||
|
||||
public JackhammerItem(int energyCapacity, RcEnergyTier tier, int cost) {
|
||||
public JackhammerItem(ToolMaterial material, int energyCapacity, RcEnergyTier tier, int cost) {
|
||||
// combat stats same as for diamond pickaxe. Fix for #2468
|
||||
super(ToolMaterials.DIAMOND, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||
super(material, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||
this.maxCharge = energyCapacity;
|
||||
this.tier = tier;
|
||||
this.cost = cost;
|
||||
|
|
|
@ -43,6 +43,7 @@ import reborncore.common.misc.MultiBlockBreakingTool;
|
|||
import reborncore.common.util.ItemUtils;
|
||||
import reborncore.common.powerSystem.RcEnergyTier;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRToolMaterials;
|
||||
import techreborn.items.tool.JackhammerItem;
|
||||
import techreborn.utils.MessageIDs;
|
||||
import techreborn.utils.ToolsUtil;
|
||||
|
@ -55,7 +56,7 @@ import java.util.stream.Collectors;
|
|||
public class AdvancedJackhammerItem extends JackhammerItem implements MultiBlockBreakingTool {
|
||||
|
||||
public AdvancedJackhammerItem() {
|
||||
super(TechRebornConfig.advancedJackhammerCharge, RcEnergyTier.EXTREME, TechRebornConfig.advancedJackhammerCost);
|
||||
super(TRToolMaterials.ADVANCED_JACKHAMMER, TechRebornConfig.advancedJackhammerCharge, RcEnergyTier.EXTREME, TechRebornConfig.advancedJackhammerCost);
|
||||
}
|
||||
|
||||
private boolean shouldBreak(World worldIn, BlockPos originalPos, BlockPos pos, ItemStack stack) {
|
||||
|
|
|
@ -42,6 +42,7 @@ import reborncore.common.powerSystem.RcEnergyTier;
|
|||
import techreborn.TechReborn;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRToolMaterials;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class RockCutterItem extends PickaxeItem implements RcEnergyItem {
|
|||
// 10k Energy with 128 E\t charge rate
|
||||
public RockCutterItem() {
|
||||
// combat stats same as for diamond pickaxe. Fix for #2468
|
||||
super(ToolMaterials.DIAMOND, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||
super(TRToolMaterials.ROCK_CUTTER, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||
}
|
||||
|
||||
// PickaxeItem
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
import reborncore.common.util.ItemUtils;
|
||||
import reborncore.common.powerSystem.RcEnergyTier;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRToolMaterials;
|
||||
import techreborn.items.tool.ChainsawItem;
|
||||
import techreborn.utils.MessageIDs;
|
||||
import techreborn.utils.TagUtils;
|
||||
|
@ -58,7 +59,7 @@ public class IndustrialChainsawItem extends ChainsawItem {
|
|||
private static final Direction[] SEARCH_ORDER = new Direction[]{Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST, Direction.UP};
|
||||
|
||||
public IndustrialChainsawItem() {
|
||||
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialChainsawCharge, RcEnergyTier.EXTREME, TechRebornConfig.industrialChainsawCost, 20F, 1.0F, Items.DIAMOND_AXE);
|
||||
super(TRToolMaterials.INDUSTRIAL_CHAINSAW, TechRebornConfig.industrialChainsawCharge, RcEnergyTier.EXTREME, TechRebornConfig.industrialChainsawCost, 20F, 1.0F, Items.DIAMOND_AXE);
|
||||
}
|
||||
|
||||
private void findWood(World world, BlockPos pos, List<BlockPos> wood, List<BlockPos> leaves) {
|
||||
|
|
|
@ -46,6 +46,7 @@ import reborncore.common.util.ItemUtils;
|
|||
import reborncore.common.powerSystem.RcEnergyTier;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRToolMaterials;
|
||||
import techreborn.items.tool.DrillItem;
|
||||
import techreborn.items.tool.MiningLevel;
|
||||
import techreborn.utils.InitUtils;
|
||||
|
@ -57,7 +58,7 @@ import java.util.List;
|
|||
public class IndustrialDrillItem extends DrillItem {
|
||||
|
||||
public IndustrialDrillItem() {
|
||||
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialDrillCharge, RcEnergyTier.INSANE, TechRebornConfig.industrialDrillCost, 20.0F, 1.0F, MiningLevel.DIAMOND);
|
||||
super(TRToolMaterials.INDUSTRIAL_DRILL, TechRebornConfig.industrialDrillCharge, RcEnergyTier.INSANE, TechRebornConfig.industrialDrillCost, 20.0F, 1.0F, MiningLevel.DIAMOND);
|
||||
}
|
||||
|
||||
private boolean shouldBreak(PlayerEntity playerIn, World worldIn, BlockPos originalPos, BlockPos pos) {
|
||||
|
|
|
@ -47,6 +47,7 @@ import reborncore.common.util.ChatUtils;
|
|||
import reborncore.common.util.ItemUtils;
|
||||
import reborncore.common.powerSystem.RcEnergyTier;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRToolMaterials;
|
||||
import techreborn.items.tool.JackhammerItem;
|
||||
import techreborn.utils.MessageIDs;
|
||||
import techreborn.utils.ToolsUtil;
|
||||
|
@ -59,7 +60,7 @@ import java.util.stream.Collectors;
|
|||
public class IndustrialJackhammerItem extends JackhammerItem implements MultiBlockBreakingTool {
|
||||
|
||||
public IndustrialJackhammerItem() {
|
||||
super(TechRebornConfig.industrialJackhammerCharge, RcEnergyTier.INSANE, TechRebornConfig.industrialJackhammerCost);
|
||||
super(TRToolMaterials.INDUSTRIAL_JACKHAMMER, TechRebornConfig.industrialJackhammerCharge, RcEnergyTier.INSANE, TechRebornConfig.industrialJackhammerCost);
|
||||
}
|
||||
|
||||
// Cycle Inactive, Active 3*3 and Active 5*5
|
||||
|
|
|
@ -52,6 +52,7 @@ import reborncore.common.powerSystem.RcEnergyTier;
|
|||
import techreborn.TechReborn;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRToolMaterials;
|
||||
import techreborn.utils.MessageIDs;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -62,7 +63,7 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem, ItemStackM
|
|||
|
||||
// 4ME max charge with 1k charge rate
|
||||
public NanosaberItem() {
|
||||
super(ToolMaterials.DIAMOND, 1, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||
super(TRToolMaterials.NANOSABER, 1, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||
}
|
||||
|
||||
// SwordItem
|
||||
|
|
|
@ -52,6 +52,7 @@ import reborncore.common.powerSystem.RcEnergyTier;
|
|||
import techreborn.TechReborn;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRToolMaterials;
|
||||
import techreborn.items.tool.MiningLevel;
|
||||
import techreborn.utils.InitUtils;
|
||||
|
||||
|
@ -66,7 +67,7 @@ public class OmniToolItem extends PickaxeItem implements RcEnergyItem, DynamicAt
|
|||
|
||||
// 4M FE max charge with 1k charge rate
|
||||
public OmniToolItem() {
|
||||
super(ToolMaterials.DIAMOND, 3, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||
super(TRToolMaterials.OMNI_TOOL, 3, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||
this.miningLevel = MiningLevel.DIAMOND.intLevel;
|
||||
}
|
||||
|
||||
|
@ -81,7 +82,7 @@ public class OmniToolItem extends PickaxeItem implements RcEnergyItem, DynamicAt
|
|||
@Override
|
||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||
if (getStoredEnergy(stack) >= cost) {
|
||||
return ToolMaterials.DIAMOND.getMiningSpeedMultiplier();
|
||||
return getMaterial().getMiningSpeedMultiplier();
|
||||
}
|
||||
return super.getMiningSpeedMultiplier(stack, state);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue