use of net.minecraft.util.ActionResult in project BiomesOPlenty by Glitchfiend.
the class ItemMudball method onItemRightClick.
// throw a mudball on right click
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (!player.capabilities.isCreativeMode) {
stack.setCount(stack.getCount() - 1);
}
world.playSound(player, player.getPosition(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!world.isRemote) {
EntityMudball mudball = new EntityMudball(world, player);
mudball.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
world.spawnEntity(mudball);
}
player.addStat(StatList.getObjectUseStats(this));
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
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 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 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 ItemPearcelMagnet 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.pearcel_magnet.disabled")));
} else {
stack.getTagCompound().setBoolean("enabled", true);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_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.pearcel_magnet.repels")));
} else {
stack.getTagCompound().setString("mode", "Attracts");
player.sendMessage(new TextComponentString(TextFormatting.GREEN + Translate.toLocal("chat.item.pearcel_magnet.attracts")));
}
}
}
return new ActionResult(EnumActionResult.SUCCESS, stack);
}
Aggregations