Fixed right click behavior.
This commit is contained in:
parent
2173e4fffe
commit
dc984eaacf
2 changed files with 33 additions and 20 deletions
|
@ -123,12 +123,14 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
|
||||||
use(aStack, 0, aPlayer);
|
use(aStack, 0, aPlayer);
|
||||||
isItemStackUsable(aStack);
|
isItemStackUsable(aStack);
|
||||||
ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack));
|
ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack));
|
||||||
if (tList != null)
|
if (tList != null) {
|
||||||
for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList)
|
for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList) {
|
||||||
if (tBehavior.onLeftClickEntity(this, aStack, aPlayer, aEntity, aPlayer.getActiveHand())) {
|
if (tBehavior.onLeftClickEntity(this, aStack, aPlayer, aEntity, aPlayer.getActiveHand())) {
|
||||||
if (aStack.stackSize <= 0) aPlayer.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, null);
|
if (aStack.stackSize <= 0) aPlayer.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (aStack.stackSize <= 0) {
|
if (aStack.stackSize <= 0) {
|
||||||
aPlayer.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, null);
|
aPlayer.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, null);
|
||||||
return false;
|
return false;
|
||||||
|
@ -143,16 +145,19 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
|
||||||
use(aStack, 0, aPlayer);
|
use(aStack, 0, aPlayer);
|
||||||
isItemStackUsable(aStack);
|
isItemStackUsable(aStack);
|
||||||
ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack));
|
ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack));
|
||||||
if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList)
|
if (tList != null) {
|
||||||
|
for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList) {
|
||||||
if (tBehavior.onItemUse(this, aStack, aPlayer, aWorld, blockPos, aSide, hitX, hitY, hitZ, hand)) {
|
if (tBehavior.onItemUse(this, aStack, aPlayer, aWorld, blockPos, aSide, hitX, hitY, hitZ, hand)) {
|
||||||
if (aStack.stackSize <= 0) aPlayer.setHeldItem(hand, null);
|
if (aStack.stackSize <= 0) aPlayer.setHeldItem(hand, null);
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (aStack.stackSize <= 0) {
|
if (aStack.stackSize <= 0) {
|
||||||
aPlayer.setHeldItem(hand, null);
|
aPlayer.setHeldItem(hand, null);
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,22 +168,22 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumActionResult onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
|
public EnumActionResult onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
|
||||||
if(!aWorld.isRemote) {
|
|
||||||
use(aStack, 0, aPlayer);
|
use(aStack, 0, aPlayer);
|
||||||
ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack));
|
ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack));
|
||||||
if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList)
|
if (tList != null) {
|
||||||
|
for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList) {
|
||||||
if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, pos, side, hitX, hitY, hitZ, hand)) {
|
if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, pos, side, hitX, hitY, hitZ, hand)) {
|
||||||
if (aStack.stackSize <= 0) aPlayer.setHeldItem(hand, null);
|
if (aStack.stackSize <= 0) aPlayer.setHeldItem(hand, null);
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (aStack.stackSize <= 0) {
|
if (aStack.stackSize <= 0) {
|
||||||
aPlayer.setHeldItem(hand, null);
|
aPlayer.setHeldItem(hand, null);
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
}
|
}
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
}
|
}
|
||||||
return EnumActionResult.PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -187,8 +192,11 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
|
||||||
use(aStack, 0, aPlayer);
|
use(aStack, 0, aPlayer);
|
||||||
isItemStackUsable(aStack);
|
isItemStackUsable(aStack);
|
||||||
ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack));
|
ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack));
|
||||||
if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList)
|
if (tList != null) {
|
||||||
|
for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList) {
|
||||||
aStack = tBehavior.onItemRightClick(this, aStack, aWorld, aPlayer, hand);
|
aStack = tBehavior.onItemRightClick(this, aStack, aWorld, aPlayer, hand);
|
||||||
|
}
|
||||||
|
}
|
||||||
return ActionResult.newResult(EnumActionResult.PASS, aStack);
|
return ActionResult.newResult(EnumActionResult.PASS, aStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,8 +205,7 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
|
||||||
String tKey = getUnlocalizedName(aStack) + ".tooltip", tString = GT_LanguageManager.getTranslation(tKey);
|
String tKey = getUnlocalizedName(aStack) + ".tooltip", tString = GT_LanguageManager.getTranslation(tKey);
|
||||||
if (GT_Utility.isStringValid(tString) && !tKey.equals(tString)) aList.add(tString);
|
if (GT_Utility.isStringValid(tString) && !tKey.equals(tString)) aList.add(tString);
|
||||||
|
|
||||||
Long[]
|
Long[] tStats = getElectricStats(aStack);
|
||||||
tStats = getElectricStats(aStack);
|
|
||||||
if (tStats != null) {
|
if (tStats != null) {
|
||||||
if (tStats[3] > 0) {
|
if (tStats[3] > 0) {
|
||||||
aList.add(TextFormatting.AQUA + "Contains " + GT_Utility.formatNumbers(tStats[3]) + " EU Tier: " + (tStats[2] >= 0 ? tStats[2] : 0) + TextFormatting.GRAY);
|
aList.add(TextFormatting.AQUA + "Contains " + GT_Utility.formatNumbers(tStats[3]) + " EU Tier: " + (tStats[2] >= 0 ? tStats[2] : 0) + TextFormatting.GRAY);
|
||||||
|
|
|
@ -289,8 +289,14 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item {
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer, EnumHand hand) {
|
public ActionResult<ItemStack> onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer, EnumHand hand) {
|
||||||
IFoodStat tStat = mFoodStats.get((short) getDamage(aStack));
|
IFoodStat tStat = mFoodStats.get((short) getDamage(aStack));
|
||||||
if (tStat != null && aPlayer.canEat(tStat.alwaysEdible(this, aStack, aPlayer)))
|
if (tStat != null) {
|
||||||
return ActionResult.newResult(EnumActionResult.PASS, aStack);
|
if (aPlayer.canEat(tStat.alwaysEdible(this, aStack, aPlayer))) {
|
||||||
|
aPlayer.setActiveHand(hand);
|
||||||
|
return ActionResult.newResult(EnumActionResult.SUCCESS, aStack);
|
||||||
|
} else {
|
||||||
|
return ActionResult.newResult(EnumActionResult.FAIL, aStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
return super.onItemRightClick(aStack, aWorld, aPlayer, hand);
|
return super.onItemRightClick(aStack, aWorld, aPlayer, hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue