use of net.minecraft.util.ActionResult in project MorePlanets by SteveKunG.
the class ItemInfectedPurloniteBomb method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
if (!player.capabilities.isCreativeMode) {
itemStack.shrink(1);
}
world.playSound(null, player.getPosition(), SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
player.swingArm(hand);
if (!world.isRemote) {
EntityInfectedPurloniteBomb bomb = new EntityInfectedPurloniteBomb(world, player);
bomb.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
world.spawnEntity(bomb);
}
player.addStat(StatList.getObjectUseStats(this));
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
use of net.minecraft.util.ActionResult in project MorePlanets by SteveKunG.
the class ItemInfectedEgg method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
if (!player.capabilities.isCreativeMode) {
itemStack.shrink(1);
}
world.playSound(null, player.getPosition(), SoundEvents.ENTITY_EGG_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
player.swingArm(hand);
if (!world.isRemote) {
EntityInfectedEgg entityegg = new EntityInfectedEgg(world, player);
entityegg.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
world.spawnEntity(entityegg);
}
player.addStat(StatList.getObjectUseStats(this));
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
use of net.minecraft.util.ActionResult in project MorePlanets by SteveKunG.
the class ItemSpaceWarperCore method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
if (!player.world.isRemote) {
if (player.isSneaking()) {
if (GCCoreUtil.getDimensionID(world) == 0 || world.provider instanceof IGalacticraftWorldProvider) {
if (!itemStack.hasTagCompound()) {
itemStack.setTagCompound(new NBTTagCompound());
itemStack.getTagCompound().setInteger("DimensionID", GCCoreUtil.getDimensionID(world));
itemStack.getTagCompound().setString("DimensionName", WorldUtil.getProviderForDimensionServer(GCCoreUtil.getDimensionID(world)).getDimensionType().getName());
itemStack.getTagCompound().setInteger("X", MathHelper.floor(player.posX));
itemStack.getTagCompound().setInteger("Y", MathHelper.floor(player.posY));
itemStack.getTagCompound().setInteger("Z", MathHelper.floor(player.posZ));
itemStack.getTagCompound().setFloat("Pitch", player.rotationPitch);
itemStack.getTagCompound().setFloat("Yaw", player.rotationYaw);
player.sendMessage(JsonUtils.create(LangUtils.translate("gui.warp_core_data_add.message")));
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
} else {
player.sendMessage(JsonUtils.create(LangUtils.translate("gui.warp_core_data_add_fail.message")));
}
} else {
player.sendMessage(JsonUtils.create(LangUtils.translate("gui.space_dimension_only.message")).setStyle(JsonUtils.red()));
}
}
}
return new ActionResult<>(EnumActionResult.PASS, itemStack);
}
use of net.minecraft.util.ActionResult in project MorePlanets by SteveKunG.
the class ItemCreativeSpaceKit method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if (player instanceof EntityPlayerMP) {
GCPlayerStats stats = GCPlayerStats.get(player);
InventoryExtended inv = stats.getExtendedInventory();
// Oxygen Mask
inv.setInventorySlotContents(0, new ItemStack(GCItems.oxMask));
// Oxygen Gear
inv.setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear));
// Creative Oxygen Tank
inv.setInventorySlotContents(2, new ItemStack(GCItems.oxygenCanisterInfinite));
// Creative Oxygen Tank
inv.setInventorySlotContents(3, new ItemStack(GCItems.oxygenCanisterInfinite));
// Parachute
inv.setInventorySlotContents(4, new ItemStack(GCItems.parachute));
// Frequency Module
inv.setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
// Thermal Armor Tier 2
inv.setInventorySlotContents(6, new ItemStack(VenusItems.thermalPaddingTier2, 1, 0));
// Thermal Armor Tier 2
inv.setInventorySlotContents(7, new ItemStack(VenusItems.thermalPaddingTier2, 1, 1));
// Thermal Armor Tier 2
inv.setInventorySlotContents(8, new ItemStack(VenusItems.thermalPaddingTier2, 1, 2));
// Thermal Armor Tier 2
inv.setInventorySlotContents(9, new ItemStack(VenusItems.thermalPaddingTier2, 1, 3));
// Shield Controller
inv.setInventorySlotContents(10, new ItemStack(VenusItems.basicItem, 1, 0));
}
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
}
use of net.minecraft.util.ActionResult in project Gaspunk by Ladysnake.
the class ItemGlassTube method onItemRightClick.
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand handIn) {
ItemStack itemstack = playerIn.getHeldItem(handIn);
RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, true);
// noinspection ConstantConditions
if (raytraceresult == null) {
return new ActionResult<>(EnumActionResult.PASS, itemstack);
} else {
if (raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos blockpos = raytraceresult.getBlockPos();
if (!worldIn.isBlockModifiable(playerIn, blockpos) || !playerIn.canPlayerEdit(blockpos.offset(raytraceresult.sideHit), raytraceresult.sideHit, itemstack)) {
return new ActionResult<>(EnumActionResult.PASS, itemstack);
}
if (worldIn.getBlockState(blockpos).getMaterial() == Material.WATER) {
worldIn.playSound(playerIn, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1.0F, 1.0F);
return new ActionResult<>(EnumActionResult.SUCCESS, this.turnBottleIntoItem(itemstack, playerIn, ((ItemGasTube) ModItems.GAS_TUBE).getItemStackFor(ModGases.AIR)));
}
}
return new ActionResult<>(EnumActionResult.PASS, itemstack);
}
}
Aggregations