Started by
Radatavi
on
Topic category: Troubleshooting, bugs, and solutions
I made a crafting GUI where I should put an ingot in a slot and press the button. Then it will -add item to inventory- (1 sheet) and -remove item from GUI slot- (1 ingot). When I exit this GUI, all crafted sheets disappear, but ingots are still the same as they were after crafting. What can I do with this bug?
Help me! Please!
1.7.5 is my Mcreator version
I searched for any alternate ways to give an item. Give command would not work properly due to the first part (thetomorrowtechthenewbeginning: or something else), so I tried to use -spawn gem-. Normally it spawns a gem at a block pos, but I wanted to add item to inventory nor I wanted it flying somewhere. I looked in the code and it now looks like this:
(I added a bold part)
protected void actionPerformed(GuiButton button) {
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = server.worlds[0];
int i = (int) entity.posX;
int j = (int) entity.posY;
int k = (int) entity.posZ;
if (button.id == 0) {
if ((Comp.getStackInSlot(0) != null) && Comp.getStackInSlot(0).getItem() == mcreator_platinumIngot.block) {
if (true) {
Comp.decrStackSize(0, 1);
}
if (true) {
if (!world.isRemote) {
EntityItem var14 = new EntityItem(world, (double) (i), (double) (j), (double) (k), new ItemStack(
mcreator_platinumSheet.block, 1, 0));
var14.setPickupDelay(10);
world.spawnEntity(var14);
}
}
}
}
Now it works without any bugs, but I'd like to know about any other ways.