Jump to content

Recommended Posts

Posted

I have a Bug with my GUI Container...I want to make a Machine but there is a Bug with the Slots. I have a little Video from the Bug, here you can see:

And here is the Code:

TileEntity:

public class TileEntityChemicalMixer extends TileEntity{

public InventoryBasic INVENTORY;

public TileEntityChemicalMixer(){
	INVENTORY = new InventoryBasic("Chemical Mixer", false, 3);
}

@Override
public void writeToNBT(NBTTagCompound compound) {
	super.writeToNBT(compound);

	NBTTagList list = new NBTTagList();

	for(int i = 0; i < INVENTORY.getSizeInventory(); i++){
		if(INVENTORY.getStackInSlot(i) != null){
			NBTTagCompound tag = new NBTTagCompound();
			tag.setByte("Slot", (byte) i);
			INVENTORY.getStackInSlot(i).writeToNBT(tag);
			list.appendTag(tag);
		}
	}

	compound.setTag("ItemStacks", list);
}

@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	NBTTagList list = compound.getTagList("ItemStacks", 10);
	this.INVENTORY = new InventoryBasic("Chemical Mixer", false, 3);
	for(int i = 0; i < list.tagCount(); i++){
		NBTTagCompound tag = list.getCompoundTagAt(i);
		byte b = tag.getByte("Slot");
		if(b >= 0 && b < INVENTORY.getSizeInventory()){
			INVENTORY.setInventorySlotContents(b, ItemStack.loadItemStackFromNBT(tag));
		}
	}
}

}

Container:

public class ContainerChemicalMixer extends Container{

private TileEntityChemicalMixer tileentiy;

public ContainerChemicalMixer(IInventory inv, TileEntityChemicalMixer tileentity) {
	this.tileentiy = tileentity;
	this.addSlotToContainer(new Slot(inv, 0, 30, 17));
	this.addSlotToContainer(new Slot(inv, 0, 130, 17));

    // Player Inventory, Slot 9-35, Slot IDs 9-35
    for (int y = 0; y < 3; ++y) {
        for (int x = 0; x < 9; ++x) {
            this.addSlotToContainer(new Slot(inv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
        }
    }

    // Player Inventory, Slot 0-8, Slot IDs 36-44
    for (int x = 0; x < 9; ++x) {
        this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142));
    }
}

@Override
public boolean canInteractWith(EntityPlayer playerIn) {
	return true;
}

}

And GUI:

public class GuiChemicalMixer extends GuiContainer{

public static final ResourceLocation BACKGROUND = new ResourceLocation(Main.MODID + ":textures/gui/chemicalmixergui.png");

public GuiChemicalMixer(Container inventorySlotsIn) {
	super(inventorySlotsIn);
	this.ySize = 166;
	this.xSize = 176;
}

@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
	mc.renderEngine.bindTexture(BACKGROUND);
	int k = (this.width - this.xSize) / 2;
	int l = (this.height - this.ySize) / 2;
	drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
}

}

Posted

Issue is here:

	this.addSlotToContainer(new Slot(inv, 0, 30, 17));
	this.addSlotToContainer(new Slot(inv, 0, 130, 17));

    // Player Inventory, Slot 0-8, Slot IDs 36-44
    for (int x = 0; x < 9; ++x) {
        this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142));
    }

The Slot takes in the parameters IInventory, Index, xPos, yPos.

You have to declare the two top slots as something else. You declare the player's hotbar with the id's 0->8, not as the commented 36-44. The player's inventory 9->35. I'd recommend setting the two "main" slots to 36 & 37 respectively.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.