Rebalance drill speed and mining level

This commit is contained in:
modmuss50 2020-07-26 15:56:05 +01:00
parent 481634d29f
commit a1e3df3c4a
5 changed files with 37 additions and 32 deletions

View file

@ -183,12 +183,12 @@ 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, EnergyTier.MEDIUM, TechRebornConfig.basicDrillCost, 10F, 0.5F, Items.IRON_PICKAXE, Items.IRON_SHOVEL), "basic_drill"));
RebornRegistry.registerItem(TRContent.BASIC_DRILL = InitUtils.setup(new DrillItem(ToolMaterials.IRON, TechRebornConfig.basicDrillCharge, EnergyTier.MEDIUM, TechRebornConfig.basicDrillCost, 6F, -.5F, MiningLevel.IRON), "basic_drill"));
RebornRegistry.registerItem(TRContent.BASIC_CHAINSAW = InitUtils.setup(new ChainsawItem(ToolMaterials.IRON, TechRebornConfig.basicChainsawCharge, EnergyTier.MEDIUM, TechRebornConfig.basicChainsawCost, 20F, 0.5F, Items.IRON_AXE), "basic_chainsaw"));
RebornRegistry.registerItem(TRContent.BASIC_JACKHAMMER = InitUtils.setup(new JackhammerItem(ToolMaterials.DIAMOND, TechRebornConfig.basicJackhammerCharge, EnergyTier.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, EnergyTier.EXTREME, TechRebornConfig.advancedDrillCost, 12F, 1.0F, Items.DIAMOND_PICKAXE, Items.DIAMOND_SHOVEL), "advanced_drill"));
RebornRegistry.registerItem(TRContent.ADVANCED_DRILL = InitUtils.setup(new DrillItem(ToolMaterials.DIAMOND, TechRebornConfig.advancedDrillCharge, EnergyTier.EXTREME, TechRebornConfig.advancedDrillCost, 12F, 0.2F, MiningLevel.DIAMOND), "advanced_drill"));
RebornRegistry.registerItem(TRContent.ADVANCED_CHAINSAW = InitUtils.setup(new ChainsawItem(ToolMaterials.DIAMOND, TechRebornConfig.advancedChainsawCharge, EnergyTier.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"));

View file

@ -78,6 +78,7 @@ import techreborn.entities.EntityNukePrimed;
import techreborn.items.DynamicCellItem;
import techreborn.items.UpgradeItem;
import techreborn.items.armor.QuantumSuitItem;
import techreborn.items.tool.MiningLevel;
import techreborn.utils.InitUtils;
import javax.annotation.Nullable;
@ -413,19 +414,6 @@ public class TRContent {
return block.asItem();
}
// Just a holder for the mining levels
private enum MiningLevel {
WOOD(0),
STONE(1),
IRON(2),
DIAMOND(3);
final int intLevel;
MiningLevel(int intLevel) {
this.intLevel = intLevel;
}
}
}
public enum StorageBlocks implements ItemConvertible {

View file

@ -25,11 +25,13 @@
package techreborn.items.tool;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.*;
import net.minecraft.tag.Tag;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -48,31 +50,28 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
public final int maxCharge;
public final int cost;
public final float poweredSpeed;
public final Item referencePickaxe;
public final Item referenceShovel;
public final float unpoweredSpeed;
public final int miningLevel;
public final EnergyTier tier;
public DrillItem(ToolMaterials material, int energyCapacity, EnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, Item referencePickaxe, Item referenceShovel) {
public DrillItem(ToolMaterials material, int energyCapacity, EnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, MiningLevel miningLevel) {
super(material, (int) material.getAttackDamage(), unpoweredSpeed, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
this.maxCharge = energyCapacity;
this.cost = cost;
this.poweredSpeed = poweredSpeed;
this.referencePickaxe = referencePickaxe;
this.referenceShovel = referenceShovel;
this.unpoweredSpeed = unpoweredSpeed;
this.miningLevel = miningLevel.intLevel;
this.tier = tier;
}
// PickaxeItem
@Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
if (Energy.of(stack).getEnergy() < cost) {
return -0.8F;
public float getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.PICKAXES) && stack.getItem().isEffectiveOn(state)) {
if (Energy.of(stack).getEnergy() >= cost) {
return poweredSpeed;
}
}
if (Items.WOODEN_PICKAXE.getMiningSpeedMultiplier(stack, state) > 1.0F
|| Items.WOODEN_SHOVEL.getMiningSpeedMultiplier(stack, state) > 1.0F) {
return poweredSpeed;
}
return super.getMiningSpeedMultiplier(stack, state);
return 0;
}
// MiningToolItem
@ -115,8 +114,11 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
}
@Override
public boolean isEffectiveOn(BlockState state) {
return referencePickaxe.isEffectiveOn(state) || referenceShovel.isEffectiveOn(state);
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.PICKAXES)) {
return miningLevel;
}
return 0;
}
// ItemDurabilityExtensions

View file

@ -0,0 +1,14 @@
package techreborn.items.tool;
public enum MiningLevel {
WOOD(0),
STONE(1),
IRON(2),
DIAMOND(3);
public final int intLevel;
MiningLevel(int intLevel) {
this.intLevel = intLevel;
}
}

View file

@ -47,6 +47,7 @@ import team.reborn.energy.EnergyTier;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.DrillItem;
import techreborn.items.tool.MiningLevel;
import techreborn.utils.InitUtils;
import techreborn.utils.MessageIDs;
import techreborn.utils.ToolsUtil;
@ -57,7 +58,7 @@ import java.util.List;
public class IndustrialDrillItem extends DrillItem {
public IndustrialDrillItem() {
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialDrillCharge, EnergyTier.INSANE, TechRebornConfig.industrialDrillCost, 15.0F, 2.0F, Items.DIAMOND_PICKAXE, Items.DIAMOND_SHOVEL);
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialDrillCharge, EnergyTier.INSANE, TechRebornConfig.industrialDrillCost, 20.0F, 1.0F, MiningLevel.DIAMOND);
}
private boolean shouldBreak(PlayerEntity playerIn, World worldIn, BlockPos originalPos, BlockPos pos) {