add buffer

This commit is contained in:
GlodBlock committed 2022-05-16 17:33:35 +08:00
1 parent 2d585bd280
commit 67abd1ec9e
21 files changed
+1895 -9

No files matched your search

@@ -4,6 +4,7 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.core.AELog;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.util.Util;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
@@ -334,7 +335,7 @@ public class AEFluidInventory implements IAEFluidTank
if( c != null )
{
this.fluids[x] = AEFluidStack.loadFluidStackFromNBT( c );
this.fluids[x] = Util.loadFluidStackFromNBT( c );
}
}
catch( final Exception e )
@@ -6,6 +6,7 @@ import appeng.tile.inventory.IAEAppEngInventory;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
import com.glodblock.github.util.ObjectArrayIterator;
import com.glodblock.github.util.Util;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.Constants;
@@ -90,7 +91,7 @@ public class AeStackInventoryImpl <T extends IAEStack<T>> implements AeStackInve
inv[i] = stackTag == null ? null : (T) AEItemStack.loadItemStackFromNBT(stackTag);
}
else {
inv[i] = stackTag == null ? null : (T) AEFluidStack.loadFluidStackFromNBT(stackTag);
inv[i] = stackTag == null ? null : (T) Util.loadFluidStackFromNBT(stackTag);
}
}
}
@@ -0,0 +1,47 @@
package com.glodblock.github.inventory.gui;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.TankDumpable;
import com.glodblock.github.network.CPacketDumpTank;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.resources.I18n;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
public class ButtonMouseHandler implements MouseRegionManager.Handler {
@Nullable
private final String tooltipKey;
private final Runnable callback;
public ButtonMouseHandler(@Nullable String tooltipKey, Runnable callback) {
this.tooltipKey = tooltipKey;
this.callback = callback;
}
@Nullable
@Override
public List<String> getTooltip() {
return tooltipKey != null ? Collections.singletonList(I18n.format(tooltipKey)) : null;
}
@Override
public boolean onClick(int button) {
if (button == 0) {
callback.run();
return true;
}
return false;
}
public static ButtonMouseHandler dumpTank(TankDumpable host, int index) {
return new ButtonMouseHandler(NameConst.TT_DUMP_TANK, () -> {
if (host.canDumpTank(index)) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketDumpTank(index));
}
});
}
}
@@ -8,6 +8,7 @@ import com.glodblock.github.client.gui.container.*;
import com.glodblock.github.common.parts.FCBasePart;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.common.tile.TileIngredientBuffer;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
@@ -16,6 +17,18 @@ import java.util.List;
public enum GuiType {
INGREDIENT_BUFFER(new TileGuiFactory<TileIngredientBuffer>(TileIngredientBuffer.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileIngredientBuffer inv) {
return new ContainerIngredientBuffer(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, TileIngredientBuffer inv) {
return new GuiIngredientBuffer(player.inventory, inv);
}
}),
FLUID_PAT_TERM_CRAFTING_STATUS(new PartGuiFactory<FCBasePart>(FCBasePart.class) {
@Override
protected Object createServerGui(EntityPlayer player, FCBasePart inv) {
@@ -0,0 +1,34 @@
package com.glodblock.github.inventory.gui;
import appeng.api.storage.data.IAEFluidStack;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.common.util.ForgeDirection;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.List;
public class TankMouseHandler implements MouseRegionManager.Handler {
private final IAEFluidTank tank;
private final int index;
public TankMouseHandler(IAEFluidTank tank, int index) {
this.tank = tank;
this.index = index;
}
@Nullable
@Override
public List<String> getTooltip() {
IAEFluidStack fluid = tank.getFluidInSlot(index);
return Arrays.asList(
fluid != null ? fluid.getFluidStack().getLocalizedName() : I18n.format(NameConst.TT_EMPTY),
EnumChatFormatting.GRAY + String.format("%,d / %,d mB",
fluid != null ? fluid.getStackSize() : 0L, tank.getTankInfo(ForgeDirection.UNKNOWN)[index].capacity));
}
}