Fix a range of config values not updating.

Closes https://github.com/TechReborn/TechReborn/issues/3146
This commit is contained in:
modmuss50 2023-06-25 11:26:49 +01:00
parent ba99161222
commit d4280ee2f1
6 changed files with 24 additions and 51 deletions

View file

@ -33,10 +33,6 @@ import techreborn.config.TechRebornConfig;
import techreborn.init.TRArmorMaterials; import techreborn.init.TRArmorMaterials;
public class CloakingDeviceItem extends TREnergyArmourItem implements ArmorBlockEntityTicker, ArmorRemoveHandler { public class CloakingDeviceItem extends TREnergyArmourItem implements ArmorBlockEntityTicker, ArmorRemoveHandler {
public static boolean isActive;
public static int cost = TechRebornConfig.cloakingDeviceCost;
// 40M FE capacity with 8k FE\t charge rate // 40M FE capacity with 8k FE\t charge rate
public CloakingDeviceItem() { public CloakingDeviceItem() {
super(TRArmorMaterials.CLOAKING_DEVICE, Type.CHESTPLATE, TechRebornConfig.cloakingDeviceCharge, RcEnergyTier.INSANE); super(TRArmorMaterials.CLOAKING_DEVICE, Type.CHESTPLATE, TechRebornConfig.cloakingDeviceCharge, RcEnergyTier.INSANE);
@ -49,7 +45,7 @@ public class CloakingDeviceItem extends TREnergyArmourItem implements ArmorBlock
// ArmorBlockEntityTicker // ArmorBlockEntityTicker
@Override @Override
public void tickArmor(ItemStack stack, PlayerEntity playerEntity) { public void tickArmor(ItemStack stack, PlayerEntity playerEntity) {
if (tryUseEnergy(stack, cost)) { if (tryUseEnergy(stack, TechRebornConfig.cloakingDeviceCost)) {
playerEntity.setInvisible(true); playerEntity.setInvisible(true);
} else { } else {
if (playerEntity.isInvisible()) { if (playerEntity.isInvisible()) {

View file

@ -43,16 +43,6 @@ import reborncore.common.powerSystem.RcEnergyTier;
import techreborn.config.TechRebornConfig; import techreborn.config.TechRebornConfig;
public class QuantumSuitItem extends TREnergyArmourItem implements ArmorBlockEntityTicker, ArmorRemoveHandler { public class QuantumSuitItem extends TREnergyArmourItem implements ArmorBlockEntityTicker, ArmorRemoveHandler {
public final long flyCost = TechRebornConfig.quantumSuitFlyingCost;
public final long swimCost = TechRebornConfig.quantumSuitSwimmingCost;
public final long breathingCost = TechRebornConfig.quantumSuitBreathingCost;
public final long sprintingCost = TechRebornConfig.quantumSuitSprintingCost;
public final long fireExtinguishCost = TechRebornConfig.fireExtinguishCost;
public final boolean enableSprint = TechRebornConfig.quantumSuitEnableSprint;
public final boolean enableFlight = TechRebornConfig.quantumSuitEnableFlight;
public QuantumSuitItem(ArmorMaterial material, Type slot) { public QuantumSuitItem(ArmorMaterial material, Type slot) {
super(material, slot, TechRebornConfig.quantumSuitCapacity, RcEnergyTier.INSANE); super(material, slot, TechRebornConfig.quantumSuitCapacity, RcEnergyTier.INSANE);
} }
@ -74,8 +64,8 @@ public class QuantumSuitItem extends TREnergyArmourItem implements ArmorBlockEnt
attributes.removeAll(EntityAttributes.GENERIC_MOVEMENT_SPEED); attributes.removeAll(EntityAttributes.GENERIC_MOVEMENT_SPEED);
if (this.getSlotType() == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS && enableSprint) { if (this.getSlotType() == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS && TechRebornConfig.quantumSuitEnableSprint) {
if (getStoredEnergy(stack) > sprintingCost) { if (getStoredEnergy(stack) > TechRebornConfig.quantumSuitSprintingCost) {
attributes.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(MODIFIERS[equipmentSlot.getEntitySlotId()], "Movement Speed", 0.15, EntityAttributeModifier.Operation.ADDITION)); attributes.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(MODIFIERS[equipmentSlot.getEntitySlotId()], "Movement Speed", 0.15, EntityAttributeModifier.Operation.ADDITION));
} }
} }
@ -93,18 +83,18 @@ public class QuantumSuitItem extends TREnergyArmourItem implements ArmorBlockEnt
public void tickArmor(ItemStack stack, PlayerEntity playerEntity) { public void tickArmor(ItemStack stack, PlayerEntity playerEntity) {
switch (this.getSlotType()) { switch (this.getSlotType()) {
case HEAD -> { case HEAD -> {
if (playerEntity.isSubmergedInWater() && tryUseEnergy(stack, breathingCost)) { if (playerEntity.isSubmergedInWater() && tryUseEnergy(stack, TechRebornConfig.quantumSuitBreathingCost)) {
playerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.WATER_BREATHING, 5, 1)); playerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.WATER_BREATHING, 5, 1));
} }
} }
case CHEST -> { case CHEST -> {
if (enableFlight) { if (TechRebornConfig.quantumSuitEnableFlight) {
if (getStoredEnergy(stack) > flyCost) { if (getStoredEnergy(stack) > TechRebornConfig.quantumSuitFlyingCost) {
playerEntity.getAbilities().allowFlying = true; playerEntity.getAbilities().allowFlying = true;
playerEntity.sendAbilitiesUpdate(); playerEntity.sendAbilitiesUpdate();
if (playerEntity.getAbilities().flying) { if (playerEntity.getAbilities().flying) {
tryUseEnergy(stack, flyCost); tryUseEnergy(stack, TechRebornConfig.quantumSuitFlyingCost);
} }
playerEntity.setOnGround(true); playerEntity.setOnGround(true);
} else { } else {
@ -113,17 +103,17 @@ public class QuantumSuitItem extends TREnergyArmourItem implements ArmorBlockEnt
playerEntity.sendAbilitiesUpdate(); playerEntity.sendAbilitiesUpdate();
} }
} }
if (playerEntity.isOnFire() && tryUseEnergy(stack, fireExtinguishCost)) { if (playerEntity.isOnFire() && tryUseEnergy(stack, TechRebornConfig.fireExtinguishCost)) {
playerEntity.extinguish(); playerEntity.extinguish();
} }
} }
case LEGS -> { case LEGS -> {
if (playerEntity.isSprinting() && enableSprint) { if (playerEntity.isSprinting() && TechRebornConfig.quantumSuitEnableSprint) {
tryUseEnergy(stack, sprintingCost); tryUseEnergy(stack, TechRebornConfig.quantumSuitSprintingCost);
} }
} }
case FEET -> { case FEET -> {
if (playerEntity.isSwimming() && tryUseEnergy(stack, swimCost)) { if (playerEntity.isSwimming() && tryUseEnergy(stack, TechRebornConfig.quantumSuitSwimmingCost)) {
playerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.DOLPHINS_GRACE, 5, 1)); playerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.DOLPHINS_GRACE, 5, 1));
} }
} }
@ -133,7 +123,7 @@ public class QuantumSuitItem extends TREnergyArmourItem implements ArmorBlockEnt
// ArmorRemoveHandler // ArmorRemoveHandler
@Override @Override
public void onRemoved(PlayerEntity playerEntity) { public void onRemoved(PlayerEntity playerEntity) {
if (this.getSlotType() == EquipmentSlot.CHEST && enableFlight) { if (this.getSlotType() == EquipmentSlot.CHEST && TechRebornConfig.quantumSuitEnableFlight) {
if (!playerEntity.isCreative() && !playerEntity.isSpectator()) { if (!playerEntity.isCreative() && !playerEntity.isSpectator()) {
playerEntity.getAbilities().allowFlying = false; playerEntity.getAbilities().allowFlying = false;
playerEntity.getAbilities().flying = false; playerEntity.getAbilities().flying = false;

View file

@ -35,9 +35,6 @@ import techreborn.config.TechRebornConfig;
* Created by modmuss50 on 05/11/2016. * Created by modmuss50 on 05/11/2016.
*/ */
public class ElectricTreetapItem extends Item implements RcEnergyItem { public class ElectricTreetapItem extends Item implements RcEnergyItem {
public final int maxCharge = TechRebornConfig.electricTreetapCharge;
public int cost = TechRebornConfig.electricTreetapCost;
public RcEnergyTier tier = RcEnergyTier.MEDIUM; public RcEnergyTier tier = RcEnergyTier.MEDIUM;
public ElectricTreetapItem() { public ElectricTreetapItem() {
@ -68,7 +65,7 @@ public class ElectricTreetapItem extends Item implements RcEnergyItem {
// EnergyHolder // EnergyHolder
@Override @Override
public long getEnergyCapacity() { public long getEnergyCapacity() {
return maxCharge; return TechRebornConfig.electricTreetapCharge;
} }
@Override @Override

View file

@ -42,10 +42,6 @@ import techreborn.config.TechRebornConfig;
import techreborn.init.TRToolMaterials; import techreborn.init.TRToolMaterials;
public class RockCutterItem extends PickaxeItem implements RcEnergyItem { public class RockCutterItem extends PickaxeItem implements RcEnergyItem {
public static final int maxCharge = TechRebornConfig.rockCutterCharge;
public int cost = TechRebornConfig.rockCutterCost;
// 10k Energy with 128 E\t charge rate // 10k Energy with 128 E\t charge rate
public RockCutterItem() { public RockCutterItem() {
// combat stats same as for diamond pickaxe. Fix for #2468 // combat stats same as for diamond pickaxe. Fix for #2468
@ -60,7 +56,7 @@ public class RockCutterItem extends PickaxeItem implements RcEnergyItem {
@Override @Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
if (getStoredEnergy(stack) < cost) { if (getStoredEnergy(stack) < TechRebornConfig.rockCutterCost) {
return 1.0f; return 1.0f;
} else { } else {
return Items.DIAMOND_PICKAXE.getMiningSpeedMultiplier(stack, state); return Items.DIAMOND_PICKAXE.getMiningSpeedMultiplier(stack, state);
@ -71,7 +67,7 @@ public class RockCutterItem extends PickaxeItem implements RcEnergyItem {
@Override @Override
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) { public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
if (worldIn.getRandom().nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) { if (worldIn.getRandom().nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
tryUseEnergy(stack, cost); tryUseEnergy(stack, TechRebornConfig.rockCutterCost);
} }
return true; return true;
} }
@ -124,7 +120,7 @@ public class RockCutterItem extends PickaxeItem implements RcEnergyItem {
// EnergyHolder // EnergyHolder
@Override @Override
public long getEnergyCapacity() { public long getEnergyCapacity() {
return maxCharge; return TechRebornConfig.rockCutterCharge;
} }
@Override @Override

View file

@ -53,9 +53,6 @@ import techreborn.init.TRToolMaterials;
import java.util.List; import java.util.List;
public class NanosaberItem extends SwordItem implements RcEnergyItem { public class NanosaberItem extends SwordItem implements RcEnergyItem {
public static final int maxCharge = TechRebornConfig.nanosaberCharge;
public int cost = TechRebornConfig.nanosaberCost;
// 4ME max charge with 1k charge rate // 4ME max charge with 1k charge rate
public NanosaberItem() { public NanosaberItem() {
super(TRToolMaterials.NANOSABER, 1, 1, new Item.Settings().maxCount(1).maxDamage(-1)); super(TRToolMaterials.NANOSABER, 1, 1, new Item.Settings().maxCount(1).maxDamage(-1));
@ -64,7 +61,7 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem {
// SwordItem // SwordItem
@Override @Override
public boolean postHit(ItemStack stack, LivingEntity entityHit, LivingEntity entityHitter) { public boolean postHit(ItemStack stack, LivingEntity entityHit, LivingEntity entityHitter) {
return tryUseEnergy(stack, cost); return tryUseEnergy(stack, TechRebornConfig.nanosaberCost);
} }
// ToolItem // ToolItem
@ -76,14 +73,14 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem {
// Item // Item
@Override @Override
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
ItemUtils.checkActive(stack, cost, entityIn); ItemUtils.checkActive(stack, TechRebornConfig.nanosaberCost, entityIn);
} }
@Override @Override
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) { public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
final ItemStack stack = player.getStackInHand(hand); final ItemStack stack = player.getStackInHand(hand);
if (player.isSneaking()) { if (player.isSneaking()) {
ItemUtils.switchActive(stack, cost, player); ItemUtils.switchActive(stack, TechRebornConfig.nanosaberCost, player);
return new TypedActionResult<>(ActionResult.SUCCESS, stack); return new TypedActionResult<>(ActionResult.SUCCESS, stack);
} }
return new TypedActionResult<>(ActionResult.PASS, stack); return new TypedActionResult<>(ActionResult.PASS, stack);
@ -107,7 +104,7 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem {
// EnergyHolder // EnergyHolder
@Override @Override
public long getEnergyCapacity() { public long getEnergyCapacity() {
return maxCharge; return TechRebornConfig.nanosaberCharge;
} }
@Override @Override

View file

@ -45,9 +45,6 @@ import techreborn.init.TRToolMaterials;
import techreborn.items.tool.MiningLevel; import techreborn.items.tool.MiningLevel;
public class OmniToolItem extends MiningToolItem implements RcEnergyItem { public class OmniToolItem extends MiningToolItem implements RcEnergyItem {
public final int maxCharge = TechRebornConfig.omniToolCharge;
public int cost = TechRebornConfig.omniToolCost;
public int hitCost = TechRebornConfig.omniToolHitCost;
public final int miningLevel; public final int miningLevel;
// 4M FE max charge with 1k charge rate // 4M FE max charge with 1k charge rate
@ -66,7 +63,7 @@ public class OmniToolItem extends MiningToolItem implements RcEnergyItem {
@Override @Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
if (getStoredEnergy(stack) >= cost) { if (getStoredEnergy(stack) >= TechRebornConfig.omniToolCost) {
return getMaterial().getMiningSpeedMultiplier(); return getMaterial().getMiningSpeedMultiplier();
} }
return super.getMiningSpeedMultiplier(stack, state); return super.getMiningSpeedMultiplier(stack, state);
@ -75,13 +72,13 @@ public class OmniToolItem extends MiningToolItem implements RcEnergyItem {
// MiningToolItem // MiningToolItem
@Override @Override
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) { public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
tryUseEnergy(stack, cost); tryUseEnergy(stack, TechRebornConfig.omniToolCost);
return true; return true;
} }
@Override @Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) { public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
if (tryUseEnergy(stack, hitCost)) { if (tryUseEnergy(stack, TechRebornConfig.omniToolHitCost)) {
target.damage(target.getWorld().getDamageSources().playerAttack((PlayerEntity) attacker), 8F); target.damage(target.getWorld().getDamageSources().playerAttack((PlayerEntity) attacker), 8F);
} }
return false; return false;
@ -127,7 +124,7 @@ public class OmniToolItem extends MiningToolItem implements RcEnergyItem {
// EnergyHolder // EnergyHolder
@Override @Override
public long getEnergyCapacity() { public long getEnergyCapacity() {
return maxCharge; return TechRebornConfig.omniToolCharge;
} }
@Override @Override