Seriously clean up loads of unnecessary item classes and add more configs

This commit is contained in:
Prospector 2020-01-12 21:20:42 -08:00
parent c4dcc8d870
commit 04a1c789c4
30 changed files with 433 additions and 1111 deletions

View file

@ -31,41 +31,41 @@ import java.util.List;
//All moved into one class as its a lot easier to find the annotations when you know where they all are
public class TechRebornConfig {
// Generators
@Config(config = "generators", category = "solarPanelGeneral", key = "internalCapacity", comment = "Multiplier for internal capacity of solar panels (multiplier * day generation rate)")
public static int solarInternalCapacityMultiplier = 2000;
@Config(config = "generators", category = "solarPanelBasic", key = "basicDayRate", comment = "Generation rate during day for Basic Solar Panel (Value in FE)")
public static int basicGenerationRateD = 1;
@Config(config = "generators", category = "solarPanelBasic", key = "basicNightRate", comment = "Generation rate during night for Basic Solar Panel (Value in FE)")
public static int basicGenerationRateN = 0;
@Config(config = "generators", category = "solarPanelAdvanced", key = "advancedDayRate", comment = "Generation rate during day for Advanced Solar Panel (Value in FE)")
public static int advancedGenerationRateD = 16;
@Config(config = "generators", category = "solarPanelAdvanced", key = "advancedNightRate", comment = "Generation rate during night for Advanced Solar Panel (Value in FE)")
public static int advancedGenerationRateN = 0;
@Config(config = "generators", category = "solarPanelIndustrial", key = "industrialDayRate", comment = "Generation rate during day for Industrial Solar Panel (Value in FE)")
public static int industrialGenerationRateD = 64;
@Config(config = "generators", category = "solarPanelIndustrial", key = "industrialNightRate", comment = "Generation rate during night for Industrial Solar Panel (Value in FE)")
public static int industrialGenerationRateN = 2;
@Config(config = "generators", category = "solarPanelUltimate", key = "ultimateDayRate", comment = "Generation rate during day for Ultimate Solar Panel (Value in FE)")
public static int ultimateGenerationRateD = 256;
@Config(config = "generators", category = "solarPanelUltimate", key = "ultimateNightRate", comment = "Generation rate during night for Ultimate Solar Panel (Value in FE)")
public static int ultimateGenerationRateN = 16;
public static int ultimateGenerationRateN = 16;
@Config(config = "generators", category = "solarPanelQuantum", key = "quantumDayRate", comment = "Generation rate during day for Quantum Solar Panel (Value in FE)")
public static int quantumGenerationRateD = 2048;
@Config(config = "generators", category = "solarPanelQuantum", key = "quantumNightRate", comment = "Generation rate during night for Quantum Solar Panel (Value in FE)")
public static int quantumGenerationRateN = 128;
@Config(config = "generators", category = "lightning_rod", key = "LightningRodMaxOutput", comment = "Lightning Rod Max Output (Value in EU)")
public static int lightningRodMaxOutput = 2048;
@ -86,7 +86,7 @@ public class TechRebornConfig {
@Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorEnergyPerTick", comment = "Thermal Generator Energy Per Tick (Value in EU)")
public static int thermalGeneratorEnergyPerTick = 16;
@Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorMaxOutput", comment = "Plasma Generator Max Output (Value in EU)")
public static int plasmaGeneratorMaxOutput = 2048;
@ -107,7 +107,7 @@ public class TechRebornConfig {
@Config(config = "generators", category = "wind_mill", key = "WindMillThunderMultiplier", comment = "Wind Mill Thunder Multiplier")
public static double windMillThunderMultiplier = 1.25;
@Config(config = "generators", category = "water_mill", key = "WaterMillMaxOutput", comment = "Water Mill Max Output (Value in EU)")
public static int waterMillMaxOutput = 32;
@ -116,7 +116,7 @@ public class TechRebornConfig {
@Config(config = "generators", category = "water_mill", key = "WaterMillEnergyPerTick", comment = "Water Mill Energy Multiplier")
public static double waterMillEnergyMultiplier = 0.1;
@Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorMaxOutput", comment = "Semifluid Generator Max Output (Value in EU)")
public static int semiFluidGeneratorMaxOutput = 128;
@ -125,7 +125,7 @@ public class TechRebornConfig {
@Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorEnergyPerTick", comment = "Semifluid Generator Energy Per Tick (Value in EU)")
public static int semiFluidGeneratorEnergyPerTick = 8;
@Config(config = "generators", category = "gas_generator", key = "GasGeneratorMaxOutput", comment = "Gas Generator Max Output (Value in EU)")
public static int gasTurbineMaxOutput = 128;
@ -134,16 +134,16 @@ public class TechRebornConfig {
@Config(config = "generators", category = "gas_generator", key = "GasGeneratorEnergyPerTick", comment = "Gas Generator Energy Per Tick (Value in EU)")
public static int gasTurbineEnergyPerTick = 16;
@Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorMaxOutput", comment = "Diesel Generator Max Output (Value in EU)")
public static int dieselGeneratorMaxOutput = 32;
@Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorMaxEnergy", comment = "Diesel Generator Max Energy (Value in EU)")
public static int dieselGeneratorMaxEnergy = 10_000;
@Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorEnergyPerTick", comment = "Diesel Generator Energy Per Tick (Value in EU)")
public static int dieselGeneratorEnergyPerTick = 20;
@Config(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerMaxOutput", comment = "Dragon Egg Siphoner Max Output (Value in EU)")
public static int dragonEggSyphonMaxOutput = 128;
@ -161,56 +161,113 @@ public class TechRebornConfig {
@Config(config = "generators", category = "generator", key = "GeneratorEnergyOutput", comment = "Solid Fuel Generator Energy Output Amount (Value in EU)")
public static int solidFuelGeneratorOutputAmount = 10;
// Items
@Config(config = "items", category = "general", key = "enableGemTools", comment = "Enable Gem armor and tools")
public static boolean enableGemArmorAndTools = true;
@Config(config = "items", category = "power", key = "nanoSaberCharge", comment = "Energy Capacity for Nano Saber (FE)")
public static int nanoSaberCharge = 4_000_000;
public static int nanosaberCharge = 4_000_000;
@Config(config = "items", category = "power", key = "nanoSaberCost", comment = "Energy Cost for Nano Saber (FE)")
public static int nanosaberCost = 250;
@Config(config = "items", category = "power", key = "electricTreetapCharge", comment = "Energy Capacity for Electric Treetap (FE)")
public static int electricTreetapCharge = 10_000;
@Config(config = "items", category = "power", key = "electricTreetapCost", comment = "Energy Cost for Electric Treetap (FE)")
public static int electricTreetapCost = 20;
@Config(config = "items", category = "power", key = "basicDrillCharge", comment = "Energy Capacity for Basic Drill (FE)")
public static int basicDrillCharge = 40_000;
@Config(config = "items", category = "power", key = "basicDrillCost", comment = "Energy Cost for Basic Drill (FE)")
public static int basicDrillCost = 50;
@Config(config = "items", category = "power", key = "advancedDrillCharge", comment = "Energy Capacity for Advanced Drill (FE)")
public static int advancedDrillCharge = 400_000;
@Config(config = "items", category = "power", key = "advancedDrillCost", comment = "Energy Cost for Advanced Drill (FE)")
public static int advancedDrillCost = 100;
@Config(config = "items", category = "power", key = "industrialDrillCharge", comment = "Energy Capacity for Industrial Drill (FE)")
public static int industrialDrillCharge = 4_000_000;
@Config(config = "items", category = "power", key = "industrialDrillCost", comment = "Energy Cost for Industrial Drill (FE)")
public static int industrialDrillCost = 250;
@Config(config = "items", category = "power", key = "basicChainsawCharge", comment = "Energy Capacity for Basic Chainsaw (FE)")
public static int basicChainsawCharge = 40_000;
@Config(config = "items", category = "power", key = "basicChainsawCost", comment = "Energy Cost for Basic Chainsaw (FE)")
public static int basicChainsawCost = 50;
@Config(config = "items", category = "power", key = "advancedChainsawCharge", comment = "Energy Capacity for Advanced Chainsaw (FE)")
public static int advancedChainsawCharge = 400_000;
@Config(config = "items", category = "power", key = "advancedChainsawCost", comment = "Energy Cost for Advanced Chainsaw (FE)")
public static int advancedChainsawCost = 100;
@Config(config = "items", category = "power", key = "industrialChainsawCharge", comment = "Energy Capacity for Industrial Chainsaw (FE)")
public static int industrialChainsawCharge = 4_000_000;
@Config(config = "items", category = "power", key = "industrialChainsawCost", comment = "Energy Cost for Industrial Chainsaw (FE)")
public static int industrialChainsawCost = 250;
@Config(config = "items", category = "power", key = "basicJackhammerCharge", comment = "Energy Capacity for Basic Jackhammer (FE)")
public static int basicJackhammerCharge = 40_000;
@Config(config = "items", category = "power", key = "basicJackhammerCost", comment = "Energy Cost for Basic Jackhammer (FE)")
public static int basicJackhammerCost = 50;
@Config(config = "items", category = "power", key = "advancedJackhammerCharge", comment = "Energy Capacity for Advanced Jackhammer (FE)")
public static int advancedJackhammerCharge = 400_000;
@Config(config = "items", category = "power", key = "industrialJackhammerCharge", comment = "Energy Capacity for Industrial Jachammer (FE)")
@Config(config = "items", category = "power", key = "advancedJackhammerCost", comment = "Energy Cost for Advanced Jackhammer (FE)")
public static int advancedJackhammerCost = 100;
@Config(config = "items", category = "power", key = "industrialJackhammerCharge", comment = "Energy Capacity for Industrial Jackhammer (FE)")
public static int industrialJackhammerCharge = 4_000_000;
@Config(config = "items", category = "power", key = "industrialJackhammerCost", comment = "Energy Cost for Industrial Jackhammer (FE)")
public static int industrialJackhammerCost = 250;
@Config(config = "items", category = "power", key = "omniToolCharge", comment = "Energy Capacity for Omni Tool (FE)")
public static int omniToolCharge = 4_000_000;
@Config(config = "items", category = "power", key = "omniToolCost", comment = "Energy Cost for Omni Tool (FE)")
public static int omniToolCost = 100;
@Config(config = "items", category = "power", key = "omniToolHitCost", comment = "Hit Energy Cost for Omni Tool (FE)")
public static int omniToolHitCost = 125;
@Config(config = "items", category = "power", key = "rockCutterCharge", comment = "Energy Capacity for Rock Cutter (FE)")
public static int rockCutterCharge = 400_000;
@Config(config = "items", category = "power", key = "rockCutterCost", comment = "Energy Cost for Rock Cutter (FE)")
public static int rockCutterCost = 500;
@Config(config = "items", category = "power", key = "lapotronPackCharge", comment = "Energy Capacity for Lapotron Pack (FE)")
public static int lapotronPackCharge = 400_000_000;
@Config(config = "items", category = "power", key = "lapotronPackTransferRate", comment = "Transfer Rate for Lapotron Pack (FE)")
public static int lapotronPackTransferRate = 100_000;
@Config(config = "items", category = "power", key = "LithiumBatpackCharge", comment = "Energy Capacity for Lithium Batpack (FE)")
public static int lithiumBatpackCharge = 8_000_000;
@Config(config = "items", category = "power", key = "lithiumBatpackTransferRate", comment = "Transfer Rate for Lithium Batpack (FE)")
public static int lithiumBatpackTransferRate = 2_000;
@Config(config = "items", category = "power", key = "redCellBatteryMaxCharge", comment = "Energy Capacity for Red Cell Battery (FE)")
public static int redCellBatteryMaxCharge = 40_000;
@Config(config = "items", category = "power", key = "lithiumIonBatteryMaxCharge", comment = "Energy Capacity for Lithium Ion Battery (FE)")
public static int lithiumIonBatteryMaxCharge = 400_000;
@Config(config = "items", category = "power", key = "energyCrystalMaxCharge", comment = "Energy Capacity for Energy Crystal (FE)")
public static int energyCrystalMaxCharge = 4_000_000;
@Config(config = "items", category = "power", key = "lapotronCrystalMaxCharge", comment = "Energy Capacity for Lapotron Crystal (FE)")
public static int lapotronCrystalMaxCharge = 40_000_000;
@ -219,10 +276,25 @@ public class TechRebornConfig {
@Config(config = "items", category = "power", key = "cloakingDeviceCharge", comment = "Energy Capacity for Clocking Device (FE)")
public static int cloakingDeviceCharge = 40_000_000;
@Config(config = "items", category = "power", key = "clockingDeviceEnergyUsage", comment = "Cloacking device energy usesage (FE)")
public static int cloackingDeviceUsage = 10;
public static int cloackingDeviceCost = 10;
@Config(config = "items", category = "power", key = "quantumSuitCapacity", comment = "Quantum Suit Energy Capacity")
public static double quantumSuitCapacity = 40_000_000;
@Config(config = "items", category = "power", key = "quantumSuitFlyingCost", comment = "Quantum Suit Flying Cost")
public static double quantumSuitFlyingCost = 50;
@Config(config = "items", category = "power", key = "quantumSuitSwimmingCost", comment = "Quantum Suit Swimming Cost")
public static double quantumSuitSwimmingCost = 20;
@Config(config = "items", category = "power", key = "quantumSuitBreathingCost", comment = "Quantum Suit Breathing Cost")
public static double quantumSuitBreathingCost = 20;
@Config(config = "items", category = "power", key = "quantumSuitSprintingCost", comment = "Quantum Suit Sprinting Cost")
public static double quantumSuitSprintingCost = 20;
@Config(config = "items", category = "upgrades", key = "overclcoker_speed", comment = "Overclocker behavior speed multipiler")
public static double overclockerSpeed = 0.25;
@ -235,6 +307,7 @@ public class TechRebornConfig {
@Config(config = "items", category = "upgrades", key = "super_conductor", comment = "Energy flow power increase")
public static double superConductorCount = 1;
// Machines
@Config(config = "machines", category = "grinder", key = "GrinderInput", comment = "Grinder Max Input (Value in EU)")
public static int grinderMaxInput = 32;
@ -304,10 +377,10 @@ public class TechRebornConfig {
@Config(config = "machines", category = "rolling_machine", key = "RollingMachineMaxEnergy", comment = "Rolling Machine Max Energy (Value in EU)")
public static int rollingMachineMaxEnergy = 10000;
@Config(config = "machines", category = "chunk_loader", key = "ChunkLoaderMaxRadius", comment = "Chunk Loader Max Radius")
public static int chunkLoaderMaxRadius = 5;
@Config(config = "machines", category = "assembling_machine", key = "AssemblingMachineMaxInput", comment = "Assembling Machine Max Input (Value in EU)")
public static int assemblingMachineMaxInput = 128;
@ -469,28 +542,28 @@ public class TechRebornConfig {
@Config(config = "machines", category = "solid_canning_machine", key = "solidCanningMachineMaxEnergy", comment = "Solid Canning Machine Max Energy (Value in EU)")
public static int solidCanningMachineMaxEnergy = 1_000;
@Config(config = "machines", category = "iron_machine", key = "fuel_scale", comment = "Multiplier for vanilla furnace item burn time")
public static double fuelScale = 1.25;
@Config(config = "machines", category = "iron_machine", key = "cooking_scale", comment = "Multiplier for vanilla furnace item cook time")
public static double cookingScale = 1.25;
@Config(config = "machines", category = "greenhouse_controller", key = "GreenhouseControllerMaxInput", comment = "Greenhouse Controller Max Input")
public static int greenhouseControllerMaxInput = 32;
@Config(config = "machines", category = "greenhouse_controller", key = "GreenhouseControllerMaxEnergy", comment = "Greenhouse Controller Max Energy")
public static int greenhouseControllerMaxEnergy = 1_000;
@Config(config = "machines", category = "greenhouse_controller", key = "GreenhouseControllerEnergyPerTick", comment = "Greenhouse Controller Energy Per Tick")
public static int greenhouseControllerEnergyPerTick = 2;
@Config(config = "machines", category = "greenhouse_controller", key = "GreenhouseControllerEnergyPerHarvest", comment = "Greenhouse Controller Energy Per Harvest")
public static int greenhouseControllerEnergyPerHarvest = 100;
@Config(config = "machines", category = "greenhouse_controller", key = "GreenhouseControllerEnergyPerBonemeal", comment = "Greenhouse Controller Energy Per Bonemeal")
public static int greenhouseControllerEnergyPerBonemeal = 50;
// Misc
@Config(config = "misc", category = "general", key = "IC2TransformersStyle", comment = "Input from dots side, output from other sides, like in IC2.")
public static boolean IC2TransformersStyle = true;
@ -509,10 +582,10 @@ public class TechRebornConfig {
@Config(config = "misc", category = "nuke", key = "enabled", comment = "Should the nuke explode, set to false to prevent block damage")
public static boolean nukeEnabled = true;
@Config(config = "misc", category = "general", key = "DispenserScrapbox", comment = "Dispensers will open scrapboxes")
public static boolean dispenseScrapboxes = true;
@Config(config = "misc", category = "cable", key = "uninsulatedElectrocutionDamage", comment = "When true an uninsulated cable will cause damage to entities")
public static boolean uninsulatedElectrocutionDamage = true;
@ -521,14 +594,14 @@ public class TechRebornConfig {
@Config(config = "misc", category = "cable", key = "uninsulatedElectrocutionParticles", comment = "When true an uninsulated cable will create a spark when an entity touches it")
public static boolean uninsulatedElectrocutionParticles = true;
// World
@Config(config = "world", category = "loot", key = "enableOverworldLoot", comment = "When true TechReborn will add ingots, machine frames and circuits to OverWorld loot chests.")
public static boolean enableOverworldLoot = true;
@Config(config = "world", category = "loot", key = "enableNetherLoot", comment = "When true TechReborn will add ingots, machine frames and circuits to Nether loot chests.")
public static boolean enableNetherLoot = true;
@Config(config = "world", category = "loot", key = "enableEndLoot", comment = "When true TechReborn will add ingots, machine frames and circuits to The End loot chests.")
public static boolean enableEndLoot = true;
}

View file

@ -24,57 +24,27 @@
package techreborn.events;
import net.minecraft.block.FenceBlock;
import net.minecraft.block.FenceGateBlock;
import net.minecraft.block.LogBlock;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.SlabBlock;
import net.minecraft.block.*;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.Item.Settings;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import reborncore.RebornRegistry;
import team.reborn.energy.EnergyTier;
import techreborn.TechReborn;
import techreborn.blocks.misc.BlockComputerCube;
import techreborn.blocks.misc.BlockNuke;
import techreborn.blocks.misc.BlockRefinedIronFence;
import techreborn.blocks.misc.BlockReinforcedGlass;
import techreborn.blocks.misc.BlockRubberLeaves;
import techreborn.blocks.misc.BlockRubberLog;
import techreborn.blocks.misc.BlockRubberPlank;
import techreborn.blocks.misc.BlockRubberPlankStair;
import techreborn.blocks.misc.BlockRubberSapling;
import techreborn.blocks.misc.RubberButtonBlock;
import techreborn.blocks.misc.RubberDoorBlock;
import techreborn.blocks.misc.RubberPressurePlateBlock;
import techreborn.blocks.misc.RubberTrapdoorBlock;
import techreborn.blocks.misc.*;
import techreborn.config.TechRebornConfig;
import techreborn.init.ModFluids;
import techreborn.init.ModSounds;
import techreborn.init.TRArmorMaterials;
import techreborn.init.TRContent;
import techreborn.init.*;
import techreborn.init.TRContent.*;
import techreborn.init.TRToolTier;
import techreborn.items.DynamicCellItem;
import techreborn.items.FrequencyTransmitterItem;
import techreborn.items.ManualItem;
import techreborn.items.ScrapBoxItem;
import techreborn.items.*;
import techreborn.items.armor.BatpackItem;
import techreborn.items.armor.CloakingDeviceItem;
import techreborn.items.armor.LapotronicOrbpackItem;
import techreborn.items.armor.LithiumIonBatpackItem;
import techreborn.items.armor.QuantumSuitItem;
import techreborn.items.armor.TRArmourItem;
import techreborn.items.battery.*;
import techreborn.items.tool.DebugToolItem;
import techreborn.items.tool.PaintingToolItem;
import techreborn.items.tool.TreeTapItem;
import techreborn.items.tool.WrenchItem;
import techreborn.items.tool.advanced.AdvancedChainsawItem;
import techreborn.items.tool.advanced.AdvancedDrillItem;
import techreborn.items.tool.*;
import techreborn.items.tool.advanced.AdvancedJackhammerItem;
import techreborn.items.tool.advanced.RockCutterItem;
import techreborn.items.tool.basic.BasicChainsawItem;
import techreborn.items.tool.basic.BasicDrillItem;
import techreborn.items.tool.basic.BasicJackhammerItem;
import techreborn.items.tool.basic.ElectricTreetapItem;
import techreborn.items.tool.industrial.*;
import techreborn.items.tool.vanilla.*;
@ -84,7 +54,6 @@ import java.util.Arrays;
/**
* @author drcrazy
*
*/
public class ModRegistry {
@ -146,7 +115,7 @@ public class ModRegistry {
RebornRegistry.registerItem(TRContent.QUANTUM_CHESTPLATE = InitUtils.setup(new QuantumSuitItem(TRArmorMaterials.QUANTUM, EquipmentSlot.CHEST), "quantum_chestplate"));
RebornRegistry.registerItem(TRContent.QUANTUM_LEGGINGS = InitUtils.setup(new QuantumSuitItem(TRArmorMaterials.QUANTUM, EquipmentSlot.LEGS), "quantum_leggings"));
RebornRegistry.registerItem(TRContent.QUANTUM_BOOTS = InitUtils.setup(new QuantumSuitItem(TRArmorMaterials.QUANTUM, EquipmentSlot.FEET), "quantum_boots"));
// Gem armor & tools
if (TechRebornConfig.enableGemArmorAndTools) {
// Todo: repair with tags
@ -196,26 +165,26 @@ public class ModRegistry {
}
// Battery
RebornRegistry.registerItem(TRContent.RED_CELL_BATTERY = InitUtils.setup(new RedCellBatteryItem(), "red_cell_battery"));
RebornRegistry.registerItem(TRContent.LITHIUM_ION_BATTERY = InitUtils.setup(new LithiumIonBatteryItem(), "lithium_ion_battery"));
RebornRegistry.registerItem(TRContent.LITHIUM_ION_BATPACK = InitUtils.setup(new LithiumIonBatpackItem(), "lithium_ion_batpack"));
RebornRegistry.registerItem(TRContent.ENERGY_CRYSTAL = InitUtils.setup(new EnergyCrystalItem(), "energy_crystal"));
RebornRegistry.registerItem(TRContent.LAPOTRON_CRYSTAL = InitUtils.setup(new LapotronCrystalItem(), "lapotron_crystal"));
RebornRegistry.registerItem(TRContent.LAPOTRONIC_ORB = InitUtils.setup(new LapotronicOrbItem(), "lapotronic_orb"));
RebornRegistry.registerItem(TRContent.LAPOTRONIC_ORBPACK = InitUtils.setup(new LapotronicOrbpackItem(), "lapotronic_orbpack"));
RebornRegistry.registerItem(TRContent.RED_CELL_BATTERY = InitUtils.setup(new BatteryItem(TechRebornConfig.redCellBatteryMaxCharge, EnergyTier.LOW), "red_cell_battery"));
RebornRegistry.registerItem(TRContent.LITHIUM_ION_BATTERY = InitUtils.setup(new BatteryItem(TechRebornConfig.lithiumIonBatteryMaxCharge, EnergyTier.HIGH), "lithium_ion_battery"));
RebornRegistry.registerItem(TRContent.LITHIUM_ION_BATPACK = InitUtils.setup(new BatpackItem(TechRebornConfig.lithiumBatpackCharge, TechRebornConfig.lithiumBatpackTransferRate, TRArmorMaterials.LITHIUM_BATPACK, EnergyTier.HIGH), "lithium_ion_batpack"));
RebornRegistry.registerItem(TRContent.ENERGY_CRYSTAL = InitUtils.setup(new BatteryItem(TechRebornConfig.energyCrystalMaxCharge, EnergyTier.HIGH), "energy_crystal"));
RebornRegistry.registerItem(TRContent.LAPOTRON_CRYSTAL = InitUtils.setup(new BatteryItem(TechRebornConfig.lapotronCrystalMaxCharge, EnergyTier.EXTREME), "lapotron_crystal"));
RebornRegistry.registerItem(TRContent.LAPOTRONIC_ORB = InitUtils.setup(new BatteryItem(TechRebornConfig.lapotronicOrbMaxCharge, EnergyTier.EXTREME), "lapotronic_orb"));
RebornRegistry.registerItem(TRContent.LAPOTRONIC_ORBPACK = InitUtils.setup(new BatpackItem(TechRebornConfig.lapotronPackCharge, TechRebornConfig.lapotronPackTransferRate, TRArmorMaterials.LAPOTRONIC_ORBPACK, EnergyTier.EXTREME), "lapotronic_orbpack"));
// Tools
RebornRegistry.registerItem(TRContent.TREE_TAP = InitUtils.setup(new TreeTapItem(), "treetap"));
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 BasicDrillItem(), "basic_drill"));
RebornRegistry.registerItem(TRContent.BASIC_CHAINSAW = InitUtils.setup(new BasicChainsawItem(), "basic_chainsaw"));
RebornRegistry.registerItem(TRContent.BASIC_JACKHAMMER = InitUtils.setup(new BasicJackhammerItem(), "basic_jackhammer"));
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_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 AdvancedDrillItem(), "advanced_drill"));
RebornRegistry.registerItem(TRContent.ADVANCED_CHAINSAW = InitUtils.setup(new AdvancedChainsawItem(), "advanced_chainsaw"));
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_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

@ -22,14 +22,16 @@
* SOFTWARE.
*/
package techreborn.items.battery;
package techreborn.items;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemPropertyGetter;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
import reborncore.common.powerSystem.PowerSystem;
@ -39,6 +41,7 @@ import team.reborn.energy.Energy;
import team.reborn.energy.EnergyHolder;
import team.reborn.energy.EnergyTier;
import techreborn.TechReborn;
import techreborn.utils.InitUtils;
import javax.annotation.Nullable;
@ -79,7 +82,15 @@ public class BatteryItem extends Item implements EnergyHolder, ItemDurabilityExt
return PowerSystem.getDisplayPower().colour;
}
// IEnergyItemInfo
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> stacks) {
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(this, stacks);
}
// EnergyHolder
@Override
public double getMaxStoredPower() {
return maxEnergy;

View file

@ -30,7 +30,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.Item;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
@ -42,38 +42,31 @@ import team.reborn.energy.Energy;
import team.reborn.energy.EnergyHolder;
import team.reborn.energy.EnergyTier;
import techreborn.TechReborn;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRArmorMaterials;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class LithiumIonBatpackItem extends ArmorItem implements EnergyHolder, ItemDurabilityExtensions {
public class BatpackItem extends ArmorItem implements EnergyHolder, ItemDurabilityExtensions {
// 8M FE maxCharge and 2k FE\t charge rate. Fully charged in 3 mins.
public static final int maxCharge = TechRebornConfig.lithiumBatpackCharge;
public int transferLimit = 2_000;
public final int maxCharge;
public final int transferLimit;
public final EnergyTier tier;
public LithiumIonBatpackItem() {
super(TRArmorMaterials.LITHIUM_BATPACK, EquipmentSlot.CHEST, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
public BatpackItem(int maxCharge, int transferLimit, ArmorMaterial material, EnergyTier tier) {
super(material, EquipmentSlot.CHEST, new Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
this.maxCharge = maxCharge;
this.transferLimit = transferLimit;
this.tier = tier;
}
public static void distributePowerToInventory(World world, PlayerEntity player, ItemStack itemStack, int maxSend) {
if (world.isClient) {
return;
}
if(!Energy.valid(itemStack)){
if (world.isClient || !Energy.valid(itemStack)) {
return;
}
for (int i = 0; i < player.inventory.getInvSize(); i++) {
if (Energy.valid(player.inventory.getInvStack(i))) {
Energy.of(itemStack)
.into(
Energy
.of(player.inventory.getInvStack(i))
)
.move();
.into(Energy.of(player.inventory.getInvStack(i)))
.move();
}
}
}
@ -117,10 +110,10 @@ public class LithiumIonBatpackItem extends ArmorItem implements EnergyHolder, It
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(TRContent.LITHIUM_ION_BATPACK, itemList);
InitUtils.initPoweredItems(this, itemList);
}
// IEnergyItemInfo
// EnergyHolder
@Override
public double getMaxStoredPower() {
return maxCharge;
@ -128,7 +121,7 @@ public class LithiumIonBatpackItem extends ArmorItem implements EnergyHolder, It
@Override
public EnergyTier getTier() {
return EnergyTier.HIGH;
return tier;
}
}

View file

@ -43,14 +43,12 @@ import team.reborn.energy.EnergyTier;
import techreborn.TechReborn;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRArmorMaterials;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class CloakingDeviceItem extends TRArmourItem implements EnergyHolder, ArmorTickable, ArmorRemoveHandler {
public static int maxCharge = TechRebornConfig.cloakingDeviceCharge;
public static int usage = TechRebornConfig.cloackingDeviceUsage;
public static int transferLimit = 10_000;
public static int cost = TechRebornConfig.cloackingDeviceCost;
public static boolean isActive;
// 40M FE capacity with 10k FE\t charge rate
@ -91,7 +89,7 @@ public class CloakingDeviceItem extends TRArmourItem implements EnergyHolder, Ar
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(TRContent.CLOAKING_DEVICE, itemList);
InitUtils.initPoweredItems(this, itemList);
}
// EnergyHolder
@ -102,12 +100,7 @@ public class CloakingDeviceItem extends TRArmourItem implements EnergyHolder, Ar
@Override
public EnergyTier getTier() {
return EnergyTier.HIGH;
}
@Override
public double getMaxInput(EnergySide side) {
return transferLimit;
return EnergyTier.INSANE;
}
@Override
@ -118,7 +111,7 @@ public class CloakingDeviceItem extends TRArmourItem implements EnergyHolder, Ar
// ArmorTickable
@Override
public void tickArmor(ItemStack stack, PlayerEntity playerEntity) {
if (Energy.of(stack).use(usage)) {
if (Energy.of(stack).use(cost)) {
playerEntity.setInvisible(true);
} else {
if (playerEntity.isInvisible()) {

View file

@ -1,108 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.items.armor;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import net.minecraft.world.World;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils;
import team.reborn.energy.EnergyHolder;
import team.reborn.energy.EnergyTier;
import techreborn.TechReborn;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRArmorMaterials;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class LapotronicOrbpackItem extends ArmorItem implements EnergyHolder, ItemDurabilityExtensions {
// 400M FE maxCharge and 100k FE\t charge rate. Fully charged in 3 mins.
public static final int maxCharge = TechRebornConfig.lapotronPackCharge;
public int transferLimit = 100_000;
public LapotronicOrbpackItem() {
super(TRArmorMaterials.LAPOTRONIC_ORBPACK, EquipmentSlot.CHEST, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
}
// Item
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(TRContent.LAPOTRONIC_ORBPACK, itemList);
}
@Override
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (entityIn instanceof PlayerEntity) {
LithiumIonBatpackItem.distributePowerToInventory(worldIn, (PlayerEntity) entityIn, stack, transferLimit);
}
}
@Override
public boolean isDamageable() {
return false;
}
@Override
public double getDurability(ItemStack stack) {
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
}
@Override
public boolean showDurability(ItemStack stack) {
return true;
}
@Override
public boolean isEnchantable(ItemStack stack) {
return true;
}
@Override
public int getDurabilityColor(ItemStack stack) {
return PowerSystem.getDisplayPower().colour;
}
// IEnergyItemInfo
@Override
public double getMaxStoredPower() {
return maxCharge;
}
@Override
public EnergyTier getTier() {
return EnergyTier.EXTREME;
}
}

View file

@ -50,14 +50,15 @@ import team.reborn.energy.EnergyHolder;
import team.reborn.energy.EnergySide;
import team.reborn.energy.EnergyTier;
import techreborn.TechReborn;
import techreborn.config.TechRebornConfig;
import techreborn.utils.InitUtils;
public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers, ArmorTickable, ArmorRemoveHandler, ArmorFovHandler, EnergyHolder {
public static final double ENERGY_FLY = 50;
public static final double ENERGY_SWIM = 20;
public static final double ENERGY_BREATHING = 20;
public static final double ENERGY_SPRINTING = 20;
public final double flyCost = TechRebornConfig.quantumSuitFlyingCost;
public final double swimCost = TechRebornConfig.quantumSuitSwimmingCost;
public final double breathingCost = TechRebornConfig.quantumSuitBreathingCost;
public final double sprintingCost = TechRebornConfig.quantumSuitSprintingCost;
public QuantumSuitItem(ArmorMaterial material, EquipmentSlot slot) {
super(material, slot, new Item.Settings().group(TechReborn.ITEMGROUP).maxDamage(-1).maxCount(1));
@ -68,7 +69,7 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
attributes.removeAll(EntityAttributes.MOVEMENT_SPEED.getId());
if (this.slot == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS) {
if (Energy.of(stack).getEnergy() > ENERGY_SPRINTING) {
if (Energy.of(stack).getEnergy() > sprintingCost) {
attributes.put(EntityAttributes.MOVEMENT_SPEED.getId(), new EntityAttributeModifier(MODIFIERS[equipmentSlot.getEntitySlotId()], "Movement Speed", 0.15, EntityAttributeModifier.Operation.ADDITION));
}
}
@ -84,16 +85,16 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
switch (this.slot) {
case HEAD:
if (playerEntity.isInWater()) {
if (Energy.of(stack).use(ENERGY_BREATHING)) {
if (Energy.of(stack).use(breathingCost)) {
playerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.WATER_BREATHING, 5, 1));
}
}
break;
case CHEST:
if (Energy.of(stack).getEnergy() > ENERGY_FLY) {
if (Energy.of(stack).getEnergy() > flyCost) {
playerEntity.abilities.allowFlying = true;
if (playerEntity.abilities.flying) {
Energy.of(stack).use(ENERGY_FLY);
Energy.of(stack).use(flyCost);
}
} else {
playerEntity.abilities.allowFlying = false;
@ -102,12 +103,12 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
break;
case LEGS:
if (playerEntity.isSprinting()) {
Energy.of(stack).use(ENERGY_SPRINTING);
Energy.of(stack).use(sprintingCost);
}
break;
case FEET:
if (playerEntity.isSwimming()) {
if (Energy.of(stack).use(ENERGY_SWIM)) {
if (Energy.of(stack).use(swimCost)) {
playerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.DOLPHINS_GRACE, 5, 1));
}
}
@ -134,7 +135,7 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
@Override
public float changeFov(float old, ItemStack stack, PlayerEntity playerEntity) {
if (this.slot == EquipmentSlot.LEGS && Energy.of(stack).getEnergy() > ENERGY_SPRINTING) {
if (this.slot == EquipmentSlot.LEGS && Energy.of(stack).getEnergy() > sprintingCost) {
old -= 0.6; //TODO possibly make it better
}
return old;
@ -167,17 +168,12 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
@Override
public double getMaxStoredPower() {
return 40_000_000;
return TechRebornConfig.quantumSuitCapacity;
}
@Override
public EnergyTier getTier() {
return EnergyTier.HIGH;
}
@Override
public double getMaxInput(EnergySide side) {
return 2048;
return EnergyTier.EXTREME;
}
@Environment(EnvType.CLIENT)

View file

@ -1,52 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.items.battery;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import team.reborn.energy.EnergyTier;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class EnergyCrystalItem extends BatteryItem {
// 4M FE storage with 1k charge rate
public EnergyCrystalItem() {
super(TechRebornConfig.energyCrystalMaxCharge, EnergyTier.HIGH);
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(TRContent.ENERGY_CRYSTAL, itemList);
}
}

View file

@ -1,52 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.items.battery;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import team.reborn.energy.EnergyTier;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class LapotronCrystalItem extends BatteryItem {
// 40M FE capacity with 10k FE\t charge rate
public LapotronCrystalItem() {
super(TechRebornConfig.lapotronCrystalMaxCharge, EnergyTier.EXTREME);
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(TRContent.LAPOTRON_CRYSTAL, itemList);
}
}

View file

@ -1,52 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.items.battery;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import team.reborn.energy.EnergyTier;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class LapotronicOrbItem extends BatteryItem {
// 400M capacity with 100k FE\t charge rate
public LapotronicOrbItem() {
super(TechRebornConfig.lapotronicOrbMaxCharge, EnergyTier.EXTREME);
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(TRContent.LAPOTRONIC_ORB, itemList);
}
}

View file

@ -1,52 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.items.battery;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import team.reborn.energy.EnergyTier;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class LithiumIonBatteryItem extends BatteryItem {
// 400k FE with 1k FE\t charge rate
public LithiumIonBatteryItem() {
super(400_000, EnergyTier.HIGH);
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(TRContent.LITHIUM_ION_BATTERY, itemList);
}
}

View file

@ -1,51 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.items.battery;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import team.reborn.energy.EnergyTier;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class RedCellBatteryItem extends BatteryItem {
// 40k FE capacity with 100 FE\t charge rate
public RedCellBatteryItem() {
super(40_000, EnergyTier.LOW);
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(TRContent.RED_CELL_BATTERY, itemList);
}
}

View file

@ -29,10 +29,8 @@ import net.minecraft.block.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterials;
import net.minecraft.item.*;
import net.minecraft.util.DefaultedList;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -44,19 +42,25 @@ import team.reborn.energy.EnergyHolder;
import team.reborn.energy.EnergySide;
import team.reborn.energy.EnergyTier;
import techreborn.TechReborn;
import techreborn.utils.InitUtils;
import java.util.Random;
public class ChainsawItem extends AxeItem implements EnergyHolder, ItemDurabilityExtensions {
public int maxCharge;
public int cost = 250;
public float poweredSpeed = 20F;
public int transferLimit = 100;
public final int maxCharge;
public final int cost;
public final float poweredSpeed;
public final Item referenceTool;
public final EnergyTier tier;
public ChainsawItem(ToolMaterials material, int energyCapacity, float unpoweredSpeed) {
public ChainsawItem(ToolMaterials material, int energyCapacity, EnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, Item referenceTool) {
super(material, (int) material.getAttackDamage(), unpoweredSpeed, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
this.maxCharge = energyCapacity;
this.tier = tier;
this.cost = cost;
this.poweredSpeed = poweredSpeed;
this.referenceTool = referenceTool;
this.addPropertyGetter(new Identifier("techreborn", "animated"), (stack, worldIn, entityIn) -> {
if (!stack.isEmpty() && Energy.of(stack).getEnergy() >= cost
@ -105,7 +109,22 @@ public class ChainsawItem extends AxeItem implements EnergyHolder, ItemDurabilit
}
@Override
public boolean isEnchantable(ItemStack stack) { return true; }
public boolean isEnchantable(ItemStack stack) {
return true;
}
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> stacks) {
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(this, stacks);
}
@Override
public boolean isEffectiveOn(BlockState state) {
return referenceTool.isEffectiveOn(state);
}
// ItemDurabilityExtensions
@Override
@ -131,12 +150,7 @@ public class ChainsawItem extends AxeItem implements EnergyHolder, ItemDurabilit
@Override
public EnergyTier getTier() {
return EnergyTier.MEDIUM;
}
@Override
public double getMaxInput(EnergySide side) {
return transferLimit;
return tier;
}
@Override

View file

@ -25,12 +25,9 @@
package techreborn.items.tool;
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.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.util.DefaultedList;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils;
@ -39,48 +36,41 @@ import team.reborn.energy.EnergyHolder;
import team.reborn.energy.EnergySide;
import team.reborn.energy.EnergyTier;
import techreborn.TechReborn;
import java.util.Random;
import techreborn.utils.InitUtils;
public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabilityExtensions {
public int maxCharge;
public int cost = 250;
public float unpoweredSpeed;
public float poweredSpeed;
public int transferLimit = 100;
public final int maxCharge;
public final int cost;
public final float poweredSpeed;
public final Item referencePickaxe;
public final Item referenceShovel;
public final EnergyTier tier;
public DrillItem(ToolMaterial material, int energyCapacity, float unpoweredSpeed, float efficiencyOnProperMaterial) {
public DrillItem(ToolMaterials material, int energyCapacity, EnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, Item referencePickaxe, Item referenceShovel) {
super(material, (int) material.getAttackDamage(), unpoweredSpeed, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
this.maxCharge = energyCapacity;
this.unpoweredSpeed = unpoweredSpeed;
this.poweredSpeed = efficiencyOnProperMaterial;
this.cost = cost;
this.poweredSpeed = poweredSpeed;
this.referencePickaxe = referencePickaxe;
this.referenceShovel = referenceShovel;
this.tier = tier;
}
// PickaxeItem
@Override
public float getMiningSpeed(ItemStack stack, BlockState state) {
if (Energy.of(stack).getEnergy() < cost) {
return unpoweredSpeed;
}
if (Items.WOODEN_PICKAXE.getMiningSpeed(stack, state) > 1.0F
|| Items.WOODEN_SHOVEL.getMiningSpeed(stack, state) > 1.0F) {
return poweredSpeed;
} else {
return super.getMiningSpeed(stack, state);
}
if (Items.WOODEN_PICKAXE.getMiningSpeed(stack, state) > 1.0F
|| Items.WOODEN_SHOVEL.getMiningSpeed(stack, state) > 1.0F) {
return poweredSpeed;
}
return super.getMiningSpeed(stack, state);
}
// MiningToolItem
@Override
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
Random rand = new Random();
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
Energy.of(stack).use(cost);
}
return true;
}
@Override
public boolean postHit(ItemStack itemstack, LivingEntity entityliving, LivingEntity entityliving1) {
return true;
@ -99,7 +89,22 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
}
@Override
public boolean isEnchantable(ItemStack stack) { return true; }
public boolean isEnchantable(ItemStack stack) {
return true;
}
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> stacks) {
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(this, stacks);
}
@Override
public boolean isEffectiveOn(BlockState state) {
return referencePickaxe.isEffectiveOn(state) || referenceShovel.isEffectiveOn(state);
}
// ItemDurabilityExtensions
@Override
@ -125,12 +130,7 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
@Override
public EnergyTier getTier() {
return EnergyTier.HIGH;
}
@Override
public double getMaxInput(EnergySide side) {
return transferLimit;
return tier;
}
@Override

View file

@ -29,10 +29,8 @@ import net.minecraft.block.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.PickaxeItem;
import net.minecraft.item.ToolMaterials;
import net.minecraft.item.*;
import net.minecraft.util.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.common.powerSystem.PowerSystem;
@ -43,18 +41,21 @@ import team.reborn.energy.EnergyHolder;
import team.reborn.energy.EnergySide;
import team.reborn.energy.EnergyTier;
import techreborn.TechReborn;
import techreborn.utils.InitUtils;
import java.util.Random;
public class JackhammerItem extends PickaxeItem implements EnergyHolder, ItemDurabilityExtensions {
public int maxCharge;
public int cost = 250;
public int transferLimit = EnergyTier.MEDIUM.getMaxInput();
public final int maxCharge;
public final int cost;
public final EnergyTier tier;
public JackhammerItem(ToolMaterials material, int energyCapacity) {
super(material, (int) material.getAttackDamage(), 1f, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
public JackhammerItem(ToolMaterials material, int energyCapacity, EnergyTier tier, int cost) {
super(material, (int) material.getAttackDamage(), 1F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
this.maxCharge = energyCapacity;
this.cost = cost;
this.tier = tier;
}
// PickaxeItem
@ -62,9 +63,8 @@ public class JackhammerItem extends PickaxeItem implements EnergyHolder, ItemDur
public float getMiningSpeed(ItemStack stack, BlockState state) {
if (state.getMaterial() == Material.STONE && Energy.of(stack).getEnergy() >= cost) {
return miningSpeed;
} else {
return 0.5F;
}
return 0.5F;
}
// MiningToolItem
@ -95,7 +95,17 @@ public class JackhammerItem extends PickaxeItem implements EnergyHolder, ItemDur
// Item
@Override
public boolean isEnchantable(ItemStack stack) { return true; }
public boolean isEnchantable(ItemStack stack) {
return true;
}
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> stacks) {
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(this, stacks);
}
// ItemDurabilityExtensions
@Override
@ -121,12 +131,7 @@ public class JackhammerItem extends PickaxeItem implements EnergyHolder, ItemDur
@Override
public EnergyTier getTier() {
return EnergyTier.MEDIUM;
}
@Override
public double getMaxInput(EnergySide side) {
return transferLimit;
return tier;
}
@Override

View file

@ -1,63 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.items.tool.advanced;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.DefaultedList;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.ChainsawItem;
import techreborn.utils.InitUtils;
public class AdvancedChainsawItem extends ChainsawItem {
// 400k max charge with 1k charge rate
public AdvancedChainsawItem() {
super(ToolMaterials.DIAMOND, TechRebornConfig.advancedChainsawCharge, 1.0F);
this.cost = 100;
this.transferLimit = 1000;
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup par2ItemGroup, DefaultedList<ItemStack> itemList) {
if (!isIn(par2ItemGroup)) {
return;
}
InitUtils.initPoweredItems(TRContent.ADVANCED_CHAINSAW, itemList);
}
@Override
public boolean isEffectiveOn(BlockState blockIn) {
return Items.DIAMOND_AXE.isEffectiveOn(blockIn);
}
}

View file

@ -1,63 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.items.tool.advanced;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.DefaultedList;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.DrillItem;
import techreborn.utils.InitUtils;
public class AdvancedDrillItem extends DrillItem {
// 400k max charge with 1k charge rate
public AdvancedDrillItem() {
super(ToolMaterials.DIAMOND, TechRebornConfig.advancedDrillCharge, 0.5F, 12F);
this.cost = 100;
this.transferLimit = 1000;
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup par2ItemGroup, DefaultedList<ItemStack> itemList) {
if (!isIn(par2ItemGroup)) {
return;
}
InitUtils.initPoweredItems(TRContent.ADVANCED_DRILL, itemList);
}
@Override
public boolean isEffectiveOn(BlockState state) {
return Items.DIAMOND_PICKAXE.isEffectiveOn(state) || Items.DIAMOND_SHOVEL.isEffectiveOn(state);
}
}

View file

@ -30,13 +30,11 @@ import net.minecraft.block.*;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.DefaultedList;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.hit.BlockHitResult;
@ -46,10 +44,9 @@ import net.minecraft.util.math.Direction;
import net.minecraft.world.RayTraceContext;
import net.minecraft.world.World;
import reborncore.common.util.ItemUtils;
import team.reborn.energy.EnergyTier;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.JackhammerItem;
import techreborn.utils.InitUtils;
import techreborn.utils.MessageIDs;
import techreborn.utils.ToolsUtil;
@ -61,119 +58,107 @@ import java.util.Set;
public class AdvancedJackhammerItem extends JackhammerItem {
// 400k max charge with 1k charge rate
public AdvancedJackhammerItem() {
super(ToolMaterials.DIAMOND, TechRebornConfig.advancedJackhammerCharge);
this.cost = 100;
this.transferLimit = 1000;
super(ToolMaterials.DIAMOND, TechRebornConfig.advancedJackhammerCharge, EnergyTier.EXTREME, TechRebornConfig.advancedJackhammerCost);
}
private Set<BlockPos> getTargetBlocks(World worldIn, BlockPos pos, @Nullable LivingEntity entityLiving) {
Set<BlockPos> targetBlocks = new HashSet<>();
if (!(entityLiving instanceof PlayerEntity)) {
return new HashSet<>();
}
PlayerEntity playerIn = (PlayerEntity) entityLiving;
private Set<BlockPos> getTargetBlocks(World worldIn, BlockPos pos, @Nullable LivingEntity entityLiving) {
Set<BlockPos> targetBlocks = new HashSet<>();
if (!(entityLiving instanceof PlayerEntity)) {
return new HashSet<>();
}
PlayerEntity playerIn = (PlayerEntity) entityLiving;
//Put a dirt block down to raytrace with to stop it raytracing past the intended block
worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState());
HitResult hitResult = rayTrace(worldIn, playerIn, RayTraceContext.FluidHandling.NONE);
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
//Put a dirt block down to raytrace with to stop it raytracing past the intended block
worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState());
HitResult hitResult = rayTrace(worldIn, playerIn, RayTraceContext.FluidHandling.NONE);
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
if(!(hitResult instanceof BlockHitResult)){
return Collections.emptySet();
}
Direction enumfacing = ((BlockHitResult) hitResult).getSide();
if (enumfacing == Direction.SOUTH || enumfacing == Direction.NORTH) {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
BlockPos newPos = pos.add(i, j, 0);
if (shouldBreak(worldIn, pos, newPos)) {
targetBlocks.add(newPos);
}
}
}
} else if (enumfacing == Direction.EAST || enumfacing == Direction.WEST) {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
BlockPos newPos = pos.add(0, j, i);
if (shouldBreak(worldIn, pos, newPos)) {
targetBlocks.add(newPos);
}
}
}
} else if (enumfacing == Direction.DOWN || enumfacing == Direction.UP) {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
BlockPos newPos = pos.add(j, 0, i);
if (shouldBreak(worldIn, pos, newPos)) {
targetBlocks.add(newPos);
}
}
}
}
return targetBlocks;
}
if (!(hitResult instanceof BlockHitResult)) {
return Collections.emptySet();
}
Direction enumfacing = ((BlockHitResult) hitResult).getSide();
if (enumfacing == Direction.SOUTH || enumfacing == Direction.NORTH) {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
BlockPos newPos = pos.add(i, j, 0);
if (shouldBreak(worldIn, pos, newPos)) {
targetBlocks.add(newPos);
}
}
}
} else if (enumfacing == Direction.EAST || enumfacing == Direction.WEST) {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
BlockPos newPos = pos.add(0, j, i);
if (shouldBreak(worldIn, pos, newPos)) {
targetBlocks.add(newPos);
}
}
}
} else if (enumfacing == Direction.DOWN || enumfacing == Direction.UP) {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
BlockPos newPos = pos.add(j, 0, i);
if (shouldBreak(worldIn, pos, newPos)) {
targetBlocks.add(newPos);
}
}
}
}
return targetBlocks;
}
private boolean shouldBreak(World worldIn, BlockPos originalPos, BlockPos pos) {
if (originalPos.equals(pos)) {
return false;
}
BlockState blockState = worldIn.getBlockState(pos);
if (blockState.getMaterial() == Material.AIR) {
return false;
}
if (blockState.getMaterial().isLiquid()) {
return false;
}
if (blockState.getBlock() instanceof OreBlock){
return false;
}
if (blockState.getBlock() instanceof RedstoneOreBlock){
return false;
}
return (Items.IRON_PICKAXE.isEffectiveOn(blockState));
}
private boolean shouldBreak(World worldIn, BlockPos originalPos, BlockPos pos) {
if (originalPos.equals(pos)) {
return false;
}
BlockState blockState = worldIn.getBlockState(pos);
if (blockState.getMaterial() == Material.AIR) {
return false;
}
if (blockState.getMaterial().isLiquid()) {
return false;
}
if (blockState.getBlock() instanceof OreBlock) {
return false;
}
if (blockState.getBlock() instanceof RedstoneOreBlock) {
return false;
}
return (Items.IRON_PICKAXE.isEffectiveOn(blockState));
}
// JackhammerItem
@Override
public boolean postMine(ItemStack stack, World worldIn, BlockState stateIn, BlockPos pos, LivingEntity entityLiving) {
if(ItemUtils.isActive(stack)){
for (BlockPos additionalPos : getTargetBlocks(worldIn, pos, entityLiving)) {
ToolsUtil.breakBlock(stack, worldIn, additionalPos, entityLiving, cost);
}
}
return super.postMine(stack, worldIn, stateIn, pos, entityLiving);
}
// JackhammerItem
@Override
public boolean postMine(ItemStack stack, World worldIn, BlockState stateIn, BlockPos pos, LivingEntity entityLiving) {
if (ItemUtils.isActive(stack)) {
for (BlockPos additionalPos : getTargetBlocks(worldIn, pos, entityLiving)) {
ToolsUtil.breakBlock(stack, worldIn, additionalPos, entityLiving, cost);
}
}
return super.postMine(stack, worldIn, stateIn, pos, entityLiving);
}
// Item
@Override
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
final ItemStack stack = player.getStackInHand(hand);
if (player.isSneaking()) {
ItemUtils.switchActive(stack, cost, world.isClient, MessageIDs.poweredToolID);
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
}
return new TypedActionResult<>(ActionResult.PASS, stack);
}
// Item
@Override
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
final ItemStack stack = player.getStackInHand(hand);
if (player.isSneaking()) {
ItemUtils.switchActive(stack, cost, world.isClient, MessageIDs.poweredToolID);
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
}
return new TypedActionResult<>(ActionResult.PASS, stack);
}
@Override
public void usageTick(World world, LivingEntity entity, ItemStack stack, int i) {
ItemUtils.checkActive(stack, cost, entity.world.isClient, MessageIDs.poweredToolID);
}
@Environment(EnvType.CLIENT)
@Override
public void appendTooltip(ItemStack stack, @Nullable World worldIn, List<Text> tooltip, TooltipContext flagIn) {
ItemUtils.buildActiveTooltip(stack, tooltip);
}
@Override
public void usageTick(World world, LivingEntity entity, ItemStack stack, int i) {
ItemUtils.checkActive(stack, cost, entity.world.isClient, MessageIDs.poweredToolID);
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup par2ItemGroup, DefaultedList<ItemStack> itemList) {
if (!isIn(par2ItemGroup)) {
return;
}
InitUtils.initPoweredItems(TRContent.ADVANCED_JACKHAMMER, itemList);
public void appendTooltip(ItemStack stack, @Nullable World worldIn, List<Text> tooltip, TooltipContext flagIn) {
ItemUtils.buildActiveTooltip(stack, tooltip);
}
}

View file

@ -51,8 +51,7 @@ import java.util.Random;
public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDurabilityExtensions {
public static final int maxCharge = TechRebornConfig.rockCutterCharge;
public int transferLimit = 1_000;
public int cost = 500;
public int cost = TechRebornConfig.rockCutterCost;
// 400k FE with 1k FE\t charge rate
public RockCutterItem() {
@ -109,12 +108,14 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
}
@Override
public boolean isEnchantable(ItemStack stack) { return true; }
public boolean isEnchantable(ItemStack stack) {
return true;
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup par2ItemGroup, DefaultedList<ItemStack> itemList) {
if (!isIn(par2ItemGroup)) {
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> stacks) {
if (!isIn(group)) {
return;
}
ItemStack uncharged = new ItemStack(this);
@ -123,8 +124,8 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
charged.addEnchantment(Enchantments.SILK_TOUCH, 1);
Energy.of(charged).set(Energy.of(charged).getMaxStored());
itemList.add(uncharged);
itemList.add(charged);
stacks.add(uncharged);
stacks.add(charged);
}
// ItemDurabilityExtensions
@ -151,12 +152,7 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
@Override
public EnergyTier getTier() {
return EnergyTier.HIGH;
}
@Override
public double getMaxInput(EnergySide side) {
return transferLimit;
return EnergyTier.EXTREME;
}
@Override

View file

@ -1,60 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.items.tool.basic;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.DefaultedList;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.ChainsawItem;
import techreborn.utils.InitUtils;
public class BasicChainsawItem extends ChainsawItem {
public BasicChainsawItem() {
super(ToolMaterials.IRON, TechRebornConfig.basicChainsawCharge, 0.5F);
this.cost = 50;
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup par2ItemGroup, DefaultedList<ItemStack> itemList) {
if (!isIn(par2ItemGroup)) {
return;
}
InitUtils.initPoweredItems(TRContent.BASIC_CHAINSAW, itemList);
}
@Override
public boolean isEffectiveOn(BlockState state) {
return Items.IRON_AXE.isEffectiveOn(state);
}
}

View file

@ -1,60 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.items.tool.basic;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.DefaultedList;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.DrillItem;
import techreborn.utils.InitUtils;
public class BasicDrillItem extends DrillItem {
public BasicDrillItem() {
super(ToolMaterials.IRON, TechRebornConfig.basicDrillCharge, 0.5F, 10F);
this.cost = 50;
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup par2ItemGroup, DefaultedList<ItemStack> itemList) {
if (!isIn(par2ItemGroup)) {
return;
}
InitUtils.initPoweredItems(TRContent.BASIC_DRILL, itemList);
}
@Override
public boolean isEffectiveOn(BlockState state) {
return Items.IRON_PICKAXE.isEffectiveOn(state) || Items.IRON_SHOVEL.isEffectiveOn(state);
}
}

View file

@ -1,53 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.items.tool.basic;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.DefaultedList;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.JackhammerItem;
import techreborn.utils.InitUtils;
public class BasicJackhammerItem extends JackhammerItem {
public BasicJackhammerItem() {
super(ToolMaterials.DIAMOND, TechRebornConfig.basicJackhammerCharge);
this.cost = 50;
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup par2ItemGroup, DefaultedList<ItemStack> itemList) {
if (!isIn(par2ItemGroup)) {
return;
}
InitUtils.initPoweredItems(TRContent.BASIC_JACKHAMMER, itemList);
}
}

View file

@ -36,7 +36,7 @@ import reborncore.common.util.ItemUtils;
import team.reborn.energy.EnergyHolder;
import team.reborn.energy.EnergyTier;
import techreborn.TechReborn;
import techreborn.init.TRContent;
import techreborn.config.TechRebornConfig;
import techreborn.utils.InitUtils;
/**
@ -44,8 +44,9 @@ import techreborn.utils.InitUtils;
*/
public class ElectricTreetapItem extends Item implements EnergyHolder, ItemDurabilityExtensions {
public static final int maxCharge = 10_000;
public int cost = 20;
public final int maxCharge = TechRebornConfig.electricTreetapCharge;
public int cost = TechRebornConfig.electricTreetapCost;
public EnergyTier tier = EnergyTier.MEDIUM;
public ElectricTreetapItem() {
super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
@ -73,14 +74,14 @@ public class ElectricTreetapItem extends Item implements EnergyHolder, ItemDurab
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup par2ItemGroup, DefaultedList<ItemStack> itemList) {
if (!isIn(par2ItemGroup)) {
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> stacks) {
if (!isIn(group)) {
return;
}
InitUtils.initPoweredItems(TRContent.ELECTRIC_TREE_TAP, itemList);
InitUtils.initPoweredItems(this, stacks);
}
// IEnergyItemInfo
// EnergyHolder
@Override
public double getMaxStoredPower() {
return maxCharge;
@ -88,6 +89,6 @@ public class ElectricTreetapItem extends Item implements EnergyHolder, ItemDurab
@Override
public EnergyTier getTier() {
return EnergyTier.MEDIUM;
return tier;
}
}

View file

@ -30,14 +30,12 @@ import net.minecraft.block.BlockState;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.tag.BlockTags;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.DefaultedList;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPos;
@ -45,10 +43,9 @@ import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import reborncore.common.util.ItemUtils;
import team.reborn.energy.Energy;
import team.reborn.energy.EnergyTier;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.ChainsawItem;
import techreborn.utils.InitUtils;
import techreborn.utils.MessageIDs;
import techreborn.utils.TagUtils;
import techreborn.utils.ToolsUtil;
@ -61,30 +58,27 @@ public class IndustrialChainsawItem extends ChainsawItem {
private static final Direction[] SEARCH_ORDER = new Direction[]{Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST, Direction.UP};
// 4M FE max charge with 1k charge rate
public IndustrialChainsawItem() {
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialChainsawCharge, 1.0F);
this.cost = 250;
this.transferLimit = 1000;
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialChainsawCharge, EnergyTier.EXTREME, TechRebornConfig.industrialChainsawCost, 20F, 1.0F, Items.DIAMOND_AXE);
}
private void findWood(World world, BlockPos pos, List<BlockPos> wood, List<BlockPos> leaves){
private void findWood(World world, BlockPos pos, List<BlockPos> wood, List<BlockPos> leaves) {
//Limit the amount of wood to be broken to 64 blocks.
if(wood.size() >= 64){
if (wood.size() >= 64) {
return;
}
//Search 150 leaves for wood
if(leaves.size() >= 150){
if (leaves.size() >= 150) {
return;
}
for(Direction facing : SEARCH_ORDER){
for (Direction facing : SEARCH_ORDER) {
BlockPos checkPos = pos.offset(facing);
if(!wood.contains(checkPos) && !leaves.contains(checkPos)){
if (!wood.contains(checkPos) && !leaves.contains(checkPos)) {
BlockState state = world.getBlockState(checkPos);
if(TagUtils.hasTag(state.getBlock(), BlockTags.LOGS)){
if (TagUtils.hasTag(state.getBlock(), BlockTags.LOGS)) {
wood.add(checkPos);
findWood(world, checkPos, wood, leaves);
} else if(TagUtils.hasTag(state.getBlock(), BlockTags.LEAVES)){
} else if (TagUtils.hasTag(state.getBlock(), BlockTags.LEAVES)) {
leaves.add(checkPos);
findWood(world, checkPos, wood, leaves);
}
@ -110,14 +104,6 @@ public class IndustrialChainsawItem extends ChainsawItem {
}
// Item
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup par2ItemGroup, DefaultedList<ItemStack> itemList) {
if (!isIn(par2ItemGroup)) {
return;
}
InitUtils.initPoweredItems(TRContent.INDUSTRIAL_CHAINSAW, itemList);
}
@Override
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
@ -130,7 +116,7 @@ public class IndustrialChainsawItem extends ChainsawItem {
}
@Override
public void usageTick(World world, LivingEntity entity, ItemStack stack, int i) {
public void usageTick(World world, LivingEntity entity, ItemStack stack, int i) {
ItemUtils.checkActive(stack, cost, entity.world.isClient, MessageIDs.poweredToolID);
}
@ -139,9 +125,4 @@ public class IndustrialChainsawItem extends ChainsawItem {
public void appendTooltip(ItemStack stack, @Nullable World worldIn, List<Text> tooltip, TooltipContext flagIn) {
ItemUtils.buildActiveTooltip(stack, tooltip);
}
@Override
public boolean isEffectiveOn(BlockState blockIn) {
return Items.DIAMOND_AXE.isEffectiveOn(blockIn);
}
}

View file

@ -24,6 +24,7 @@
package techreborn.items.tool.industrial;
import com.google.common.collect.ImmutableSet;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
@ -48,7 +49,7 @@ import net.minecraft.util.math.Direction;
import net.minecraft.world.RayTraceContext;
import net.minecraft.world.World;
import reborncore.common.util.ItemUtils;
import team.reborn.energy.Energy;
import team.reborn.energy.EnergyTier;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.DrillItem;
@ -64,18 +65,15 @@ import java.util.Set;
public class IndustrialDrillItem extends DrillItem {
// 4M FE max charge with 1k charge rate
public IndustrialDrillItem() {
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialDrillCharge, 2.0F, 15F);
this.cost = 250;
this.transferLimit = 1000;
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialDrillCharge, EnergyTier.INSANE, TechRebornConfig.industrialDrillCost, 15.0F, 2.0F, Items.DIAMOND_PICKAXE, Items.DIAMOND_SHOVEL);
}
private Set<BlockPos> getTargetBlocks(World worldIn, BlockPos pos, @Nullable LivingEntity entityLiving) {
Set<BlockPos> targetBlocks = new HashSet<>();
if (!(entityLiving instanceof PlayerEntity) || entityLiving == null) {
return new HashSet<>();
if (!(entityLiving instanceof PlayerEntity)) {
return ImmutableSet.of();
}
Set<BlockPos> targetBlocks = new HashSet<>();
PlayerEntity playerIn = (PlayerEntity) entityLiving;
//Put a dirt block down to raytrace with to stop it raytracing past the intended block
@ -83,7 +81,7 @@ public class IndustrialDrillItem extends DrillItem {
HitResult hitResult = rayTrace(worldIn, playerIn, RayTraceContext.FluidHandling.NONE);
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
if(!(hitResult instanceof BlockHitResult)){
if (!(hitResult instanceof BlockHitResult)) {
return Collections.emptySet();
}
Direction enumfacing = ((BlockHitResult) hitResult).getSide();
@ -140,7 +138,7 @@ public class IndustrialDrillItem extends DrillItem {
// DrillItem
@Override
public boolean postMine(ItemStack stack, World worldIn, BlockState stateIn, BlockPos pos, LivingEntity entityLiving) {
if(ItemUtils.isActive(stack)){
if (ItemUtils.isActive(stack)) {
for (BlockPos additionalPos : getTargetBlocks(worldIn, pos, entityLiving)) {
ToolsUtil.breakBlock(stack, worldIn, additionalPos, entityLiving, cost);
}
@ -166,7 +164,7 @@ public class IndustrialDrillItem extends DrillItem {
}
@Override
public void usageTick(World world, LivingEntity entity, ItemStack stack, int i) {
public void usageTick(World world, LivingEntity entity, ItemStack stack, int i) {
ItemUtils.checkActive(stack, cost, entity.world.isClient, MessageIDs.poweredToolID);
}

View file

@ -30,13 +30,15 @@ import net.minecraft.block.*;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.*;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
@ -47,10 +49,9 @@ import reborncore.common.util.ChatUtils;
import reborncore.common.util.ItemUtils;
import reborncore.common.util.StringUtils;
import team.reborn.energy.Energy;
import team.reborn.energy.EnergyTier;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.JackhammerItem;
import techreborn.utils.InitUtils;
import techreborn.utils.MessageIDs;
import techreborn.utils.ToolsUtil;
@ -62,35 +63,27 @@ import java.util.Set;
public class IndustrialJackhammerItem extends JackhammerItem {
// 4M FE max charge with 1k charge rate
public IndustrialJackhammerItem() {
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialJackhammerCharge);
this.cost = 250;
this.transferLimit = 1000;
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialJackhammerCharge, EnergyTier.INSANE, TechRebornConfig.industrialJackhammerCost);
}
// Cycle Inactive, Active 3*3 and Active 5*5
private void switchAOE(ItemStack stack, int cost, boolean isClient, int messageId){
private void switchAOE(ItemStack stack, int cost, boolean isClient, int messageId) {
ItemUtils.checkActive(stack, cost, isClient, messageId);
if (!ItemUtils.isActive(stack)) {
ItemUtils.switchActive(stack, cost, isClient, messageId);
stack.getOrCreateTag().putBoolean("AOE5", false);
if (isClient) {
ChatUtils.sendNoSpamMessages(messageId, new LiteralText(
Formatting.GRAY + StringUtils.t("techreborn.message.setTo") + " "
+ Formatting.GOLD + "3*3"));
ChatUtils.sendNoSpamMessages(messageId, new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.message.setTo") + " " + Formatting.GOLD + "3*3"));
}
} else {
if (isAOE(stack)){
if (isAOE(stack)) {
ItemUtils.switchActive(stack, cost, isClient, messageId);
stack.getOrCreateTag().putBoolean("AOE5", false);
}
else {
} else {
stack.getOrCreateTag().putBoolean("AOE5", true);
if (isClient) {
ChatUtils.sendNoSpamMessages(messageId, new LiteralText(
Formatting.GRAY + StringUtils.t("techreborn.message.setTo") + " "
+ Formatting.GOLD + "5*5"));
ChatUtils.sendNoSpamMessages(messageId, new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.message.setTo") + " " + Formatting.GOLD + "5*5"));
}
}
}
@ -108,13 +101,13 @@ public class IndustrialJackhammerItem extends JackhammerItem {
HitResult hitResult = rayTrace(worldIn, playerIn, RayTraceContext.FluidHandling.NONE);
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
if(!(hitResult instanceof BlockHitResult)){
if (!(hitResult instanceof BlockHitResult)) {
return Collections.emptySet();
}
Direction enumfacing = ((BlockHitResult) hitResult).getSide();
int add = isAOE(entityLiving.getMainHandStack()) ? 2 : 0;
if (enumfacing == Direction.SOUTH || enumfacing == Direction.NORTH) {
for (int i = -1 - add/2; i < 2 + add/2; i++) {
for (int i = -1 - add / 2; i < 2 + add / 2; i++) {
for (int j = -1; j < 2 + add; j++) {
BlockPos newPos = pos.add(i, j, 0);
if (shouldBreak(worldIn, pos, newPos)) {
@ -123,7 +116,7 @@ public class IndustrialJackhammerItem extends JackhammerItem {
}
}
} else if (enumfacing == Direction.EAST || enumfacing == Direction.WEST) {
for (int i = -1 - add/2; i < 2 + add/2; i++) {
for (int i = -1 - add / 2; i < 2 + add / 2; i++) {
for (int j = -1; j < 2 + add; j++) {
BlockPos newPos = pos.add(0, j, i);
if (shouldBreak(worldIn, pos, newPos)) {
@ -137,7 +130,7 @@ public class IndustrialJackhammerItem extends JackhammerItem {
int maxX = 0;
int minZ = 0;
int maxZ = 0;
switch (playerFacing){
switch (playerFacing) {
case SOUTH:
minZ = -1;
maxZ = 3;
@ -186,23 +179,23 @@ public class IndustrialJackhammerItem extends JackhammerItem {
if (blockState.getMaterial().isLiquid()) {
return false;
}
if (blockState.getBlock() instanceof OreBlock){
if (blockState.getBlock() instanceof OreBlock) {
return false;
}
if (blockState.getBlock() instanceof RedstoneOreBlock){
if (blockState.getBlock() instanceof RedstoneOreBlock) {
return false;
}
return (Items.IRON_PICKAXE.isEffectiveOn(blockState));
}
private boolean isAOE(ItemStack stack){
private boolean isAOE(ItemStack stack) {
return !stack.isEmpty() && stack.getTag() != null && stack.getTag().getBoolean("AOE5");
}
// JackhammerItem
@Override
public boolean postMine(ItemStack stack, World worldIn, BlockState stateIn, BlockPos pos, LivingEntity entityLiving) {
if(ItemUtils.isActive(stack)){
if (ItemUtils.isActive(stack)) {
for (BlockPos additionalPos : getTargetBlocks(worldIn, pos, entityLiving)) {
ToolsUtil.breakBlock(stack, worldIn, additionalPos, entityLiving, cost);
}
@ -241,7 +234,7 @@ public class IndustrialJackhammerItem extends JackhammerItem {
@Override
public void appendTooltip(ItemStack stack, @Nullable World worldIn, List<Text> tooltip, TooltipContext flagIn) {
ItemUtils.buildActiveTooltip(stack, tooltip);
if (ItemUtils.isActive(stack)){
if (ItemUtils.isActive(stack)) {
if (isAOE(stack)) {
tooltip.add(new LiteralText("5*5").formatted(Formatting.RED));
} else {
@ -249,14 +242,4 @@ public class IndustrialJackhammerItem extends JackhammerItem {
}
}
}
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(
ItemGroup par2ItemGroup, DefaultedList<ItemStack> itemList) {
if (!isIn(par2ItemGroup)) {
return;
}
InitUtils.initPoweredItems(TRContent.INDUSTRIAL_JACKHAMMER, itemList);
}
}

View file

@ -56,9 +56,8 @@ import javax.annotation.Nullable;
import java.util.List;
public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabilityExtensions, ItemStackModifiers {
public static final int maxCharge = TechRebornConfig.nanoSaberCharge;
public int transferLimit = 1_000;
public int cost = 250;
public static final int maxCharge = TechRebornConfig.nanosaberCharge;
public int cost = TechRebornConfig.nanosaberCost;
// 4M FE max charge with 1k charge rate
public NanosaberItem() {
@ -150,12 +149,7 @@ public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabi
@Override
public EnergyTier getTier() {
return EnergyTier.HIGH;
}
@Override
public double getMaxInput(EnergySide side) {
return transferLimit;
return EnergyTier.EXTREME;
}
@Override

View file

@ -57,16 +57,15 @@ import java.util.List;
public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurabilityExtensions {
public static final int maxCharge = TechRebornConfig.omniToolCharge;
public int transferLimit = 1_000;
public int cost = 100;
public int hitCost = 125;
public final int maxCharge = TechRebornConfig.omniToolCharge;
public int cost = TechRebornConfig.omniToolCost;
public int hitCost = TechRebornConfig.omniToolHitCost;
// 4M FE max charge with 1k charge rate
public OmniToolItem() {
super(ToolMaterials.DIAMOND, 1, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1));
}
// PickaxeItem
@Override
public boolean isEffectiveOn(BlockState state) {
@ -92,7 +91,7 @@ public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurab
@Override
public boolean postHit(ItemStack stack, LivingEntity entityliving, LivingEntity attacker) {
if(Energy.of(stack).use(hitCost)) {
if (Energy.of(stack).use(hitCost)) {
entityliving.damage(DamageSource.player((PlayerEntity) attacker), 8F);
}
return false;
@ -116,7 +115,9 @@ public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurab
}
@Override
public boolean isEnchantable(ItemStack stack) { return true; }
public boolean isEnchantable(ItemStack stack) {
return true;
}
@Environment(EnvType.CLIENT)
@Override
@ -155,11 +156,6 @@ public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurab
return maxCharge;
}
@Override
public double getMaxInput(EnergySide side) {
return transferLimit;
}
@Override
public double getMaxOutput(EnergySide side) {
return 0;
@ -167,6 +163,6 @@ public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurab
@Override
public EnergyTier getTier() {
return EnergyTier.HIGH;
return EnergyTier.EXTREME;
}
}