mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
display every shitttttt!
This commit is contained in:
1 parent
12102ed23d
commit
3dcc7a72d1
6 files changed
+111
-27
No files matched your search
@@ -5,12 +5,15 @@ import appeng.client.gui.widgets.GuiNumberBox;
|
||||
import appeng.core.localization.GuiText;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.container.ContainerFluidLevelMaintainer;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.tile.TileFluidLevelMaintainer;
|
||||
import com.glodblock.github.network.CPacketUpdateFluidLevel;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -33,6 +36,22 @@ public class GuiFluidLevelMaintainer extends AEBaseGui {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderHoveredToolTip(int p_191948_1_, int p_191948_2_)
|
||||
{
|
||||
if (this.mc.player.inventory.getItemStack().isEmpty() && this.getSlotUnderMouse() != null
|
||||
&& this.getSlotUnderMouse().getHasStack() && this.getSlotUnderMouse() instanceof ContainerFluidLevelMaintainer.DisplayFluidSlot)
|
||||
{
|
||||
ItemStack packet = this.getSlotUnderMouse().getStack();
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(packet);
|
||||
this.renderToolTip(ItemFluidPacket.newDisplayStack(fluid), p_191948_1_, p_191948_2_);
|
||||
}
|
||||
else {
|
||||
super.renderHoveredToolTip(p_191948_1_, p_191948_2_);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key) throws IOException {
|
||||
|
||||
if (!this.checkHotbarKeys(key)) {
|
||||
@@ -92,7 +111,8 @@ public class GuiFluidLevelMaintainer extends AEBaseGui {
|
||||
IItemHandler inv = tile.getInventoryHandler();
|
||||
for (int i = 0; i < inv.getSlots(); i ++) {
|
||||
if (!inv.getStackInSlot(i).isEmpty()) {
|
||||
this.maintain[i].setText(String.valueOf(inv.getStackInSlot(i).getCount()));
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(inv.getStackInSlot(i));
|
||||
this.maintain[i].setText(String.valueOf(fluid == null ? "0" : fluid.amount));
|
||||
}
|
||||
else {
|
||||
this.maintain[i].setText("0");
|
||||
|
||||
+35
-14
@@ -2,16 +2,19 @@ package com.glodblock.github.client.container;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.tile.TileFluidLevelMaintainer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ContainerFluidLevelMaintainer extends AEBaseContainer {
|
||||
@@ -32,40 +35,58 @@ public class ContainerFluidLevelMaintainer extends AEBaseContainer {
|
||||
return tile;
|
||||
}
|
||||
|
||||
private static class DisplayFluidSlot extends SlotFake {
|
||||
@Override
|
||||
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
|
||||
Slot slot = getSlot(slotId);
|
||||
if (slot instanceof DisplayFluidSlot) {
|
||||
final ItemStack stack = player.inventory.getItemStack();
|
||||
slot.putStack(stack.isEmpty() ? stack : stack.copy());
|
||||
} else {
|
||||
super.doAction(player, action, slotId, id);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DisplayFluidSlot extends SlotFake {
|
||||
|
||||
final AppEngInternalAEInventory handler;
|
||||
|
||||
public DisplayFluidSlot(IItemHandler inv, int idx, int x, int y) {
|
||||
super(inv, idx, x, y);
|
||||
this.handler = (AppEngInternalAEInventory) inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack is) {
|
||||
//System.out.print(is + "\n");
|
||||
if (is.isEmpty()) {
|
||||
super.putStack(is);
|
||||
return;
|
||||
}
|
||||
if (is.getItem() instanceof ItemFluidPacket) {
|
||||
super.putStack(is);
|
||||
return;
|
||||
}
|
||||
if (is.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
|
||||
IFluidTankProperties[] tanks = Objects.requireNonNull(
|
||||
is.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null))
|
||||
.getTankProperties();
|
||||
for (IFluidTankProperties tank : tanks) {
|
||||
ItemStack drops = ItemFluidDrop.newStack(tank.getContents());
|
||||
super.putStack(drops);
|
||||
ItemStack packet = ItemFluidPacket.newStack(tank.getContents());
|
||||
super.putStack(packet);
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public ItemStack getDisplayStack() {
|
||||
ItemStack drops = super.getDisplayStack();
|
||||
System.out.print(drops + "\n");
|
||||
FluidStack fluid = ItemFluidDrop.getFluidStack(drops);
|
||||
System.out.print(fluid + "\n");
|
||||
return ItemFluidPacket.newDisplayStack(fluid);
|
||||
}*/
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemStackLimit(@Nonnull ItemStack stack) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ItemFluidPacket extends Item implements HasCustomModel {
|
||||
FluidStack fluid = getFluidStack(stack);
|
||||
boolean display = isDisplay(stack);
|
||||
if (display) {
|
||||
return fluid != null ? fluid.getUnlocalizedName() : super.getItemStackDisplayName(stack);
|
||||
return fluid != null ? fluid.getLocalizedName() : super.getItemStackDisplayName(stack);
|
||||
}
|
||||
return fluid != null ? String.format("%s, %,d mB", fluid.getLocalizedName(), fluid.amount)
|
||||
: super.getItemStackDisplayName(stack);
|
||||
|
||||
@@ -29,18 +29,34 @@ import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.util.DummyInvAdaptor;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
||||
public class TileFluidLevelMaintainer extends AENetworkTile implements IStackWatcherHost, ICraftingRequester, IAEAppEngInventory {
|
||||
|
||||
public static final int MAX_FLUID = 5;
|
||||
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, MAX_FLUID);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, MAX_FLUID) {
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getStackLimit(int slot, @Nonnull ItemStack stack) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
};
|
||||
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker(this, MAX_FLUID);
|
||||
private final long[] request = new long[MAX_FLUID];
|
||||
private final long[] reportValue = new long[MAX_FLUID];
|
||||
@@ -65,7 +81,11 @@ public class TileFluidLevelMaintainer extends AENetworkTile implements IStackWat
|
||||
if (id < 0 || id > MAX_FLUID || this.config.getStackInSlot(id).isEmpty()) {
|
||||
return;
|
||||
}
|
||||
this.config.getStackInSlot(id).setCount(size);
|
||||
ItemStack packet = this.config.getStackInSlot(id);
|
||||
FluidStack copy = ItemFluidPacket.getFluidStack(packet);
|
||||
if (copy != null)
|
||||
copy.amount = size;
|
||||
this.config.setStackInSlot(id, ItemFluidPacket.newStack(copy));
|
||||
}
|
||||
|
||||
public void setRequest(int id, long amount) {
|
||||
@@ -83,6 +103,27 @@ public class TileFluidLevelMaintainer extends AENetworkTile implements IStackWat
|
||||
return this.request;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream(ByteBuf data) throws IOException {
|
||||
boolean changed = super.readFromStream(data);
|
||||
for (int i = 0; i < config.getSlots(); i++) {
|
||||
ItemStack stack = ByteBufUtils.readItemStack(data);
|
||||
if (!ItemStack.areItemStacksEqual(stack, config.getStackInSlot(i))) {
|
||||
config.setStackInSlot(i, stack);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream(ByteBuf data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
for (int i = 0; i < config.getSlots(); i++) {
|
||||
ByteBufUtils.writeItemStack(data, config.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
@@ -179,7 +220,8 @@ public class TileFluidLevelMaintainer extends AENetworkTile implements IStackWat
|
||||
watcher.reset();
|
||||
for (int i = 0; i < MAX_FLUID; i ++ ) {
|
||||
if (this.config.getAEStackInSlot(i) != null && !this.config.getAEStackInSlot(i).getDefinition().isEmpty()) {
|
||||
watcher.add(this.config.getAEStackInSlot(i));
|
||||
IAEItemStack packet = this.config.getAEStackInSlot(i);
|
||||
watcher.add(ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(packet)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,13 +232,14 @@ public class TileFluidLevelMaintainer extends AENetworkTile implements IStackWat
|
||||
if (chan == AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class) && fullStack instanceof IAEFluidStack) {
|
||||
for (int i = 0; i < MAX_FLUID; i ++) {
|
||||
try {
|
||||
IAEItemStack marked = this.config.getAEStackInSlot(i);
|
||||
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(marked);
|
||||
IAEItemStack packet = this.config.getAEStackInSlot(i);
|
||||
IAEFluidStack fluid = AEFluidStack.fromFluidStack(ItemFluidPacket.getFluidStack(packet));
|
||||
if (fluid != null && fluid.getFluidStack() != null
|
||||
&& fluid.getFluidStack().isFluidEqual(((IAEFluidStack)diffStack).getFluidStack())) {
|
||||
this.reportValue[i] = fullStack.getStackSize();
|
||||
if (this.reportValue[i] < this.config.getAEStackInSlot(i).getStackSize()) {
|
||||
this.craftingTracker.handleCrafting(i, request[i], this.config.getAEStackInSlot(i), DummyInvAdaptor.INSTANCE, this.world, this.getProxy().getGrid(), this.getProxy().getCrafting(), this.source );
|
||||
IAEItemStack drops = ItemFluidDrop.newAeStack(fluid);
|
||||
if (drops != null && this.reportValue[i] < drops.getStackSize()) {
|
||||
this.craftingTracker.handleCrafting(i, request[i], drops, DummyInvAdaptor.INSTANCE, this.world, this.getProxy().getGrid(), this.getProxy().getCrafting(), this.source );
|
||||
}
|
||||
}
|
||||
} catch (GridAccessException e) {
|
||||
|
||||
@@ -20,8 +20,8 @@ public class FCBlocks {
|
||||
public static BlockBurette BURETTE;
|
||||
@GameRegistry.ObjectHolder(FluidCraft.MODID + ":" + NameConst.BLOCK_DUAL_INTERFACE)
|
||||
public static BlockDualInterface DUAL_INTERFACE;
|
||||
/*@GameRegistry.ObjectHolder(FluidCraft.MODID + ":" + NameConst.BLOCK_FLUID_LEVEL_MAINTAINER)
|
||||
public static BlockFluidLevelMaintainer FLUID_LEVEL_MAINTAINER;*/
|
||||
@GameRegistry.ObjectHolder(FluidCraft.MODID + ":" + NameConst.BLOCK_FLUID_LEVEL_MAINTAINER)
|
||||
public static BlockFluidLevelMaintainer FLUID_LEVEL_MAINTAINER;
|
||||
|
||||
public static void init(RegistryHandler regHandler) {
|
||||
regHandler.block(NameConst.BLOCK_FLUID_DISCRETIZER, new BlockFluidDiscretizer());
|
||||
@@ -30,7 +30,7 @@ public class FCBlocks {
|
||||
regHandler.block(NameConst.BLOCK_INGREDIENT_BUFFER, new BlockIngredientBuffer());
|
||||
regHandler.block(NameConst.BLOCK_BURETTE, new BlockBurette());
|
||||
regHandler.block(NameConst.BLOCK_DUAL_INTERFACE, new BlockDualInterface());
|
||||
//regHandler.block(NameConst.BLOCK_FLUID_LEVEL_MAINTAINER, new BlockFluidLevelMaintainer());
|
||||
regHandler.block(NameConst.BLOCK_FLUID_LEVEL_MAINTAINER, new BlockFluidLevelMaintainer());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class CommonProxy {
|
||||
GameRegistry.registerTileEntity(TileIngredientBuffer.class, FluidCraft.resource(NameConst.BLOCK_INGREDIENT_BUFFER));
|
||||
GameRegistry.registerTileEntity(TileBurette.class, FluidCraft.resource(NameConst.BLOCK_BURETTE));
|
||||
GameRegistry.registerTileEntity(TileDualInterface.class, FluidCraft.resource(NameConst.BLOCK_DUAL_INTERFACE));
|
||||
//GameRegistry.registerTileEntity(TileFluidLevelMaintainer.class, FluidCraft.resource(NameConst.BLOCK_FLUID_LEVEL_MAINTAINER));
|
||||
GameRegistry.registerTileEntity(TileFluidLevelMaintainer.class, FluidCraft.resource(NameConst.BLOCK_FLUID_LEVEL_MAINTAINER));
|
||||
(new ChannelLoader()).run();
|
||||
if (ModAndClassUtil.AUTO_P) {
|
||||
initPackagedAutoIntegration();
|
||||
|
||||
Reference in new issue
Block a user