use of net.minecraft.util.ActionResult in project VoodooCraft by Mod-DevCafeTeam.
the class ItemChalk method onItemRightClick.
/**
* Changes glyphtype NBT, cycles through all in the {@link EnumGlyphType}
*/
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
if (playerIn.isSneaking()) {
NBTTagCompound nbt = NBTHelper.getTagCompound(itemStackIn);
EnumGlyphType newtype = EnumGlyphType.byIndex(nbt.getInteger(KEY_GLYPH)).next();
nbt.setInteger(KEY_GLYPH, newtype.ordinal());
itemStackIn.setTagCompound(nbt);
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
}
return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
}
use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.
the class ItemPearcelArrow method onItemRightClick.
@Override
public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
Random rand = new Random();
if (player.inventory.hasItemStack(infItem)) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setBoolean("inf", true);
player.inventory.clearMatchingItems(infItem.getItem(), 0, 1, null);
player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
if (!world.isRemote) {
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.inf")));
}
} else {
stack.getTagCompound().setBoolean("inf", true);
player.inventory.clearMatchingItems(infItem.getItem(), 0, 1, null);
player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
if (!world.isRemote) {
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.inf")));
}
}
}
if (player.inventory.hasItemStack(powItem)) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setBoolean("pow", true);
player.inventory.clearMatchingItems(powItem.getItem(), 0, 1, null);
player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
if (!world.isRemote) {
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.pow")));
}
} else {
stack.getTagCompound().setBoolean("pow", true);
player.inventory.clearMatchingItems(powItem.getItem(), 0, 1, null);
player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
if (!world.isRemote) {
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.pow")));
}
}
}
if (player.inventory.hasItemStack(knockItem)) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setBoolean("knock", true);
player.inventory.clearMatchingItems(knockItem.getItem(), 0, 1, null);
player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
if (!world.isRemote) {
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.knock")));
}
} else {
stack.getTagCompound().setBoolean("knock", true);
player.inventory.clearMatchingItems(knockItem.getItem(), 0, 1, null);
player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
if (!world.isRemote) {
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.knock")));
}
}
}
if (player.inventory.hasItemStack(zoomItem)) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setBoolean("zoom", true);
player.inventory.clearMatchingItems(zoomItem.getItem(), 0, 1, null);
player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
if (!world.isRemote) {
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.zoom")));
}
} else {
stack.getTagCompound().setBoolean("zoom", true);
player.inventory.clearMatchingItems(zoomItem.getItem(), 0, 1, null);
player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
if (!world.isRemote) {
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.zoom")));
}
}
}
return new ActionResult(EnumActionResult.PASS, stack);
}
use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.
the class ItemPearcelBlockPlacer 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.pbp.modeChange"))));
}
} else {
item.getTagCompound().setInteger("mode", 1);
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.GOLD + (Translate.toLocal("chat.item.pbp.modeChange"))));
}
}
}
return new ActionResult(EnumActionResult.PASS, item);
} else {
return new ActionResult(EnumActionResult.PASS, item);
}
}
use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.
the class ItemEnderPearcel method onItemRightClick.
@Override
public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
float velocity = ConfigurationHandler.enderPearcelVelocity;
if (!player.isCreative()) {
if (hasEnoughEnergy(stack, ConfigurationHandler.rfPerUse_enderPearcel, player)) {
useEnergy(stack, ConfigurationHandler.rfPerUse_enderPearcel, false, player);
} else {
stack.damageItem(1, player);
}
}
if (ConfigurationHandler.doEnderPearcelCooldown) {
player.getCooldownTracker().setCooldown(this, ConfigurationHandler.enderPearcelCooldownTime * 20);
}
world.playSound(player, player.getPosition(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F);
if (!world.isRemote) {
EntityEnderPearcel pearl = new EntityEnderPearcel(world, player);
pearl.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, velocity, 0.0F);
world.spawnEntity(pearl);
}
return new ActionResult(EnumActionResult.SUCCESS, stack);
}
use of net.minecraft.util.ActionResult in project ConvenientAdditions by Necr0.
the class ItemPlayerChannelModule method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack item = player.getHeldItem(hand);
if (!world.isRemote) {
if (!item.hasTagCompound())
item.setTagCompound(new NBTTagCompound());
NBTTagCompound t = item.getTagCompound();
if (!player.isSneaking()) {
t.setString("MATCHER_PLAYER_ID", player.getUniqueID().toString());
t.setString("MATCHER_PLAYER_NAME", player.getDisplayNameString());
player.sendMessage(new TextComponentString(Helper.localize("message." + ModConstants.Mod.MODID + ":playerSetTo", player.getDisplayNameString())));
new ActionResult<>(EnumActionResult.SUCCESS, item);
} else {
t.removeTag("MATCHER_PLAYER_ID");
t.removeTag("MATCHER_PLAYER_NAME");
player.sendMessage(new TextComponentString(Helper.localize("message." + ModConstants.Mod.MODID + ":playerReset")));
new ActionResult<>(EnumActionResult.SUCCESS, item);
}
}
return new ActionResult<>(EnumActionResult.PASS, item);
}
Aggregations