Config for Quantum Armor flight and speed. Closes #2362, #2011

This commit is contained in:
drcrazy 2021-03-19 11:09:32 +00:00 committed by modmuss50
parent 84a418707d
commit 268c7fa14b
2 changed files with 23 additions and 11 deletions

View file

@ -292,6 +292,12 @@ public class TechRebornConfig {
@Config(config = "items", category = "power", key = "quantumSuitFireExtinguishCost", comment = "Quantum Suit Cost for Fire Extinguish")
public static double fireExtinguishCost = 50;
@Config(config = "items", category = "power", key = "quantumSuitEnableSprint", comment = "Enable Sprint Speed increase for Quantum Legs")
public static boolean quantumSuitEnableSprint = true;
@Config(config = "items", category = "power", key = "quantumSuitEnableFlight", comment = "Enable Flight for Quantum Chest")
public static boolean quantumSuitEnableFlight = true;
@Config(config = "items", category = "power", key = "quantumSuitDamageAbsorbCost", comment = "Quantum Suit Cost for Damage Absorbed")
public static double damageAbsorbCost = 10;

View file

@ -60,6 +60,10 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
public final double sprintingCost = TechRebornConfig.quantumSuitSprintingCost;
public final double fireExtinguishCost = TechRebornConfig.fireExtinguishCost;
public final boolean enableSprint = TechRebornConfig.quantumSuitEnableSprint;
public final boolean enableFlight = TechRebornConfig.quantumSuitEnableFlight;
public QuantumSuitItem(ArmorMaterial material, EquipmentSlot slot) {
super(material, slot, new Item.Settings().group(TechReborn.ITEMGROUP).maxDamage(-1).maxCount(1));
}
@ -68,7 +72,7 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
public void getAttributeModifiers(EquipmentSlot equipmentSlot, ItemStack stack, Multimap<EntityAttribute, EntityAttributeModifier> attributes) {
attributes.removeAll(EntityAttributes.GENERIC_MOVEMENT_SPEED);
if (this.slot == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS) {
if (this.slot == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS && enableSprint) {
if (Energy.of(stack).getEnergy() > sprintingCost) {
attributes.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(MODIFIERS[equipmentSlot.getEntitySlotId()], "Movement Speed", 0.15, EntityAttributeModifier.Operation.ADDITION));
}
@ -91,22 +95,24 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
}
break;
case CHEST:
if (Energy.of(stack).getEnergy() > flyCost && !TechReborn.elytraPredicate.test(playerEntity)) {
playerEntity.getAbilities().allowFlying = true;
if (playerEntity.getAbilities().flying) {
Energy.of(stack).use(flyCost);
if (enableFlight){
if (Energy.of(stack).getEnergy() > flyCost && !TechReborn.elytraPredicate.test(playerEntity)) {
playerEntity.getAbilities().allowFlying = true;
if (playerEntity.getAbilities().flying) {
Energy.of(stack).use(flyCost);
}
playerEntity.setOnGround(true);
} else {
playerEntity.getAbilities().allowFlying = false;
playerEntity.getAbilities().flying = false;
}
playerEntity.setOnGround(true);
} else {
playerEntity.getAbilities().allowFlying = false;
playerEntity.getAbilities().flying = false;
}
if (playerEntity.isOnFire() && Energy.of(stack).getEnergy() > fireExtinguishCost) {
playerEntity.extinguish();
}
break;
case LEGS:
if (playerEntity.isSprinting()) {
if (playerEntity.isSprinting() && enableSprint) {
Energy.of(stack).use(sprintingCost);
}
break;
@ -129,7 +135,7 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
@Override
public void onRemoved(PlayerEntity playerEntity) {
if (this.slot == EquipmentSlot.CHEST) {
if (this.slot == EquipmentSlot.CHEST && enableFlight) {
if (!playerEntity.isCreative() && !playerEntity.isSpectator()) {
playerEntity.getAbilities().allowFlying = false;
playerEntity.getAbilities().flying = false;