Jump to content

[1.10.2] GUI changes not saving


Villfuk02

Recommended Posts

Instantiate it.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I thought it requires more things....

I allready had the ItemStackHandler here, but i thought i am supposed to implement IItemHandler

 

 

But now what do i do with this?

this.addSlotToContainer(new SlotItemHandler(te, x + y * 9, 15 + x * 16, 15 + y * 16));

 

(adding slots to a container)

Link to comment
Share on other sites

te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I think i have this wrong:

 

ItemStackHandler itemHandler = new ItemStackHandler(81);

@Override
public boolean hasCapability(Capability capability, EnumFacing facing) {
     return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? true : super.hasCapability(capability, facing);
}

@Override
public Capability getCapability(Capability capability, EnumFacing facing) {
	if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
	    return itemHandler;
	  }
	  return super.getCapability(capability, facing);
}

Link to comment
Share on other sites

Use generics.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I'm back now.

i mde some changes and it works, but when i place itemstack in slot, it goes in there, but it is also left in my cursor and when i remove itemstack it just disappears.

 

package com.villfuk02.essence.tileentities;

import java.awt.ItemSelectable;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler;

public class TileEntityStoneCrate extends TileEntity implements ICapabilityProvider{

private String customName;

private static ItemStackHandler itemHandler = new ItemStackHandler(81);

@Override
public boolean hasCapability(Capability capability, EnumFacing facing) {
     return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? true : super.hasCapability(capability, facing);
}

@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
	if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
	    return (T) itemHandler;
	  }
	  return super.getCapability(capability, facing);
}

public String getCustomName(){
	return this.customName;
}

public void setCustomName(String customName){
	this.customName = customName;
}



public String getName() {
	return this.hasCustomName() ? this.customName : "Stone Storage Crate";
}

public boolean hasCustomName() {
	return this.customName != null && !this.customName.equals("");
}

public int getSizeInventory() {
	return 81;
}


public boolean isUseableByPlayer(EntityPlayer player) {
	return this.worldObj.getTileEntity(this.getPos()) == this && player.getDistanceSq(this.pos.add(0.5, 0.5, 0.5)) <= 64;
}


}

Link to comment
Share on other sites

I think everything happens twice and doesnt sync perfectly, because when i place less than 32 items in the slot, it just doubles in the slot. When i put 48 items in, in the slot goes 64 and i get 32 back. when i split the stack with rightclicking, in the slot is left just quarter of the items and in my cursor too.

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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