Cleanup Altar Upgrade system

This commit is contained in:
Nicholas Ignoffo 2018-02-16 16:37:02 -08:00
parent 2fecb427fd
commit e4e6a8c4ca
7 changed files with 64 additions and 179 deletions

View file

@ -1,122 +1,24 @@
package WayofTime.bloodmagic.altar;
public class AltarUpgrade {
private int speedCount;
private int efficiencyCount;
private int sacrificeCount;
private int selfSacrificeCount;
private int displacementCount;
private int capacityCount;
private int orbCapacityCount;
private int betterCapacityCount;
private int accelerationCount;
private int chargingCount;
import WayofTime.bloodmagic.block.enums.BloodRuneType;
import com.google.common.collect.Maps;
public AltarUpgrade(int speedCount, int efficiencyCount, int sacrificeCount, int selfSacrificeCount, int displacementCount, int capacityCount, int orbCapacityCount, int betterCapacityCount, int accelerationCount, int chargingCount) {
this.speedCount = speedCount;
this.efficiencyCount = efficiencyCount;
this.sacrificeCount = sacrificeCount;
this.selfSacrificeCount = selfSacrificeCount;
this.displacementCount = displacementCount;
this.capacityCount = capacityCount;
this.orbCapacityCount = orbCapacityCount;
this.betterCapacityCount = betterCapacityCount;
this.accelerationCount = accelerationCount;
this.chargingCount = chargingCount;
}
import java.util.EnumMap;
public class AltarUpgrade {
private final EnumMap<BloodRuneType, Integer> upgradeLevels;
public AltarUpgrade() {
this.upgradeLevels = Maps.newEnumMap(BloodRuneType.class);
}
// Adders
public AltarUpgrade addSpeed() {
speedCount++;
public AltarUpgrade upgrade(BloodRuneType rune) {
upgradeLevels.compute(rune, (r, l) -> l == null ? 0 : l + 1);
return this;
}
public AltarUpgrade addEfficiency() {
efficiencyCount++;
return this;
}
public AltarUpgrade addSacrifice() {
sacrificeCount++;
return this;
}
public AltarUpgrade addSelfSacrifice() {
selfSacrificeCount++;
return this;
}
public AltarUpgrade addDisplacement() {
displacementCount++;
return this;
}
public AltarUpgrade addCapacity() {
capacityCount++;
return this;
}
public AltarUpgrade addOrbCapacity() {
orbCapacityCount++;
return this;
}
public AltarUpgrade addBetterCapacity() {
betterCapacityCount++;
return this;
}
public AltarUpgrade addAcceleration() {
accelerationCount++;
return this;
}
public AltarUpgrade addCharging() {
chargingCount++;
return this;
}
public int getSpeedCount() {
return speedCount;
}
public int getEfficiencyCount() {
return efficiencyCount;
}
public int getSacrificeCount() {
return sacrificeCount;
}
public int getSelfSacrificeCount() {
return selfSacrificeCount;
}
public int getDisplacementCount() {
return displacementCount;
}
public int getCapacityCount() {
return capacityCount;
}
public int getOrbCapacityCount() {
return orbCapacityCount;
}
public int getBetterCapacityCount() {
return betterCapacityCount;
}
public int getAccelerationCount() {
return accelerationCount;
}
public int getChargingCount() {
return chargingCount;
public int getLevel(BloodRuneType rune) {
return upgradeLevels.getOrDefault(rune, 0);
}
}

View file

@ -3,12 +3,12 @@ package WayofTime.bloodmagic.altar;
import WayofTime.bloodmagic.api.event.BloodMagicCraftedEvent;
import WayofTime.bloodmagic.api.impl.BloodMagicAPI;
import WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
import WayofTime.bloodmagic.util.BlockStack;
import WayofTime.bloodmagic.block.enums.BloodRuneType;
import WayofTime.bloodmagic.iface.IBloodRune;
import WayofTime.bloodmagic.util.Constants;
import WayofTime.bloodmagic.orb.BloodOrb;
import WayofTime.bloodmagic.orb.IBloodOrb;
import WayofTime.bloodmagic.util.helper.NetworkHelper;
import WayofTime.bloodmagic.block.BlockBloodRune;
import WayofTime.bloodmagic.block.BlockLifeEssence;
import WayofTime.bloodmagic.tile.TileAltar;
import com.google.common.base.Enums;
@ -388,17 +388,17 @@ public class BloodAltar implements IFluidHandler {
return;
} else if (!tier.equals(EnumAltarTier.ONE) && upgrade != null) {
this.isUpgraded = true;
this.accelerationUpgrades = upgrade.getAccelerationCount();
this.consumptionMultiplier = (float) (0.20 * upgrade.getSpeedCount());
this.efficiencyMultiplier = (float) Math.pow(0.85, upgrade.getEfficiencyCount());
this.sacrificeEfficiencyMultiplier = (float) (0.10 * upgrade.getSacrificeCount());
this.selfSacrificeEfficiencyMultiplier = (float) (0.10 * upgrade.getSelfSacrificeCount());
this.capacityMultiplier = (float) ((1 * Math.pow(1.10, upgrade.getBetterCapacityCount()) + 0.20 * upgrade.getCapacityCount()));
this.dislocationMultiplier = (float) (Math.pow(1.2, upgrade.getDisplacementCount()));
this.orbCapacityMultiplier = (float) (1 + 0.02 * upgrade.getOrbCapacityCount());
this.chargingFrequency = Math.max(20 - upgrade.getAccelerationCount(), 1);
this.chargingRate = (int) (10 * upgrade.getChargingCount() * (1 + consumptionMultiplier / 2));
this.maxCharge = (int) (Fluid.BUCKET_VOLUME * Math.max(0.5 * capacityMultiplier, 1) * upgrade.getChargingCount());
this.accelerationUpgrades = upgrade.getLevel(BloodRuneType.ACCELERATION);
this.consumptionMultiplier = (float) (0.20 * upgrade.getLevel(BloodRuneType.SPEED));
this.efficiencyMultiplier = (float) Math.pow(0.85, upgrade.getLevel(BloodRuneType.EFFICIENCY));
this.sacrificeEfficiencyMultiplier = (float) (0.10 * upgrade.getLevel(BloodRuneType.SACRIFICE));
this.selfSacrificeEfficiencyMultiplier = (float) (0.10 * upgrade.getLevel(BloodRuneType.SELF_SACRIFICE));
this.capacityMultiplier = (float) ((1 * Math.pow(1.10, upgrade.getLevel(BloodRuneType.AUGMENTED_CAPACITY))) + 0.20 * upgrade.getLevel(BloodRuneType.CAPACITY));
this.dislocationMultiplier = (float) (Math.pow(1.2, upgrade.getLevel(BloodRuneType.DISPLACEMENT)));
this.orbCapacityMultiplier = (float) (1 + 0.02 * upgrade.getLevel(BloodRuneType.ORB));
this.chargingFrequency = Math.max(20 - accelerationUpgrades, 1);
this.chargingRate = (int) (10 * upgrade.getLevel(BloodRuneType.CHARGING) * (1 + consumptionMultiplier / 2));
this.maxCharge = (int) (Fluid.BUCKET_VOLUME * Math.max(0.5 * capacityMultiplier, 1) * upgrade.getLevel(BloodRuneType.CHARGING));
}
this.capacity = (int) (Fluid.BUCKET_VOLUME * 10 * capacityMultiplier);
@ -701,50 +701,10 @@ public class BloodAltar implements IFluidHandler {
BlockPos componentPos = pos.add(altarComponent.getOffset());
if (altarComponent.isUpgradeSlot()) {
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
if (worldBlock.getBlock() instanceof BlockBloodRune) {
switch (((BlockBloodRune) worldBlock.getBlock()).getRuneEffect(worldBlock.getMeta())) {
case 1:
upgrades.addSpeed();
break;
case 2:
upgrades.addEfficiency();
break;
case 3:
upgrades.addSacrifice();
break;
case 4:
upgrades.addSelfSacrifice();
break;
case 5:
upgrades.addDisplacement();
break;
case 6:
upgrades.addCapacity();
break;
case 7:
upgrades.addBetterCapacity();
break;
case 8:
upgrades.addOrbCapacity();
break;
case 9:
upgrades.addAcceleration();
break;
case 10:
upgrades.addCharging();
break;
}
IBlockState state = world.getBlockState(componentPos);
if (state.getBlock() instanceof IBloodRune) {
BloodRuneType rune = ((IBloodRune) state.getBlock()).getBloodRune(world, componentPos, state);
upgrades.upgrade(rune);
}
}
}

View file

@ -8,7 +8,7 @@ import WayofTime.bloodmagic.api.IBloodMagicPlugin;
import WayofTime.bloodmagic.altar.EnumAltarComponent;
import WayofTime.bloodmagic.block.BlockBloodRune;
import WayofTime.bloodmagic.block.BlockDecorative;
import WayofTime.bloodmagic.block.enums.EnumBloodRune;
import WayofTime.bloodmagic.block.enums.BloodRuneType;
import WayofTime.bloodmagic.block.enums.EnumDecorative;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
import WayofTime.bloodmagic.core.RegistrarBloodMagicRecipes;
@ -76,7 +76,7 @@ public class BloodMagicCorePlugin implements IBloodMagicPlugin {
api.registerAltarComponent(decorative.getDefaultState().withProperty(decorative.getProperty(), EnumDecorative.CRYSTAL_TILE), EnumAltarComponent.CRYSTAL.name());
BlockBloodRune bloodRune = (BlockBloodRune) RegistrarBloodMagicBlocks.BLOOD_RUNE;
for (EnumBloodRune runeType : EnumBloodRune.values())
for (BloodRuneType runeType : BloodRuneType.values())
api.registerAltarComponent(bloodRune.getDefaultState().withProperty(bloodRune.getProperty(), runeType), EnumAltarComponent.BLOODRUNE.name());
RegistrarBloodMagicRecipes.registerAltarRecipes(api.getRecipeRegistrar());

View file

@ -2,19 +2,25 @@ package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.block.base.BlockEnum;
import WayofTime.bloodmagic.block.enums.EnumBloodRune;
import WayofTime.bloodmagic.block.enums.BloodRuneType;
import WayofTime.bloodmagic.iface.IBloodRune;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.util.List;
public class BlockBloodRune extends BlockEnum<EnumBloodRune> {
public class BlockBloodRune extends BlockEnum<BloodRuneType> implements IBloodRune {
public BlockBloodRune() {
super(Material.ROCK, EnumBloodRune.class);
super(Material.ROCK, BloodRuneType.class);
setUnlocalizedName(BloodMagic.MODID + ".rune.");
setCreativeTab(BloodMagic.TAB_BM);
@ -24,8 +30,10 @@ public class BlockBloodRune extends BlockEnum<EnumBloodRune> {
setHarvestLevel("pickaxe", 2);
}
public int getRuneEffect(int meta) {
return meta;
@Nullable
@Override
public BloodRuneType getBloodRune(IBlockAccess world, BlockPos pos, IBlockState state) {
return state.getValue(getProperty());
}
@Override

View file

@ -4,15 +4,15 @@ import net.minecraft.util.IStringSerializable;
import java.util.Locale;
public enum EnumBloodRune implements IStringSerializable {
public enum BloodRuneType implements IStringSerializable {
BLANK,
SPEED,
EFFICIENCY,
SACRIFICE,
SELFSACRIFICE,
SELF_SACRIFICE,
DISPLACEMENT,
CAPACITY,
AUGCAPACITY,
AUGMENTED_CAPACITY,
ORB,
ACCELERATION,
CHARGING;

View file

@ -0,0 +1,15 @@
package WayofTime.bloodmagic.iface;
import WayofTime.bloodmagic.block.enums.BloodRuneType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import javax.annotation.Nullable;
public interface IBloodRune {
@Nullable
BloodRuneType getBloodRune(IBlockAccess world, BlockPos pos, IBlockState state);
}

View file

@ -27,7 +27,7 @@
"all": "bloodmagic:blocks/RuneOfSacrifice"
}
},
"selfsacrifice": {
"self_sacrifice": {
"textures": {
"all": "bloodmagic:blocks/RuneOfSelfSacrifice"
}
@ -42,7 +42,7 @@
"all": "bloodmagic:blocks/AltarCapacityRune"
}
},
"augcapacity": {
"augmented_capacity": {
"textures": {
"all": "bloodmagic:blocks/BetterCapacityRune"
}