Fix a range of config values not updating.
Closes https://github.com/TechReborn/TechReborn/issues/3146
This commit is contained in:
parent
ba99161222
commit
d4280ee2f1
6 changed files with 24 additions and 51 deletions
|
@ -33,10 +33,6 @@ import techreborn.config.TechRebornConfig;
|
|||
import techreborn.init.TRArmorMaterials;
|
||||
|
||||
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
|
||||
public CloakingDeviceItem() {
|
||||
super(TRArmorMaterials.CLOAKING_DEVICE, Type.CHESTPLATE, TechRebornConfig.cloakingDeviceCharge, RcEnergyTier.INSANE);
|
||||
|
@ -49,7 +45,7 @@ public class CloakingDeviceItem extends TREnergyArmourItem implements ArmorBlock
|
|||
// ArmorBlockEntityTicker
|
||||
@Override
|
||||
public void tickArmor(ItemStack stack, PlayerEntity playerEntity) {
|
||||
if (tryUseEnergy(stack, cost)) {
|
||||
if (tryUseEnergy(stack, TechRebornConfig.cloakingDeviceCost)) {
|
||||
playerEntity.setInvisible(true);
|
||||
} else {
|
||||
if (playerEntity.isInvisible()) {
|
||||
|
|
|
@ -43,16 +43,6 @@ import reborncore.common.powerSystem.RcEnergyTier;
|
|||
import techreborn.config.TechRebornConfig;
|
||||
|
||||
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) {
|
||||
super(material, slot, TechRebornConfig.quantumSuitCapacity, RcEnergyTier.INSANE);
|
||||
}
|
||||
|
@ -74,8 +64,8 @@ public class QuantumSuitItem extends TREnergyArmourItem implements ArmorBlockEnt
|
|||
|
||||
attributes.removeAll(EntityAttributes.GENERIC_MOVEMENT_SPEED);
|
||||
|
||||
if (this.getSlotType() == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS && enableSprint) {
|
||||
if (getStoredEnergy(stack) > sprintingCost) {
|
||||
if (this.getSlotType() == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS && TechRebornConfig.quantumSuitEnableSprint) {
|
||||
if (getStoredEnergy(stack) > TechRebornConfig.quantumSuitSprintingCost) {
|
||||
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) {
|
||||
switch (this.getSlotType()) {
|
||||
case HEAD -> {
|
||||
if (playerEntity.isSubmergedInWater() && tryUseEnergy(stack, breathingCost)) {
|
||||
if (playerEntity.isSubmergedInWater() && tryUseEnergy(stack, TechRebornConfig.quantumSuitBreathingCost)) {
|
||||
playerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.WATER_BREATHING, 5, 1));
|
||||
}
|
||||
}
|
||||
case CHEST -> {
|
||||
if (enableFlight) {
|
||||
if (getStoredEnergy(stack) > flyCost) {
|
||||
if (TechRebornConfig.quantumSuitEnableFlight) {
|
||||
if (getStoredEnergy(stack) > TechRebornConfig.quantumSuitFlyingCost) {
|
||||
playerEntity.getAbilities().allowFlying = true;
|
||||
playerEntity.sendAbilitiesUpdate();
|
||||
|
||||
if (playerEntity.getAbilities().flying) {
|
||||
tryUseEnergy(stack, flyCost);
|
||||
tryUseEnergy(stack, TechRebornConfig.quantumSuitFlyingCost);
|
||||
}
|
||||
playerEntity.setOnGround(true);
|
||||
} else {
|
||||
|
@ -113,17 +103,17 @@ public class QuantumSuitItem extends TREnergyArmourItem implements ArmorBlockEnt
|
|||
playerEntity.sendAbilitiesUpdate();
|
||||
}
|
||||
}
|
||||
if (playerEntity.isOnFire() && tryUseEnergy(stack, fireExtinguishCost)) {
|
||||
if (playerEntity.isOnFire() && tryUseEnergy(stack, TechRebornConfig.fireExtinguishCost)) {
|
||||
playerEntity.extinguish();
|
||||
}
|
||||
}
|
||||
case LEGS -> {
|
||||
if (playerEntity.isSprinting() && enableSprint) {
|
||||
tryUseEnergy(stack, sprintingCost);
|
||||
if (playerEntity.isSprinting() && TechRebornConfig.quantumSuitEnableSprint) {
|
||||
tryUseEnergy(stack, TechRebornConfig.quantumSuitSprintingCost);
|
||||
}
|
||||
}
|
||||
case FEET -> {
|
||||
if (playerEntity.isSwimming() && tryUseEnergy(stack, swimCost)) {
|
||||
if (playerEntity.isSwimming() && tryUseEnergy(stack, TechRebornConfig.quantumSuitSwimmingCost)) {
|
||||
playerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.DOLPHINS_GRACE, 5, 1));
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +123,7 @@ public class QuantumSuitItem extends TREnergyArmourItem implements ArmorBlockEnt
|
|||
// ArmorRemoveHandler
|
||||
@Override
|
||||
public void onRemoved(PlayerEntity playerEntity) {
|
||||
if (this.getSlotType() == EquipmentSlot.CHEST && enableFlight) {
|
||||
if (this.getSlotType() == EquipmentSlot.CHEST && TechRebornConfig.quantumSuitEnableFlight) {
|
||||
if (!playerEntity.isCreative() && !playerEntity.isSpectator()) {
|
||||
playerEntity.getAbilities().allowFlying = false;
|
||||
playerEntity.getAbilities().flying = false;
|
||||
|
|
|
@ -35,9 +35,6 @@ import techreborn.config.TechRebornConfig;
|
|||
* Created by modmuss50 on 05/11/2016.
|
||||
*/
|
||||
public class ElectricTreetapItem extends Item implements RcEnergyItem {
|
||||
|
||||
public final int maxCharge = TechRebornConfig.electricTreetapCharge;
|
||||
public int cost = TechRebornConfig.electricTreetapCost;
|
||||
public RcEnergyTier tier = RcEnergyTier.MEDIUM;
|
||||
|
||||
public ElectricTreetapItem() {
|
||||
|
@ -68,7 +65,7 @@ public class ElectricTreetapItem extends Item implements RcEnergyItem {
|
|||
// EnergyHolder
|
||||
@Override
|
||||
public long getEnergyCapacity() {
|
||||
return maxCharge;
|
||||
return TechRebornConfig.electricTreetapCharge;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,10 +42,6 @@ import techreborn.config.TechRebornConfig;
|
|||
import techreborn.init.TRToolMaterials;
|
||||
|
||||
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
|
||||
public RockCutterItem() {
|
||||
// combat stats same as for diamond pickaxe. Fix for #2468
|
||||
|
@ -60,7 +56,7 @@ public class RockCutterItem extends PickaxeItem implements RcEnergyItem {
|
|||
|
||||
@Override
|
||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||
if (getStoredEnergy(stack) < cost) {
|
||||
if (getStoredEnergy(stack) < TechRebornConfig.rockCutterCost) {
|
||||
return 1.0f;
|
||||
} else {
|
||||
return Items.DIAMOND_PICKAXE.getMiningSpeedMultiplier(stack, state);
|
||||
|
@ -71,7 +67,7 @@ public class RockCutterItem extends PickaxeItem implements RcEnergyItem {
|
|||
@Override
|
||||
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
||||
if (worldIn.getRandom().nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
||||
tryUseEnergy(stack, cost);
|
||||
tryUseEnergy(stack, TechRebornConfig.rockCutterCost);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -124,7 +120,7 @@ public class RockCutterItem extends PickaxeItem implements RcEnergyItem {
|
|||
// EnergyHolder
|
||||
@Override
|
||||
public long getEnergyCapacity() {
|
||||
return maxCharge;
|
||||
return TechRebornConfig.rockCutterCharge;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,9 +53,6 @@ import techreborn.init.TRToolMaterials;
|
|||
import java.util.List;
|
||||
|
||||
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
|
||||
public NanosaberItem() {
|
||||
super(TRToolMaterials.NANOSABER, 1, 1, new Item.Settings().maxCount(1).maxDamage(-1));
|
||||
|
@ -64,7 +61,7 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem {
|
|||
// SwordItem
|
||||
@Override
|
||||
public boolean postHit(ItemStack stack, LivingEntity entityHit, LivingEntity entityHitter) {
|
||||
return tryUseEnergy(stack, cost);
|
||||
return tryUseEnergy(stack, TechRebornConfig.nanosaberCost);
|
||||
}
|
||||
|
||||
// ToolItem
|
||||
|
@ -76,14 +73,14 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem {
|
|||
// Item
|
||||
@Override
|
||||
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
|
||||
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, player);
|
||||
ItemUtils.switchActive(stack, TechRebornConfig.nanosaberCost, player);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.PASS, stack);
|
||||
|
@ -107,7 +104,7 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem {
|
|||
// EnergyHolder
|
||||
@Override
|
||||
public long getEnergyCapacity() {
|
||||
return maxCharge;
|
||||
return TechRebornConfig.nanosaberCharge;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,9 +45,6 @@ import techreborn.init.TRToolMaterials;
|
|||
import techreborn.items.tool.MiningLevel;
|
||||
|
||||
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;
|
||||
|
||||
// 4M FE max charge with 1k charge rate
|
||||
|
@ -66,7 +63,7 @@ public class OmniToolItem extends MiningToolItem implements RcEnergyItem {
|
|||
|
||||
@Override
|
||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||
if (getStoredEnergy(stack) >= cost) {
|
||||
if (getStoredEnergy(stack) >= TechRebornConfig.omniToolCost) {
|
||||
return getMaterial().getMiningSpeedMultiplier();
|
||||
}
|
||||
return super.getMiningSpeedMultiplier(stack, state);
|
||||
|
@ -75,13 +72,13 @@ public class OmniToolItem extends MiningToolItem implements RcEnergyItem {
|
|||
// MiningToolItem
|
||||
@Override
|
||||
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
||||
tryUseEnergy(stack, cost);
|
||||
tryUseEnergy(stack, TechRebornConfig.omniToolCost);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
return false;
|
||||
|
@ -127,7 +124,7 @@ public class OmniToolItem extends MiningToolItem implements RcEnergyItem {
|
|||
// EnergyHolder
|
||||
@Override
|
||||
public long getEnergyCapacity() {
|
||||
return maxCharge;
|
||||
return TechRebornConfig.omniToolCharge;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue