EMT Foci Bugfixes/Cleanup (#90)

This commit is contained in:
koolkrafter5 authored and GitHub committed 2025-03-16 13:11:20 -05:00
1 parent 3456ce64d7
commit cb68d0a951
12 files changed
+129 -87

No files matched your search

@@ -34,20 +34,6 @@ public abstract class ItemBaseFocus extends ItemFocusBasic {
this.icon = ir.registerIcon(EMT.TEXTURE_PATH + ":" + "focus_" + textureName);
}
boolean hasDepth() {
return false;
}
@Override
public int getFocusColor(ItemStack stack) {
return 0;
}
@Override
public boolean isItemTool(ItemStack par1ItemStack) {
return true;
}
@Override
public EnumRarity getRarity(ItemStack itemstack) {
return EnumRarity.rare;
@@ -63,18 +49,10 @@ public abstract class ItemBaseFocus extends ItemFocusBasic {
return new AspectList();
}
public boolean isUseItem(ItemStack stack) {
return isVisCostPerTick(stack);
}
public boolean isVisCostPerTick() {
return false;
}
@Override
public ItemStack onFocusRightClick(ItemStack paramItemStack, World paramWorld, EntityPlayer paramEntityPlayer,
MovingObjectPosition paramMovingObjectPosition) {
if (isUseItem(paramItemStack)) paramEntityPlayer.setItemInUse(paramItemStack, Integer.MAX_VALUE);
if (isVisCostPerTick(paramItemStack)) paramEntityPlayer.setItemInUse(paramItemStack, Integer.MAX_VALUE);
return paramItemStack;
}
@@ -84,19 +62,9 @@ public abstract class ItemBaseFocus extends ItemFocusBasic {
@Override
public void onPlayerStoppedUsingFocus(ItemStack itemstack, World world, EntityPlayer player, int count) {}
@Override
public String getSortingHelper(ItemStack itemstack) {
return "00";
}
@Override
public boolean onFocusBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) {
return false;
}
@Override
public int getItemEnchantability() {
return 5;
}
}
@@ -1,10 +1,12 @@
package emt.item.focus;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import emt.util.EMTConfigHandler;
@@ -35,32 +37,27 @@ public class ItemChargeFocus extends ItemBaseFocus {
for (Entry<Aspect, Integer> e : visCost.aspects.entrySet()) actualCost.add(
e.getKey(),
(int) (e.getValue() * Math.pow(1.1, getUpgradeLevel(stack, FocusUpgradeType.potency))));
return visCost;
return actualCost;
}
@Override
public String getSortingHelper(ItemStack itemstack) {
return "WANDCHARGING";
return "WANDCHARGING" + super.getSortingHelper(itemstack);
}
public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) {
return new FocusUpgradeType[] { FocusUpgradeType.potency, FocusUpgradeType.frugal };
}
public boolean canApplyUpgrade(ItemStack focusstack, EntityPlayer player, FocusUpgradeType type, int rank) {
return true;
}
@Override
public ItemStack onFocusRightClick(ItemStack itemstack, World world, EntityPlayer player,
MovingObjectPosition movingobjectposition) {
ItemWandCasting wand = (ItemWandCasting) itemstack.getItem();
if (player.capabilities.isCreativeMode
|| wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, true)) {
|| wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, false)) {
if (!world.isRemote) {
int energyLeft = (int) (EMTConfigHandler.chargeFocusProduction
* Math.pow(1.1, getUpgradeLevel(itemstack, FocusUpgradeType.potency)));
int energyLeft = getChargeRate(itemstack);
for (int i = 0; i < player.inventory.armorInventory.length; i++) {
if (energyLeft > 0) {
if ((player.inventory.armorInventory[i] != null)
@@ -89,4 +86,16 @@ public class ItemChargeFocus extends ItemBaseFocus {
}
return itemstack;
}
private int getChargeRate(ItemStack itemstack) {
return (int) (EMTConfigHandler.chargeFocusProduction
* Math.pow(1.1, getUpgradeLevel(itemstack, FocusUpgradeType.potency)));
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
list.add(StatCollector.translateToLocal("item.EMT.focus.EU.cost.info"));
list.add(StatCollector.translateToLocalFormatted("item.EMT.focus.EU.cost.once", getChargeRate(stack)));
super.addInformation(stack, player, list, par4);
}
}
@@ -8,6 +8,7 @@ import net.minecraft.world.World;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.wands.FocusUpgradeType;
import thaumcraft.common.items.wands.ItemWandCasting;
public class ItemChristmasFocus extends ItemBaseFocus {
@@ -30,7 +31,12 @@ public class ItemChristmasFocus extends ItemBaseFocus {
@Override
public String getSortingHelper(ItemStack itemstack) {
return "CHRISTMAS";
return "CHRISTMAS" + super.getSortingHelper(itemstack);
}
@Override
public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) {
return new FocusUpgradeType[] { FocusUpgradeType.frugal };
}
@Override
@@ -42,7 +48,7 @@ public class ItemChristmasFocus extends ItemBaseFocus {
int y = mop.blockY + 1;
int z = mop.blockZ;
if (player.capabilities.isCreativeMode
|| wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, true)) {
|| wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, false)) {
if (!world.isRemote) {
EntitySnowman snowman;
snowman = new EntitySnowman(world);
@@ -1,13 +1,17 @@
package emt.item.focus;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import emt.entity.EntityEnergyBall;
import ic2.api.item.ElectricItem;
import thaumcraft.api.wands.FocusUpgradeType;
public class ItemEnergyBallFocus extends ItemBaseFocus {
@@ -22,7 +26,12 @@ public class ItemEnergyBallFocus extends ItemBaseFocus {
@Override
public String getSortingHelper(ItemStack itemstack) {
return "ENERGYBALL";
return "ENERGYBALL" + super.getSortingHelper(itemstack);
}
@Override
public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) {
return new FocusUpgradeType[] { FocusUpgradeType.frugal };
}
@Override
@@ -36,9 +45,10 @@ public class ItemEnergyBallFocus extends ItemBaseFocus {
return stack;
}
double val = ElectricItem.manager.discharge(armor, 5120, 4, true, false, false);
int cost = getCost(stack);
double val = ElectricItem.manager.discharge(armor, cost, 4, true, false, false);
if (val < 5120) {
if (val < cost) {
return stack;
}
@@ -51,4 +61,18 @@ public class ItemEnergyBallFocus extends ItemBaseFocus {
return stack;
}
/**
* Base cost of 5120 with a 10% discount per level of frugal.
*/
private int getCost(ItemStack stack) {
return (int) (5120 * (1.0 - (0.1 * getUpgradeLevel(stack, FocusUpgradeType.frugal))));
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
list.add(StatCollector.translateToLocal("item.EMT.focus.EU.cost.info"));
list.add(StatCollector.translateToLocalFormatted("item.EMT.focus.EU.cost.once", getCost(stack)));
this.addFocusInformation(stack, player, list, par4);
}
}
@@ -31,7 +31,7 @@ public class ItemExplosionFocus extends ItemBaseFocus {
@Override
public String getSortingHelper(ItemStack itemstack) {
return "EXPLOSION";
return "EXPLOSION" + super.getSortingHelper(itemstack);
}
@Override
@@ -39,7 +39,7 @@ public class ItemExplosionFocus extends ItemBaseFocus {
MovingObjectPosition movingobjectposition) {
ItemWandCasting wand = (ItemWandCasting) itemstack.getItem();
if (player.capabilities.isCreativeMode
|| wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, true)) {
|| wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, false)) {
if (!world.isRemote) {
EntityLaser laser;
laser = new EntityLaser(world, player, 1);
@@ -54,12 +54,4 @@ public class ItemExplosionFocus extends ItemBaseFocus {
return new FocusUpgradeType[] { FocusUpgradeType.potency, FocusUpgradeType.frugal };
}
/**
* Use this method to define custom logic about which upgrades can be applied. This can be used to set up upgrade
* "trees" that make certain upgrades available only when others are unlocked first, when certain research is
* completed, or similar logic.
*/
public boolean canApplyUpgrade(ItemStack focusstack, EntityPlayer player, FocusUpgradeType type, int rank) {
return true;
}
}
@@ -35,7 +35,7 @@ public class ItemMaintenanceFocus extends ItemBaseFocus {
@Override
public String getSortingHelper(ItemStack itemstack) {
return "MAINTENANCE";
return "MAINTENANCE" + super.getSortingHelper(itemstack);
}
@Override
@@ -60,7 +60,7 @@ public class ItemMaintenanceFocus extends ItemBaseFocus {
if (hatchCandidateMetaTile instanceof MTEHatchMaintenance) {
MTEHatchMaintenance hatch = (MTEHatchMaintenance) hatchCandidateMetaTile;
if (player.capabilities.isCreativeMode
|| wand.consumeAllVis(itemStack, player, getVisCost(itemStack), true, true)) {
|| wand.consumeAllVis(itemStack, player, getVisCost(itemStack), true, false)) {
hatch.mCrowbar = true;
hatch.mScrewdriver = true;
hatch.mHardHammer = true;
@@ -1,7 +1,5 @@
package emt.item.focus;
import java.util.LinkedList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
@@ -12,6 +10,7 @@ import emt.entity.EntityShield;
import ic2.core.IC2;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.wands.FocusUpgradeType;
import thaumcraft.common.items.wands.ItemWandCasting;
public class ItemShieldFocus extends ItemBaseFocus {
@@ -35,22 +34,27 @@ public class ItemShieldFocus extends ItemBaseFocus {
@Override
public String getSortingHelper(ItemStack itemstack) {
return "SHIELD";
return "SHIELD" + super.getSortingHelper(itemstack);
}
@Override
public boolean isUseItem(ItemStack stack) {
public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) {
return new FocusUpgradeType[] { FocusUpgradeType.frugal };
}
@Override
public boolean isVisCostPerTick(ItemStack stack) {
return true;
}
@Override
public void onUsingFocusTick(ItemStack itemstack, EntityPlayer player, int count) {
ItemWandCasting wand = (ItemWandCasting) itemstack.getItem();
for (PotionEffect effect : new LinkedList<PotionEffect>(player.getActivePotionEffects())) {
for (PotionEffect effect : player.getActivePotionEffects()) {
IC2.platform.removePotion(player, effect.getPotionID());
}
if (!player.capabilities.isCreativeMode
&& !wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, true)) {
&& !wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, false)) {
player.stopUsingItem();
}
}
@@ -61,7 +65,7 @@ public class ItemShieldFocus extends ItemBaseFocus {
ItemWandCasting wand = (ItemWandCasting) itemstack.getItem();
player.setItemInUse(itemstack, Integer.MAX_VALUE);
if (!world.isRemote && (player.capabilities.isCreativeMode
|| wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, true))) {
|| wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, false))) {
EntityShield shield = new EntityShield(world, player);
world.spawnEntityInWorld(shield);
}
@@ -1,9 +1,11 @@
package emt.item.focus;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import emt.util.EMTConfigHandler;
import ic2.api.item.ElectricItem;
@@ -28,7 +30,7 @@ public class ItemWandChargingFocus extends ItemBaseFocus {
@Override
public String getSortingHelper(ItemStack itemstack) {
return "ELECTRICCHARGING";
return "ELECTRICCHARGING" + super.getSortingHelper(itemstack);
}
@Override
@@ -42,38 +44,63 @@ public class ItemWandChargingFocus extends ItemBaseFocus {
for (Entry<Aspect, Integer> e : visCost.aspects.entrySet()) actualCost.add(
e.getKey(),
(int) (e.getValue() * Math.pow(1.1, getUpgradeLevel(stack, FocusUpgradeType.potency))));
return visCost;
return actualCost;
}
public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) {
return new FocusUpgradeType[] { FocusUpgradeType.potency, FocusUpgradeType.frugal };
}
public boolean canApplyUpgrade(ItemStack focusstack, EntityPlayer player, FocusUpgradeType type, int rank) {
return true;
}
@Override
public void onUsingFocusTick(ItemStack itemstack, EntityPlayer player, int integer) {
if (!player.worldObj.isRemote) {
ItemWandCasting wandItem = (ItemWandCasting) itemstack.getItem();
if (wandIsFull(itemstack, wandItem)) {
return;
}
ItemStack armor = player.inventory.armorInventory[1];
if (armor != null) {
if ((ElectricItem.manager.use(armor, EMTConfigHandler.wandChargeFocusCost / 4, player)
&& (ElectricItem.manager.use(armor, EMTConfigHandler.wandChargeFocusCost / 4, player))
&& (ElectricItem.manager.use(armor, EMTConfigHandler.wandChargeFocusCost / 4, player))
&& (ElectricItem.manager.use(armor, EMTConfigHandler.wandChargeFocusCost / 4, player)))) {
int amount = (int) (100 * Math.pow(1.1, getUpgradeLevel(itemstack, FocusUpgradeType.potency)));
wandItem.addRealVis(itemstack, Aspect.ORDER, amount, true);
wandItem.addRealVis(itemstack, Aspect.FIRE, amount, true);
wandItem.addRealVis(itemstack, Aspect.ENTROPY, amount, true);
wandItem.addRealVis(itemstack, Aspect.WATER, amount, true);
wandItem.addRealVis(itemstack, Aspect.EARTH, amount, true);
wandItem.addRealVis(itemstack, Aspect.AIR, amount, true);
int cost = getCost(itemstack) / 4;
for (ItemStack stack : player.inventory.armorInventory) {
if (stack == null || ElectricItem.manager.getCharge(stack) < cost) {
return;
}
}
for (ItemStack stack : player.inventory.armorInventory) {
ElectricItem.manager.use(stack, cost, player);
}
int amount = (int) (100 * Math.pow(1.1, getUpgradeLevel(itemstack, FocusUpgradeType.potency)));
wandItem.addRealVis(itemstack, Aspect.ORDER, amount, true);
wandItem.addRealVis(itemstack, Aspect.FIRE, amount, true);
wandItem.addRealVis(itemstack, Aspect.ENTROPY, amount, true);
wandItem.addRealVis(itemstack, Aspect.WATER, amount, true);
wandItem.addRealVis(itemstack, Aspect.EARTH, amount, true);
wandItem.addRealVis(itemstack, Aspect.AIR, amount, true);
}
}
private boolean wandIsFull(ItemStack itemstack, ItemWandCasting wandItem) {
int size = wandItem.getMaxVis(itemstack);
for (Aspect a : Aspect.getPrimalAspects()) {
if (wandItem.getVis(itemstack, a) < size) {
return false;
}
}
return true;
}
/**
* Base cost from config with a 10% discount per level of frugal.
*/
private int getCost(ItemStack stack) {
return (int) (EMTConfigHandler.wandChargeFocusCost
* (1.0 - (0.1 * getUpgradeLevel(stack, FocusUpgradeType.frugal))));
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
list.add(StatCollector.translateToLocal("item.EMT.focus.EU.cost.info"));
list.add(StatCollector.translateToLocalFormatted("item.EMT.focus.EU.cost.tick", getCost(stack)));
super.addInformation(stack, player, list, par4);
}
}