当前位置: 首页>>代码示例>>Java>>正文


Java RayTraceResult类代码示例

本文整理汇总了Java中net.minecraft.util.math.RayTraceResult的典型用法代码示例。如果您正苦于以下问题:Java RayTraceResult类的具体用法?Java RayTraceResult怎么用?Java RayTraceResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RayTraceResult类属于net.minecraft.util.math包,在下文中一共展示了RayTraceResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onImpact

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
@Override
public void onImpact(RayTraceResult result)
{
	if (!this.getEntityWorld().isRemote)
	{
		Stats statsCap = (Stats) player.getCapability(CapabilityPlayerStats.STATS, null);
		
		if (result.entityHit != null && result.entityHit instanceof EntityLivingBase && statsCap != null)
		{
			NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
			double magicalPower = statsCap.getMagicalPower();
			double damage = (Math.random() * (nbt.getInteger("MaxDamage") - nbt.getInteger("MinDamage"))) + (nbt.getInteger("MinDamage") + (int) magicalPower);
			
			// apply damage
			result.entityHit.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) damage);
			result.entityHit.hurtResistantTime = 0; // set hurt resistant time to zero because other calculations might be added.
			
			// apply attributes
			EventLivingHurtAttack.useWeaponAttributes((float) damage, player, (EntityLivingBase) result.entityHit, stack, NBTHelper.loadStackNBT(stack));
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:23,代码来源:EntityProjectileBase.java

示例2: onClientTick

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
@SubscribeEvent
public static void onClientTick(ClientTickEvent event) throws Throwable {
    if (event.phase == Phase.START && (!Configs.creativeOnly || Minecraft.getMinecraft().player.isCreative())) {
        int timer = (int) getDelayTimer.invoke(Minecraft.getMinecraft());
        RayTraceResult hover = Minecraft.getMinecraft().objectMouseOver;
        if (hover != null && hover.typeOfHit == Type.BLOCK) {
            BlockPos pos = hover.getBlockPos();
            if (timer > 0 && !pos.equals(lastTargetPos) && (lastTargetPos == null || !pos.equals(lastTargetPos.offset(lastTargetSide)))) {
                setDelayTimer.invoke(Minecraft.getMinecraft(), 0);
            } else if (Configs.forceNewLoc && timer == 0 && pos.equals(lastTargetPos) && hover.sideHit == lastTargetSide) {
                setDelayTimer.invoke(Minecraft.getMinecraft(), 4);
            }
            lastTargetPos = pos.toImmutable();
            lastTargetSide = hover.sideHit;
        }
    }
}
 
开发者ID:tterrag1098,项目名称:BetterPlacement,代码行数:18,代码来源:BetterPlacement.java

示例3: onImpact

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(RayTraceResult result)
{
    if (!this.worldObj.isRemote)
    {
        this.worldObj.playEvent(2002, new BlockPos(this), 0);
        int i = 3 + this.worldObj.rand.nextInt(5) + this.worldObj.rand.nextInt(5);

        while (i > 0)
        {
            int j = EntityXPOrb.getXPSplit(i);
            i -= j;
            this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
        }

        this.setDead();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:EntityExpBottle.java

示例4: onBucketUse

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
public static ActionResult<ItemStack> onBucketUse(EntityPlayer player, World world, ItemStack stack, RayTraceResult target)
{
    FillBucketEvent event = new FillBucketEvent(player, stack, world, target);
    if (MinecraftForge.EVENT_BUS.post(event)) return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);

    if (event.getResult() == Result.ALLOW)
    {
        if (player.capabilities.isCreativeMode)
            return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);

        if (--stack.stackSize <= 0)
            return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, event.getFilledBucket());

        if (!player.inventory.addItemStackToInventory(event.getFilledBucket()))
            player.dropItem(event.getFilledBucket(), false);

        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
    }
    return null;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:ForgeEventFactory.java

示例5: onImpact

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
@Override
public void onImpact(RayTraceResult result) {

	if (fallingTile == null) {
		this.setDead();
		return;
	}
	BlockPos pos = new BlockPos(result.hitVec);
	if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
		IBlockState state = worldObj.getBlockState(pos);
		if (!(state.getBlock() instanceof BlockCrops)) {
			worldObj.setBlockState(pos.offset(result.sideHit), fallingTile, 3);
			this.setDead();
			return;
		}
	}
	else this.setDead();
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:19,代码来源:EntityLivingBlock.java

示例6: updatePoint

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
@Override
public void updatePoint(float partialTicks) {
    RayTraceResult result = entity.rayTrace(traceDistance, partialTicks);
    if (result == null) {
        return;
    }
    BlockPos pos = result.getBlockPos();
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();

    if (this.lastX != x || this.lastY != y || this.lastZ != z) {
        this.lastX = x;
        this.lastY = y;
        this.lastZ = z;
        this.point = new Vector3(x, y, z);
        this.box.setPosition(this.point.subtract(PointCube.MIN_VEC), this.point.add(PointCube.MAX_VEC));
        this.notifyObservers();
    }
}
 
开发者ID:kenzierocks,项目名称:HardVox,代码行数:21,代码来源:PointCubeTracking.java

示例7: onImpact

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
@Override
protected void onImpact(RayTraceResult result)
{
	if (result.typeOfHit == Type.ENTITY && result.entityHit != null)
	{
		result.entityHit.attackEntityFrom(this.createDamageSource(), this.getDamage());
	}
	else
	{
		if (result.typeOfHit == Type.BLOCK)
		{
			BlockPos blockpos = result.getBlockPos();
            IBlockState iblockstate = this.world.getBlockState(blockpos);
			this.inGround = true;
			this.reflectImpactTileData(result.getBlockPos());
			if (iblockstate.getMaterial() != Material.AIR)
            {
                iblockstate.getBlock().onEntityCollidedWithBlock(this.world, blockpos, iblockstate, this);
            }
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:23,代码来源:EntityThrownWeapon.java

示例8: performEffect

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
@Override
public void performEffect(RayTraceResult rtrace, EntityLivingBase caster, World world) {
	if (rtrace.typeOfHit == Type.ENTITY && rtrace.entityHit instanceof EntityLivingBase) {
		EntityLivingBase entity = (EntityLivingBase) rtrace.entityHit;
		EnumHand hand = null;
		if (!entity.getHeldItemMainhand().isEmpty()) hand = EnumHand.MAIN_HAND;
		else if (!entity.getHeldItemOffhand().isEmpty()) hand = EnumHand.OFF_HAND;
		if (hand != null) {
			ItemStack stack = entity.getHeldItem(hand).copy();
			entity.setHeldItem(hand, ItemStack.EMPTY);
			if (!(entity instanceof EntityPlayer) && stack.isItemStackDamageable() && stack.getItemDamage() == 0) {
				stack.setItemDamage((int) (stack.getMaxDamage() * (0.5D + 0.5D * Math.random())));
			}
			EntityItem ei = new EntityItem(world, entity.posX, entity.posY, entity.posZ, stack);
			ei.setPickupDelay(200);
			ei.setNoDespawn();
			if (!world.isRemote) world.spawnEntity(ei);
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:21,代码来源:SpellDisarming.java

示例9: sendClickBlockToController

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
private void sendClickBlockToController(boolean leftClick)
{
    if (!leftClick)
    {
        this.leftClickCounter = 0;
    }

    if (this.leftClickCounter <= 0 && !this.player.isHandActive())
    {
        if (leftClick && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK)
        {
            BlockPos blockpos = this.objectMouseOver.getBlockPos();

            if (this.world.getBlockState(blockpos).getMaterial() != Material.AIR && this.playerController.onPlayerDamageBlock(blockpos, this.objectMouseOver.sideHit))
            {
                this.effectRenderer.addBlockHitEffects(blockpos, this.objectMouseOver.sideHit);
                this.player.swingArm(EnumHand.MAIN_HAND);
            }
        }
        else
        {
            this.playerController.resetBlockRemoving();
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:Minecraft.java

示例10: prepare

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
public void prepare(World p_190056_1_, TextureManager p_190056_2_, FontRenderer p_190056_3_, Entity p_190056_4_, RayTraceResult p_190056_5_, float p_190056_6_)
{
    if (this.worldObj != p_190056_1_)
    {
        this.setWorld(p_190056_1_);
    }

    this.renderEngine = p_190056_2_;
    this.entity = p_190056_4_;
    this.fontRenderer = p_190056_3_;
    this.cameraHitResult = p_190056_5_;
    this.entityYaw = p_190056_4_.prevRotationYaw + (p_190056_4_.rotationYaw - p_190056_4_.prevRotationYaw) * p_190056_6_;
    this.entityPitch = p_190056_4_.prevRotationPitch + (p_190056_4_.rotationPitch - p_190056_4_.prevRotationPitch) * p_190056_6_;
    this.entityX = p_190056_4_.lastTickPosX + (p_190056_4_.posX - p_190056_4_.lastTickPosX) * (double)p_190056_6_;
    this.entityY = p_190056_4_.lastTickPosY + (p_190056_4_.posY - p_190056_4_.lastTickPosY) * (double)p_190056_6_;
    this.entityZ = p_190056_4_.lastTickPosZ + (p_190056_4_.posZ - p_190056_4_.lastTickPosZ) * (double)p_190056_6_;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:TileEntityRendererDispatcher.java

示例11: rayTraceResistance

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) {
    RayTraceResult hit = world.rayTraceBlocks(start.vec3(), end.vec3());

    if (hit == null)
        return prevresistance;

    if (hit.typeOfHit == Type.BLOCK) {
        IBlockState state = world.getBlockState(hit.getBlockPos());
        if (state.getBlock().isAir(state, world, hit.getBlockPos()))
            return prevresistance;
        
        /*if(Block.blocksList[blockID] instanceof ISpecialResistance) 
        {
            ISpecialResistance isr = (ISpecialResistance) Block.blocksList[blockID];
             return prevresistance + (isr.getSpecialExplosionResistance(world, hit.blockX, hit.blockY, hit.blockZ,
                     start.x, start.y, start.z, wrapper) + 0.3F);
        } 
        else 
        {*/
        return prevresistance + state.getBlock().getExplosionResistance(wrapper) + 0.3F;
        //}
    }
    return prevresistance;
}
 
开发者ID:TheCBProject,项目名称:WirelessRedstone,代码行数:25,代码来源:WirelessBolt.java

示例12: onImpact

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
protected void onImpact(RayTraceResult result) {
	if (!this.world.isRemote && this.world instanceof WorldServer) {
		if (result.typeOfHit == RayTraceResult.Type.ENTITY && result.entityHit != null
				&& !result.entityHit.equals(this.caster)) {
			Entity entity = result.entityHit;
			if (!entity.isImmuneToFire()) {
				entity.setFire(7);
			}
		} else if (result.typeOfHit == RayTraceResult.Type.BLOCK && result.getBlockPos() != null
				&& result.sideHit != null) {
			BlockPos offsetPos = result.getBlockPos().offset(result.sideHit);
			if (this.world.getBlockState(offsetPos).getMaterial() != Material.WATER
					&& (this.world.isAirBlock(offsetPos)
							|| this.world.getBlockState(offsetPos).getBlock().isReplaceable(this.world, offsetPos))
					&& Blocks.FIRE.canPlaceBlockAt(this.world, offsetPos)) {
				this.world.setBlockState(offsetPos, Blocks.FIRE.getDefaultState(), 11);
			}
		}
	}
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:21,代码来源:EntityFireBreath.java

示例13: sendClickBlockToController

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
private void sendClickBlockToController(boolean leftClick)
{
    if (!leftClick)
    {
        this.leftClickCounter = 0;
    }

    if (this.leftClickCounter <= 0 && !this.thePlayer.isHandActive())
    {
        if (leftClick && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK)
        {
            BlockPos blockpos = this.objectMouseOver.getBlockPos();

            if (!this.theWorld.isAirBlock(blockpos) && this.playerController.onPlayerDamageBlock(blockpos, this.objectMouseOver.sideHit))
            {
                this.effectRenderer.addBlockHitEffects(blockpos, this.objectMouseOver);
                this.thePlayer.swingArm(EnumHand.MAIN_HAND);
            }
        }
        else
        {
            this.playerController.resetBlockRemoving();
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:Minecraft.java

示例14: onItemRightClick

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
	ItemStack stack = player.getHeldItem(hand); //Not entirely convinced it works
	RayTraceResult result = world.isRemote ? RayTraceHelper.tracePlayerHighlight((EntityPlayerSP) player) : RayTraceHelper.tracePlayerHighlight((EntityPlayerMP) player);
	if(result.typeOfHit != RayTraceResult.Type.BLOCK) {
		if(!world.isRemote) {
			Vector3 vec = Vector3.create(player.posX, player.posY + player.getEyeHeight(), player.posZ);
			vec.add(Vector3.create(player.getLookVec()).multiply(2.5D));
			BlockPos pos = new BlockPos(vec.toVec3d());
			IBlockState replaced = world.getBlockState(pos);
			if(world.isAirBlock(pos) || replaced.getBlock().isReplaceable(world, pos)) {
				IBlockState state = ModBlocks.ANGSTROM.getDefaultState();
				SoundType type = ModBlocks.ANGSTROM.getSoundType(state, world, pos, player);
				world.setBlockState(pos, state);
				world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), type.getPlaceSound(), SoundCategory.BLOCKS, 0.75F, 0.8F);
			}
			if(!player.capabilities.isCreativeMode) {
				stack.shrink(1);
			}
		}
		return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
	}
	return ActionResult.newResult(EnumActionResult.PASS, stack);
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:25,代码来源:ItemAngstrom.java

示例15: updateTask

import net.minecraft.util.math.RayTraceResult; //导入依赖的package包/类
/**
 * Updates the task
 */
@Override
public void updateTask() {
	Random random = enderman.getRNG();
	World world = EasyMappings.world(enderman);
	int i = MathUtils.floor(enderman.posX - 2.0D + random.nextDouble() * 4.0D);
	int j = MathUtils.floor(enderman.posY + random.nextDouble() * 3.0D);
	int k = MathUtils.floor(enderman.posZ - 2.0D + random.nextDouble() * 4.0D);
	BlockPos blockpos = new BlockPos(i, j, k);
	IBlockState iblockstate = world.getBlockState(blockpos);
	Block block = iblockstate.getBlock();
	RayTraceResult raytraceresult = world.rayTraceBlocks(new Vec3d(MathUtils.floor(enderman.posX) + 0.5F, j + 0.5F, MathUtils.floor(enderman.posZ) + 0.5F), new Vec3d(i + 0.5F, j + 0.5F, k + 0.5F), false, true, false);
	boolean flag = raytraceresult != null && raytraceresult.getBlockPos().equals(blockpos);

	if (EntityEvolvedEnderman.getCarriable(block) && flag) {
		enderman.setHeldBlockState(iblockstate);
		world.setBlockToAir(blockpos);
	}
}
 
开发者ID:p455w0rd,项目名称:EndermanEvolution,代码行数:22,代码来源:EntityEvolvedEnderman.java


注:本文中的net.minecraft.util.math.RayTraceResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。