Skip to content

Instantly share code, notes, and snippets.

@triphion
Created September 5, 2017 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save triphion/c5bb47baa2bdf47242e0e9a2183cf2bb to your computer and use it in GitHub Desktop.
Save triphion/c5bb47baa2bdf47242e0e9a2183cf2bb to your computer and use it in GitHub Desktop.
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