From 67abd1ec9e4bc11bba6d3cc926faf42b026bec07 Mon Sep 17 00:00:00 2001 From: GlodBlock <1356392126@qq.com> Date: Mon, 16 May 2022 17:33:35 +0800 Subject: [PATCH] add buffer --- .../client/gui/GuiIngredientBuffer.java | 102 ++ .../github/client/gui/TankDumpable.java | 9 + .../container/ContainerIngredientBuffer.java | 64 + .../common/block/BlockIngredientBuffer.java | 55 + .../common/tile/TileIngredientBuffer.java | 154 ++ .../github/inventory/AEFluidInventory.java | 3 +- .../inventory/AeStackInventoryImpl.java | 3 +- .../inventory/gui/ButtonMouseHandler.java | 47 + .../github/inventory/gui/GuiType.java | 13 + .../inventory/gui/TankMouseHandler.java | 34 + .../github/loader/ChannelLoader.java | 2 + .../github/loader/ItemAndBlockHolder.java | 6 +- .../glodblock/github/loader/RecipeLoader.java | 5 + .../github/network/CPacketDumpTank.java | 48 + .../github/network/SPacketFluidUpdate.java | 81 ++ .../glodblock/github/util/GlStateManager.java | 1252 +++++++++++++++++ .../com/glodblock/github/util/NameConst.java | 4 + .../java/com/glodblock/github/util/Util.java | 18 +- .../resources/assets/ae2fc/lang/en_US.lang | 4 + .../textures/blocks/ingredient_buffer.png | Bin 0 -> 6180 bytes .../ae2fc/textures/gui/ingredient_buffer.png | Bin 0 -> 1614 bytes 21 files changed, 1895 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/glodblock/github/client/gui/GuiIngredientBuffer.java create mode 100644 src/main/java/com/glodblock/github/client/gui/TankDumpable.java create mode 100644 src/main/java/com/glodblock/github/client/gui/container/ContainerIngredientBuffer.java create mode 100644 src/main/java/com/glodblock/github/common/block/BlockIngredientBuffer.java create mode 100644 src/main/java/com/glodblock/github/common/tile/TileIngredientBuffer.java create mode 100644 src/main/java/com/glodblock/github/inventory/gui/ButtonMouseHandler.java create mode 100644 src/main/java/com/glodblock/github/inventory/gui/TankMouseHandler.java create mode 100644 src/main/java/com/glodblock/github/network/CPacketDumpTank.java create mode 100644 src/main/java/com/glodblock/github/network/SPacketFluidUpdate.java create mode 100644 src/main/java/com/glodblock/github/util/GlStateManager.java create mode 100644 src/main/resources/assets/ae2fc/textures/blocks/ingredient_buffer.png create mode 100644 src/main/resources/assets/ae2fc/textures/gui/ingredient_buffer.png diff --git a/src/main/java/com/glodblock/github/client/gui/GuiIngredientBuffer.java b/src/main/java/com/glodblock/github/client/gui/GuiIngredientBuffer.java new file mode 100644 index 00000000..f7c397ec --- /dev/null +++ b/src/main/java/com/glodblock/github/client/gui/GuiIngredientBuffer.java @@ -0,0 +1,102 @@ +package com.glodblock.github.client.gui; + +import appeng.api.storage.data.IAEFluidStack; +import appeng.client.gui.AEBaseGui; +import appeng.core.localization.GuiText; +import com.glodblock.github.FluidCraft; +import com.glodblock.github.client.gui.container.ContainerIngredientBuffer; +import com.glodblock.github.common.tile.TileIngredientBuffer; +import com.glodblock.github.inventory.IAEFluidTank; +import com.glodblock.github.inventory.gui.ButtonMouseHandler; +import com.glodblock.github.inventory.gui.MouseRegionManager; +import com.glodblock.github.inventory.gui.TankMouseHandler; +import com.glodblock.github.util.GlStateManager; +import com.glodblock.github.util.NameConst; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; + +import javax.annotation.Nullable; + +public class GuiIngredientBuffer extends AEBaseGui { + + private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/ingredient_buffer.png"); + private static final int TANK_X = 47, TANK_X_OFF = 22, TANK_Y = 18; + private static final int TANK_WIDTH = 16, TANK_HEIGHT = 74; + + private final ContainerIngredientBuffer cont; + private final MouseRegionManager mouseRegions = new MouseRegionManager(this, this.fontRendererObj); + + public GuiIngredientBuffer(InventoryPlayer ipl, TileIngredientBuffer tile) { + super(new ContainerIngredientBuffer(ipl, tile)); + this.cont = (ContainerIngredientBuffer) inventorySlots; + this.ySize = 222; + for (int i = 0; i < 4; i++) { + mouseRegions.addRegion(TANK_X + TANK_X_OFF * i, TANK_Y, TANK_WIDTH, TANK_HEIGHT, + new TankMouseHandler(cont.getTile().getFluidInventory(), i)); + mouseRegions.addRegion(TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7, + ButtonMouseHandler.dumpTank(cont, i)); + } + } + + @Override + protected void mouseClicked(int xCoord, int yCoord, int btn) { + if (mouseRegions.onClick(xCoord, yCoord, btn)) { + super.mouseClicked(xCoord, yCoord, btn); + } + } + + @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_INGREDIENT_BUFFER)), 8, 6, 0x404040); + fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040); + GlStateManager.color(1F, 1F, 1F, 1F); + + IAEFluidTank fluidInv = cont.getTile().getFluidInventory(); + mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + Tessellator tess = Tessellator.instance; + for (int i = 0; i < 4; i++) { + renderFluidIntoGui(tess, TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT, + fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity); + } + GlStateManager.color(1F, 1F, 1F, 1F); + + mouseRegions.render(mouseX, mouseY); + } + + public void renderFluidIntoGui(Tessellator tess, int x, int y, int width, int height, + @Nullable IAEFluidStack aeFluidStack, int capacity) { + if (aeFluidStack != null) { + GL11.glDisable(2896); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + int hi = (int) (height * ((double) aeFluidStack.getStackSize() / capacity)); + if (aeFluidStack.getStackSize() > 0 && hi > 0) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon(); + GL11.glColor3f((float)(aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() & 255) / 255.0F); + for (int th = 0; th <= hi; th += 16) { + if (hi - th <= 0) break; + this.drawTexturedModelRectFromIcon(x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th)); + } + GL11.glColor3f(1.0F, 1.0F, 1.0F); + } + } + } + + public void update(int slot, IAEFluidStack aeFluidStack) { + cont.getTile().getFluidInventory().setFluidInSlot(slot, aeFluidStack); + } + +} diff --git a/src/main/java/com/glodblock/github/client/gui/TankDumpable.java b/src/main/java/com/glodblock/github/client/gui/TankDumpable.java new file mode 100644 index 00000000..b71f2fe3 --- /dev/null +++ b/src/main/java/com/glodblock/github/client/gui/TankDumpable.java @@ -0,0 +1,9 @@ +package com.glodblock.github.client.gui; + +public interface TankDumpable { + + boolean canDumpTank(int index); + + void dumpTank(int index); + +} diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerIngredientBuffer.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerIngredientBuffer.java new file mode 100644 index 00000000..c2f06be5 --- /dev/null +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerIngredientBuffer.java @@ -0,0 +1,64 @@ +package com.glodblock.github.client.gui.container; + +import appeng.api.storage.data.IAEFluidStack; +import appeng.container.AEBaseContainer; +import appeng.container.slot.SlotNormal; +import com.glodblock.github.FluidCraft; +import com.glodblock.github.client.gui.TankDumpable; +import com.glodblock.github.common.tile.TileIngredientBuffer; +import com.glodblock.github.network.SPacketFluidUpdate; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; + +import java.util.HashMap; +import java.util.Map; + +public class ContainerIngredientBuffer extends AEBaseContainer implements TankDumpable { + + private final TileIngredientBuffer tile; + + public ContainerIngredientBuffer(InventoryPlayer ipl, TileIngredientBuffer tile) { + super(ipl, tile); + this.tile = tile; + IInventory inv = tile.getInternalInventory(); + for (int i = 0; i < 9; i++) { + addSlotToContainer(new SlotNormal(inv, i, 8 + 18 * i, 108)); + } + bindPlayerInventory(ipl, 0, 140); + } + + public TileIngredientBuffer getTile() { + return tile; + } + + @Override + public boolean canDumpTank(int index) { + return tile.getFluidInventory().getFluidInSlot(index) != null; + } + + @Override + public void dumpTank(int index) { + if (index >= 0 && index < tile.getFluidInventory().getSlots()) { + tile.getFluidInventory().setFluidInSlot(index, null); + } + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + Map tmp = new HashMap<>(); + for (int i = 0; i < tile.getFluidInventory().getSlots(); i ++) { + tmp.put(i, tile.getFluidInventory().getFluidInSlot(i)); + } + for( final Object g : this.crafters ) + { + if( g instanceof EntityPlayer) + { + FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g); + } + } + } +} diff --git a/src/main/java/com/glodblock/github/common/block/BlockIngredientBuffer.java b/src/main/java/com/glodblock/github/common/block/BlockIngredientBuffer.java new file mode 100644 index 00000000..d1308fd4 --- /dev/null +++ b/src/main/java/com/glodblock/github/common/block/BlockIngredientBuffer.java @@ -0,0 +1,55 @@ +package com.glodblock.github.common.block; + +import appeng.block.AEBaseItemBlock; +import com.glodblock.github.common.tile.TileIngredientBuffer; +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 cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +public class BlockIngredientBuffer extends FCBaseBlock { + + public BlockIngredientBuffer() { + super(Material.iron, NameConst.BLOCK_INGREDIENT_BUFFER); + setTileEntity(TileIngredientBuffer.class); + setOpaque(false); + setFullBlock(false); + this.lightOpacity = 4; + } + + @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; + } + TileIngredientBuffer tile = getTileEntity(world, x, y, z); + if (tile != null) { + if (!world.isRemote) { + InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.INGREDIENT_BUFFER); + } + return true; + } + return false; + } + + public BlockIngredientBuffer register() { + GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_INGREDIENT_BUFFER); + GameRegistry.registerTileEntity(TileIngredientBuffer.class, NameConst.BLOCK_INGREDIENT_BUFFER); + return this; + } + + public ItemStack stack(int size) { + return new ItemStack(this, size); + } + + public ItemStack stack() { + return new ItemStack(this, 1); + } + +} diff --git a/src/main/java/com/glodblock/github/common/tile/TileIngredientBuffer.java b/src/main/java/com/glodblock/github/common/tile/TileIngredientBuffer.java new file mode 100644 index 00000000..8a3817e5 --- /dev/null +++ b/src/main/java/com/glodblock/github/common/tile/TileIngredientBuffer.java @@ -0,0 +1,154 @@ +package com.glodblock.github.common.tile; + +import appeng.api.storage.data.IAEFluidStack; +import appeng.tile.AEBaseInvTile; +import appeng.tile.TileEvent; +import appeng.tile.events.TileEventType; +import appeng.tile.inventory.AppEngInternalInventory; +import appeng.tile.inventory.InvOperation; +import appeng.util.item.AEFluidStack; +import com.glodblock.github.inventory.AEFluidInventory; +import com.glodblock.github.inventory.IAEFluidInventory; +import com.glodblock.github.inventory.IAEFluidTank; +import cpw.mods.fml.common.network.ByteBufUtils; +import io.netty.buffer.ByteBuf; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +import javax.annotation.Nonnull; +import java.io.IOException; + +public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInventory, IFluidHandler { + + private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 9); + private final AEFluidInventory invFluids = new AEFluidInventory(this, 4, 64000); + + @Nonnull + @Override + public IInventory getInternalInventory() { + return invItems; + } + + public IAEFluidTank getFluidInventory() { + return invFluids; + } + + @Override + public boolean canBeRotated() { + return false; + } + + @Override + public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added) { + markForUpdate(); + } + + @Override + public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) { + return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8}; + } + + @Override + public void onFluidInventoryChanged(IAEFluidTank inv, int slot) { + saveChanges(); + markForUpdate(); + } + + @TileEvent( TileEventType.NETWORK_WRITE ) + protected void writeToStream(ByteBuf data) throws IOException { + for (int i = 0; i < invItems.getSizeInventory(); i++) { + ByteBufUtils.writeItemStack(data, invItems.getStackInSlot(i)); + } + int fluidMask = 0; + for (int i = 0; i < invFluids.getSlots(); i++) { + if (invFluids.getFluidInSlot(i) != null) { + fluidMask |= 1 << i; + } + } + data.writeByte(fluidMask); + for (int i = 0; i < invFluids.getSlots(); i++) { + IAEFluidStack fluid = invFluids.getFluidInSlot(i); + if (fluid != null) { + fluid.writeToPacket(data); + } + } + } + + @TileEvent( TileEventType.NETWORK_READ ) + protected boolean readFromStream(ByteBuf data) throws IOException { + boolean changed = false; + for (int i = 0; i < invItems.getSizeInventory(); i++) { + ItemStack stack = ByteBufUtils.readItemStack(data); + if (!ItemStack.areItemStacksEqual(stack, invItems.getStackInSlot(i))) { + invItems.setInventorySlotContents(i, stack); + changed = true; + } + } + int fluidMask = data.readByte(); + for (int i = 0; i < invFluids.getSlots(); i++) { + if ((fluidMask & (1 << i)) != 0) { + IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data); + if (fluid != null) { // this shouldn't happen, but better safe than sorry + IAEFluidStack origFluid = invFluids.getFluidInSlot(i); + if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) { + invFluids.setFluidInSlot(i, fluid); + changed = true; + } + } + } else if (invFluids.getFluidInSlot(i) != null) { + invFluids.setFluidInSlot(i, null); + changed = true; + } + } + return changed; + } + + @TileEvent( TileEventType.WORLD_NBT_READ ) + public void readFromNBTEvent(NBTTagCompound data) { + invItems.readFromNBT(data, "ItemInv"); + invFluids.readFromNBT(data, "FluidInv"); + } + + @TileEvent( TileEventType.WORLD_NBT_WRITE ) + public NBTTagCompound writeToNBTEvent(NBTTagCompound data) { + invItems.writeToNBT(data, "ItemInv"); + invFluids.writeToNBT(data, "FluidInv"); + return data; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return invFluids.fill(from, resource, doFill); + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return invFluids.drain(from, resource, doDrain); + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return invFluids.drain(from, maxDrain, doDrain); + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return invFluids.canFill(from, fluid); + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return invFluids.canDrain(from, fluid); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return invFluids.getTankInfo(ForgeDirection.UNKNOWN); + } +} diff --git a/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java b/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java index b029b0b3..fa59f5bc 100644 --- a/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java +++ b/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java @@ -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 ) diff --git a/src/main/java/com/glodblock/github/inventory/AeStackInventoryImpl.java b/src/main/java/com/glodblock/github/inventory/AeStackInventoryImpl.java index 53bc590d..f34b21f6 100644 --- a/src/main/java/com/glodblock/github/inventory/AeStackInventoryImpl.java +++ b/src/main/java/com/glodblock/github/inventory/AeStackInventoryImpl.java @@ -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 > 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); } } } diff --git a/src/main/java/com/glodblock/github/inventory/gui/ButtonMouseHandler.java b/src/main/java/com/glodblock/github/inventory/gui/ButtonMouseHandler.java new file mode 100644 index 00000000..33e354cb --- /dev/null +++ b/src/main/java/com/glodblock/github/inventory/gui/ButtonMouseHandler.java @@ -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 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)); + } + }); + } + +} diff --git a/src/main/java/com/glodblock/github/inventory/gui/GuiType.java b/src/main/java/com/glodblock/github/inventory/gui/GuiType.java index 826cdcf9..fc44b4cc 100644 --- a/src/main/java/com/glodblock/github/inventory/gui/GuiType.java +++ b/src/main/java/com/glodblock/github/inventory/gui/GuiType.java @@ -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.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.class) { @Override protected Object createServerGui(EntityPlayer player, FCBasePart inv) { diff --git a/src/main/java/com/glodblock/github/inventory/gui/TankMouseHandler.java b/src/main/java/com/glodblock/github/inventory/gui/TankMouseHandler.java new file mode 100644 index 00000000..369fe21c --- /dev/null +++ b/src/main/java/com/glodblock/github/inventory/gui/TankMouseHandler.java @@ -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 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)); + } + +} diff --git a/src/main/java/com/glodblock/github/loader/ChannelLoader.java b/src/main/java/com/glodblock/github/loader/ChannelLoader.java index 317a7f5c..b5ea8ac6 100644 --- a/src/main/java/com/glodblock/github/loader/ChannelLoader.java +++ b/src/main/java/com/glodblock/github/loader/ChannelLoader.java @@ -18,5 +18,7 @@ public class ChannelLoader implements Runnable { FluidCraft.proxy.netHandler.registerMessage(new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id ++, Side.CLIENT); FluidCraft.proxy.netHandler.registerMessage(new SPacketFluidSlot.Handler(), SPacketFluidSlot.class, id ++, Side.SERVER); FluidCraft.proxy.netHandler.registerMessage(new CPacketTransferRecipe.Handler(), CPacketTransferRecipe.class, id ++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage(new CPacketDumpTank.Handler(), CPacketDumpTank.class, id ++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage(new SPacketFluidUpdate.Handler(), SPacketFluidUpdate.class, id ++, Side.CLIENT); } } diff --git a/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java b/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java index 7c4f9d47..267655d2 100644 --- a/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java +++ b/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java @@ -1,10 +1,7 @@ package com.glodblock.github.loader; import com.glodblock.github.common.Config; -import com.glodblock.github.common.block.BlockFluidDiscretizer; -import com.glodblock.github.common.block.BlockFluidInterface; -import com.glodblock.github.common.block.BlockFluidPacketDecoder; -import com.glodblock.github.common.block.BlockFluidPatternEncoder; +import com.glodblock.github.common.block.*; import com.glodblock.github.common.item.*; import com.glodblock.github.common.storage.CellType; @@ -29,6 +26,7 @@ public class ItemAndBlockHolder { public static BlockFluidPatternEncoder ENCODER = new BlockFluidPatternEncoder().register(); public static BlockFluidPacketDecoder DECODER = new BlockFluidPacketDecoder().register(); public static BlockFluidInterface INTERFACE = new BlockFluidInterface().register(); + public static BlockIngredientBuffer BUFFER = new BlockIngredientBuffer().register(); public static void loadSetting() { if (!Config.fluidCells) return; diff --git a/src/main/java/com/glodblock/github/loader/RecipeLoader.java b/src/main/java/com/glodblock/github/loader/RecipeLoader.java index 724a328b..4df4c685 100644 --- a/src/main/java/com/glodblock/github/loader/RecipeLoader.java +++ b/src/main/java/com/glodblock/github/loader/RecipeLoader.java @@ -5,6 +5,7 @@ import com.glodblock.github.common.item.ItemBasicFluidStorageCell; import com.glodblock.github.common.storage.CellType; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; @@ -27,6 +28,9 @@ public class RecipeLoader implements Runnable { public final static ItemStack AE2_QUARTZ_GLASS = GameRegistry.findItemStack("appliedenergistics2", "tile.BlockQuartzGlass", 1); public final static ItemStack AE2_LAMP_GLASS = GameRegistry.findItemStack("appliedenergistics2", "tile.BlockQuartzLamp", 1); public final static ItemStack AE2_CELL_HOUSING = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 39); + public final static ItemStack AE2_CELL_1K = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 35); + public final static ItemStack AE2_CORE_ANN = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 44); + public final static ItemStack AE2_CORE_FOM = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 43); @Override public void run() { @@ -38,6 +42,7 @@ public class RecipeLoader implements Runnable { GameRegistry.addRecipe(new ShapedOreRecipe(ENCODER.stack(), "LPL", "IWI", "III", 'I', "ingotIron", 'L', "blockLapis", 'P', AE2_PROCESS_ENG, 'W', AE2_WORK_BENCH)); GameRegistry.addShapelessRecipe(FLUID_TERMINAL.stack(), AE2_PATTERN_TERM, ENCODER); GameRegistry.addShapelessRecipe(FLUID_TERMINAL_EX.stack(), FLUID_TERMINAL.stack(), AE2_PROCESS_CAL, AE2_PROCESS_ENG, AE2_PROCESS_LOG); + GameRegistry.addRecipe(new ShapedOreRecipe(BUFFER.stack(), "ILI", "AGF", "IBI", 'I', "ingotIron", 'G', AE2_QUARTZ_GLASS, 'L', AE2_CELL_1K, 'A', AE2_CORE_ANN, 'F', AE2_CORE_FOM, 'B', Items.bucket)); if (Config.fluidCells) { OreDictionary.registerOre("anyCertusCrystal", AE2_PURE_CERTUS); diff --git a/src/main/java/com/glodblock/github/network/CPacketDumpTank.java b/src/main/java/com/glodblock/github/network/CPacketDumpTank.java new file mode 100644 index 00000000..8906b074 --- /dev/null +++ b/src/main/java/com/glodblock/github/network/CPacketDumpTank.java @@ -0,0 +1,48 @@ +package com.glodblock.github.network; + +import com.glodblock.github.client.gui.TankDumpable; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayerMP; + +import javax.annotation.Nullable; + +public class CPacketDumpTank implements IMessage { + + private int index; + + public CPacketDumpTank(int index) { + this.index = index; + } + + public CPacketDumpTank() { + // NO-OP + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeShort(index); + } + + @Override + public void fromBytes(ByteBuf buf) { + index = buf.readShort(); + } + + public static class Handler implements IMessageHandler { + + @Nullable + @Override + public IMessage onMessage(CPacketDumpTank message, MessageContext ctx) { + EntityPlayerMP player = ctx.getServerHandler().playerEntity; + if (player.openContainer instanceof TankDumpable) { + ((TankDumpable)player.openContainer).dumpTank(message.index); + } + return null; + } + + } + +} diff --git a/src/main/java/com/glodblock/github/network/SPacketFluidUpdate.java b/src/main/java/com/glodblock/github/network/SPacketFluidUpdate.java new file mode 100644 index 00000000..63a4d859 --- /dev/null +++ b/src/main/java/com/glodblock/github/network/SPacketFluidUpdate.java @@ -0,0 +1,81 @@ +package com.glodblock.github.network; + +import appeng.api.storage.data.IAEFluidStack; +import appeng.util.item.AEFluidStack; +import com.glodblock.github.client.gui.GuiIngredientBuffer; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class SPacketFluidUpdate implements IMessage { + + private Map list; + + public SPacketFluidUpdate() { + } + + public SPacketFluidUpdate(Map data) { + this.list = data; + } + + @Override + public void fromBytes(ByteBuf buf) { + int size = buf.readInt(); + this.list = new HashMap<>(); + try { + for (int i = 0; i < size; i ++) { + int id = buf.readInt(); + boolean isNull = buf.readBoolean(); + if (!isNull) + list.put(id, null); + else { + IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(buf); + list.put(id, fluid); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(list.size()); + try { + for (Map.Entry fs : list.entrySet()) { + buf.writeInt(fs.getKey()); + if (fs.getValue() == null) + buf.writeBoolean(false); + else { + buf.writeBoolean(true); + fs.getValue().writeToPacket(buf); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static class Handler implements IMessageHandler { + + @Override + public IMessage onMessage(SPacketFluidUpdate message, MessageContext ctx) { + final GuiScreen gs = Minecraft.getMinecraft().currentScreen; + if( gs instanceof GuiIngredientBuffer) + { + for (Map.Entry e : message.list.entrySet() ) { + ( (GuiIngredientBuffer) gs ).update(e.getKey(), e.getValue()); + } + } + return null; + } + + } +} diff --git a/src/main/java/com/glodblock/github/util/GlStateManager.java b/src/main/java/com/glodblock/github/util/GlStateManager.java new file mode 100644 index 00000000..68b24ea4 --- /dev/null +++ b/src/main/java/com/glodblock/github/util/GlStateManager.java @@ -0,0 +1,1252 @@ +package com.glodblock.github.util; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import javax.annotation.Nullable; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; +import org.lwjgl.opengl.GLContext; +import org.lwjgl.util.vector.Quaternion; + +@SideOnly(Side.CLIENT) +public class GlStateManager { + private static final FloatBuffer colorBuffer = GLAllocation.createDirectFloatBuffer(16); + private static final FloatBuffer BUF_FLOAT_16 = BufferUtils.createFloatBuffer(16); + private static final FloatBuffer BUF_FLOAT_4 = BufferUtils.createFloatBuffer(4); + private static final GlStateManager.AlphaState alphaState = new GlStateManager.AlphaState(); + private static final GlStateManager.BooleanState lightingState = new GlStateManager.BooleanState(2896); + private static final GlStateManager.BooleanState[] lightState = new GlStateManager.BooleanState[8]; + private static final GlStateManager.ColorMaterialState colorMaterialState; + private static final GlStateManager.BlendState blendState; + private static final GlStateManager.DepthState depthState; + private static final GlStateManager.FogState fogState; + private static final GlStateManager.CullState cullState; + private static final GlStateManager.PolygonOffsetState polygonOffsetState; + private static final GlStateManager.ColorLogicState colorLogicState; + private static final GlStateManager.TexGenState texGenState; + private static final GlStateManager.ClearState clearState; + private static final GlStateManager.StencilState stencilState; + private static final GlStateManager.BooleanState normalizeState; + private static int activeTextureUnit; + private static final GlStateManager.TextureState[] textureState; + private static int activeShadeModel; + private static final GlStateManager.BooleanState rescaleNormalState; + private static final GlStateManager.ColorMask colorMaskState; + private static final GlStateManager.Color colorState; + + public GlStateManager() { + } + + public static void pushAttrib() { + GL11.glPushAttrib(8256); + } + + public static void popAttrib() { + GL11.glPopAttrib(); + } + + public static void disableAlpha() { + alphaState.alphaTest.setDisabled(); + } + + public static void enableAlpha() { + alphaState.alphaTest.setEnabled(); + } + + public static void alphaFunc(int func, float ref) { + if (func != alphaState.func || ref != alphaState.ref) { + alphaState.func = func; + alphaState.ref = ref; + GL11.glAlphaFunc(func, ref); + } + + } + + public static void enableLighting() { + lightingState.setEnabled(); + } + + public static void disableLighting() { + lightingState.setDisabled(); + } + + public static void enableLight(int light) { + lightState[light].setEnabled(); + } + + public static void disableLight(int light) { + lightState[light].setDisabled(); + } + + public static void enableColorMaterial() { + colorMaterialState.colorMaterial.setEnabled(); + } + + public static void disableColorMaterial() { + colorMaterialState.colorMaterial.setDisabled(); + } + + public static void colorMaterial(int face, int mode) { + if (face != colorMaterialState.face || mode != colorMaterialState.mode) { + colorMaterialState.face = face; + colorMaterialState.mode = mode; + GL11.glColorMaterial(face, mode); + } + + } + + public static void glLight(int light, int pname, FloatBuffer params) { + GL11.glLight(light, pname, params); + } + + public static void glLightModel(int pname, FloatBuffer params) { + GL11.glLightModel(pname, params); + } + + public static void glNormal3f(float nx, float ny, float nz) { + GL11.glNormal3f(nx, ny, nz); + } + + public static void disableDepth() { + depthState.depthTest.setDisabled(); + } + + public static void enableDepth() { + depthState.depthTest.setEnabled(); + } + + public static void depthFunc(int depthFunc) { + if (depthFunc != depthState.depthFunc) { + depthState.depthFunc = depthFunc; + GL11.glDepthFunc(depthFunc); + } + + } + + public static void depthMask(boolean flagIn) { + if (flagIn != depthState.maskEnabled) { + depthState.maskEnabled = flagIn; + GL11.glDepthMask(flagIn); + } + + } + + public static void disableBlend() { + blendState.blend.setDisabled(); + } + + public static void enableBlend() { + blendState.blend.setEnabled(); + } + + public static void blendFunc(GlStateManager.SourceFactor srcFactor, GlStateManager.DestFactor dstFactor) { + blendFunc(srcFactor.factor, dstFactor.factor); + } + + public static void blendFunc(int srcFactor, int dstFactor) { + if (srcFactor != blendState.srcFactor || dstFactor != blendState.dstFactor) { + blendState.srcFactor = srcFactor; + blendState.dstFactor = dstFactor; + GL11.glBlendFunc(srcFactor, dstFactor); + } + + } + + public static void tryBlendFuncSeparate(GlStateManager.SourceFactor srcFactor, GlStateManager.DestFactor dstFactor, GlStateManager.SourceFactor srcFactorAlpha, GlStateManager.DestFactor dstFactorAlpha) { + tryBlendFuncSeparate(srcFactor.factor, dstFactor.factor, srcFactorAlpha.factor, dstFactorAlpha.factor); + } + + public static void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha) { + if (srcFactor != blendState.srcFactor || dstFactor != blendState.dstFactor || srcFactorAlpha != blendState.srcFactorAlpha || dstFactorAlpha != blendState.dstFactorAlpha) { + blendState.srcFactor = srcFactor; + blendState.dstFactor = dstFactor; + blendState.srcFactorAlpha = srcFactorAlpha; + blendState.dstFactorAlpha = dstFactorAlpha; + OpenGlHelper.glBlendFunc(srcFactor, dstFactor, srcFactorAlpha, dstFactorAlpha); + } + + } + + public static void glBlendEquation(int blendEquation) { + GL14.glBlendEquation(blendEquation); + } + + public static void enableOutlineMode(int color) { + BUF_FLOAT_4.put(0, (float)(color >> 16 & 255) / 255.0F); + BUF_FLOAT_4.put(1, (float)(color >> 8 & 255) / 255.0F); + BUF_FLOAT_4.put(2, (float)(color >> 0 & 255) / 255.0F); + BUF_FLOAT_4.put(3, (float)(color >> 24 & 255) / 255.0F); + glTexEnv(8960, 8705, BUF_FLOAT_4); + glTexEnvi(8960, 8704, 34160); + glTexEnvi(8960, 34161, 7681); + glTexEnvi(8960, 34176, 34166); + glTexEnvi(8960, 34192, 768); + glTexEnvi(8960, 34162, 7681); + glTexEnvi(8960, 34184, 5890); + glTexEnvi(8960, 34200, 770); + } + + public static void disableOutlineMode() { + glTexEnvi(8960, 8704, 8448); + glTexEnvi(8960, 34161, 8448); + glTexEnvi(8960, 34162, 8448); + glTexEnvi(8960, 34176, 5890); + glTexEnvi(8960, 34184, 5890); + glTexEnvi(8960, 34192, 768); + glTexEnvi(8960, 34200, 770); + } + + public static void enableFog() { + fogState.fog.setEnabled(); + } + + public static void disableFog() { + fogState.fog.setDisabled(); + } + + public static void setFog(GlStateManager.FogMode fogMode) { + setFog(fogMode.capabilityId); + } + + private static void setFog(int param) { + if (param != fogState.mode) { + fogState.mode = param; + GL11.glFogi(2917, param); + } + + } + + public static void setFogDensity(float param) { + if (param != fogState.density) { + fogState.density = param; + GL11.glFogf(2914, param); + } + + } + + public static void setFogStart(float param) { + if (param != fogState.start) { + fogState.start = param; + GL11.glFogf(2915, param); + } + + } + + public static void setFogEnd(float param) { + if (param != fogState.end) { + fogState.end = param; + GL11.glFogf(2916, param); + } + + } + + public static void glFog(int pname, FloatBuffer param) { + GL11.glFog(pname, param); + } + + public static void glFogi(int pname, int param) { + GL11.glFogi(pname, param); + } + + public static void enableCull() { + cullState.cullFace.setEnabled(); + } + + public static void disableCull() { + cullState.cullFace.setDisabled(); + } + + public static void cullFace(GlStateManager.CullFace cullFace) { + cullFace(cullFace.mode); + } + + private static void cullFace(int mode) { + if (mode != cullState.mode) { + cullState.mode = mode; + GL11.glCullFace(mode); + } + + } + + public static void glPolygonMode(int face, int mode) { + GL11.glPolygonMode(face, mode); + } + + public static void enablePolygonOffset() { + polygonOffsetState.polygonOffsetFill.setEnabled(); + } + + public static void disablePolygonOffset() { + polygonOffsetState.polygonOffsetFill.setDisabled(); + } + + public static void doPolygonOffset(float factor, float units) { + if (factor != polygonOffsetState.factor || units != polygonOffsetState.units) { + polygonOffsetState.factor = factor; + polygonOffsetState.units = units; + GL11.glPolygonOffset(factor, units); + } + + } + + public static void enableColorLogic() { + colorLogicState.colorLogicOp.setEnabled(); + } + + public static void disableColorLogic() { + colorLogicState.colorLogicOp.setDisabled(); + } + + public static void colorLogicOp(GlStateManager.LogicOp logicOperation) { + colorLogicOp(logicOperation.opcode); + } + + public static void colorLogicOp(int opcode) { + if (opcode != colorLogicState.opcode) { + colorLogicState.opcode = opcode; + GL11.glLogicOp(opcode); + } + + } + + public static void enableTexGenCoord(GlStateManager.TexGen texGen) { + texGenCoord(texGen).textureGen.setEnabled(); + } + + public static void disableTexGenCoord(GlStateManager.TexGen texGen) { + texGenCoord(texGen).textureGen.setDisabled(); + } + + public static void texGen(GlStateManager.TexGen texGen, int param) { + GlStateManager.TexGenCoord glstatemanager$texgencoord = texGenCoord(texGen); + if (param != glstatemanager$texgencoord.param) { + glstatemanager$texgencoord.param = param; + GL11.glTexGeni(glstatemanager$texgencoord.coord, 9472, param); + } + + } + + public static void texGen(GlStateManager.TexGen texGen, int pname, FloatBuffer params) { + GL11.glTexGen(texGenCoord(texGen).coord, pname, params); + } + + private static GlStateManager.TexGenCoord texGenCoord(GlStateManager.TexGen texGen) { + switch(texGen) { + case S: + return texGenState.s; + case T: + return texGenState.t; + case R: + return texGenState.r; + case Q: + return texGenState.q; + default: + return texGenState.s; + } + } + + public static void setActiveTexture(int texture) { + if (activeTextureUnit != texture - OpenGlHelper.defaultTexUnit) { + activeTextureUnit = texture - OpenGlHelper.defaultTexUnit; + OpenGlHelper.setActiveTexture(texture); + } + + } + + public static void enableTexture2D() { + textureState[activeTextureUnit].texture2DState.setEnabled(); + } + + public static void disableTexture2D() { + textureState[activeTextureUnit].texture2DState.setDisabled(); + } + + public static void glTexEnv(int target, int parameterName, FloatBuffer parameters) { + GL11.glTexEnv(target, parameterName, parameters); + } + + public static void glTexEnvi(int target, int parameterName, int parameter) { + GL11.glTexEnvi(target, parameterName, parameter); + } + + public static void glTexEnvf(int target, int parameterName, float parameter) { + GL11.glTexEnvf(target, parameterName, parameter); + } + + public static void glTexParameterf(int target, int parameterName, float parameter) { + GL11.glTexParameterf(target, parameterName, parameter); + } + + public static void glTexParameteri(int target, int parameterName, int parameter) { + GL11.glTexParameteri(target, parameterName, parameter); + } + + public static int glGetTexLevelParameteri(int target, int level, int parameterName) { + return GL11.glGetTexLevelParameteri(target, level, parameterName); + } + + public static int generateTexture() { + return GL11.glGenTextures(); + } + + public static void deleteTexture(int texture) { + GL11.glDeleteTextures(texture); + GlStateManager.TextureState[] var1 = textureState; + int var2 = var1.length; + + for(int var3 = 0; var3 < var2; ++var3) { + GlStateManager.TextureState glstatemanager$texturestate = var1[var3]; + if (glstatemanager$texturestate.textureName == texture) { + glstatemanager$texturestate.textureName = -1; + } + } + + } + + public static void bindTexture(int texture) { + if (texture != textureState[activeTextureUnit].textureName) { + textureState[activeTextureUnit].textureName = texture; + GL11.glBindTexture(3553, texture); + } + + } + + public static void glTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, @Nullable IntBuffer pixels) { + GL11.glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels); + } + + public static void glTexSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int type, IntBuffer pixels) { + GL11.glTexSubImage2D(target, level, xOffset, yOffset, width, height, format, type, pixels); + } + + public static void glCopyTexSubImage2D(int target, int level, int xOffset, int yOffset, int x, int y, int width, int height) { + GL11.glCopyTexSubImage2D(target, level, xOffset, yOffset, x, y, width, height); + } + + public static void glGetTexImage(int target, int level, int format, int type, IntBuffer pixels) { + GL11.glGetTexImage(target, level, format, type, pixels); + } + + public static void enableNormalize() { + normalizeState.setEnabled(); + } + + public static void disableNormalize() { + normalizeState.setDisabled(); + } + + public static void shadeModel(int mode) { + if (mode != activeShadeModel) { + activeShadeModel = mode; + GL11.glShadeModel(mode); + } + + } + + public static void enableRescaleNormal() { + rescaleNormalState.setEnabled(); + } + + public static void disableRescaleNormal() { + rescaleNormalState.setDisabled(); + } + + public static void viewport(int x, int y, int width, int height) { + GL11.glViewport(x, y, width, height); + } + + public static void colorMask(boolean red, boolean green, boolean blue, boolean alpha) { + if (red != colorMaskState.red || green != colorMaskState.green || blue != colorMaskState.blue || alpha != colorMaskState.alpha) { + colorMaskState.red = red; + colorMaskState.green = green; + colorMaskState.blue = blue; + colorMaskState.alpha = alpha; + GL11.glColorMask(red, green, blue, alpha); + } + + } + + public static void clearDepth(double depth) { + if (depth != clearState.depth) { + clearState.depth = depth; + GL11.glClearDepth(depth); + } + + } + + public static void clearColor(float red, float green, float blue, float alpha) { + if (red != clearState.color.red || green != clearState.color.green || blue != clearState.color.blue || alpha != clearState.color.alpha) { + clearState.color.red = red; + clearState.color.green = green; + clearState.color.blue = blue; + clearState.color.alpha = alpha; + GL11.glClearColor(red, green, blue, alpha); + } + + } + + public static void clear(int mask) { + GL11.glClear(mask); + } + + public static void matrixMode(int mode) { + GL11.glMatrixMode(mode); + } + + public static void loadIdentity() { + GL11.glLoadIdentity(); + } + + public static void pushMatrix() { + GL11.glPushMatrix(); + } + + public static void popMatrix() { + GL11.glPopMatrix(); + } + + public static void getFloat(int pname, FloatBuffer params) { + GL11.glGetFloat(pname, params); + } + + public static void ortho(double left, double right, double bottom, double top, double zNear, double zFar) { + GL11.glOrtho(left, right, bottom, top, zNear, zFar); + } + + public static void rotate(float angle, float x, float y, float z) { + GL11.glRotatef(angle, x, y, z); + } + + public static void scale(float x, float y, float z) { + GL11.glScalef(x, y, z); + } + + public static void scale(double x, double y, double z) { + GL11.glScaled(x, y, z); + } + + public static void translate(float x, float y, float z) { + GL11.glTranslatef(x, y, z); + } + + public static void translate(double x, double y, double z) { + GL11.glTranslated(x, y, z); + } + + public static void multMatrix(FloatBuffer matrix) { + GL11.glMultMatrix(matrix); + } + + public static void rotate(Quaternion quaternionIn) { + multMatrix(quatToGlMatrix(BUF_FLOAT_16, quaternionIn)); + } + + public static FloatBuffer quatToGlMatrix(FloatBuffer buffer, Quaternion quaternionIn) { + buffer.clear(); + float f = quaternionIn.x * quaternionIn.x; + float f1 = quaternionIn.x * quaternionIn.y; + float f2 = quaternionIn.x * quaternionIn.z; + float f3 = quaternionIn.x * quaternionIn.w; + float f4 = quaternionIn.y * quaternionIn.y; + float f5 = quaternionIn.y * quaternionIn.z; + float f6 = quaternionIn.y * quaternionIn.w; + float f7 = quaternionIn.z * quaternionIn.z; + float f8 = quaternionIn.z * quaternionIn.w; + buffer.put(1.0F - 2.0F * (f4 + f7)); + buffer.put(2.0F * (f1 + f8)); + buffer.put(2.0F * (f2 - f6)); + buffer.put(0.0F); + buffer.put(2.0F * (f1 - f8)); + buffer.put(1.0F - 2.0F * (f + f7)); + buffer.put(2.0F * (f5 + f3)); + buffer.put(0.0F); + buffer.put(2.0F * (f2 + f6)); + buffer.put(2.0F * (f5 - f3)); + buffer.put(1.0F - 2.0F * (f + f4)); + buffer.put(0.0F); + buffer.put(0.0F); + buffer.put(0.0F); + buffer.put(0.0F); + buffer.put(1.0F); + buffer.rewind(); + return buffer; + } + + public static void color(float colorRed, float colorGreen, float colorBlue, float colorAlpha) { + if (colorRed != colorState.red || colorGreen != colorState.green || colorBlue != colorState.blue || colorAlpha != colorState.alpha) { + colorState.red = colorRed; + colorState.green = colorGreen; + colorState.blue = colorBlue; + colorState.alpha = colorAlpha; + GL11.glColor4f(colorRed, colorGreen, colorBlue, colorAlpha); + } + + } + + public static void color(float colorRed, float colorGreen, float colorBlue) { + color(colorRed, colorGreen, colorBlue, 1.0F); + } + + public static void glTexCoord2f(float sCoord, float tCoord) { + GL11.glTexCoord2f(sCoord, tCoord); + } + + public static void glVertex3f(float x, float y, float z) { + GL11.glVertex3f(x, y, z); + } + + public static void resetColor() { + colorState.red = -1.0F; + colorState.green = -1.0F; + colorState.blue = -1.0F; + colorState.alpha = -1.0F; + } + + public static void glNormalPointer(int type, int stride, ByteBuffer buffer) { + GL11.glNormalPointer(type, stride, buffer); + } + + public static void glTexCoordPointer(int size, int type, int stride, int buffer_offset) { + GL11.glTexCoordPointer(size, type, stride, (long)buffer_offset); + } + + public static void glTexCoordPointer(int size, int type, int stride, ByteBuffer buffer) { + GL11.glTexCoordPointer(size, type, stride, buffer); + } + + public static void glVertexPointer(int size, int type, int stride, int buffer_offset) { + GL11.glVertexPointer(size, type, stride, (long)buffer_offset); + } + + public static void glVertexPointer(int size, int type, int stride, ByteBuffer buffer) { + GL11.glVertexPointer(size, type, stride, buffer); + } + + public static void glColorPointer(int size, int type, int stride, int buffer_offset) { + GL11.glColorPointer(size, type, stride, (long)buffer_offset); + } + + public static void glColorPointer(int size, int type, int stride, ByteBuffer buffer) { + GL11.glColorPointer(size, type, stride, buffer); + } + + public static void glDisableClientState(int cap) { + GL11.glDisableClientState(cap); + } + + public static void glEnableClientState(int cap) { + GL11.glEnableClientState(cap); + } + + public static void glBegin(int mode) { + GL11.glBegin(mode); + } + + public static void glEnd() { + GL11.glEnd(); + } + + public static void glDrawArrays(int mode, int first, int count) { + GL11.glDrawArrays(mode, first, count); + } + + public static void glLineWidth(float width) { + GL11.glLineWidth(width); + } + + public static void callList(int list) { + GL11.glCallList(list); + } + + public static void glDeleteLists(int list, int range) { + GL11.glDeleteLists(list, range); + } + + public static void glNewList(int list, int mode) { + GL11.glNewList(list, mode); + } + + public static void glEndList() { + GL11.glEndList(); + } + + public static int glGenLists(int range) { + return GL11.glGenLists(range); + } + + public static void glPixelStorei(int parameterName, int param) { + GL11.glPixelStorei(parameterName, param); + } + + public static void glReadPixels(int x, int y, int width, int height, int format, int type, IntBuffer pixels) { + GL11.glReadPixels(x, y, width, height, format, type, pixels); + } + + public static int glGetError() { + return GL11.glGetError(); + } + + public static String glGetString(int name) { + return GL11.glGetString(name); + } + + public static void glGetInteger(int parameterName, IntBuffer parameters) { + GL11.glGetInteger(parameterName, parameters); + } + + public static int glGetInteger(int parameterName) { + return GL11.glGetInteger(parameterName); + } + + public static void enableBlendProfile(GlStateManager.Profile p_187408_0_) { + p_187408_0_.apply(); + } + + public static void disableBlendProfile(GlStateManager.Profile p_187440_0_) { + p_187440_0_.clean(); + } + + static { + int j; + for(j = 0; j < 8; ++j) { + lightState[j] = new GlStateManager.BooleanState(16384 + j); + } + + colorMaterialState = new GlStateManager.ColorMaterialState(); + blendState = new GlStateManager.BlendState(); + depthState = new GlStateManager.DepthState(); + fogState = new GlStateManager.FogState(); + cullState = new GlStateManager.CullState(); + polygonOffsetState = new GlStateManager.PolygonOffsetState(); + colorLogicState = new GlStateManager.ColorLogicState(); + texGenState = new GlStateManager.TexGenState(); + clearState = new GlStateManager.ClearState(); + stencilState = new GlStateManager.StencilState(); + normalizeState = new GlStateManager.BooleanState(2977); + textureState = new GlStateManager.TextureState[8]; + + for(j = 0; j < 8; ++j) { + textureState[j] = new GlStateManager.TextureState(); + } + + activeShadeModel = 7425; + rescaleNormalState = new GlStateManager.BooleanState(32826); + colorMaskState = new GlStateManager.ColorMask(); + colorState = new GlStateManager.Color(); + } + + @SideOnly(Side.CLIENT) + static class TextureState { + public GlStateManager.BooleanState texture2DState; + public int textureName; + + private TextureState() { + this.texture2DState = new GlStateManager.BooleanState(3553); + } + } + + @SideOnly(Side.CLIENT) + static class TexGenState { + public GlStateManager.TexGenCoord s; + public GlStateManager.TexGenCoord t; + public GlStateManager.TexGenCoord r; + public GlStateManager.TexGenCoord q; + + private TexGenState() { + this.s = new GlStateManager.TexGenCoord(8192, 3168); + this.t = new GlStateManager.TexGenCoord(8193, 3169); + this.r = new GlStateManager.TexGenCoord(8194, 3170); + this.q = new GlStateManager.TexGenCoord(8195, 3171); + } + } + + @SideOnly(Side.CLIENT) + static class TexGenCoord { + public GlStateManager.BooleanState textureGen; + public int coord; + public int param = -1; + + public TexGenCoord(int coordIn, int capabilityIn) { + this.coord = coordIn; + this.textureGen = new GlStateManager.BooleanState(capabilityIn); + } + } + + @SideOnly(Side.CLIENT) + public static enum TexGen { + S, + T, + R, + Q; + + private TexGen() { + } + } + + @SideOnly(Side.CLIENT) + static class StencilState { + public GlStateManager.StencilFunc func; + public int mask; + public int fail; + public int zfail; + public int zpass; + + private StencilState() { + this.func = new GlStateManager.StencilFunc(); + this.mask = -1; + this.fail = 7680; + this.zfail = 7680; + this.zpass = 7680; + } + } + + @SideOnly(Side.CLIENT) + static class StencilFunc { + public int func; + public int mask; + + private StencilFunc() { + this.func = 519; + this.mask = -1; + } + } + + @SideOnly(Side.CLIENT) + public static enum SourceFactor { + CONSTANT_ALPHA(32771), + CONSTANT_COLOR(32769), + DST_ALPHA(772), + DST_COLOR(774), + ONE(1), + ONE_MINUS_CONSTANT_ALPHA(32772), + ONE_MINUS_CONSTANT_COLOR(32770), + ONE_MINUS_DST_ALPHA(773), + ONE_MINUS_DST_COLOR(775), + ONE_MINUS_SRC_ALPHA(771), + ONE_MINUS_SRC_COLOR(769), + SRC_ALPHA(770), + SRC_ALPHA_SATURATE(776), + SRC_COLOR(768), + ZERO(0); + + public final int factor; + + private SourceFactor(int factorIn) { + this.factor = factorIn; + } + } + + @SideOnly(Side.CLIENT) + public static enum Profile { + DEFAULT { + public void apply() { + GlStateManager.disableAlpha(); + GlStateManager.alphaFunc(519, 0.0F); + GlStateManager.disableLighting(); + GL11.glLightModel(2899, setColorBuffer(0.2F, 0.2F, 0.2F, 1.0F)); + + for(int i = 0; i < 8; ++i) { + GlStateManager.disableLight(i); + GL11.glLight(16384 + i, 4608, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glLight(16384 + i, 4611, setColorBuffer(0.0F, 0.0F, 1.0F, 0.0F)); + if (i == 0) { + GL11.glLight(16384 + i, 4609, setColorBuffer(1.0F, 1.0F, 1.0F, 1.0F)); + GL11.glLight(16384 + i, 4610, setColorBuffer(1.0F, 1.0F, 1.0F, 1.0F)); + } else { + GL11.glLight(16384 + i, 4609, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glLight(16384 + i, 4610, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + } + } + + GlStateManager.disableColorMaterial(); + GlStateManager.colorMaterial(1032, 5634); + GlStateManager.disableDepth(); + GlStateManager.depthFunc(513); + GlStateManager.depthMask(true); + GlStateManager.disableBlend(); + GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + GL14.glBlendEquation(32774); + GlStateManager.disableFog(); + GL11.glFogi(2917, 2048); + GlStateManager.setFogDensity(1.0F); + GlStateManager.setFogStart(0.0F); + GlStateManager.setFogEnd(1.0F); + GL11.glFog(2918, setColorBuffer(0.0F, 0.0F, 0.0F, 0.0F)); + if (GLContext.getCapabilities().GL_NV_fog_distance) { + GL11.glFogi(2917, 34140); + } + + GlStateManager.doPolygonOffset(0.0F, 0.0F); + GlStateManager.disableColorLogic(); + GlStateManager.colorLogicOp(5379); + GlStateManager.disableTexGenCoord(GlStateManager.TexGen.S); + GlStateManager.texGen(GlStateManager.TexGen.S, 9216); + GlStateManager.texGen(GlStateManager.TexGen.S, 9474, setColorBuffer(1.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.S, 9217, setColorBuffer(1.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.disableTexGenCoord(GlStateManager.TexGen.T); + GlStateManager.texGen(GlStateManager.TexGen.T, 9216); + GlStateManager.texGen(GlStateManager.TexGen.T, 9474, setColorBuffer(0.0F, 1.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.T, 9217, setColorBuffer(0.0F, 1.0F, 0.0F, 0.0F)); + GlStateManager.disableTexGenCoord(GlStateManager.TexGen.R); + GlStateManager.texGen(GlStateManager.TexGen.R, 9216); + GlStateManager.texGen(GlStateManager.TexGen.R, 9474, setColorBuffer(0.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.R, 9217, setColorBuffer(0.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.disableTexGenCoord(GlStateManager.TexGen.Q); + GlStateManager.texGen(GlStateManager.TexGen.Q, 9216); + GlStateManager.texGen(GlStateManager.TexGen.Q, 9474, setColorBuffer(0.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.Q, 9217, setColorBuffer(0.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.setActiveTexture(0); + GL11.glTexParameteri(3553, 10240, 9729); + GL11.glTexParameteri(3553, 10241, 9986); + GL11.glTexParameteri(3553, 10242, 10497); + GL11.glTexParameteri(3553, 10243, 10497); + GL11.glTexParameteri(3553, 33085, 1000); + GL11.glTexParameteri(3553, 33083, 1000); + GL11.glTexParameteri(3553, 33082, -1000); + GL11.glTexParameterf(3553, 34049, 0.0F); + GL11.glTexEnvi(8960, 8704, 8448); + GL11.glTexEnv(8960, 8705, setColorBuffer(0.0F, 0.0F, 0.0F, 0.0F)); + GL11.glTexEnvi(8960, 34161, 8448); + GL11.glTexEnvi(8960, 34162, 8448); + GL11.glTexEnvi(8960, 34176, 5890); + GL11.glTexEnvi(8960, 34177, 34168); + GL11.glTexEnvi(8960, 34178, 34166); + GL11.glTexEnvi(8960, 34184, 5890); + GL11.glTexEnvi(8960, 34185, 34168); + GL11.glTexEnvi(8960, 34186, 34166); + GL11.glTexEnvi(8960, 34192, 768); + GL11.glTexEnvi(8960, 34193, 768); + GL11.glTexEnvi(8960, 34194, 770); + GL11.glTexEnvi(8960, 34200, 770); + GL11.glTexEnvi(8960, 34201, 770); + GL11.glTexEnvi(8960, 34202, 770); + GL11.glTexEnvf(8960, 34163, 1.0F); + GL11.glTexEnvf(8960, 3356, 1.0F); + GlStateManager.disableNormalize(); + GlStateManager.shadeModel(7425); + GlStateManager.disableRescaleNormal(); + GlStateManager.colorMask(true, true, true, true); + GlStateManager.clearDepth(1.0D); + GL11.glLineWidth(1.0F); + GL11.glNormal3f(0.0F, 0.0F, 1.0F); + GL11.glPolygonMode(1028, 6914); + GL11.glPolygonMode(1029, 6914); + } + + public void clean() { + } + }, + PLAYER_SKIN { + public void apply() { + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + } + + public void clean() { + GlStateManager.disableBlend(); + } + }, + TRANSPARENT_MODEL { + public void apply() { + GlStateManager.color(1.0F, 1.0F, 1.0F, 0.15F); + GlStateManager.depthMask(false); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); + GlStateManager.alphaFunc(516, 0.003921569F); + } + + public void clean() { + GlStateManager.disableBlend(); + GlStateManager.alphaFunc(516, 0.1F); + GlStateManager.depthMask(true); + } + }; + + private Profile() { + } + + public abstract void apply(); + + public abstract void clean(); + } + + @SideOnly(Side.CLIENT) + static class PolygonOffsetState { + public GlStateManager.BooleanState polygonOffsetFill; + public GlStateManager.BooleanState polygonOffsetLine; + public float factor; + public float units; + + private PolygonOffsetState() { + this.polygonOffsetFill = new GlStateManager.BooleanState(32823); + this.polygonOffsetLine = new GlStateManager.BooleanState(10754); + } + } + + @SideOnly(Side.CLIENT) + public static enum LogicOp { + AND(5377), + AND_INVERTED(5380), + AND_REVERSE(5378), + CLEAR(5376), + COPY(5379), + COPY_INVERTED(5388), + EQUIV(5385), + INVERT(5386), + NAND(5390), + NOOP(5381), + NOR(5384), + OR(5383), + OR_INVERTED(5389), + OR_REVERSE(5387), + SET(5391), + XOR(5382); + + public final int opcode; + + private LogicOp(int opcodeIn) { + this.opcode = opcodeIn; + } + } + + @SideOnly(Side.CLIENT) + static class FogState { + public GlStateManager.BooleanState fog; + public int mode; + public float density; + public float start; + public float end; + + private FogState() { + this.fog = new GlStateManager.BooleanState(2912); + this.mode = 2048; + this.density = 1.0F; + this.end = 1.0F; + } + } + + @SideOnly(Side.CLIENT) + public static enum FogMode { + LINEAR(9729), + EXP(2048), + EXP2(2049); + + public final int capabilityId; + + private FogMode(int capabilityIn) { + this.capabilityId = capabilityIn; + } + } + + @SideOnly(Side.CLIENT) + public static enum DestFactor { + CONSTANT_ALPHA(32771), + CONSTANT_COLOR(32769), + DST_ALPHA(772), + DST_COLOR(774), + ONE(1), + ONE_MINUS_CONSTANT_ALPHA(32772), + ONE_MINUS_CONSTANT_COLOR(32770), + ONE_MINUS_DST_ALPHA(773), + ONE_MINUS_DST_COLOR(775), + ONE_MINUS_SRC_ALPHA(771), + ONE_MINUS_SRC_COLOR(769), + SRC_ALPHA(770), + SRC_COLOR(768), + ZERO(0); + + public final int factor; + + private DestFactor(int factorIn) { + this.factor = factorIn; + } + } + + @SideOnly(Side.CLIENT) + static class DepthState { + public GlStateManager.BooleanState depthTest; + public boolean maskEnabled; + public int depthFunc; + + private DepthState() { + this.depthTest = new GlStateManager.BooleanState(2929); + this.maskEnabled = true; + this.depthFunc = 513; + } + } + + @SideOnly(Side.CLIENT) + static class CullState { + public GlStateManager.BooleanState cullFace; + public int mode; + + private CullState() { + this.cullFace = new GlStateManager.BooleanState(2884); + this.mode = 1029; + } + } + + @SideOnly(Side.CLIENT) + public static enum CullFace { + FRONT(1028), + BACK(1029), + FRONT_AND_BACK(1032); + + public final int mode; + + private CullFace(int modeIn) { + this.mode = modeIn; + } + } + + @SideOnly(Side.CLIENT) + static class ColorMaterialState { + public GlStateManager.BooleanState colorMaterial; + public int face; + public int mode; + + private ColorMaterialState() { + this.colorMaterial = new GlStateManager.BooleanState(2903); + this.face = 1032; + this.mode = 5634; + } + } + + @SideOnly(Side.CLIENT) + static class ColorMask { + public boolean red; + public boolean green; + public boolean blue; + public boolean alpha; + + private ColorMask() { + this.red = true; + this.green = true; + this.blue = true; + this.alpha = true; + } + } + + @SideOnly(Side.CLIENT) + static class ColorLogicState { + public GlStateManager.BooleanState colorLogicOp; + public int opcode; + + private ColorLogicState() { + this.colorLogicOp = new GlStateManager.BooleanState(3058); + this.opcode = 5379; + } + } + + @SideOnly(Side.CLIENT) + static class Color { + public float red; + public float green; + public float blue; + public float alpha; + + public Color() { + this(1.0F, 1.0F, 1.0F, 1.0F); + } + + public Color(float redIn, float greenIn, float blueIn, float alphaIn) { + this.red = 1.0F; + this.green = 1.0F; + this.blue = 1.0F; + this.alpha = 1.0F; + this.red = redIn; + this.green = greenIn; + this.blue = blueIn; + this.alpha = alphaIn; + } + } + + @SideOnly(Side.CLIENT) + static class ClearState { + public double depth; + public GlStateManager.Color color; + + private ClearState() { + this.depth = 1.0D; + this.color = new GlStateManager.Color(0.0F, 0.0F, 0.0F, 0.0F); + } + } + + @SideOnly(Side.CLIENT) + static class BooleanState { + private final int capability; + private boolean currentState; + + public BooleanState(int capabilityIn) { + this.capability = capabilityIn; + } + + public void setDisabled() { + this.setState(false); + } + + public void setEnabled() { + this.setState(true); + } + + public void setState(boolean state) { + if (state != this.currentState) { + this.currentState = state; + if (state) { + GL11.glEnable(this.capability); + } else { + GL11.glDisable(this.capability); + } + } + + } + } + + @SideOnly(Side.CLIENT) + static class BlendState { + public GlStateManager.BooleanState blend; + public int srcFactor; + public int dstFactor; + public int srcFactorAlpha; + public int dstFactorAlpha; + + private BlendState() { + this.blend = new GlStateManager.BooleanState(3042); + this.srcFactor = 1; + this.dstFactor = 0; + this.srcFactorAlpha = 1; + this.dstFactorAlpha = 0; + } + } + + @SideOnly(Side.CLIENT) + static class AlphaState { + public GlStateManager.BooleanState alphaTest; + public int func; + public float ref; + + public AlphaState() { + this.alphaTest = new GlStateManager.BooleanState(3008); + this.func = 519; + this.ref = -1.0F; + } + } + + private static FloatBuffer setColorBuffer(float p_74521_0_, float p_74521_1_, float p_74521_2_, float p_74521_3_) + { + colorBuffer.clear(); + colorBuffer.put(p_74521_0_).put(p_74521_1_).put(p_74521_2_).put(p_74521_3_); + colorBuffer.flip(); + /** Float buffer used to set OpenGL material colors */ + return colorBuffer; + } +} diff --git a/src/main/java/com/glodblock/github/util/NameConst.java b/src/main/java/com/glodblock/github/util/NameConst.java index be269dba..624fbc47 100644 --- a/src/main/java/com/glodblock/github/util/NameConst.java +++ b/src/main/java/com/glodblock/github/util/NameConst.java @@ -8,6 +8,7 @@ public class NameConst { public static final String BLOCK_FLUID_PATTERN_ENCODER = "fluid_pattern_encoder"; public static final String BLOCK_FLUID_PACKET_DECODER = "fluid_packet_decoder"; public static final String BLOCK_FLUID_INTERFACE = "fluid_interface"; + public static final String BLOCK_INGREDIENT_BUFFER = "ingredient_buffer"; public static final String ITEM_FLUID_DROP = "fluid_drop"; public static final String ITEM_FLUID_ENCODED_PATTERN = "fluid_encoded_pattern"; @@ -22,6 +23,8 @@ public class NameConst { public static final String TT_INVALID_FLUID = TT_KEY + "invalid_fluid"; public static final String TT_FLUID_PACKET = TT_KEY + "fluid_packet"; public static final String TT_ENCODE_PATTERN = TT_KEY + "encode_pattern"; + public static final String TT_EMPTY = TT_KEY + "empty"; + public static final String TT_DUMP_TANK = TT_KEY + "dump_tank"; public static final String RES_KEY = FluidCraft.MODID + ":"; @@ -30,5 +33,6 @@ public class NameConst { public static final String GUI_FLUID_PATTERN_TERMINAL_EX = GUI_KEY + ITEM_PART_FLUID_PATTERN_TERMINAL_EX; 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_INGREDIENT_BUFFER = GUI_KEY + BLOCK_INGREDIENT_BUFFER; } diff --git a/src/main/java/com/glodblock/github/util/Util.java b/src/main/java/com/glodblock/github/util/Util.java index 61da63ea..4596c795 100644 --- a/src/main/java/com/glodblock/github/util/Util.java +++ b/src/main/java/com/glodblock/github/util/Util.java @@ -6,14 +6,15 @@ import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; import appeng.api.networking.security.ISecurityGrid; import appeng.api.parts.IPart; +import appeng.api.storage.data.IAEFluidStack; +import appeng.util.item.AEFluidStack; import com.glodblock.github.common.item.ItemFluidPacket; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.fluids.*; public final class Util { @@ -104,4 +105,15 @@ public final class Util { return null; } + public static IAEFluidStack loadFluidStackFromNBT( final NBTTagCompound i ) + { + //Fuck ae2 + final FluidStack t = FluidRegistry.getFluidStack(i.getString("FluidName"), 1); + final AEFluidStack fluid = AEFluidStack.create( t ); + fluid.setStackSize( i.getLong( "Cnt" ) ); + fluid.setCountRequestable( i.getLong( "Req" ) ); + fluid.setCraftable( i.getBoolean( "Craft" ) ); + return fluid; + } + } diff --git a/src/main/resources/assets/ae2fc/lang/en_US.lang b/src/main/resources/assets/ae2fc/lang/en_US.lang index 01cc83c8..bd92e5a1 100644 --- a/src/main/resources/assets/ae2fc/lang/en_US.lang +++ b/src/main/resources/assets/ae2fc/lang/en_US.lang @@ -23,12 +23,16 @@ tile.fluid_discretizer.name=Fluid Discretizer tile.fluid_pattern_encoder.name=Fluid Pattern Encoder tile.fluid_packet_decoder.name=ME Fluid Packet Decoder tile.fluid_interface.name=Fluid Interface +tile.ingredient_buffer.name=Ingredient Buffer ae2fc.tooltip.invalid_fluid=Invalid fluid! ae2fc.tooltip.encode_pattern=Encode Patter ae2fc.tooltip.fluid_packet=Use a Fluid Packet Decoder to\nconvert this back into fluid. +ae2fc.tooltip.empty=Empty +ae2fc.tooltip.dump_tank=Dump Tank Contents ae2fc.gui.part_fluid_pattern_terminal=Fluid Pattern Terminal ae2fc.gui.part_fluid_pattern_terminal_ex=Fluid Processing Pattern Terminal ae2fc.gui.fluid_pattern_encoder=Fluid Pattern Encoder ae2fc.gui.fluid_packet_decoder=ME Fluid Packet Decoder +ae2fc.gui.ingredient_buffer=Ingredient Buffer diff --git a/src/main/resources/assets/ae2fc/textures/blocks/ingredient_buffer.png b/src/main/resources/assets/ae2fc/textures/blocks/ingredient_buffer.png new file mode 100644 index 0000000000000000000000000000000000000000..8233dcdcb2c48a9d6e3dedfcb83ac3ff5f524bdc GIT binary patch literal 6180 zcmeHLdpuO@8XgjnTO}&VGze*~X2#59+$YARWb9ljwPt1w!`zw~W`vVVoobUpyLL)x z7t%$EP!hUqx~E*aNF|lnv4x`0Su<2Rr_(bzTaB2*>|zK zj@B$K7!0OE_i*!r{_88=lhmP4)7}pN45l`;)<00{2gu+ev5>>%fpBTG2!w-jE(Zpa z-_Hr)?`WH+J#^DrtfoJydd)yA+OD>TaW}sF<-NrX}t-12CiHJY&`anCA) zOGL}p@7*$gw(_2EwH434&Ub3cxALLw$OUDNFSz$=;K$t$b*cfL=i~C%NS4(W*|myf z2WhbvN!y|l%Nm}9p$%#rZj|or4LX*iw(n37i_pc++xh0)RMgh;!a1EOku%D@x{g-1 z9+?hLn*68zjl0B(1A~UUw_Is*?9X8NP|j9YxM!$$uv)VdgbaaR-%uC&G{sVTozB}0 zFO%I{OMtb#hidq)mFFo1EfMV%5A(ckJgxo5obarRhrH;=qqjZ2|GZAkh_xUfIZWlH zUsd7Z!RNSow6$md1vcf z%zuY(Q-N6=m=NSXbJ7gXVNv=XT8HLb&DFuc)?Xu#*oR_&I=tG0p+c;i7yoQ_l4GkX zY5U!iEY8jI31*hUrQvBnOS0)R;^yg=3qsry-RRZoMx+7w-1Rg34u&n=LPnUdHeqws zc57y41ZZ|nGv9UcI!f{;NL-7}Q+;O;P&R8X{di(Lz5V;cinQa`)Ht~e_l275+KCj~++8?3YQy3IX^L)5A9jE7suC$xV}L|fMdcr( z2i0wAasuij-@7921=mx&1D$<_-Bp6)(<(Kr%s}^CFZ;rdvsHx_gSLrl9+;ncT4xy9 ztW}$=Tgj^0Fxiw*d>7phHCmR0tm z;|7}Q%ad+BdHaX@os!s%c*_9KJEeP{_wY}03vRSKM7{kDb@JLXF!k-h%Qmz*I9}?r z$Y9;&$A|0RXKw5;8u1VDjIr9P^}(yjAlAmzUMHe+UUp2_72~v#bmtD_FMGG&H#EK) zko{(w|D`v^je`Vw+)KGfUTMb6ZAWAUj>J39InANboKtZ>;eH>u(Xzpw+JCg(cI8#d z+$OV?YYblp05Rli-EUUDuFnkvXx!y_y%Q19Mho}%(##h&wH9vaSZZ-CX!Ff8UebzG zR3f#jO%K(VwK2J@=Kwzcz@#oer=et{7eW1@b*BC83D1+6l}A(?lGM714M&!aaCrlL zr~*5r*6^UtpSvsGRT?`QJo&IAq{p=6ozb~xZJ9X}W4obt$oXm?+0%DcXj>Pd7(Ue;?k%d7o28aTE#ep zm_Bi#!J1m%tOc8XCV5UzUcJ9~dT=D>bl>Dmyty?hH8G;Pdh4abNy$Y8x&?{w0hQLa z_Ji#RixISS@ur@~Wv1O-)UFm4mjmbhiy~Bg30FNXv6#ft`RXBcNzU4HQ{pdrQ`17O zRY_tWUZ`m*x4QY-;q8m|fYVkqa-)*gJm+4Ul`FzJ~t$HLWO@4Qs2!;1!88o>>{hM}kYSjS>s8>#o+_ss0X zyX)6Xo$BGTK4sRGLsc%@mu)eaW_^Ea^uR`wb?GZ`r?0GT3v`-3-@Ha|M5D5tFqx4d z@WZG}EAPIkvC_XgF*EYPh(pP%=bDe#sTUNNRNjYi9O=hPPt{JroX}aZqLdJ=SJtd@ ze#sfOM`~N1wSiXE`8MUh9ZNlTxNz$2@%cup+BsI3~B@ zk)8uvoPJyLF|;A-{ltZK!ayHy3QNdG0c;@?M9KLg$Qm%1y`x+Nup&SyoC$_<1yn?L zc_jkQWm6FW1Rso#$Q2CZdaM#2LhmR7z_!C!69*E^!Rw_sE^O5Xn|x* zMMzJy91x+gC=8m<{~|&nrA2+t_tglAKXgNa_5&rtNHGhfMS%jT+4!U)UZiAv&PWNU zm{P8r$L64+MJY3nk8!8__+ffX$Ov@SR&>^)&_XvSEZn0LsWP>Jb}ap@JKv};~?=&k}ZkEB z0jH!=2upGHrBe|&6z21cFAtD%gknBaFI)jzD3g3X`U3@Mp$Kflv@F5`-#4pjA^`#ULORiv5K`9u=Wj z66L~nc#op`3(KU;w+ZR zgyM)L;w8**kR|;#&)2}8nEaqNC6S7w>3?xj|Aw<4HKqp?D-=hM%g+GUjE+Wo36HCk z3JzD+F9l#JRHPy#KorPUUIIwR(L<~-KoAN-jdH9?KF)K$VptZN!vQ$}8A-rmA*-=T zOeBegV?skB3Bv>l7#xZ8CA&n(k;(uu=o|`_5p=n(0LRT1$5h)V!xS;q;oj&^J zzu?Bjk9qX3!pFl#qg{ofXsBAlq)TLiZ>IkWaFoHD%K`-w;kTAP9x^J+xE%yq^XMG3 zGeH|2`qNG~<`P9A{f)0N_x+6-AnG4UzDwU9a{Z9&yA=2?@DF$Wkn6h?_%84dcm3bw z()#?Y3<{w8J{j~R+*qXg3-lDN&h&D3gMCo^Wmn{7Kr@;mk01#QhB8yURpdF2QP8A@ zlUM{wW=d&+Qdc2g@w5aRyIY6LxY97V;?_POLDvZSJ!LN4&Do!H zH7BE*e*vRSGqs+ma@J)@R#h#2rujx*nhDNtUVFZcfeJ63TI_$Ys@6hP&H2O!Ge`Pm z`nUcRuYvtRGTgIB-i=4sgIeSD~~BOblPIK0+-c^{{pxd BV5|TD literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/ae2fc/textures/gui/ingredient_buffer.png b/src/main/resources/assets/ae2fc/textures/gui/ingredient_buffer.png new file mode 100644 index 0000000000000000000000000000000000000000..e1d3519457cb50afb28467209252f585d14071b3 GIT binary patch literal 1614 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$5xX)7d$|)7e>}peR2rGbfdS zL1SX=L|c!;4l+mMgSRS)vRaE2o(Pz$)6r$&CEA^^aEoYEslm=K+_OwnH1+zLvJW2Y zKf0>9d-FQJbxjIC7#}@(vE+r4>OXzWEgc^p?2v!|&i36sMyJJxLN;eJ1(=@pIGUVf zwq1)Y?qahek77^55g*%$ac2$`*W5jP{Q7Q<^PlX#KYtPaNsYNi>7&eL-tLO#inPm@ zEZ+;aM|cKxobNo&yG!At^7Yi|_btR_#VXQHoLKU#)A>l!#^$GdX{yeu^VIq@R=NFj zx|Z7dSuA~PQ1aU9PvUH!Z+XpnZQ?F)Tu8{nsijBi)QSU6Q^I;hgf(yVSN>?1t)CQQ zwDVNLlL!Yzp2lZ_0wrtyf ziy_V4bN%+MCj<>P@W#Y!H?8E~afk7c|E?5|z9-8yMYs<9maGltli0=j>)M@rQNJx} z8H}!6{lr^Pz|kYBS$+5M-Mw@7{;ghi^*+B{O3|d8e_Yb zCYGe8D3oWGWGJ|M`UZqI@`*Dru&8;uIEGZ*dVAN=@3wbx0KGjtB_;+`2)^e^~? z<82eA4U^>k>b#0=Q&fvFva%ke^V}(5(9htLYIM)=gK6t{;$iTuNz~BH% zerSvaCYve0_}~Awt9H9ydU4y@o#D@v7-nBDjlFhXzU|>FYlX8%br}>G8W$f|fd0zajF<(!0^)tl>uk*z9+YjG%{QulD zL60dQkmZ`)i?gl_TpMJ*oc`bNOl}S%Q^56;^_7x2>o~5g>1uEI{nzff?S4y_#EO5mnVo#D{dvXwL*lFnm5fC^hXtTQ zKR#}W#u{JH7!+Xe21ZE8i)VEV*|p#HSU%g}YbW0D=tm60c3g1Cfo!jN zetxa_^WtY)a$o!W?PAc;cj$ZnXXn>vHRojVgUgW|j2Y=n37ifL4P1Bc@E>@7ZT99? z%RBzUf|^T31V83IX0>LT2^5)b&D8r?LQwFsiSBWO?>m?x;u>Vi_86*{_sKTeFf*W~ zLF81)xPe81!J+jHN6NWp&kO9!Sd7v?7r){7;u_9yntQ_GKJ#Z!&TUklkdDijAm=JD zOaof6VuEbrnVWxP-aUWT=di)GjHL+Ts{`$KYB(~&6N0)rB%&7VI$eM5qky3AWs{c`Hc>GvzHlw5tg6~1 uC32YgKxvF#!X_1wsy9r)q5?ly^F(~g?gz_T9|U{^DfD#pb6Mw<&;$U16FN%( literal 0 HcmV?d00001