Mining Gadgets

Mining Gadgets

33M Downloads

[Suggestion] Add a charged Mining Gadget to the creative/JEI inventory

bibo38 opened this issue ยท 4 comments

commented

When testing a mod I really like having a charged energy cell or item in the creative inventory and JEI, so that I can quickly test without needing to charge the block/item.

Therefore it would be nice, if the Mining Gadget could also be added as a charged variant to the creative inventory and JEI.

commented

/give {playername} mininggadgets:mininggadget{energy:1000000} 1
That'll give you a charged one but I could definitely look at adding a charged version. If you're in creative the gadget will always work.

commented

/give {playername} mininggadgets:mininggadget{energy:1000000} 1

Nice to know. Much easier than getting RFTools Power alpha build for a creative energy cell, which can charge items ;D.

That'll give you a charged one but I could definitely look at adding a charged version.

would be convenient, maybe also with all/most upgrades already installed.

If you're in creative the gadget will always work.

Didn't work for me in a creative singleplayer world with the code on the master branch:

for (BlockPos coord : coords) {
BlockState state = world.getBlockState(coord);
if (!(state.getBlock() instanceof RenderBlock)) {
//if (!world.isRemote) {
if (!canMine(stack, world)) {
return;
}

E.g. no block that doesn't pass the canMine function will ever get to be a Render block (and be broken by the render block).

public static boolean canMine(ItemStack tool, World world) {
IEnergyStorage energy = tool.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
int cost = getEnergyCost(tool);
if (MiningProperties.getRange(tool) == 3) cost = cost * 9;
if (energy.getEnergyStored() <= cost)
return false;
return true;
}

And as long, as the cost variable doesnt get 0, the canMine function will return false.

public static int getEnergyCost(ItemStack stack) {
int cost = Config.MININGGADGET_BASECOST.get();
List<Upgrade> upgrades = UpgradeTools.getActiveUpgrades(stack);
if (upgrades.isEmpty())
return cost;
return cost + upgrades.stream().mapToInt(Upgrade::getCostPerBlock).sum();
}

So the only way would be to set the MININGGADGET_BASECOST to 0, as no upgrade can be assigned a negative value.

commented

I'll add a bypass on the canMine method, I was likely thinking on Building Gadgets as that does allow use when in creative mode :P. I'll see what I can do about JEI, of course not all upgrades can be installed at once but it would be handy to have a few pre-set versions :D

commented

@MichaelHillcox Did this!