mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-23 13:30:04 +00:00
Merge remote-tracking branch 'asdflj/bookmark' into dev
This commit is contained in:
14 files changed
+522
-10
No files matched your search
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.21-GTNH:dev')
|
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.21-GTNH:dev')
|
||||||
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-148-GTNH-pre:dev')
|
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-149-GTNH:dev')
|
||||||
compile('curse.maven:cofh-core-69162:2388751')
|
compile('curse.maven:cofh-core-69162:2388751')
|
||||||
compile('com.github.GTNewHorizons:waila:1.5.22:dev')
|
compile('com.github.GTNewHorizons:waila:1.5.22:dev')
|
||||||
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false }
|
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false }
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.glodblock.github.client.gui;
|
||||||
|
|
||||||
|
import appeng.client.gui.AEBaseMEGui;
|
||||||
|
import appeng.core.localization.GuiText;
|
||||||
|
import com.glodblock.github.FluidCraft;
|
||||||
|
import com.glodblock.github.client.gui.container.ContainerFluidAutoFiller;
|
||||||
|
import com.glodblock.github.common.tile.TileFluidAutoFiller;
|
||||||
|
import com.glodblock.github.util.NameConst;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class GuiFluidAutoFiller extends AEBaseMEGui {
|
||||||
|
protected EntityPlayer player;
|
||||||
|
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/fluid_auto_filler.png");
|
||||||
|
|
||||||
|
public GuiFluidAutoFiller(InventoryPlayer ipl, TileFluidAutoFiller tile) {
|
||||||
|
super(new ContainerFluidAutoFiller(ipl, tile));
|
||||||
|
this.player = ipl.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||||
|
mc.getTextureManager().bindTexture(TEX_BG);
|
||||||
|
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||||
|
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_AUTO_FILLER)), 8, 6, 0x404040);
|
||||||
|
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.glodblock.github.client.gui.container;
|
||||||
|
|
||||||
|
import appeng.container.AEBaseContainer;
|
||||||
|
import appeng.container.slot.SlotFake;
|
||||||
|
import com.glodblock.github.common.tile.TileFluidAutoFiller;
|
||||||
|
import com.glodblock.github.util.Util;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import org.apache.commons.lang3.tuple.MutablePair;
|
||||||
|
|
||||||
|
public class ContainerFluidAutoFiller extends AEBaseContainer {
|
||||||
|
public static class FakeSlot extends SlotFake {
|
||||||
|
public FakeSlot(IInventory inv, int idx, int x, int y) {
|
||||||
|
super(inv, idx, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putStack(ItemStack is) {
|
||||||
|
MutablePair<Boolean, ItemStack> result = ContainerFluidAutoFiller.isItemValid(is);
|
||||||
|
if (result.left) {
|
||||||
|
if (super.getHasStack()) super.clearStack();
|
||||||
|
super.putStack(result.right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final TileFluidAutoFiller tile;
|
||||||
|
|
||||||
|
public ContainerFluidAutoFiller(InventoryPlayer ipl, TileFluidAutoFiller tile) {
|
||||||
|
super(ipl, tile);
|
||||||
|
this.tile = tile;
|
||||||
|
addSlotToContainer(new FakeSlot(tile.getInventory(), 0, 80, 35));
|
||||||
|
bindPlayerInventory(ipl, 0, 84);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MutablePair<Boolean, ItemStack> isItemValid(ItemStack itemStack) {
|
||||||
|
boolean result = Util.FluidUtil.isFluidContainer(itemStack);
|
||||||
|
if (!result) return new MutablePair<>(false, null);
|
||||||
|
ItemStack tank = itemStack.copy();
|
||||||
|
tank.stackSize = 1;
|
||||||
|
if (Util.FluidUtil.isFilled(tank)) {
|
||||||
|
return new MutablePair<>(true, Util.FluidUtil.clearFluid(tank));
|
||||||
|
} else {
|
||||||
|
return new MutablePair<>(true, tank);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detectAndSendChanges() {
|
||||||
|
super.detectAndSendChanges();
|
||||||
|
tile.updatePattern();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.glodblock.github.common.block;
|
||||||
|
|
||||||
|
import appeng.api.config.SecurityPermissions;
|
||||||
|
import appeng.util.Platform;
|
||||||
|
import com.glodblock.github.common.item.FCBaseItemBlock;
|
||||||
|
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||||
|
import com.glodblock.github.common.tile.TileFluidAutoFiller;
|
||||||
|
import com.glodblock.github.inventory.InventoryHandler;
|
||||||
|
import com.glodblock.github.inventory.gui.GuiType;
|
||||||
|
import com.glodblock.github.util.BlockPos;
|
||||||
|
import com.glodblock.github.util.NameConst;
|
||||||
|
import com.glodblock.github.util.Util;
|
||||||
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
public class BlockFluidAutoFiller extends FCBaseBlock {
|
||||||
|
|
||||||
|
public BlockFluidAutoFiller() {
|
||||||
|
super(Material.iron, NameConst.BLOCK_FLUID_AUTO_FILLER);
|
||||||
|
setTileEntity(TileFluidAutoFiller.class);
|
||||||
|
setFullBlock(false);
|
||||||
|
setOpaque(false);
|
||||||
|
this.lightOpacity = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockFluidAutoFiller register() {
|
||||||
|
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_AUTO_FILLER);
|
||||||
|
GameRegistry.registerTileEntity(TileFluidAutoFiller.class, NameConst.BLOCK_FLUID_AUTO_FILLER);
|
||||||
|
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onActivated(
|
||||||
|
World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
|
||||||
|
if (player.isSneaking()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TileFluidAutoFiller tile = getTileEntity(world, x, y, z);
|
||||||
|
if (tile != null) {
|
||||||
|
if (Platform.isServer()) {
|
||||||
|
if (Util.hasPermission(player, SecurityPermissions.INJECT, tile)) {
|
||||||
|
InventoryHandler.openGui(
|
||||||
|
player,
|
||||||
|
world,
|
||||||
|
new BlockPos(x, y, z),
|
||||||
|
ForgeDirection.getOrientation(facing),
|
||||||
|
GuiType.FLUID_AUTO_FILLER);
|
||||||
|
} else {
|
||||||
|
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,6 @@ import javax.annotation.Nullable;
|
|||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.StatCollector;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class ItemPartFluidTerminal extends FCBaseItem implements IPartItem {
|
public class ItemPartFluidTerminal extends FCBaseItem implements IPartItem {
|
||||||
@@ -50,8 +49,12 @@ public class ItemPartFluidTerminal extends FCBaseItem implements IPartItem {
|
|||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flag) {
|
public void addInformation(ItemStack stack, EntityPlayer player, List toolTip, boolean flag) {
|
||||||
if (isShiftKeyDown()) tooltip.add(StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_TERMINAL));
|
if (isShiftKeyDown()) {
|
||||||
|
toolTip.add(NameConst.i18n(NameConst.TT_FLUID_TERMINAL));
|
||||||
|
} else {
|
||||||
|
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,292 @@
|
|||||||
|
package com.glodblock.github.common.tile;
|
||||||
|
|
||||||
|
import static com.glodblock.github.loader.RecipeLoader.BUCKET;
|
||||||
|
|
||||||
|
import appeng.api.AEApi;
|
||||||
|
import appeng.api.config.Actionable;
|
||||||
|
import appeng.api.config.PowerMultiplier;
|
||||||
|
import appeng.api.implementations.ICraftingPatternItem;
|
||||||
|
import appeng.api.networking.GridFlags;
|
||||||
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
|
import appeng.api.networking.crafting.ICraftingProvider;
|
||||||
|
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||||
|
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||||
|
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
||||||
|
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||||
|
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||||
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
|
import appeng.api.networking.security.MachineSource;
|
||||||
|
import appeng.api.networking.storage.IBaseMonitor;
|
||||||
|
import appeng.api.networking.storage.IStorageGrid;
|
||||||
|
import appeng.api.networking.ticking.IGridTickable;
|
||||||
|
import appeng.api.networking.ticking.TickRateModulation;
|
||||||
|
import appeng.api.networking.ticking.TickingRequest;
|
||||||
|
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||||
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
|
import appeng.api.storage.data.IItemList;
|
||||||
|
import appeng.api.util.AECableType;
|
||||||
|
import appeng.api.util.DimensionalCoord;
|
||||||
|
import appeng.helpers.Reflected;
|
||||||
|
import appeng.me.GridAccessException;
|
||||||
|
import appeng.tile.TileEvent;
|
||||||
|
import appeng.tile.events.TileEventType;
|
||||||
|
import appeng.tile.grid.AENetworkInvTile;
|
||||||
|
import appeng.tile.inventory.AppEngInternalInventory;
|
||||||
|
import appeng.tile.inventory.InvOperation;
|
||||||
|
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||||
|
import com.glodblock.github.util.Util;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTBase;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import org.apache.commons.lang3.tuple.MutablePair;
|
||||||
|
|
||||||
|
public class TileFluidAutoFiller extends AENetworkInvTile
|
||||||
|
implements ICraftingProvider, IMEMonitorHandlerReceiver<IAEFluidStack>, IGridTickable {
|
||||||
|
private final AppEngInternalInventory inventory = new AppEngInternalInventory(this, 1);
|
||||||
|
private final BaseActionSource source = new MachineSource(this);
|
||||||
|
private IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
|
||||||
|
public ItemStack containerItem;
|
||||||
|
private final Item encodedPattern =
|
||||||
|
AEApi.instance().definitions().items().encodedPattern().maybeItem().orNull();
|
||||||
|
private IAEItemStack returnStack;
|
||||||
|
private boolean isPowered;
|
||||||
|
|
||||||
|
public IInventory getInventory() {
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Reflected
|
||||||
|
public TileFluidAutoFiller() {
|
||||||
|
getProxy().setIdlePowerUsage(1D);
|
||||||
|
getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||||
|
inventory.setInventorySlotContents(0, BUCKET);
|
||||||
|
this.containerItem = getInventory().getStackInSlot(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) {
|
||||||
|
return new int[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBeRotated() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePattern() {
|
||||||
|
ItemStack is = inventory.getStackInSlot(0);
|
||||||
|
if (is == null || this.containerItem.isItemEqual(is)) return;
|
||||||
|
this.containerItem = is;
|
||||||
|
postEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||||
|
public void readFromNBTEvent(NBTTagCompound data) {
|
||||||
|
inventory.readFromNBT(data, "Inv");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||||
|
public NBTTagCompound writeToNBTEvent(NBTTagCompound data) {
|
||||||
|
inventory.writeToNBT(data, "Inv");
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public IInventory getInternalInventory() {
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DimensionalCoord getLocation() {
|
||||||
|
return new DimensionalCoord(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||||
|
return AECableType.DENSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IStorageGrid getStorageGrid() {
|
||||||
|
try {
|
||||||
|
return this.getProxy().getGrid().getCache(IStorageGrid.class);
|
||||||
|
} catch (GridAccessException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void provideCrafting(ICraftingProviderHelper craftingTracker) {
|
||||||
|
IStorageGrid storage = getStorageGrid();
|
||||||
|
if (storage == null) return;
|
||||||
|
IItemList<IAEFluidStack> fluidStorage =
|
||||||
|
this.fluids.isEmpty() ? storage.getFluidInventory().getStorageList() : this.fluids;
|
||||||
|
for (IAEFluidStack fluidStack : fluidStorage) {
|
||||||
|
Fluid fluid = fluidStack.getFluid();
|
||||||
|
if (fluid == null) continue;
|
||||||
|
int maxCapacity = Util.FluidUtil.getCapacity(this.containerItem, fluid);
|
||||||
|
if (maxCapacity == 0) continue;
|
||||||
|
MutablePair<Integer, ItemStack> filled =
|
||||||
|
Util.FluidUtil.fillStack(this.containerItem.copy(), new FluidStack(fluid, maxCapacity));
|
||||||
|
if (filled.right == null) continue;
|
||||||
|
ItemStack pattern = getPattern(this.containerItem, filled.right);
|
||||||
|
ICraftingPatternItem patter = (ICraftingPatternItem) pattern.getItem();
|
||||||
|
craftingTracker.addCraftingOption(this, patter.getPatternForItem(pattern, getWorldObj()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemStack getPattern(ItemStack emptyContainer, ItemStack filledContainer) {
|
||||||
|
NBTTagList in = new NBTTagList();
|
||||||
|
NBTTagList out = new NBTTagList();
|
||||||
|
in.appendTag(emptyContainer.writeToNBT(new NBTTagCompound()));
|
||||||
|
ItemStack fluidDrop = ItemFluidDrop.newStack(Util.FluidUtil.getFluidFromContainer(filledContainer));
|
||||||
|
in.appendTag(createItemTag(fluidDrop));
|
||||||
|
out.appendTag(filledContainer.writeToNBT(new NBTTagCompound()));
|
||||||
|
NBTTagCompound itemTag = new NBTTagCompound();
|
||||||
|
itemTag.setTag("in", in);
|
||||||
|
itemTag.setTag("out", out);
|
||||||
|
itemTag.setBoolean("crafting", false);
|
||||||
|
ItemStack pattern = new ItemStack(this.encodedPattern);
|
||||||
|
pattern.setTagCompound(itemTag);
|
||||||
|
return pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected NBTBase createItemTag(final ItemStack i) {
|
||||||
|
final NBTTagCompound c = new NBTTagCompound();
|
||||||
|
if (i != null) {
|
||||||
|
i.writeToNBT(c);
|
||||||
|
c.setInteger("Count", i.stackSize);
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table) {
|
||||||
|
this.returnStack =
|
||||||
|
AEApi.instance().storage().createItemStack(patternDetails.getCondensedOutputs()[0].getItemStack());
|
||||||
|
try {
|
||||||
|
this.getProxy().getTick().alertDevice(this.getProxy().getNode());
|
||||||
|
} catch (GridAccessException ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBusy() {
|
||||||
|
return this.returnStack != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid(Object verificationToken) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postChange(
|
||||||
|
IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change, BaseActionSource source) {
|
||||||
|
if (this.getProxy().isActive() && this.getStorageGrid() != null) {
|
||||||
|
boolean hasChanged = false;
|
||||||
|
IItemList<IAEFluidStack> stored = this.getStorageGrid()
|
||||||
|
.getFluidInventory()
|
||||||
|
.getAvailableItems(AEApi.instance().storage().createFluidList());
|
||||||
|
for (IAEFluidStack tmp : change) {
|
||||||
|
if (stored.findPrecise(tmp) == null || this.fluids.findPrecise(tmp) == null) {
|
||||||
|
hasChanged = true;
|
||||||
|
this.fluids = stored;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasChanged) postEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean postEvent() {
|
||||||
|
try {
|
||||||
|
this.getProxy()
|
||||||
|
.getGrid()
|
||||||
|
.postEvent(new MENetworkCraftingPatternChange(this, getGridNode(ForgeDirection.UNKNOWN)));
|
||||||
|
return true;
|
||||||
|
} catch (GridAccessException ignored) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onListUpdate() {}
|
||||||
|
|
||||||
|
@MENetworkEventSubscribe
|
||||||
|
public void stateChange(final MENetworkPowerStatusChange p) {
|
||||||
|
this.updatePowerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@MENetworkEventSubscribe
|
||||||
|
public final void bootingRender(final MENetworkBootingStatusChange c) {
|
||||||
|
this.updatePowerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePowerState() {
|
||||||
|
boolean newState = false;
|
||||||
|
try {
|
||||||
|
newState = this.getProxy().isActive()
|
||||||
|
&& this.getProxy().getEnergy().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG)
|
||||||
|
> 0.0001;
|
||||||
|
if (newState != this.isPowered && newState) {
|
||||||
|
this.getProxy().getStorage().getFluidInventory().addListener(this, null);
|
||||||
|
}
|
||||||
|
} catch (final GridAccessException ignored) {
|
||||||
|
}
|
||||||
|
if (newState != this.isPowered) {
|
||||||
|
this.isPowered = newState;
|
||||||
|
this.markForUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gridChanged() {
|
||||||
|
try {
|
||||||
|
this.getProxy().getStorage().getFluidInventory().removeListener(this);
|
||||||
|
} catch (final GridAccessException ignored) {
|
||||||
|
}
|
||||||
|
super.gridChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TickingRequest getTickingRequest(IGridNode node) {
|
||||||
|
return new TickingRequest(1, 5, this.returnStack == null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) {
|
||||||
|
if (this.getStorageGrid() == null) {
|
||||||
|
return TickRateModulation.SLOWER;
|
||||||
|
}
|
||||||
|
IAEItemStack nodAdded =
|
||||||
|
getStorageGrid().getItemInventory().injectItems(this.returnStack, Actionable.SIMULATE, this.source);
|
||||||
|
if (nodAdded == null) {
|
||||||
|
getStorageGrid().getItemInventory().injectItems(this.returnStack, Actionable.MODULATE, this.source);
|
||||||
|
this.returnStack = null;
|
||||||
|
return TickRateModulation.SLEEP;
|
||||||
|
} else {
|
||||||
|
return TickRateModulation.SLOWER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dropItems() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,17 @@ import javax.annotation.Nullable;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
|
||||||
public enum GuiType {
|
public enum GuiType {
|
||||||
|
FLUID_AUTO_FILLER(new TileGuiFactory<TileFluidAutoFiller>(TileFluidAutoFiller.class) {
|
||||||
|
@Override
|
||||||
|
protected Object createServerGui(EntityPlayer player, TileFluidAutoFiller inv) {
|
||||||
|
return new ContainerFluidAutoFiller(player.inventory, inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object createClientGui(EntityPlayer player, TileFluidAutoFiller inv) {
|
||||||
|
return new GuiFluidAutoFiller(player.inventory, inv);
|
||||||
|
}
|
||||||
|
}),
|
||||||
FLUID_LEVEL_EMITTER(new PartGuiFactory<PartFluidLevelEmitter>(PartFluidLevelEmitter.class) {
|
FLUID_LEVEL_EMITTER(new PartGuiFactory<PartFluidLevelEmitter>(PartFluidLevelEmitter.class) {
|
||||||
@Override
|
@Override
|
||||||
protected Object createServerGui(EntityPlayer player, PartFluidLevelEmitter inv) {
|
protected Object createServerGui(EntityPlayer player, PartFluidLevelEmitter inv) {
|
||||||
|
|||||||
@@ -1,23 +1,72 @@
|
|||||||
package com.glodblock.github.inventory.slot;
|
package com.glodblock.github.inventory.slot;
|
||||||
|
|
||||||
import appeng.container.slot.SlotRestrictedInput;
|
import appeng.container.slot.SlotRestrictedInput;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import org.apache.commons.lang3.tuple.MutablePair;
|
||||||
|
|
||||||
public class FCSlotRestrictedInput extends SlotRestrictedInput {
|
public class FCSlotRestrictedInput extends SlotRestrictedInput {
|
||||||
private ItemStack valid;
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Filter {
|
||||||
|
MutablePair<Boolean, ItemStack> isItemValid(final ItemStack inputItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Filter filter;
|
||||||
|
private final InventoryPlayer p;
|
||||||
|
private ItemStack validItem = null;
|
||||||
|
|
||||||
public FCSlotRestrictedInput(ItemStack valid, IInventory i, int slotIndex, int x, int y, InventoryPlayer p) {
|
public FCSlotRestrictedInput(ItemStack valid, IInventory i, int slotIndex, int x, int y, InventoryPlayer p) {
|
||||||
|
this(
|
||||||
|
(inputItem) -> new MutablePair<>(
|
||||||
|
valid.getItem()
|
||||||
|
.getClass()
|
||||||
|
.isAssignableFrom(inputItem.getItem().getClass()),
|
||||||
|
valid),
|
||||||
|
i,
|
||||||
|
slotIndex,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
p);
|
||||||
|
this.validItem = valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FCSlotRestrictedInput(Filter filter, IInventory i, int slotIndex, int x, int y, InventoryPlayer p) {
|
||||||
super(PlacableItemType.INSCRIBER_PLATE, i, slotIndex, x, y, p);
|
super(PlacableItemType.INSCRIBER_PLATE, i, slotIndex, x, y, p);
|
||||||
this.valid = valid;
|
this.filter = filter;
|
||||||
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(final ItemStack i) {
|
public boolean isItemValid(final ItemStack inputItem) {
|
||||||
if (i.getItem().getClass().isAssignableFrom(valid.getItem().getClass())) {
|
MutablePair<Boolean, ItemStack> result = this.filter.isItemValid(inputItem);
|
||||||
return true;
|
return result.left;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAllowEdit() {
|
||||||
|
return super.canTakeStack(this.p.player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||||
|
return getAllowEdit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPickupFromSlot(final EntityPlayer p, final ItemStack i) {
|
||||||
|
if (getAllowEdit()) {
|
||||||
|
super.onPickupFromSlot(p, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIcon() {
|
||||||
|
if (validItem != null) {
|
||||||
|
return super.getIcon();
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import com.glodblock.github.common.storage.CellType;
|
|||||||
|
|
||||||
public class ItemAndBlockHolder {
|
public class ItemAndBlockHolder {
|
||||||
|
|
||||||
|
public static BlockFluidAutoFiller FLUID_AUTO_FILLER = new BlockFluidAutoFiller().register();
|
||||||
public static BlockFluidDiscretizer DISCRETIZER = new BlockFluidDiscretizer().register();
|
public static BlockFluidDiscretizer DISCRETIZER = new BlockFluidDiscretizer().register();
|
||||||
public static BlockLevelMaintainer LEVEL_MAINTAINER = new BlockLevelMaintainer().register();
|
public static BlockLevelMaintainer LEVEL_MAINTAINER = new BlockLevelMaintainer().register();
|
||||||
public static BlockFluidPatternEncoder ENCODER = new BlockFluidPatternEncoder().register();
|
public static BlockFluidPatternEncoder ENCODER = new BlockFluidPatternEncoder().register();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class NameConst {
|
|||||||
public static final String BLOCK_FLUID_INTERFACE = "fluid_interface";
|
public static final String BLOCK_FLUID_INTERFACE = "fluid_interface";
|
||||||
public static final String BLOCK_INGREDIENT_BUFFER = "ingredient_buffer";
|
public static final String BLOCK_INGREDIENT_BUFFER = "ingredient_buffer";
|
||||||
public static final String BLOCK_FLUID_BUFFER = "fluid_buffer";
|
public static final String BLOCK_FLUID_BUFFER = "fluid_buffer";
|
||||||
|
public static final String BLOCK_FLUID_AUTO_FILLER = "fluid_auto_filler";
|
||||||
public static final String BLOCK_LARGE_INGREDIENT_BUFFER = "large_ingredient_buffer";
|
public static final String BLOCK_LARGE_INGREDIENT_BUFFER = "large_ingredient_buffer";
|
||||||
public static final String BLOCK_OC_PATTERN_EDITOR = "oc_pattern_editor";
|
public static final String BLOCK_OC_PATTERN_EDITOR = "oc_pattern_editor";
|
||||||
public static final String BLOCK_LEVEL_MAINTAINER = "level_maintainer";
|
public static final String BLOCK_LEVEL_MAINTAINER = "level_maintainer";
|
||||||
@@ -81,6 +82,7 @@ public class NameConst {
|
|||||||
public static final String GUI_LEVEL_MAINTAINER = GUI_KEY + BLOCK_LEVEL_MAINTAINER;
|
public static final String GUI_LEVEL_MAINTAINER = GUI_KEY + BLOCK_LEVEL_MAINTAINER;
|
||||||
public static final String GUI_FLUID_PATTERN_ENCODER = GUI_KEY + BLOCK_FLUID_PATTERN_ENCODER;
|
public static final String GUI_FLUID_PATTERN_ENCODER = GUI_KEY + BLOCK_FLUID_PATTERN_ENCODER;
|
||||||
public static final String GUI_FLUID_PACKET_DECODER = GUI_KEY + BLOCK_FLUID_PACKET_DECODER;
|
public static final String GUI_FLUID_PACKET_DECODER = GUI_KEY + BLOCK_FLUID_PACKET_DECODER;
|
||||||
|
public static final String GUI_FLUID_AUTO_FILLER = GUI_KEY + BLOCK_FLUID_AUTO_FILLER;
|
||||||
public static final String GUI_INGREDIENT_BUFFER = GUI_KEY + BLOCK_INGREDIENT_BUFFER;
|
public static final String GUI_INGREDIENT_BUFFER = GUI_KEY + BLOCK_INGREDIENT_BUFFER;
|
||||||
public static final String GUI_LARGE_INGREDIENT_BUFFER = GUI_KEY + BLOCK_LARGE_INGREDIENT_BUFFER;
|
public static final String GUI_LARGE_INGREDIENT_BUFFER = GUI_KEY + BLOCK_LARGE_INGREDIENT_BUFFER;
|
||||||
public static final String GUI_FLUID_INTERFACE = GUI_KEY + BLOCK_FLUID_INTERFACE;
|
public static final String GUI_FLUID_INTERFACE = GUI_KEY + BLOCK_FLUID_INTERFACE;
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ tile.oc_pattern_editor.name=OC Pattern Editor
|
|||||||
tile.level_maintainer.name=ME Level Maintainer
|
tile.level_maintainer.name=ME Level Maintainer
|
||||||
tile.fluid_buffer.name=ME Fluid Buffer
|
tile.fluid_buffer.name=ME Fluid Buffer
|
||||||
tile.walrus.name=Walrus
|
tile.walrus.name=Walrus
|
||||||
|
tile.fluid_auto_filler.name=ME Fluid Auto Filler
|
||||||
|
|
||||||
ae2fc.waila.speed=Speed
|
ae2fc.waila.speed=Speed
|
||||||
ae2fc.waila.enable=Enable
|
ae2fc.waila.enable=Enable
|
||||||
@@ -108,6 +109,7 @@ ae2fc.gui.part_fluid_import=ME Fluid Import Bus
|
|||||||
ae2fc.gui.part_fluid_export=ME Fluid Export Bus
|
ae2fc.gui.part_fluid_export=ME Fluid Export Bus
|
||||||
ae2fc.gui.part_fluid_terminal=ME Fluid Terminal
|
ae2fc.gui.part_fluid_terminal=ME Fluid Terminal
|
||||||
ae2fc.gui.part_fluid_storage_bus=ME Fluid Storage Bus
|
ae2fc.gui.part_fluid_storage_bus=ME Fluid Storage Bus
|
||||||
|
ae2fc.gui.fluid_auto_filler=ME Fluid Auto Filler
|
||||||
|
|
||||||
error.unknown=Unknown
|
error.unknown=Unknown
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ tile.oc_pattern_editor.name=OC样板编辑器
|
|||||||
tile.level_maintainer.name=ME库存维持器
|
tile.level_maintainer.name=ME库存维持器
|
||||||
tile.fluid_buffer.name=ME流体缓存器
|
tile.fluid_buffer.name=ME流体缓存器
|
||||||
tile.walrus.name=海象
|
tile.walrus.name=海象
|
||||||
|
tile.fluid_auto_filler.name=ME流体自动装填器
|
||||||
|
|
||||||
ae2fc.waila.speed=速度
|
ae2fc.waila.speed=速度
|
||||||
ae2fc.waila.enable=启用
|
ae2fc.waila.enable=启用
|
||||||
@@ -106,6 +107,7 @@ ae2fc.gui.part_fluid_import=ME流体输入总线
|
|||||||
ae2fc.gui.part_fluid_export=ME流体输出总线
|
ae2fc.gui.part_fluid_export=ME流体输出总线
|
||||||
ae2fc.gui.part_fluid_terminal=流体终端
|
ae2fc.gui.part_fluid_terminal=流体终端
|
||||||
ae2fc.gui.part_fluid_storage_bus=ME流体存储总线
|
ae2fc.gui.part_fluid_storage_bus=ME流体存储总线
|
||||||
|
ae2fc.gui.fluid_auto_filler=ME流体自动装填器
|
||||||
|
|
||||||
error.unknown=未知流体
|
error.unknown=未知流体
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 995 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Reference in new issue
Block a user