use of net.minecraft.util.ActionResult in project ConvenientAdditions by Necr0.
the class ItemPlayerChannelModule 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());
NBTTagCompound t = item.getTagCompound();
if (!player.isSneaking()) {
t.setString("MATCHER_PLAYER_ID", player.getUniqueID().toString());
t.setString("MATCHER_PLAYER_NAME", player.getDisplayNameString());
player.sendMessage(new TextComponentString(Helper.localize("message." + ModConstants.Mod.MODID + ":playerSetTo", player.getDisplayNameString())));
new ActionResult<>(EnumActionResult.SUCCESS, item);
} else {
t.removeTag("MATCHER_PLAYER_ID");
t.removeTag("MATCHER_PLAYER_NAME");
player.sendMessage(new TextComponentString(Helper.localize("message." + ModConstants.Mod.MODID + ":playerReset")));
new ActionResult<>(EnumActionResult.SUCCESS, item);
}
}
return new ActionResult<>(EnumActionResult.PASS, item);
}
use of net.minecraft.util.ActionResult in project ConvenientAdditions by Necr0.
the class ItemEnderPlate method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
int dmg = itemStack.getItemDamage();
if (!world.isRemote)
if (dmg == 0) {
itemStack.setItemDamage(1);
} else
itemStack.setItemDamage(0);
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
use of net.minecraft.util.ActionResult in project ConvenientAdditions by Necr0.
the class ItemSunstone method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
int dmg = itemStack.getItemDamage();
if (!world.isRemote)
if (dmg == 0) {
itemStack.setItemDamage(1);
} else
itemStack.setItemDamage(0);
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
use of net.minecraft.util.ActionResult in project VoodooCraft by Mod-DevCafeTeam.
the class ItemChalk method onItemRightClick.
/**
* Changes glyphtype NBT, cycles through all in the {@link EnumGlyphType}
*/
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
if (playerIn.isSneaking()) {
NBTTagCompound nbt = NBTHelper.getTagCompound(itemStackIn);
EnumGlyphType newtype = EnumGlyphType.byIndex(nbt.getInteger(KEY_GLYPH)).next();
nbt.setInteger(KEY_GLYPH, newtype.ordinal());
itemStackIn.setTagCompound(nbt);
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
}
return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
}
use of net.minecraft.util.ActionResult in project NetherEx by LogicTechCorp.
the class ItemObsidianBoat method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * 1.0F;
float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * 1.0F;
double d0 = player.prevPosX + (player.posX - player.prevPosX) * 1.0D;
double d1 = player.prevPosY + (player.posY - player.prevPosY) * 1.0D + (double) player.getEyeHeight();
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * 1.0D;
Vec3d vec3d = new Vec3d(d0, d1, d2);
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
float f5 = -MathHelper.cos(-f1 * 0.017453292F);
float f6 = MathHelper.sin(-f1 * 0.017453292F);
float f7 = f4 * f5;
float f8 = f3 * f5;
Vec3d vec3d1 = vec3d.addVector((double) f7 * 5.0D, (double) f6 * 5.0D, (double) f8 * 5.0D);
RayTraceResult raytraceresult = world.rayTraceBlocks(vec3d, vec3d1, true);
if (raytraceresult == null) {
return new ActionResult(EnumActionResult.PASS, stack);
} else {
Vec3d vec3d2 = player.getLook(1.0F);
boolean flag = false;
List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(player, player.getEntityBoundingBox().addCoord(vec3d2.xCoord * 5.0D, vec3d2.yCoord * 5.0D, vec3d2.zCoord * 5.0D).expandXyz(1.0D));
for (Entity entity : entities) {
if (entity.canBeCollidedWith()) {
AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().expandXyz((double) entity.getCollisionBorderSize());
if (axisalignedbb.isVecInside(vec3d)) {
flag = true;
}
}
}
if (flag) {
return new ActionResult(EnumActionResult.PASS, stack);
} else if (raytraceresult.typeOfHit != RayTraceResult.Type.BLOCK) {
return new ActionResult(EnumActionResult.PASS, stack);
} else {
Block block = world.getBlockState(raytraceresult.getBlockPos()).getBlock();
boolean flag1 = block == Blocks.WATER || block == Blocks.FLOWING_WATER;
EntityObsidianBoat boat = new EntityObsidianBoat(world, raytraceresult.hitVec.xCoord, flag1 ? raytraceresult.hitVec.yCoord - 0.12D : raytraceresult.hitVec.yCoord, raytraceresult.hitVec.zCoord);
boat.rotationYaw = player.rotationYaw;
if (!world.getCollisionBoxes(boat, boat.getEntityBoundingBox().expandXyz(-0.1D)).isEmpty()) {
return new ActionResult(EnumActionResult.FAIL, stack);
} else {
if (!world.isRemote) {
world.spawnEntity(boat);
}
if (!player.capabilities.isCreativeMode) {
stack.shrink(1);
}
return new ActionResult(EnumActionResult.SUCCESS, stack);
}
}
}
}
Aggregations