use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.
the class ItemTPPearcel method onItemRightClick.
@Override
public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setDouble("tpX", player.posX);
stack.getTagCompound().setDouble("tpY", player.posY);
stack.getTagCompound().setDouble("tpZ", player.posZ);
stack.getTagCompound().setInteger("dim", player.dimension);
stack.getTagCompound().setFloat("yaw", player.rotationYaw);
stack.getTagCompound().setFloat("pitch", player.rotationPitch);
stack.getTagCompound().setBoolean("set", true);
}
if (player.isSneaking()) {
stack.getTagCompound().setDouble("tpX", player.posX);
stack.getTagCompound().setDouble("tpY", player.posY);
stack.getTagCompound().setDouble("tpZ", player.posZ);
stack.getTagCompound().setInteger("dim", player.dimension);
stack.getTagCompound().setFloat("yaw", player.rotationYaw);
stack.getTagCompound().setFloat("pitch", player.rotationPitch);
stack.getTagCompound().setBoolean("set", true);
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.DARK_GREEN + (Translate.toLocal("chat.tpPearcel.location.set"))));
}
} else {
tpX = stack.getTagCompound().getDouble("tpX");
tpY = stack.getTagCompound().getDouble("tpY");
tpZ = stack.getTagCompound().getDouble("tpZ");
dim = stack.getTagCompound().getInteger("dim");
yaw = stack.getTagCompound().getFloat("yaw");
pitch = stack.getTagCompound().getFloat("pitch");
if (!stack.getTagCompound().getBoolean("set")) {
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.RED + (Translate.toLocal("chat.tpPearcel.location.notSet"))));
}
} else {
if (player.dimension == dim) {
//player.setPositionAndUpdate(tpX, tpY, tpZ);
player.setLocationAndAngles(tpX, tpY, tpZ, yaw, pitch);
player.addStat(Achievements.achievement_use_tp_pearcel);
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.GOLD + (Translate.toLocal("chat.tpPearcel.tp"))));
}
if (!player.capabilities.isCreativeMode) {
if (player.inventory.hasItemStack(new ItemStack(ModItems.pearcel_item))) {
player.inventory.deleteStack(new ItemStack(ModItems.pearcel_item, 1));
} else {
stack.damageItem(1, player);
}
}
} else {
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.RED + (Translate.toLocal("chat.tpPearcel.wrongDim"))));
}
}
}
}
return new ActionResult(EnumActionResult.PASS, stack);
}
use of net.minecraft.util.ActionResult in project ConvenientAdditions by Necr0.
the class ItemLocationModule 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());
if (player.isSneaking()) {
item.getTagCompound().removeTag("MODULE_LOCATION");
player.sendMessage(new TextComponentString(Helper.localize("message." + ModConstants.Mod.MODID + ":locationReset")));
return new ActionResult<>(EnumActionResult.SUCCESS, item);
}
}
return new ActionResult<>(EnumActionResult.PASS, item);
}
use of net.minecraft.util.ActionResult in project RecurrentComplex by Ivorforce.
the class ItemBlockSelectorFloating method onItemRightClick.
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
ItemStack itemStackIn = playerIn.getHeldItem(hand);
if (worldIn.isRemote) {
BlockPos position = getHoveredBlock(playerIn, getSelectionRange(itemStackIn));
sendClickToServer(itemStackIn, worldIn, playerIn, position);
}
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
}
use of net.minecraft.util.ActionResult in project Railcraft by Railcraft.
the class ItemFilterBeeGenome method onItemRightClick.
@Optional.Method(modid = ForestryPlugin.FORESTRY_ID)
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
NBTTagCompound nbt = InvTools.getItemDataRailcraft(stack, "filter");
if (nbt != null) {
try {
EnumBeeChromosome chromosome = EnumBeeChromosome.SPECIES;
try {
chromosome = EnumBeeChromosome.valueOf(nbt.getString("chromosome"));
} catch (IllegalArgumentException ignored) {
}
chromosome = EnumTools.next(chromosome, EnumBeeChromosome.values());
nbt.setString("chromosome", chromosome.name());
} catch (Throwable throwable) {
Game.logErrorAPI(Mod.FORESTRY.modId, throwable, EnumBeeChromosome.class);
}
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack.copy());
}
use of net.minecraft.util.ActionResult in project Railcraft by Railcraft.
the class ItemFluidContainer method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
RayTraceResult mop = rayTrace(world, player, false);
//noinspection ConstantConditions
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos pos = mop.getBlockPos();
if (!world.isBlockModifiable(player, pos))
return new ActionResult<>(EnumActionResult.FAIL, stack);
pos = pos.offset(mop.sideHit);
if (!player.canPlayerEdit(pos, mop.sideHit, stack))
return new ActionResult<>(EnumActionResult.FAIL, stack);
if (tryPlaceContainedLiquid(world, pos) && !player.capabilities.isCreativeMode) {
ItemStack empty = getContainerItem(stack);
if (InvTools.isEmpty(empty)) {
empty = stack.copy();
empty.stackSize = 0;
}
return new ActionResult<>(EnumActionResult.SUCCESS, empty);
}
}
return new ActionResult<>(EnumActionResult.PASS, stack);
}
Aggregations