Skip to content

Commit

Permalink
allow fluids to be taken out of generators
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Jul 9, 2021
1 parent 7d5a5aa commit c7dcf5c
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

public class SimpleGeneratorMetaTileEntity extends TieredMetaTileEntity {

private FuelRecipeLogic workableHandler;
private ItemStackHandler containerInventory;
private OrientedOverlayRenderer overlayRenderer;
private FuelRecipeMap recipeMap;
private final FuelRecipeLogic workableHandler;
private final ItemStackHandler containerInventory;
private final OrientedOverlayRenderer overlayRenderer;
private final FuelRecipeMap recipeMap;

public SimpleGeneratorMetaTileEntity(ResourceLocation metaTileEntityId, FuelRecipeMap recipeMap, OrientedOverlayRenderer renderer, int tier) {
super(metaTileEntityId, tier);
Expand All @@ -58,6 +58,11 @@ protected FluidTankList createImportFluidHandler() {
.setFillPredicate(this::canInputFluid));
}

@Override
protected FluidTankList createExportFluidHandler() {
return new FluidTankList(false, this.importFluids);
}

private boolean canInputFluid(FluidStack fluid) {
return workableHandler.recipeMap.findRecipe(GTValues.V[getTier()], fluid) != null;
}
Expand Down Expand Up @@ -102,7 +107,8 @@ public void clearMachineInventory(NonNullList<ItemStack> itemBuffer) {
@Override
public void update() {
super.update();
if (!getWorld().isRemote && getOffsetTimer() % 5 == 0) {
if (!getWorld().isRemote && !containerInventory.getStackInSlot(0).isEmpty()) {
fillContainerFromInternalTank(containerInventory, containerInventory, 0, 1);
fillInternalTankFromFluidContainer(containerInventory, containerInventory, 0, 1);
}
}
Expand All @@ -122,7 +128,7 @@ protected ModularUI.Builder createGuiTemplate(EntityPlayer player) {
builder.dynamicLabel(11, 30, tankWidget::getFormattedFluidAmount, 0xFFFFFF);
builder.dynamicLabel(11, 40, tankWidget::getFluidLocalizedName, 0xFFFFFF);
return builder.label(6, 6, getMetaFullName())
.widget(new FluidContainerSlotWidget(containerInventory, 0, 90, 17, true)
.widget(new FluidContainerSlotWidget(containerInventory, 0, 90, 17, false)
.setBackgroundTexture(GuiTextures.SLOT, GuiTextures.IN_SLOT_OVERLAY))
.widget(new ImageWidget(91, 36, 14, 15, GuiTextures.TANK_ICON))
.widget(new SlotWidget(containerInventory, 1, 90, 54, true, false)
Expand Down

0 comments on commit c7dcf5c

Please sign in to comment.