Skip to content

Commit

Permalink
ie: add multiblock storage,
Browse files Browse the repository at this point in the history
ie: fix furnace progress inverted
  • Loading branch information
deirn committed Feb 4, 2024
1 parent 505708a commit 7362572
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@
import blusunrize.immersiveengineering.common.blocks.multiblocks.logic.AssemblerLogic;
import blusunrize.immersiveengineering.common.blocks.multiblocks.logic.BlastFurnaceLogic;
import blusunrize.immersiveengineering.common.blocks.multiblocks.logic.CokeOvenLogic;
import blusunrize.immersiveengineering.common.blocks.multiblocks.logic.DieselGeneratorLogic;
import blusunrize.immersiveengineering.common.blocks.multiblocks.logic.MetalPressLogic;
import blusunrize.immersiveengineering.common.blocks.multiblocks.logic.SheetmetalTankLogic;
import blusunrize.immersiveengineering.common.blocks.multiblocks.logic.SiloLogic;
import blusunrize.immersiveengineering.common.blocks.multiblocks.process.ProcessContext;
import blusunrize.immersiveengineering.common.util.inventory.IIEInventory;
import lol.bai.megane.module.ie.provider.AssemblerProvider;
import lol.bai.megane.module.ie.provider.CokeOvenProvider;
import lol.bai.megane.module.ie.provider.FurnaceProvider;
import lol.bai.megane.module.ie.provider.IEInventoryProvider;
import lol.bai.megane.module.ie.provider.MetalPressProvider;
import lol.bai.megane.module.ie.provider.MultiblockProvider;
import lol.bai.megane.module.ie.provider.ProcessProvider;
import lol.bai.megane.module.ie.provider.SheetmetalTankProvider;
import lol.bai.megane.module.ie.provider.SiloProvider;
import mcp.mobius.waila.api.IRegistrar;
Expand All @@ -36,22 +39,25 @@ public class MeganeImmersiveEngineering implements IWailaPlugin {
@Override
public void register(IRegistrar registrar) {
EnergyData.describe("immersiveengineering").unit("IF");

var multiblockProvider = new MultiblockProvider();
registrar.addComponent(multiblockProvider, TooltipPosition.BODY, IMultiblockBE.class);
registrar.addBlockData(multiblockProvider, IMultiblockBE.class, 100);

registrar.addBlockData(EnergyData.newInfiniteProvider(), CapacitorCreativeBlockEntity.class, 900);
registrar.addBlockData(new BlockingDataProvider<>(EnergyData.class), DynamoBlockEntity.class, 900);
registrar.addBlockData(new BlockingDataProvider<>(EnergyData.class), ThermoelectricGenBlockEntity.class, 900);
MultiblockProvider.addData(new BlockingDataProvider<>(EnergyData.class), DieselGeneratorLogic.State.class);

registrar.addBlockData(new IEInventoryProvider(), IIEInventory.class);

var multiblockProvider = new MultiblockProvider();
registrar.addComponent(multiblockProvider, TooltipPosition.BODY, IMultiblockBE.class);
registrar.addBlockData(multiblockProvider, IMultiblockBE.class);

MultiblockProvider.addData(new CokeOvenProvider(), CokeOvenLogic.State.class);
MultiblockProvider.addData(new FurnaceProvider<>(BlastFurnaceLogic.State::getStateView), BlastFurnaceLogic.State.class);
MultiblockProvider.addData(new FurnaceProvider<>(AdvBlastFurnaceLogic.State::getStateView), AdvBlastFurnaceLogic.State.class);
MultiblockProvider.addData(new FurnaceProvider<>(AlloySmelterLogic.State::getStateView), AlloySmelterLogic.State.class);
MultiblockProvider.addData(new SiloProvider(), SiloLogic.State.class);
MultiblockProvider.addData(new SheetmetalTankProvider(), SheetmetalTankLogic.State.class);
MultiblockProvider.addData(new ProcessProvider<>(), ProcessContext.class);

registrar.addFeatureConfig(CONFIG_SHOW_METAL_PRESS_MOLD, true);
MultiblockProvider.addBody(new MetalPressProvider(), MetalPressLogic.State.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public void appendData(IDataWriter data, IServerAccessor<IMultiblockBE<S>> acces
var stateView = (FurnaceHandler<?>.StateView & AccessFurnaceHandlerStateView) containerDataFunction.apply(state);
var processStep = (float) FurnaceHandler.StateView.getProcess(stateView);
var processMax = (float) FurnaceHandler.StateView.getMaxProcess(stateView);
if (processStep == 0) return;
if (processMax == 0) return;

var ratio = processStep / processMax;
var ratio = (processMax - processStep) / processMax;
var progressData = ProgressData.ratio(ratio)
.itemGetter(inventory::getStackInSlot);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package lol.bai.megane.module.ie.provider;

import blusunrize.immersiveengineering.api.multiblocks.blocks.logic.IMultiblockBE;
import blusunrize.immersiveengineering.api.multiblocks.blocks.logic.IMultiblockState;
import blusunrize.immersiveengineering.common.blocks.multiblocks.process.ProcessContext;
import mcp.mobius.waila.api.IDataProvider;
import mcp.mobius.waila.api.IDataWriter;
import mcp.mobius.waila.api.IPluginConfig;
import mcp.mobius.waila.api.IServerAccessor;
import mcp.mobius.waila.api.data.FluidData;
import mcp.mobius.waila.api.data.ItemData;
import mcp.mobius.waila.api.forge.ForgeFluidData;
import net.minecraftforge.fluids.IFluidTank;

public class ProcessProvider<S extends IMultiblockState & ProcessContext<?>> implements IDataProvider<IMultiblockBE<S>> {

@Override
public void appendData(IDataWriter data, IServerAccessor<IMultiblockBE<S>> accessor, IPluginConfig config) {
var state = accessor.getTarget().getHelper().getState();
if (state == null) return;

data.add(ItemData.class, res -> {
var inventory = state.getInventory();
if (inventory.getSlots() == 0) return;

res.add(ItemData.of(config)
.getter(inventory::getStackInSlot, inventory.getSlots()));
});

data.add(FluidData.class, res -> {
var tanks = state.getInternalTanks();
if (tanks.length == 0) return;

var fluidData = ForgeFluidData.of(tanks.length);
for (IFluidTank tank : tanks) {
fluidData.add(tank.getFluid(), tank.getCapacity());
}
res.add(fluidData);
});
}

}

0 comments on commit 7362572

Please sign in to comment.