Jump to content

[1.8] Container Not Working Properly


Tikaji
 Share

Recommended Posts

Ok so first of I'm assuming its the container that's not working correctly. I've been updating to 1.8 and this is the first major issue I've run into. Well more like two problems.

 

One of my Tile Entities will accept an item however it will immediately spit it back out but create a copy of the item in the correct slot with a stack size of zero.

 

The other Tile Entity just eats the item and nothing happens.

 

I copied my code over from 1.7.10, and using TheGreyGhost's MinecraftByExample updated it to 1.8. I'm not entirely sure where exactly my issue is so if you need anything to help just let me know.

 

Any help is much appreciated.

 

Container that spits item out:

 

 

public class ContainerCrusher extends ContainerHC

{

private int lastCrushTime;

private TileEntityCrusher tileEntity;

 

public ContainerCrusher(InventoryPlayer inventoryPlayer, TileEntityCrusher te)

{

this.addSlotToContainer(new Slot(te, 0, 56, 34));

this.addSlotToContainer(new Slot(te, 1, 116, 34));

this.addSlotToContainer(new Slot(te, 2, 8, 62));

this.addPlayerSlots(inventoryPlayer, 8, 84);

 

this.tileEntity = te;

}

 

@Override

public void addCraftingToCrafters(ICrafting p_75132_1_)

{

super.addCraftingToCrafters(p_75132_1_);

p_75132_1_.sendProgressBarUpdate(this, 0, this.tileEntity.getCrushTime());

p_75132_1_.sendProgressBarUpdate(this, 1, this.tileEntity.getCrushTime());

 

p_75132_1_.func_175173_a(this, this.tileEntity);

}

 

@Override

public boolean canInteractWith(EntityPlayer playerIn)

{

return tileEntity.isUseableByPlayer(playerIn);

}

 

@Override

public void detectAndSendChanges()

{

super.detectAndSendChanges();

 

for (Object crafter : this.crafters)

{

ICrafting icrafting = (ICrafting) crafter;

 

if (this.lastCrushTime != this.tileEntity.getCrushTime())

{

icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.getCrushTime());

}

}

 

this.lastCrushTime = this.tileEntity.getField(0);

}

 

@Override

public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)

{

ItemStack itemstack = null;

Slot slot = (Slot) this.inventorySlots.get(slotIndex);

 

if (slot != null && slot.getHasStack())

{

ItemStack itemstack1 = slot.getStack();

itemstack = itemstack1.copy();

 

//Change accordingly from here...

if (slotIndex < 3)

{

if (!this.mergeItemStack(itemstack1, 3, 39, true))

{

return null;

}

}

else

{

if (itemstack1.stackSize == 1)

{

for (int i = 0; i < 3; i++)

{

//Shift click single items only

Slot shiftedInSlot = ((Slot) inventorySlots.get(i));

if (!shiftedInSlot.getHasStack() && shiftedInSlot.isItemValid(itemstack1))

{

mergeItemStack(itemstack1, i, i + 1, false);

}

}

return null;

}

}

//..to here.

 

if (itemstack1.stackSize == 0)

{

slot.putStack((ItemStack) null);

}

else

{

slot.onSlotChanged();

}

 

if (itemstack1.stackSize == itemstack.stackSize)

{

return null;

}

 

slot.onPickupFromSlot(player, itemstack1);

}

 

return itemstack;

}

 

@SideOnly(Side.CLIENT)

public void updateProgressBar(int p_75137_1_, int p_75137_2_)

{

if (p_75137_1_ == 0)

{

this.tileEntity.setCrushTime(p_75137_2_);

}

}

}

 

 

 

Container that eats items

 

 

public class ContainerLaserFurnace extends ContainerHC

{

private int lastCookTime;

private TileEntityLaserFurnace te;

 

public ContainerLaserFurnace(InventoryPlayer inventoryPlayer, TileEntityLaserFurnace te)

{

this.addSlotToContainer(new Slot(te, 0, 56, 17));

this.addSlotToContainer(new Slot(te, 1, 116, 35));

this.addSlotToContainer(new Slot(te, 2, 8, 62));

 

this.addPlayerSlots(inventoryPlayer, 8, 84);

this.te = te;

}

 

@Override

public void addCraftingToCrafters(ICrafting p_75132_1_)

{

super.addCraftingToCrafters(p_75132_1_);

p_75132_1_.sendProgressBarUpdate(this, 0, this.te.getFurnaceCookTime());

p_75132_1_.sendProgressBarUpdate(this, 1, this.te.getFurnaceCookTime());

 

p_75132_1_.func_175173_a(this, te);

}

 

@Override

public boolean canInteractWith(EntityPlayer p_75145_1_)

{

return te.isUseableByPlayer(p_75145_1_);

}

 

@Override

public void detectAndSendChanges()

{

super.detectAndSendChanges();

 

for (int i = 0; i < this.crafters.size(); ++i)

{

ICrafting icrafting = (ICrafting) this.crafters.get(i);

 

if (this.lastCookTime != this.te.getFurnaceCookTime())

{

icrafting.sendProgressBarUpdate(this, 0, this.te.getFurnaceCookTime());

}

}

 

this.lastCookTime = this.te.getFurnaceCookTime();

}

 

@Override

public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)

{

ItemStack itemstack = null;

Slot slot = (Slot) this.inventorySlots.get(slotIndex);

 

if (slot != null && slot.getHasStack())

{

ItemStack itemstack1 = slot.getStack();

itemstack = itemstack1.copy();

 

//Change accordingly from here...

if (slotIndex < 3)

{

if (!this.mergeItemStack(itemstack1, 3, 39, true))

{

return null;

}

}

else

{

if (itemstack1.stackSize == 1)

{

for (int i = 0; i < 3; i++)

{

//Shift click single items only

Slot shiftedInSlot = ((Slot) inventorySlots.get(i));

if (!shiftedInSlot.getHasStack() && shiftedInSlot.isItemValid(itemstack1))

{

mergeItemStack(itemstack1, i, i + 1, false);

}

}

return null;

}

}

//..to here.

 

if (itemstack1.stackSize == 0)

{

slot.putStack((ItemStack) null);

}

else

{

slot.onSlotChanged();

}

 

if (itemstack1.stackSize == itemstack.stackSize)

{

return null;

}

 

slot.onPickupFromSlot(player, itemstack1);

}

 

return itemstack;

}

 

@SideOnly(Side.CLIENT)

public void updateProgressBar(int p_75137_1_, int p_75137_2_)

{

if (p_75137_1_ == 0)

{

this.te.setFurnaceCookTime(p_75137_2_);

}

}

}

 

 

 

Base Container

 

 

public abstract class ContainerHC extends Container

{

protected void addPlayerSlots(InventoryPlayer playerInventory, int x, int y)

{

for (int i = 0; i < 3; ++i)

{

for (int j = 0; j < 9; ++j)

{

addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, x + j * 18, y + i * 18));

}

}

 

for (int i = 0; i < 9; ++i)

{

addSlotToContainer(new Slot(playerInventory, i, x + i * 18, y + 58));

}

}

}

 

 

Link to comment
Share on other sites

Did you open the Gui and Container on the client or server side?

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I created an SOUL_JAR Item that has been registered for each mob like - mod:soul_jar_minecraft_cow etc.. but it all has different registry names, i have a model file name soul_jar.json and i want to know how to bind each of those items to this class (When mod iterates through all of vanilla mobs and registering items for them).   I didn't found any info about it because all of info is outdated, and forge docs is complicated asf (i wish there would be more examples) i also used AI but it showing me only outdated info, but theres some code where i registering my item and trying to bind it to model ->   public static void register(IEventBus eventBus){ ITEMS.register(eventBus); Set<ResourceLocation> entityKeyList = ForgeRegistries.ENTITY_TYPES.getKeys(); for (ResourceLocation k : entityKeyList) { EntityType<?> entityType = ForgeRegistries.ENTITY_TYPES.getValue(k); if (!entityType.getCategory().equals(MobCategory.MISC)) { RegistryObject<Item> SOUL_JAR = ITEMS.register("soul_jar" + '_' + k.toString().replace(':', '_').replace('.', '_'), () -> new JarItem(new Item.Properties().rarity(Rarity.RARE).tab(ModTabs.MAGICAL_OBSESSION_JARS), entityType)); if (Thread.currentThread().getThreadGroup() == SidedThreadGroups.CLIENT) { ItemModelShaper itemModelShaper = Minecraft.getInstance().getItemRenderer().getItemModelShaper(); itemModelShaper.register(SOUL_JAR.get().asItem(), new ModelResourceLocation("item.soul_jar", "inventory")); } } } } I also have more questions like how to iterate through all other mods mobs also, or render mob inside of a jar in inventory, but i will try to figure it out.
    • I looked into OctoEconomyAPI and saw that it was a JAR api for fabric. This means you have a fabric mod in your mods folder. I downloaded your mod folder and wasted 2 solid hours creating a Python script to try to find the faulty mod, and eventually just gave up. I suggest you create two installations with half or the mods in each, find which one doesn't launch, cut that one in half, and repeat until you find the fabric mod. Investigué OctoEconomyAPI y vi que era una API JAR para fabric. Esto significa que tienes un mod de Fabric en tu carpeta de mods. Descargué su carpeta de mods y desperdicié 2 horas completas creando un script de Python para tratar de encontrar el mod defectuoso, y finalmente me di por vencido. Le sugiero que cree dos instalaciones con la mitad o las modificaciones en cada una, encuentre cuál no se inicia, córtela por la mitad y repita hasta que encuentre la modificación Fabric.   (The Python script I made is here): (El script de Python que hice está aquí):  
    • I've got it to work now. Instead of using the texture manager I used the Render System:   RenderSystem.setShaderTexture(0, new ResourceLocation("mcaquests", "textures/item/questbook.png"));  
    • Hello ive been having the same issue over Curse Forge's auto modding or when i use manual modding. The error seems to be within either Oculus or Rubidium. Im using 1.19 with the latest 1.19 forge + 1.19 compatible Oculus and Rubidium. Just in case the versions i am using; Oculus - oculus-1.4.3a Rubidium - rubidium-0.6.3 Note: I tried removing the two and add Optifine and it opens without a problem. I didnt use all 3 together to get this error im talking tho, i know they are not compatible with optifine dont worry. Logs Debug The actual error code im getting on start-up is ''1'' and nothing else on the pop up box. I have tried finding the jar files on the internet and insert them on my own but that didnt go too far.
  • Topics

×
×
  • Create New...

Important Information

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