Skip to content

Commit

Permalink
remove energy usage from configurator
Browse files Browse the repository at this point in the history
  • Loading branch information
thiakil committed Mar 6, 2024
1 parent e13923b commit 92cf26f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 43 deletions.
17 changes: 1 addition & 16 deletions src/main/java/mekanism/common/config/GearConfig.java
Expand Up @@ -49,11 +49,7 @@ public class GearConfig extends BaseMekanismConfig {
public final CachedDoubleValue disassemblerAttackSpeed;
public final CachedFloatingLongValue disassemblerMaxEnergy;
public final CachedFloatingLongValue disassemblerChargeRate;
//Configurator
public final CachedFloatingLongValue configuratorMaxEnergy;
public final CachedFloatingLongValue configuratorChargeRate;
public final CachedFloatingLongValue configuratorEnergyPerConfigure;
public final CachedFloatingLongValue configuratorEnergyPerItem;

//Electric Bow
public final CachedFloatingLongValue electricBowMaxEnergy;
public final CachedFloatingLongValue electricBowChargeRate;
Expand Down Expand Up @@ -180,17 +176,6 @@ public class GearConfig extends BaseMekanismConfig {
"chargeRate", FloatingLong.createConst(5_000));
builder.pop();

builder.comment("Configurator Settings").push(CONFIGURATOR_CATEGORY);
configuratorMaxEnergy = CachedFloatingLongValue.define(this, builder, "Maximum amount (joules) of energy the Configurator can contain.",
"maxEnergy", FloatingLong.createConst(60_000));
configuratorChargeRate = CachedFloatingLongValue.define(this, builder, "Amount (joules) of energy the Configurator can accept per tick.",
"chargeRate", FloatingLong.createConst(300));
configuratorEnergyPerConfigure = CachedFloatingLongValue.define(this, builder, "Energy usage in joules of using the configurator to configure machines.",
"energyPerConfigure", FloatingLong.createConst(400));
configuratorEnergyPerItem = CachedFloatingLongValue.define(this, builder, "Energy cost in joules for each item the configurator ejects from a machine on empty mode.",
"energyPerItem", FloatingLong.createConst(8));
builder.pop();

builder.comment("Electric Bow Settings").push(ELECTRIC_BOW_CATEGORY);
electricBowMaxEnergy = CachedFloatingLongValue.define(this, builder, "Maximum amount (joules) of energy the Electric Bow can contain.",
"maxEnergy", FloatingLong.createConst(120_000));
Expand Down
30 changes: 3 additions & 27 deletions src/main/java/mekanism/common/item/ItemConfigurator.java
Expand Up @@ -2,16 +2,12 @@

import java.util.List;
import java.util.Objects;
import mekanism.api.Action;
import mekanism.api.AutomationType;
import mekanism.api.IConfigurable;
import mekanism.api.IIncrementalEnum;
import mekanism.api.RelativeSide;
import mekanism.api.annotations.NothingNullByDefault;
import mekanism.api.energy.IEnergyContainer;
import mekanism.api.inventory.IInventorySlot;
import mekanism.api.inventory.IMekanismInventory;
import mekanism.api.math.FloatingLong;
import mekanism.api.math.MathUtils;
import mekanism.api.radial.IRadialDataHelper;
import mekanism.api.radial.RadialData;
Expand All @@ -26,7 +22,6 @@
import mekanism.common.block.attribute.Attribute;
import mekanism.common.block.attribute.AttributeStateFacing;
import mekanism.common.capabilities.Capabilities;
import mekanism.common.config.MekanismConfig;
import mekanism.common.item.ItemConfigurator.ConfiguratorMode;
import mekanism.common.item.interfaces.IItemHUDProvider;
import mekanism.common.lib.radial.IRadialModeItem;
Expand All @@ -41,7 +36,6 @@
import mekanism.common.util.InventoryUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.common.util.StorageUtils;
import mekanism.common.util.WorldUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand All @@ -50,6 +44,7 @@
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.TooltipFlag;
Expand All @@ -63,13 +58,13 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class ItemConfigurator extends ItemEnergized implements IRadialModeItem<ConfiguratorMode>, IItemHUDProvider {
public class ItemConfigurator extends Item implements IRadialModeItem<ConfiguratorMode>, IItemHUDProvider {

public static final Lazy<RadialData<ConfiguratorMode>> LAZY_RADIAL_DATA = Lazy.of(() ->
IRadialDataHelper.INSTANCE.dataForEnum(Mekanism.rl("configurator_mode"), ConfiguratorMode.class));

public ItemConfigurator(Properties properties) {
super(MekanismConfig.gear.configuratorChargeRate, MekanismConfig.gear.configuratorMaxEnergy, properties.rarity(Rarity.UNCOMMON));
super(properties.rarity(Rarity.UNCOMMON));
}

@Override
Expand Down Expand Up @@ -108,14 +103,6 @@ public InteractionResult useOn(UseOnContext context) {
} else if (!IBlockSecurityUtils.INSTANCE.canAccessOrDisplayError(player, world, pos, tile)) {
return InteractionResult.FAIL;
} else {
if (!player.isCreative()) {
IEnergyContainer energyContainer = StorageUtils.getEnergyContainer(stack, 0);
FloatingLong energyPerConfigure = MekanismConfig.gear.configuratorEnergyPerConfigure.get();
if (energyContainer == null || energyContainer.extract(energyPerConfigure, Action.SIMULATE, AutomationType.MANUAL).smallerThan(energyPerConfigure)) {
return InteractionResult.FAIL;
}
energyContainer.extract(energyPerConfigure, Action.EXECUTE, AutomationType.MANUAL);
}
DataType old = dataType;
dataType = info.incrementDataType(relativeSide);
if (dataType != old) {
Expand Down Expand Up @@ -152,20 +139,9 @@ public InteractionResult useOn(UseOnContext context) {
}
return InteractionResult.FAIL;
}
IEnergyContainer energyContainer = creative ? null : StorageUtils.getEnergyContainer(stack, 0);
if (!creative && energyContainer == null) {
return InteractionResult.FAIL;
}
//TODO: Switch this to items being handled by TileEntityMekanism, energy handled here (via lambdas?)
FloatingLong energyPerItemDump = MekanismConfig.gear.configuratorEnergyPerItem.get();
for (IInventorySlot inventorySlot : inv.getInventorySlots(null)) {
if (!inventorySlot.isEmpty()) {
if (!creative) {
if (energyContainer.extract(energyPerItemDump, Action.SIMULATE, AutomationType.MANUAL).smallerThan(energyPerItemDump)) {
break;
}
energyContainer.extract(energyPerItemDump, Action.EXECUTE, AutomationType.MANUAL);
}
InventoryUtils.dropStack(inventorySlot.getStack().copy(), slotStack -> Block.popResourceFromFace(world, pos, side, slotStack));
inventorySlot.setEmpty();
}
Expand Down

0 comments on commit 92cf26f

Please sign in to comment.