Skip to content

Commit

Permalink
100% fix #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Tfarcenim committed Aug 27, 2019
1 parent 450cd81 commit 6c28952
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public class CraftingStationContainer extends Container implements CraftingStati

public ITextComponent containerName;

public int subContainerSlotStart = -1;
public int subContainerSlotEnd = -1;
public int subContainerSlotStart = 10;
public int subContainerSlotEnd = 46;


public CraftingStationContainer(InventoryPlayer InventoryPlayer, World world, BlockPos pos, EntityPlayer player) {
Expand Down Expand Up @@ -102,7 +102,7 @@ else if(te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir.getO
}

private void addSideContainerSlots(TileEntity te, EnumFacing dir, int xPos, int yPos){
subContainerSlotStart = inventorySlots.size();
subContainerSlotStart = 10;
IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir);
int slotCount = handler.getSlots();
for (int y = 0; y < (int)Math.ceil((double)slotCount / 6);y++)
Expand Down Expand Up @@ -179,19 +179,13 @@ public boolean canInteractWith(EntityPlayer player) {
@Nonnull
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
// shamelessly copied from ContainerWorkbench

int playerMainStart = 10;
int playerMainEnd = 36;
int hotbarStart = 37;
int hotBarEnd = 46;

if (subContainerSlotStart != -1 && subContainerSlotEnd != -1){
playerMainStart = subContainerSlotEnd + 1;
playerMainEnd = playerMainStart + 26;
hotbarStart = playerMainEnd + 1;
hotBarEnd = hotbarStart + 9;
}

//shift click sucks

int hotBarEnd = this.inventorySlots.size() - 1;
int hotbarStart = hotBarEnd - 8;
int playerMainEnd = hotbarStart - 1;
int playerMainStart = playerMainEnd - 26;

ItemStack itemstack = ItemStack.EMPTY;
Slot slot = inventorySlots.get(index);
Expand All @@ -208,15 +202,15 @@ public ItemStack transferStackInSlot(EntityPlayer player, int index) {
}

slot.onSlotChange(itemstack1, itemstack);
} else if (index >= 10 && index < 37) {
if (!mergeItemStack(itemstack1, 37, hotBarEnd, false)) {
} else if (index >= playerMainStart && index < playerMainEnd) {
if (!mergeItemStack(itemstack1, hotbarStart, hotBarEnd, false)) {
return ItemStack.EMPTY;
}
} else if (index >= 37 && index < 46) {
if (!mergeItemStack(itemstack1, 10, 37, false)) {
} else if (index >= hotbarStart && index < hotBarEnd) {
if (!mergeItemStack(itemstack1, playerMainStart, hotbarStart, false)) {
return ItemStack.EMPTY;
}
} else if (!mergeItemStack(itemstack1, 10, 46, false)) {
} else if (!mergeItemStack(itemstack1, playerMainStart, hotBarEnd, false)) {
return ItemStack.EMPTY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
fontRenderer.drawString(I18n.format("title.crafting_station"), 28, 6, 0x404040);
fontRenderer.drawString(I18n.format("container.inventory"), 8, ySize - 96 + 2, 0x404040);
if (((CraftingStationContainer) inventorySlots).subContainerSlotStart != -1) {
this.fontRenderer.drawString(((CraftingStationContainer) inventorySlots).containerName.getFormattedText(), -110, 6, 4210752);
}
if (((CraftingStationContainer)this.inventorySlots).hasSideContainer)
this.fontRenderer.drawString(((CraftingStationContainer) inventorySlots)
.containerName.getFormattedText(), -110, 6, 4210752);
}

@Override
Expand All @@ -58,7 +58,7 @@ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, i
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
int i = this.guiLeft;
int j = (this.height - this.ySize) / 2;
if (((CraftingStationContainer) this.inventorySlots).subContainerSlotStart != -1) {
if (((CraftingStationContainer)this.inventorySlots).hasSideContainer){
this.mc.getTextureManager().bindTexture(SECONDARY_GUI_TEXTURE);
this.drawTexturedModalRect(i - 117, j, 0, 0, this.xSize, this.ySize + 18);

Expand Down

0 comments on commit 6c28952

Please sign in to comment.