Jump to content

[1.8] [Half-Solved] Multiple Custom Crafting Table Problems


AnonymousModder

Recommended Posts

EDIT - my items craft and disspear from the custom crafting table, however Minecraft crashes when exiting the world. I'd love to know how to fix this. I updated the crash report below.

 

I have a custom crafting table that when you craft something in it the items in both slots do not dissapear. Also, when you close the Minecraft world the game crashes. I have gone all over the internet trying to find a solution and I've seen other people have had the same problem. I've looked at the crafting table's container and I've got the same code, yet I'm still having this problem.

 

Crash Report -

---- Minecraft Crash Report ----

// Ooh. Shiny.

 

Time: 2/6/16 3:51 PM

Description: Updating screen events

 

com.google.common.util.concurrent.UncheckedExecutionException: java.lang.ArrayIndexOutOfBoundsException: 1

at com.google.common.util.concurrent.Futures.wrapAndThrowUnchecked(Futures.java:1437)

at com.google.common.util.concurrent.Futures.getUnchecked(Futures.java:1423)

at net.minecraft.server.integrated.IntegratedServer.initiateShutdown(IntegratedServer.java:370)

at net.minecraft.client.Minecraft.loadWorld(Minecraft.java:2357)

at net.minecraft.client.Minecraft.loadWorld(Minecraft.java:2336)

at net.minecraft.client.gui.GuiIngameMenu.actionPerformed(GuiIngameMenu.java:54)

at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:510)

at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:606)

at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:572)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:1760)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1087)

at net.minecraft.client.Minecraft.run(Minecraft.java:376)

at net.minecraft.client.main.Main.main(Main.java:117)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

Caused by: java.lang.ArrayIndexOutOfBoundsException: 1

at net.minecraft.inventory.InventoryCrafting.getStackInSlotOnClosing(InventoryCrafting.java:80)

at steamfox.pinesmod.container.ContainerVendingMachine.onContainerClosed(ContainerVendingMachine.java:66)

at net.minecraft.entity.player.EntityPlayer.setDead(EntityPlayer.java:1531)

at net.minecraft.world.World.removeEntity(World.java:1270)

at net.minecraft.server.management.ServerConfigurationManager.playerLoggedOut(ServerConfigurationManager.java:386)

at net.minecraft.server.integrated.IntegratedServer$3.run(IntegratedServer.java:381)

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.util.concurrent.FutureTask.run(Unknown Source)

at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:160)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540)

at java.lang.Thread.run(Unknown Source)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at com.google.common.util.concurrent.Futures.wrapAndThrowUnchecked(Futures.java:1437)

at com.google.common.util.concurrent.Futures.getUnchecked(Futures.java:1423)

at net.minecraft.server.integrated.IntegratedServer.initiateShutdown(IntegratedServer.java:370)

at net.minecraft.client.Minecraft.loadWorld(Minecraft.java:2357)

at net.minecraft.client.Minecraft.loadWorld(Minecraft.java:2336)

at net.minecraft.client.gui.GuiIngameMenu.actionPerformed(GuiIngameMenu.java:54)

at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:510)

at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:606)

at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:572)

 

-- Affected screen --

Details:

Screen name: net.minecraft.client.gui.GuiIngameMenu

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityPlayerSP['Player679'/310, l='MpServer', x=-100.44, y=68.00, z=326.50]]

Chunk stats: MultiplayerChunkCache: 289, 289

Level seed: 0

Level generator: ID 00 - default, ver 1. Features enabled: false

Level generator options:

Level spawn location: -89.00,70.00,334.00 - World: (-89,70,334), Chunk: (at 7,4,14 in -6,20; contains blocks -96,0,320 to -81,255,335), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Level time: 497211 game time, 111408 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

Forced entities: 37 total; [EntitySheep['Sheep'/193, l='MpServer', x=-52.91, y=66.00, z=255.03], EntityZombie['Zombie'/195, l='MpServer', x=-55.50, y=26.00, z=270.50], EntitySpider['Spider'/196, l='MpServer', x=-58.50, y=67.00, z=270.50], EntitySpider['Spider'/197, l='MpServer', x=-57.50, y=67.00, z=274.50], EntitySheep['Sheep'/134, l='MpServer', x=-115.38, y=70.00, z=255.22], EntityItem['item.item.egg'/136, l='MpServer', x=-119.53, y=70.00, z=291.84], EntityChicken['Chicken'/137, l='MpServer', x=-119.16, y=70.50, z=291.91], EntityCreeper['Creeper'/714, l='MpServer', x=-83.50, y=72.02, z=247.50], EntityItem['item.item.egg'/139, l='MpServer', x=-114.66, y=69.00, z=368.53], EntityChicken['Chicken'/140, l='MpServer', x=-114.66, y=69.00, z=369.34], EntitySpider['Spider'/720, l='MpServer', x=-93.50, y=71.02, z=248.50], EntityZombie['Zombie'/657, l='MpServer', x=-83.69, y=67.00, z=286.06], EntitySheep['Sheep'/211, l='MpServer', x=-24.06, y=70.00, z=268.03], EntityBat['Bat'/403, l='MpServer', x=-128.50, y=17.22, z=288.88], EntityCreeper['Creeper'/659, l='MpServer', x=-81.50, y=68.02, z=280.50], EntitySpider['Spider'/213, l='MpServer', x=-29.50, y=67.00, z=317.50], EntityBat['Bat'/469, l='MpServer', x=-124.59, y=34.10, z=291.25], EntityCreeper['Creeper'/150, l='MpServer', x=-106.50, y=70.00, z=254.50], EntitySkeleton['Skeleton'/151, l='MpServer', x=-92.31, y=40.00, z=304.56], EntityCreeper['Creeper'/154, l='MpServer', x=-111.50, y=19.00, z=401.50], EntityCreeper['Creeper'/671, l='MpServer', x=-22.50, y=70.02, z=276.50], EntitySheep['Sheep'/99, l='MpServer', x=-169.50, y=70.00, z=386.81], MobLeprecornMob['Leprecorn'/164, l='MpServer', x=-82.50, y=68.00, z=364.50], EntityZombie['Zombie'/676, l='MpServer', x=-144.50, y=73.02, z=345.50], EntityZombie['Zombie'/684, l='MpServer', x=-42.50, y=68.02, z=266.50], EntityBat['Bat'/110, l='MpServer', x=-165.25, y=45.27, z=308.46], EntitySpider['Spider'/111, l='MpServer', x=-147.50, y=72.00, z=310.50], EntitySkeleton['Skeleton'/112, l='MpServer', x=-144.50, y=22.00, z=321.50], EntityChicken['Chicken'/178, l='MpServer', x=-73.63, y=67.00, z=281.59], EntityItem['item.item.egg'/179, l='MpServer', x=-72.91, y=67.00, z=282.00], MobGnomeMob['Shmebulock'/181, l='MpServer', x=-66.81, y=68.00, z=364.22], MobOctaviaMob['Octavia'/183, l='MpServer', x=-72.47, y=68.00, z=364.44], EntityBat['Bat'/633, l='MpServer', x=-109.28, y=18.63, z=274.28], EntitySkeleton['Skeleton'/122, l='MpServer', x=-143.50, y=22.00, z=317.50], EntityBat['Bat'/574, l='MpServer', x=-55.13, y=25.02, z=266.57], EntityPlayerSP['Player679'/310, l='MpServer', x=-100.44, y=68.00, z=326.50], EntityBat['Bat'/575, l='MpServer', x=-59.42, y=26.38, z=268.67]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:392)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2614)

at net.minecraft.client.Minecraft.run(Minecraft.java:398)

at net.minecraft.client.main.Main.main(Main.java:117)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

 

-- System Details --

Details:

Minecraft Version: 1.8

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.8.0_65, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 691739872 bytes (659 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

IntCache: cache: 1, tcache: 1, allocated: 12, tallocated: 94

FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.4.1577 4 mods loaded, 4 mods active

States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)

UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.4.1577.jar)

UCHIJAAAA Forge{11.14.4.1577} [Minecraft Forge] (forgeSrc-1.8-11.14.4.1577.jar)

UCHIJAAAA pm{Alpha 2.0} [Pines Mod] (bin)

Loaded coremods (and transformers):

GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 358.91' Renderer: 'NVS 5200M/PCIe/SSE2'

Launched Version: 1.8

LWJGL: 2.9.1

OpenGL: NVS 5200M/PCIe/SSE2 GL version 4.5.0 NVIDIA 358.91, NVIDIA Corporation

GL Caps: Using GL 1.3 multitexturing.

Using GL 1.3 texture combiners.

Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.

Shaders are available because OpenGL 2.1 is supported.

VBOs are available because OpenGL 1.5 is supported.

 

Using VBOs: No

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Packs: []

Current Language: English (US)

Profiler Position: N/A (disabled)

 

Container Class -

 

public class ContainerVendingMachine extends Container {

public InventoryCrafting craftMatrix;
public IInventory craftResult;
private World worldObj;
private int posX;
private int posY;
private int posZ;

public ContainerVendingMachine(InventoryPlayer invPlayer, World world, int x, int y, int z){
	craftMatrix = new InventoryCrafting(this, 1, 1);
	craftResult = new InventoryCraftResult();
	worldObj = world;
	posX = x;
	posY = y;
	posZ = z;

	this.addSlotToContainer(new SlotCrafting(invPlayer.player, craftMatrix, craftResult, 0, 124, 45));

	for (int i = 0; i < 1; i++){
		for(int k = 0; k < 1; k++){
			this.addSlotToContainer(new Slot(craftMatrix, k + i * 5, 48 + k * 18, 45 + i * 18));
		}
	}

	for (int i = 0; i < 3; i++){
		for(int k = 0; k <9; k++){
			this.addSlotToContainer(new Slot(invPlayer, k + i * 9 + 9, 8 + k * 18, 94 + i * 18));
		}
	}

	for (int i = 0; i < 9; i++){
		this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 152));
	}

	onCraftMatrixChanged(craftMatrix);
}

public void onCraftMatrixChanged(IInventory iinventory) {
	craftResult.setInventorySlotContents(0, VendingMachineManager.getInstance().findMatchingRecipe(craftMatrix, worldObj));
}


@Override
public boolean canInteractWith(EntityPlayer playerIn) {
	return true;
}
    public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
    {
        ItemStack itemstack = null;
        Slot slot = (Slot)this.inventorySlots.get(index);

        if (slot != null && slot.getHasStack())
        {
            ItemStack itemstack1 = slot.getStack();
            itemstack = itemstack1.copy();

            if (index == 0)
            {
                if (!this.mergeItemStack(itemstack1, 10, 46, true))
                {
                    return null;
                }

                slot.onSlotChange(itemstack1, itemstack);
            }
            else if (index >= 10 && index < 37)
            {
                if (!this.mergeItemStack(itemstack1, 37, 46, false))
                {
                    return null;
                }
            }
            else if (index >= 37 && index < 46)
            {
                if (!this.mergeItemStack(itemstack1, 10, 37, false))
                {
                    return null;
                }
            }
            else if (!this.mergeItemStack(itemstack1, 10, 46, false))
            {
                return null;
            }

            if (itemstack1.stackSize == 0)
            {
                slot.putStack((ItemStack)null);
            }
            else
            {
                slot.onSlotChanged();
            }

            if (itemstack1.stackSize == itemstack.stackSize)
            {
                return null;
            }

            slot.onPickupFromSlot(playerIn, itemstack1);
        }

        return itemstack;
    }

    public void onContainerClosed(EntityPlayer playerIn)
    {
        super.onContainerClosed(playerIn);

        if (!this.worldObj.isRemote)
        {
            for (int i = 0; i < 9; ++i)
            {
                ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i);

                if (itemstack != null)
                {
                    playerIn.dropPlayerItemWithRandomChoice(itemstack, false);
                }
            }
        }
    }
}

 

If you need any more classes just ask.

Link to comment
Share on other sites

I was able to figure it out! When you create a slot you use "this.addSlotToContainer(new SlotCrafting". What you need to do is create a custom SlotCrafting class with the same code, however there is one line that says "ItemStack[] aitemstack = CraftingManager.getInstance().func_180303_b(this.craftMatrix, playerIn.worldObj);" and change the "CraftingManager" to your custom Crafting Manager class. Hope that helps for anyone with the same problem.

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.



×
×
  • Create New...

Important Information

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