Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 87 additions & 39 deletions src/main/java/logisticspipes/gui/modules/GuiApiaristSink.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

Expand All @@ -18,59 +19,54 @@
import logisticspipes.proxy.MainProxy;
import logisticspipes.proxy.SimpleServiceLocator;
import logisticspipes.utils.gui.DummyContainer;
import logisticspipes.utils.gui.GuiGraphics;
import logisticspipes.utils.gui.IItemTextureRenderSlot;
import logisticspipes.utils.gui.ISmallColorRenderSlot;
import logisticspipes.utils.item.ItemIdentifierInventory;

public class GuiApiaristSink extends ModuleBaseGui {

private static final ResourceLocation TEXTURE = new ResourceLocation(
"logisticspipes",
"textures/gui/apiarist_sink.png");

private final ModuleApiaristSink module;

public GuiApiaristSink(ModuleApiaristSink module, EntityPlayer player) {
super(new DummyContainer(player.inventory, null), module);
super(null, module);

this.module = module;

DummyContainer dummy = new DummyContainer(player.inventory, this.module.getInventoryBee());
dummy.addNormalSlotsForHotbar(8, 157);
dummy.addDummySlot(0, 110, 121);

for (int i = 0; i < 6; i++) {
SinkSetting filter = module.filter[i];
addRenderSlot(new TypeSlot(20, 20 + (i * 18), filter, i));
addRenderSlot(new GroupSlot(guiLeft + 45, guiTop + 25 + (i * 18), filter, i));
addRenderSlot(new BeeSlot(60, 20 + (i * 18), filter, 0, i));
addRenderSlot(new BeeSlot(78, 20 + (i * 18), filter, 1, i));
addRenderSlot(new TypeSlot(24 + (i * 22), 20, filter, i));
addRenderSlot(new GroupSlot(guiLeft + 29 + (i * 22), guiTop + 45, filter, i));
addRenderSlot(new BeeSlot(24 + (i * 22), 60, filter, 0, i));
addRenderSlot(new BeeSlot(24 + (i * 22), 60 + 18, filter, 1, i));
}
xSize = 120;
ySize = 150;
}

public void renderForestryBeeAt(Minecraft mc, int x, int y, float zLevel, String id) {
GL11.glDisable(GL11.GL_LIGHTING);
mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
inventorySlots = dummy;

for (int i = 0; i < SimpleServiceLocator.forestryProxy.getRenderPassesForAlleleId(id); i++) {
IIcon icon = SimpleServiceLocator.forestryProxy.getIconIndexForAlleleId(id, i);
if (icon == null) {
continue;
}
int color = SimpleServiceLocator.forestryProxy.getColorForAlleleId(id, i);
float colorR = (color >> 16 & 0xFF) / 255.0F;
float colorG = (color >> 8 & 0xFF) / 255.0F;
float colorB = (color & 0xFF) / 255.0F;

GL11.glColor4f(colorR, colorG, colorB, 1.0F);

// Render icon
Tessellator var9 = Tessellator.instance;
var9.startDrawingQuads();
var9.addVertexWithUV(x, y + 16, zLevel, icon.getMinU(), icon.getMaxV());
var9.addVertexWithUV(x + 16, y + 16, zLevel, icon.getMaxU(), icon.getMaxV());
var9.addVertexWithUV(x + 16, y, zLevel, icon.getMaxU(), icon.getMinV());
var9.addVertexWithUV(x, y, zLevel, icon.getMinU(), icon.getMinV());
var9.draw();
}
GL11.glEnable(GL11.GL_LIGHTING);
xSize = 175;
ySize = 180;
}

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop, right, bottom, zLevel, true);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(GuiApiaristSink.TEXTURE);
int j = guiLeft;
int k = guiTop;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
}

@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
mc.fontRenderer.drawString(module.getInventoryBee().getInventoryName(), 35, 125, 0x404040);
}

private class TypeSlot extends IItemTextureRenderSlot {
Expand Down Expand Up @@ -263,27 +259,79 @@ private BeeSlot(int xPos, int yPos, SinkSetting setting, int slotNumber, int row
this.row = row;
}

private void renderForestryBeeAt(Minecraft mc, int x, int y, float zLevel, String id) {
GL11.glDisable(GL11.GL_LIGHTING);
mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);

for (int i = 0; i < SimpleServiceLocator.forestryProxy.getRenderPassesForAlleleId(id); i++) {
IIcon icon = SimpleServiceLocator.forestryProxy.getIconIndexForAlleleId(id, i);
if (icon == null) {
continue;
}
int color = SimpleServiceLocator.forestryProxy.getColorForAlleleId(id, i);
float colorR = (color >> 16 & 0xFF) / 255.0F;
float colorG = (color >> 8 & 0xFF) / 255.0F;
float colorB = (color & 0xFF) / 255.0F;

GL11.glColor4f(colorR, colorG, colorB, 1.0F);

// Render icon
Tessellator var9 = Tessellator.instance;
var9.startDrawingQuads();
var9.addVertexWithUV(x, y + 16, zLevel, icon.getMinU(), icon.getMaxV());
var9.addVertexWithUV(x + 16, y + 16, zLevel, icon.getMaxU(), icon.getMaxV());
var9.addVertexWithUV(x + 16, y, zLevel, icon.getMaxU(), icon.getMinV());
var9.addVertexWithUV(x, y, zLevel, icon.getMinU(), icon.getMinV());
var9.draw();
}
GL11.glEnable(GL11.GL_LIGHTING);
}

@Override
public void mouseClicked(int button) {

if (button == 2) {
if (slotNumber == 0) {
setting.firstBeeReset();
} else {
setting.secondBeeReset();
}
}

if (button == 0) {
ItemIdentifierInventory inventoryBee = module.getInventoryBee();
if (slotNumber == 0) {
setting.firstBeeUp();
if (!inventoryBee.isEmpty() && SinkSetting.isBee(inventoryBee, 0)) {
setting.firstBeeSetFirstAlleleID(inventoryBee, 0);
} else {
setting.firstBeeUp();
}
} else {
setting.secondBeeUp();
if (!inventoryBee.isEmpty() && SinkSetting.isBee(inventoryBee, 0)) {
setting.secondBeeSetFirstAlleleID(module.getInventoryBee(), 0);
} else {
setting.secondBeeUp();
}
}
}
if (button == 1) {
ItemIdentifierInventory inventoryBee = module.getInventoryBee();
if (slotNumber == 0) {
setting.firstBeeDown();
if (!inventoryBee.isEmpty() && SinkSetting.isBee(inventoryBee, 0)) {
if (SinkSetting.isAnalyzedBee(inventoryBee, 0)) {
setting.firstBeeSetSecondAlleleID(inventoryBee, 0);
}
} else {
setting.firstBeeDown();
}
} else {
setting.secondBeeDown();
if (!inventoryBee.isEmpty() && SinkSetting.isBee(inventoryBee, 0)) {
if (SinkSetting.isAnalyzedBee(inventoryBee, 0)) {
setting.secondBeeSetSecondAlleleID(inventoryBee, 0);
}
} else {
setting.secondBeeDown();
}
}
}
MainProxy.sendPacketToServer(
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/logisticspipes/modules/ModuleApiaristSink.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
import logisticspipes.utils.SinkReply;
import logisticspipes.utils.SinkReply.FixedPriority;
import logisticspipes.utils.item.ItemIdentifier;
import logisticspipes.utils.item.ItemIdentifierInventory;

public class ModuleApiaristSink extends LogisticsGuiModule {

private final ItemIdentifierInventory _inventoryBee = new ItemIdentifierInventory(1, "Set on click ->", 1);
Copy link
Copy Markdown

@Ranzuu Ranzuu Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Localize "Set on click" without arrow. Like key=Set on click %s
See: https://github.com/GTNewHorizons/LogisticsPipes/pull/114/changes


public enum FilterType {

Null("", "anything", 0),
Expand Down Expand Up @@ -62,6 +65,34 @@ public SinkSetting(ModuleApiaristSink module) {
this.module = module;
}

public static boolean isBee(ItemIdentifierInventory inventory, int i) {
return SimpleServiceLocator.forestryProxy.isBee(inventory.getIDStackInSlot(i).makeNormalStack());
}

public static boolean isAnalyzedBee(ItemIdentifierInventory inventory, int i) {
return SimpleServiceLocator.forestryProxy.isAnalysedBee(inventory.getIDStackInSlot(i).makeNormalStack());
}

public void firstBeeSetFirstAlleleID(ItemIdentifierInventory inventory, int i) {
firstBee = SimpleServiceLocator.forestryProxy
.getFirstAlleleId(inventory.getIDStackInSlot(i).makeNormalStack());
}

public void firstBeeSetSecondAlleleID(ItemIdentifierInventory inventory, int i) {
firstBee = SimpleServiceLocator.forestryProxy
.getSecondAlleleId(inventory.getIDStackInSlot(i).makeNormalStack());
}

public void secondBeeSetFirstAlleleID(ItemIdentifierInventory inventory, int i) {
secondBee = SimpleServiceLocator.forestryProxy
.getFirstAlleleId(inventory.getIDStackInSlot(i).makeNormalStack());
}

public void secondBeeSetSecondAlleleID(ItemIdentifierInventory inventory, int i) {
secondBee = SimpleServiceLocator.forestryProxy
.getSecondAlleleId(inventory.getIDStackInSlot(i).makeNormalStack());
}

public void firstBeeUp() {
firstBee = SimpleServiceLocator.forestryProxy.getNextAlleleId(firstBee, module._world.getWorld());
}
Expand Down Expand Up @@ -200,13 +231,18 @@ public ModuleApiaristSink() {
filter[5] = new SinkSetting(this);
}

public ItemIdentifierInventory getInventoryBee() {
return _inventoryBee;
}

@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
NBTTagCompound filters = nbttagcompound.getCompoundTag("filters");
for (int i = 0; i < filter.length; i++) {
NBTTagCompound filterNBT = filters.getCompoundTag("" + i);
filter[i].readFromNBT(filterNBT);
}
_inventoryBee.readFromNBT(nbttagcompound, "");
}

@Override
Expand All @@ -218,6 +254,7 @@ public void writeToNBT(NBTTagCompound nbttagcompound) {
filters.setTag("" + i, filterNBT);
}
nbttagcompound.setTag("filters", filters);
_inventoryBee.writeToNBT(nbttagcompound, "");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public DummyContainer getContainer(EntityPlayer player) {
if (!(dummy.getModule() instanceof ModuleApiaristSink)) {
return null;
}
dummy.setInventory(((ModuleApiaristSink) dummy.getModule()).getInventoryBee());

dummy.addNormalSlotsForHotbar(8, 157);
dummy.addDummySlot(0, 110, 121);

return dummy;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ public DummyContainer getContainer(EntityPlayer player) {
if (module == null) {
return null;
}
return new DummyContainer(player.inventory, null);

DummyContainer dummy = new DummyContainer(player.inventory, module.getInventoryBee());

dummy.addNormalSlotsForHotbar(8, 157);
dummy.addDummySlot(0, 110, 121);

return dummy;
}

@Override
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/logisticspipes/utils/gui/DummyContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ public void addNormalSlotsForPlayerInventory(int xOffset, int yOffset) {
}
}

public void addNormalSlotsForHotbar(int xOffset, int yOffset) {

if (_playerInventory == null) {
return;
}

for (int i1 = 0; i1 < 9; i1++) {
Slot slot = new Slot(_playerInventory, i1, xOffset + i1 * 18, yOffset);
addSlotToContainer(slot);
transferBottom.add(slot);
}
}

/**
* Add a dummy slot that will not consume players items
*
Expand Down
Copy link
Copy Markdown

@Ranzuu Ranzuu Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the background transparent
+ missing pixel image

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.