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

@ -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;
}
}