use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.
the class ItemCharmBag method onItemRightClick.
@Override
public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if (!player.isSneaking()) {
if (!world.isRemote) {
if (!player.isSneaking() && hand == EnumHand.MAIN_HAND) {
player.openGui(Reference.MOD_ID, GUIs.gui_id_charm_bag, world, 0, 0, 0);
}
}
} else {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setBoolean("active", true);
}
NBTTagCompound compound = stack.getTagCompound();
NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < items.tagCount(); i++) {
NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i);
int slot = item.getInteger("Slot");
ItemStack charmStack = ItemStack.loadItemStackFromNBT(item);
if (slot >= 0 && slot < InventoryCharmBag.INV_SIZE) {
if (!stack.getTagCompound().getBoolean("active")) {
charmStack.getTagCompound().setBoolean("active", true);
} else {
charmStack.getTagCompound().setBoolean("active", false);
}
}
}
if (!world.isRemote) {
if (stack.getTagCompound().getBoolean("active")) {
player.sendMessage(new TextComponentString(ChatFormatting.RED + Translate.toLocal("chat.item.charmed_pearcel.deactivated")));
stack.getTagCompound().setBoolean("active", false);
} else {
player.sendMessage(new TextComponentString(ChatFormatting.GREEN + Translate.toLocal("chat.item.charmed_pearcel.activated")));
stack.getTagCompound().setBoolean("active", true);
}
}
}
return new ActionResult(EnumActionResult.SUCCESS, stack);
}
use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.
the class ItemCharmedPearcel method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
}
if (player.isSneaking() && !world.isRemote) {
if (!stack.getTagCompound().getBoolean("active")) {
stack.getTagCompound().setBoolean("active", true);
player.sendMessage(new TextComponentString(ChatFormatting.GREEN + Translate.toLocal("chat.item.charmed_pearcel.activated")));
} else {
stack.getTagCompound().setBoolean("active", false);
player.sendMessage(new TextComponentString(ChatFormatting.RED + Translate.toLocal("chat.item.charmed_pearcel.deactivated")));
}
}
return new ActionResult(EnumActionResult.SUCCESS, stack);
}
use of net.minecraft.util.ActionResult in project ImmersiveEngineering by BluSunrize.
the class ItemBlockClothDevice method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
if (itemStackIn.getMetadata() != BlockTypes_ClothDevice.BALLOON.getMeta())
return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
if (playerIn.isSneaking())
increaseOffset(itemStackIn);
else {
Vec3d pos = playerIn.getPositionVector().addVector(0, playerIn.getEyeHeight(), 0).add(playerIn.getLookVec());
BlockPos bPos = new BlockPos(pos);
NBTTagCompound nbt = itemStackIn.getTagCompound();
int offset = nbt == null ? 0 : nbt.getByte("offset");
bPos = bPos.up(offset);
if (worldIn.isAirBlock(bPos)) {
if (!worldIn.isRemote) {
worldIn.setBlockState(bPos, IEContent.blockClothDevice.getStateFromMeta(BlockTypes_ClothDevice.BALLOON.getMeta()));
itemStackIn.stackSize--;
if (itemStackIn.stackSize <= 0)
playerIn.setHeldItem(hand, null);
}
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
}
return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
use of net.minecraft.util.ActionResult in project minecolonies by Minecolonies.
the class ItemScepterPermission method onItemRightClick.
/**
* Handles mid air use.
*
* @param worldIn the world
* @param playerIn the player
* @param hand the hand
* @return the result
*/
@Override
@NotNull
public ActionResult<ItemStack> onItemRightClick(final World worldIn, final EntityPlayer playerIn, final EnumHand hand) {
final ItemStack scepter = playerIn.getHeldItem(hand);
if (worldIn.isRemote) {
return new ActionResult<>(EnumActionResult.SUCCESS, scepter);
}
if (!scepter.hasTagCompound()) {
scepter.setTagCompound(new NBTTagCompound());
}
final NBTTagCompound compound = scepter.getTagCompound();
toggleItemMode(playerIn, compound);
return new ActionResult<>(EnumActionResult.SUCCESS, scepter);
}
use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.
the class ItemPearcelStaff method onItemRightClick.
@Override
public ActionResult onItemRightClick(ItemStack item, World world, EntityPlayer player, EnumHand hand) {
if (player.isSneaking()) {
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 5000, 1));
item.damageItem(50, player);
return new ActionResult(EnumActionResult.PASS, item);
} else {
if (player.posY <= ConfigurationHandler.maxStaffFlyHeight || player.capabilities.isCreativeMode) {
player.addVelocity(0, 0.5, 0);
} else {
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.DARK_RED + Translate.toLocal("chat.pearcel_staff.weaken")));
item.damageItem(10, player);
}
}
item.damageItem(1, player);
return new ActionResult(EnumActionResult.PASS, item);
}
}
Aggregations