I solve the problem with fail
if (entity.capabilities.isCreativeMode) {
if (entity.inventory.getCurrentItem() != null && entity.inventory.getCurrentItem().getItem() == mcreator_expand1.block) {
if (true) {
if (entity instanceof EntityPlayer)
((EntityPlayer) entity).inventory.setInventorySlotContents(selSlot, new ItemS(mcreator_expand50.block, 1));
((EntityPlayer) entity).inventory.markDirty();
}
}
}
but it isn`t help with my problem...
If I use markDirty() to save inventory changes, it get me fail. What can make problems? May be I must import library, or something else?
Part of code where I use it
if (entity.capabilities.isCreativeMode) {
if (entity.inventory.getCurrentItem() != null && entity.inventory.getCurrentItem().getItem() == mcreator_expand1.block) {
if (true) {
if (entity instanceof EntityPlayer)
((EntityPlayer) entity).inventory.setInventorySlotContents(selSlot, new ItemStack(mcreator_expand50.block, 1));
stopExpand = 1;
markDirty();
}
}
}
Sorry, but the most of this code isn`t mine, I use ModCreator, so I understend not more the 20% of that. I just want to solve this problem. So, my problem was called by reaching across logical sides, or the reason not here?
I use this code to replace item in hotbar slot
((EntityPlayer) entity).inventory.setInventorySlotContents(5, new ItemStack(example.block, 1));
and this works, but if I use this item(RClick) it go back to the previous state. But! If I open inventory and pick it and put in any slot it won`t go back to the previous state after RClick.
I was not sure that I would succeed and therefore asked for help. But this code works !
((EntityPlayer) entity).inventory.setInventorySlotContents(5, null);
Thank you!