mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-13 16:54:06 +00:00
Baubles can now be swapped in the fly by right clicking one.
This commit is contained in:
1 parent
a5c0ae07e6
commit
86b16202c7
1 file changed
+19
-9
@@ -41,17 +41,27 @@ public abstract class ItemBauble extends ItemMod implements IBauble {
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(par3EntityPlayer);
|
||||
for(int i = 0; i < baubles.getSizeInventory(); i++)
|
||||
if(baubles.getStackInSlot(i) == null && baubles.isItemValidForSlot(i, par1ItemStack)) {
|
||||
if(!par2World.isRemote) {
|
||||
baubles.setInventorySlotContents(i, par1ItemStack.copy());
|
||||
if(!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
par3EntityPlayer.inventory.setInventorySlotContents(par3EntityPlayer.inventory.currentItem, null);
|
||||
}
|
||||
for(int i = 0; i < baubles.getSizeInventory(); i++) {
|
||||
if(baubles.isItemValidForSlot(i, par1ItemStack)) {
|
||||
ItemStack stackInSlot = baubles.getStackInSlot(i);
|
||||
if(stackInSlot == null || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, par3EntityPlayer)) {
|
||||
if(!par2World.isRemote) {
|
||||
baubles.setInventorySlotContents(i, par1ItemStack.copy());
|
||||
if(!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
par3EntityPlayer.inventory.setInventorySlotContents(par3EntityPlayer.inventory.currentItem, null);
|
||||
}
|
||||
|
||||
onEquipped(par1ItemStack, par3EntityPlayer);
|
||||
break;
|
||||
onEquipped(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if(stackInSlot != null) {
|
||||
((IBauble) stackInSlot.getItem()).onUnequipped(stackInSlot, par3EntityPlayer);
|
||||
return stackInSlot.copy();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user