use of net.minecraft.util.ActionResult in project ConvenientAdditions by Necr0.
the class ItemEnderPlate method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
int dmg = itemStack.getItemDamage();
if (!world.isRemote)
if (dmg == 0) {
itemStack.setItemDamage(1);
} else
itemStack.setItemDamage(0);
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
use of net.minecraft.util.ActionResult in project ConvenientAdditions by Necr0.
the class ItemSunstone method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
int dmg = itemStack.getItemDamage();
if (!world.isRemote)
if (dmg == 0) {
itemStack.setItemDamage(1);
} else
itemStack.setItemDamage(0);
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.
the class ItemExperiencePearcel method onItemRightClick.
@Override
public ActionResult onItemRightClick(ItemStack item, World world, EntityPlayer player, EnumHand hand) {
if (!item.hasTagCompound()) {
item.setTagCompound(new NBTTagCompound());
item.getTagCompound().setInteger("playerXP", 0);
}
if (!player.isSneaking()) {
int xpToGather = player.experienceLevel + item.getTagCompound().getInteger("playerXP");
player.experienceLevel = xpToGather;
item.getTagCompound().setInteger("playerXP", 0);
player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 0.2F, rand.nextFloat() * 2.5F);
return new ActionResult(EnumActionResult.PASS, item);
} else {
int xpToStore = player.experienceLevel + item.getTagCompound().getInteger("playerXP");
item.getTagCompound().setInteger("playerXP", xpToStore);
player.experienceLevel = 0;
player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 0.2F, rand.nextFloat() * 2.5F);
player.addStat(Achievements.achievement_use_experience_pearcel);
return new ActionResult(EnumActionResult.PASS, item);
}
}
use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.
the class ItemLivingMagnet method onItemRightClick.
@Override
public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setBoolean("enabled", false);
stack.getTagCompound().setString("mode", "Attracts");
}
if (!world.isRemote) {
if (!player.isSneaking()) {
if (stack.getTagCompound().getBoolean("enabled")) {
stack.getTagCompound().setBoolean("enabled", false);
player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("chat.item.living_magnet.disabled")));
} else {
stack.getTagCompound().setBoolean("enabled", true);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.living_magnet.enabled")));
}
} else {
if (stack.getTagCompound().getString("mode").equalsIgnoreCase("attracts")) {
stack.getTagCompound().setString("mode", "Repels");
player.sendMessage(new TextComponentString(TextFormatting.RED + Translate.toLocal("chat.item.living_magnet.repels")));
} else {
stack.getTagCompound().setString("mode", "Attracts");
player.sendMessage(new TextComponentString(TextFormatting.GREEN + Translate.toLocal("chat.item.living_magnet.attracts")));
}
}
}
return new ActionResult(EnumActionResult.SUCCESS, stack);
}
use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.
the class ItemMatterFabricator method onItemRightClick.
@Override
public ActionResult onItemRightClick(ItemStack item, World world, EntityPlayer player, EnumHand hand) {
if (player.isSneaking()) {
if (!item.hasTagCompound()) {
item.setTagCompound(new NBTTagCompound());
item.getTagCompound().setInteger("mode", 1);
} else {
if (item.getTagCompound().getInteger("mode") == 1) {
item.getTagCompound().setInteger("mode", 2);
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.GOLD + (Translate.toLocal("chat.item.mf.modeChange"))));
}
} else {
item.getTagCompound().setInteger("mode", 1);
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.GOLD + (Translate.toLocal("chat.item.mf.modeChange"))));
}
}
}
return new ActionResult(EnumActionResult.PASS, item);
} else {
return new ActionResult(EnumActionResult.PASS, item);
}
}
Aggregations