Slight cleanup. Energy packs uses transfer rates from tier.
This commit is contained in:
parent
04a1c789c4
commit
b9c8a1a215
7 changed files with 52 additions and 78 deletions
|
@ -247,17 +247,11 @@ public class TechRebornConfig {
|
|||
@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 = "lapotronPackCharge", comment = "Energy Capacity for Lapotron Pack")
|
||||
public static int lapotronPackCharge = 100_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 = "LithiumBatpackCharge", comment = "Energy Capacity for Lithium Batpack")
|
||||
public static int lithiumBatpackCharge = 600_000;
|
||||
|
||||
@Config(config = "items", category = "power", key = "redCellBatteryMaxCharge", comment = "Energy Capacity for Red Cell Battery (FE)")
|
||||
public static int redCellBatteryMaxCharge = 40_000;
|
||||
|
|
|
@ -167,11 +167,11 @@ public class ModRegistry {
|
|||
// Battery
|
||||
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.LITHIUM_ION_BATPACK = InitUtils.setup(new BatpackItem(TechRebornConfig.lithiumBatpackCharge, TRArmorMaterials.LITHIUM_BATPACK, EnergyTier.MEDIUM), "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"));
|
||||
RebornRegistry.registerItem(TRContent.LAPOTRONIC_ORBPACK = InitUtils.setup(new BatpackItem(TechRebornConfig.lapotronPackCharge, TRArmorMaterials.LAPOTRONIC_ORBPACK, EnergyTier.INSANE), "lapotronic_orbpack"));
|
||||
|
||||
// Tools
|
||||
RebornRegistry.registerItem(TRContent.TREE_TAP = InitUtils.setup(new TreeTapItem(), "treetap"));
|
||||
|
|
|
@ -24,16 +24,11 @@
|
|||
|
||||
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;
|
||||
import reborncore.common.util.ItemDurabilityExtensions;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
|
@ -43,8 +38,6 @@ import team.reborn.energy.EnergyTier;
|
|||
import techreborn.TechReborn;
|
||||
import techreborn.utils.InitUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BatteryItem extends Item implements EnergyHolder, ItemDurabilityExtensions {
|
||||
|
||||
private final int maxEnergy;
|
||||
|
@ -54,15 +47,11 @@ public class BatteryItem extends Item implements EnergyHolder, ItemDurabilityExt
|
|||
super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamageIfAbsent(1));
|
||||
this.maxEnergy = maxEnergy;
|
||||
this.tier = tier;
|
||||
this.addPropertyGetter(new Identifier("techreborn:empty"), new ItemPropertyGetter() {
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public float call(ItemStack stack, @Nullable World worldIn, @Nullable LivingEntity entityIn) {
|
||||
if (!stack.isEmpty() && Energy.of(stack).getEnergy() == 0) {
|
||||
return 1.0F;
|
||||
}
|
||||
return 0.0F;
|
||||
this.addPropertyGetter(new Identifier("techreborn:empty"), (stack, worldIn, entityIn) -> {
|
||||
if (!stack.isEmpty() && Energy.of(stack).getEnergy() == 0) {
|
||||
return 1.0F;
|
||||
}
|
||||
return 0.0F;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -26,17 +26,13 @@ package techreborn.items;
|
|||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemPropertyGetter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -45,6 +41,7 @@ import net.minecraft.world.World;
|
|||
import net.minecraft.world.dimension.DimensionType;
|
||||
import reborncore.client.hud.StackInfoElement;
|
||||
import reborncore.common.util.ChatUtils;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.utils.MessageIDs;
|
||||
|
@ -56,16 +53,12 @@ public class FrequencyTransmitterItem extends Item {
|
|||
|
||||
public FrequencyTransmitterItem() {
|
||||
super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1));
|
||||
this.addPropertyGetter(new Identifier("techreborn", "coords"), new ItemPropertyGetter() {
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public float call(ItemStack stack, @Nullable World worldIn, @Nullable LivingEntity entityIn) {
|
||||
if (!stack.isEmpty() && stack.hasTag() && stack.getTag() != null && stack.getTag().contains("x")
|
||||
&& stack.getTag().contains("y") && stack.getTag().contains("z") && stack.getTag().contains("dim")) {
|
||||
return 1.0F;
|
||||
}
|
||||
return 0.0F;
|
||||
this.addPropertyGetter(new Identifier("techreborn", "coords"), (stack, worldIn, entityIn) -> {
|
||||
if (!stack.isEmpty() && stack.hasTag() && stack.getTag() != null && stack.getTag().contains("x")
|
||||
&& stack.getTag().contains("y") && stack.getTag().contains("z") && stack.getTag().contains("dim")) {
|
||||
return 1.0F;
|
||||
}
|
||||
return 0.0F;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -76,10 +69,10 @@ public class FrequencyTransmitterItem extends Item {
|
|||
ItemStack stack = context.getStack();
|
||||
|
||||
stack.setTag(new CompoundTag());
|
||||
stack.getTag().putInt("x", pos.getX());
|
||||
stack.getTag().putInt("y", pos.getY());
|
||||
stack.getTag().putInt("z", pos.getZ());
|
||||
stack.getTag().putInt("dim", world.getDimension().getType().getRawId());
|
||||
stack.getOrCreateTag().putInt("x", pos.getX());
|
||||
stack.getOrCreateTag().putInt("y", pos.getY());
|
||||
stack.getOrCreateTag().putInt("z", pos.getZ());
|
||||
stack.getOrCreateTag().putInt("dim", world.getDimension().getType().getRawId());
|
||||
|
||||
if (!world.isClient) {
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.freqTransmitterID, new LiteralText(
|
||||
|
|
|
@ -47,17 +47,15 @@ import techreborn.utils.InitUtils;
|
|||
public class BatpackItem extends ArmorItem implements EnergyHolder, ItemDurabilityExtensions {
|
||||
|
||||
public final int maxCharge;
|
||||
public final int transferLimit;
|
||||
public final EnergyTier tier;
|
||||
|
||||
public BatpackItem(int maxCharge, int transferLimit, ArmorMaterial material, EnergyTier tier) {
|
||||
public BatpackItem(int maxCharge, 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) {
|
||||
private void distributePowerToInventory(World world, PlayerEntity player, ItemStack itemStack, int maxOutput) {
|
||||
if (world.isClient || !Energy.valid(itemStack)) {
|
||||
return;
|
||||
}
|
||||
|
@ -66,7 +64,7 @@ public class BatpackItem extends ArmorItem implements EnergyHolder, ItemDurabili
|
|||
if (Energy.valid(player.inventory.getInvStack(i))) {
|
||||
Energy.of(itemStack)
|
||||
.into(Energy.of(player.inventory.getInvStack(i)))
|
||||
.move();
|
||||
.move(maxOutput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +73,7 @@ public class BatpackItem extends ArmorItem implements EnergyHolder, ItemDurabili
|
|||
@Override
|
||||
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
|
||||
if (entityIn instanceof PlayerEntity) {
|
||||
distributePowerToInventory(worldIn, (PlayerEntity) entityIn, stack, (int) transferLimit);
|
||||
distributePowerToInventory(worldIn, (PlayerEntity) entityIn, stack, tier.getMaxOutput());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,26 +82,11 @@ public class BatpackItem extends ArmorItem implements EnergyHolder, ItemDurabili
|
|||
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;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Override
|
||||
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
|
||||
|
@ -124,4 +107,19 @@ public class BatpackItem extends ArmorItem implements EnergyHolder, ItemDurabili
|
|||
return tier;
|
||||
}
|
||||
|
||||
// ItemDurabilityExtensions
|
||||
@Override
|
||||
public int getDurabilityColor(ItemStack stack) {
|
||||
return PowerSystem.getDisplayPower().colour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurability(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurability(ItemStack stack) {
|
||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,9 +55,7 @@ public class PaintingToolItem extends Item {
|
|||
|
||||
context.getWorld().playSound(player, context.getBlockPos(), SoundEvents.BLOCK_WOOL_PLACE, SoundCategory.BLOCKS, 0.6F, 1.0F);
|
||||
if (!context.getWorld().isClient) {
|
||||
context.getStack().damage(1, player, playerCb -> {
|
||||
playerCb.sendToolBreakStatus(context.getHand());
|
||||
});
|
||||
context.getStack().damage(1, player, playerCb -> playerCb.sendToolBreakStatus(context.getHand()));
|
||||
}
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
|
|
|
@ -52,11 +52,22 @@ public class ElectricTreetapItem extends Item implements EnergyHolder, ItemDurab
|
|||
super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||
}
|
||||
|
||||
// Item
|
||||
@Override
|
||||
public boolean isDamageable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Override
|
||||
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> stacks) {
|
||||
if (!isIn(group)) {
|
||||
return;
|
||||
}
|
||||
InitUtils.initPoweredItems(this, stacks);
|
||||
}
|
||||
|
||||
// ItemDurabilityExtensions
|
||||
@Override
|
||||
public double getDurability(ItemStack stack) {
|
||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
||||
|
@ -72,15 +83,6 @@ public class ElectricTreetapItem extends Item implements EnergyHolder, ItemDurab
|
|||
return PowerSystem.getDisplayPower().colour;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Override
|
||||
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> stacks) {
|
||||
if (!isIn(group)) {
|
||||
return;
|
||||
}
|
||||
InitUtils.initPoweredItems(this, stacks);
|
||||
}
|
||||
|
||||
// EnergyHolder
|
||||
@Override
|
||||
public double getMaxStoredPower() {
|
||||
|
|
Loading…
Reference in a new issue