Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.triphion.ancient.items;
import com.mojang.authlib.yggdrasil.response.User;
import com.triphion.ancient.Reference;
import net.minecraft.client.particle.ParticleCrit.DamageIndicatorFactory;
import net.minecraft.entity.item.EntityEnderPearl;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntitySmallFireball;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
public class ItemTheCosmician extends Item {
public ItemTheCosmician(String unlocalizedName) {
this.setUnlocalizedName(unlocalizedName);
this.setRegistryName(new ResourceLocation(Reference.MODID, unlocalizedName));
this.setMaxStackSize(1);
this.setMaxDamage(90);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
if(!worldIn.isRemote){
RayTraceResult pos = playerIn.rayTrace(120, 60);
double x = pos.getBlockPos().getX();
double y = pos.getBlockPos().getY();
double z = pos.getBlockPos().getZ();
playerIn.setPositionAndUpdate(x, y, z);
playerIn.getHeldItem(handIn).damageItem(1, playerIn);
}
else{
return new ActionResult(EnumActionResult.FAIL, playerIn.getHeldItem(handIn));
}
return new ActionResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.