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


Java EnumFacing.getFrontOffsetZ方法代码示例

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


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

示例1: ejectFailure

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public void ejectFailure(World world, BlockPos pos, ItemStack failure, EnumFacing direction)
{
    float xEject = direction.getFrontOffsetX();
    float zEject = direction.getFrontOffsetZ();

    float xOff = world.rand.nextFloat() * 0.05F + 0.475F + xEject * 0.7F;
    float yOff = 0.5F;
    float zOff = world.rand.nextFloat() * 0.05F + 0.475F + zEject * 0.7F;

    if(world.isRemote)
    {
        for (int i = 0; i < 12; i ++) {
            float ejectSpeed = world.rand.nextFloat() * 0.1f + 0.1f;
            ParticleUtil.spawnParticleSmoke(world, pos.getX() + xOff, pos.getY() + yOff, pos.getZ() + zOff, xEject * ejectSpeed, 0, zEject * ejectSpeed, 64, 64, 64, 0.125f, 5.0f + 3.0f * world.rand.nextFloat(), 80);
        }
    }

    EntityItem item = new EntityItem(world, pos.getX() + xOff, pos.getY() + yOff - 0.4f, pos.getZ() + zOff, failure);
    item.motionX = xEject * 0.1f;
    item.motionY = 0.0D;
    item.motionZ = zEject * 0.1f;
    item.setDefaultPickupDelay();
    world.spawnEntity(item);
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:25,代码来源:UpgradeAlchemyGlobe.java

示例2: doDispense

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public static void doDispense(World worldIn, ItemStack stack, int speed, EnumFacing facing, IPosition position)
{
    double d0 = position.getX();
    double d1 = position.getY();
    double d2 = position.getZ();

    if (facing.getAxis() == EnumFacing.Axis.Y)
    {
        d1 = d1 - 0.125D;
    }
    else
    {
        d1 = d1 - 0.15625D;
    }

    EntityItem entityitem = new EntityItem(worldIn, d0, d1, d2, stack);
    double d3 = worldIn.rand.nextDouble() * 0.1D + 0.2D;
    entityitem.motionX = (double)facing.getFrontOffsetX() * d3;
    entityitem.motionY = 0.20000000298023224D;
    entityitem.motionZ = (double)facing.getFrontOffsetZ() * d3;
    entityitem.motionX += worldIn.rand.nextGaussian() * 0.007499999832361937D * (double)speed;
    entityitem.motionY += worldIn.rand.nextGaussian() * 0.007499999832361937D * (double)speed;
    entityitem.motionZ += worldIn.rand.nextGaussian() * 0.007499999832361937D * (double)speed;
    worldIn.spawnEntityInWorld(entityitem);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:BehaviorDefaultDispenseItem.java

示例3: setShootingDirection

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public void setShootingDirection(EnumFacing facing) {
	
	if (facing == null) return;
	
	double x = facing.getFrontOffsetX();
	double y = facing.getFrontOffsetY();
	double z = facing.getFrontOffsetZ();
	this.setThrowableHeading(x, y, z, 0.5F, 0);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:10,代码来源:EntityLivingBlock.java

示例4: offset

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
/**
 * Offset this BlockPos 1 block in the given direction
 */
public BlockPos offset(EnumFacing facing)
{
    if (this.level <= 0)
    {
        return super.offset(facing, 1).toImmutable();
    }
    else
    {
        if (this.facings == null)
        {
            this.facings = new BlockPosM[EnumFacing.VALUES.length];
        }

        if (this.needsUpdate)
        {
            this.update();
        }

        int i = facing.getIndex();
        BlockPosM blockposm = this.facings[i];

        if (blockposm == null)
        {
            int j = this.mx + facing.getFrontOffsetX();
            int k = this.my + facing.getFrontOffsetY();
            int l = this.mz + facing.getFrontOffsetZ();
            blockposm = new BlockPosM(j, k, l, this.level - 1);
            this.facings[i] = blockposm;
        }

        return blockposm;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:37,代码来源:BlockPosM.java

示例5: getDispensePosition

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
/**
 * Get the position where the dispenser at the given Coordinates should dispense to.
 */
public static IPosition getDispensePosition(IBlockSource coords)
{
    EnumFacing enumfacing = getFacing(coords.getBlockMetadata());
    double d0 = coords.getX() + 0.7D * (double)enumfacing.getFrontOffsetX();
    double d1 = coords.getY() + 0.7D * (double)enumfacing.getFrontOffsetY();
    double d2 = coords.getZ() + 0.7D * (double)enumfacing.getFrontOffsetZ();
    return new PositionImpl(d0, d1, d2);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:12,代码来源:BlockDispenser.java

示例6: updateBoundingBox

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
/**
 * Updates the entity bounding box based on current facing
 */
protected void updateBoundingBox()
{
    if (this.facingDirection != null)
    {
        double d0 = (double)this.hangingPosition.getX() + 0.5D;
        double d1 = (double)this.hangingPosition.getY() + 0.5D;
        double d2 = (double)this.hangingPosition.getZ() + 0.5D;
        double d3 = 0.46875D;
        double d4 = this.offs(this.getWidthPixels());
        double d5 = this.offs(this.getHeightPixels());
        d0 = d0 - (double)this.facingDirection.getFrontOffsetX() * 0.46875D;
        d2 = d2 - (double)this.facingDirection.getFrontOffsetZ() * 0.46875D;
        d1 = d1 + d5;
        EnumFacing enumfacing = this.facingDirection.rotateYCCW();
        d0 = d0 + d4 * (double)enumfacing.getFrontOffsetX();
        d2 = d2 + d4 * (double)enumfacing.getFrontOffsetZ();
        this.posX = d0;
        this.posY = d1;
        this.posZ = d2;
        double d6 = (double)this.getWidthPixels();
        double d7 = (double)this.getHeightPixels();
        double d8 = (double)this.getWidthPixels();

        if (this.facingDirection.getAxis() == EnumFacing.Axis.Z)
        {
            d8 = 1.0D;
        }
        else
        {
            d6 = 1.0D;
        }

        d6 = d6 / 32.0D;
        d7 = d7 / 32.0D;
        d8 = d8 / 32.0D;
        this.setEntityBoundingBox(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8));
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:42,代码来源:EntityHanging.java

示例7: offset

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
/**
 * Offset this BlockPos 1 block in the given direction
 */
public BlockPos offset(EnumFacing facing)
{
    if (this.level <= 0)
    {
        return super.offset(facing, 1);
    }
    else
    {
        if (this.facings == null)
        {
            this.facings = new BlockPosM[EnumFacing.VALUES.length];
        }

        if (this.needsUpdate)
        {
            this.update();
        }

        int i = facing.getIndex();
        BlockPosM blockposm = this.facings[i];

        if (blockposm == null)
        {
            int j = this.mx + facing.getFrontOffsetX();
            int k = this.my + facing.getFrontOffsetY();
            int l = this.mz + facing.getFrontOffsetZ();
            blockposm = new BlockPosM(j, k, l, this.level - 1);
            this.facings[i] = blockposm;
        }

        return blockposm;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:37,代码来源:BlockPosM.java

示例8: setBlockBoundsBasedOnState

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
    TileEntityPiston tileentitypiston = this.getTileEntity(worldIn, pos);

    if (tileentitypiston != null)
    {
        IBlockState iblockstate = tileentitypiston.getPistonState();
        Block block = iblockstate.getBlock();

        if (block == this || block.getMaterial() == Material.air)
        {
            return;
        }

        float f = tileentitypiston.getProgress(0.0F);

        if (tileentitypiston.isExtending())
        {
            f = 1.0F - f;
        }

        block.setBlockBoundsBasedOnState(worldIn, pos);

        if (block == Blocks.piston || block == Blocks.sticky_piston)
        {
            f = 0.0F;
        }

        EnumFacing enumfacing = tileentitypiston.getFacing();
        this.minX = block.getBlockBoundsMinX() - (double)((float)enumfacing.getFrontOffsetX() * f);
        this.minY = block.getBlockBoundsMinY() - (double)((float)enumfacing.getFrontOffsetY() * f);
        this.minZ = block.getBlockBoundsMinZ() - (double)((float)enumfacing.getFrontOffsetZ() * f);
        this.maxX = block.getBlockBoundsMaxX() - (double)((float)enumfacing.getFrontOffsetX() * f);
        this.maxY = block.getBlockBoundsMaxY() - (double)((float)enumfacing.getFrontOffsetY() * f);
        this.maxZ = block.getBlockBoundsMaxZ() - (double)((float)enumfacing.getFrontOffsetZ() * f);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:38,代码来源:BlockPistonMoving.java

示例9: getSafeExitLocation

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
/**
 * Returns a safe BlockPos to disembark the bed
 */
public static BlockPos getSafeExitLocation(World worldIn, BlockPos pos, int tries)
{
    EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
    int i = pos.getX();
    int j = pos.getY();
    int k = pos.getZ();

    for (int l = 0; l <= 1; ++l)
    {
        int i1 = i - enumfacing.getFrontOffsetX() * l - 1;
        int j1 = k - enumfacing.getFrontOffsetZ() * l - 1;
        int k1 = i1 + 2;
        int l1 = j1 + 2;

        for (int i2 = i1; i2 <= k1; ++i2)
        {
            for (int j2 = j1; j2 <= l1; ++j2)
            {
                BlockPos blockpos = new BlockPos(i2, j, j2);

                if (hasRoomForPlayer(worldIn, blockpos))
                {
                    if (tries <= 0)
                    {
                        return blockpos;
                    }

                    --tries;
                }
            }
        }
    }

    return null;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:39,代码来源:BlockBed.java

示例10: getBoundingBox

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public AxisAlignedBB getBoundingBox(World worldIn, BlockPos pos, IBlockState extendingBlock, float progress, EnumFacing direction)
{
    if (extendingBlock.getBlock() != this && extendingBlock.getBlock().getMaterial() != Material.air)
    {
        AxisAlignedBB axisalignedbb = extendingBlock.getBlock().getCollisionBoundingBox(worldIn, pos, extendingBlock);

        if (axisalignedbb == null)
        {
            return null;
        }
        else
        {
            double d0 = axisalignedbb.minX;
            double d1 = axisalignedbb.minY;
            double d2 = axisalignedbb.minZ;
            double d3 = axisalignedbb.maxX;
            double d4 = axisalignedbb.maxY;
            double d5 = axisalignedbb.maxZ;

            if (direction.getFrontOffsetX() < 0)
            {
                d0 -= (double)((float)direction.getFrontOffsetX() * progress);
            }
            else
            {
                d3 -= (double)((float)direction.getFrontOffsetX() * progress);
            }

            if (direction.getFrontOffsetY() < 0)
            {
                d1 -= (double)((float)direction.getFrontOffsetY() * progress);
            }
            else
            {
                d4 -= (double)((float)direction.getFrontOffsetY() * progress);
            }

            if (direction.getFrontOffsetZ() < 0)
            {
                d2 -= (double)((float)direction.getFrontOffsetZ() * progress);
            }
            else
            {
                d5 -= (double)((float)direction.getFrontOffsetZ() * progress);
            }

            return new AxisAlignedBB(d0, d1, d2, d3, d4, d5);
        }
    }
    else
    {
        return null;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:55,代码来源:BlockPistonMoving.java

示例11: placeBlock

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public boolean placeBlock(BlockPos blockpos) {
	Block block = this.block.getBlock();
	IBlockState prevstate=this.world.getBlockState(blockpos);
	if (!this.isBreakingAnvil
			&& this.world.mayPlace(block, blockpos, true, EnumFacing.UP, (Entity) null)
			&& (!BlockFalling.canFallThrough(this.world.getBlockState(blockpos.offset(EnumFacing.DOWN)))
					|| (this.sticky == 1 && this.canBuildAt(blockpos)) || this.nogravity)
			&& this.world.setBlockState(blockpos, this.block, 3)) {
		if (this.isFired)
			for (int a = 0; a < 6; a++) {
				EnumFacing facing = EnumFacing.VALUES[a];
				BlockPos firepos = new BlockPos(blockpos.getX() + facing.getFrontOffsetX(),
						blockpos.getY() + facing.getFrontOffsetY(), blockpos.getZ() + facing.getFrontOffsetZ());
				if (this.world.getBlockState(firepos).getBlock().isReplaceable(world, firepos))
					this.world.setBlockState(firepos, this.fireBlock.getDefaultState());
			}
		if (block instanceof BlockFalling)
			((BlockFalling) block).onEndFalling(this.world, blockpos, this.block, prevstate);

		if (this.dataTag != null && block instanceof ITileEntityProvider) {
			TileEntity tileentity = this.world.getTileEntity(blockpos);

			if (tileentity != null) {
				NBTTagCompound nbttagcompound = new NBTTagCompound();
				tileentity.writeToNBT(nbttagcompound);
				Iterator iterator = this.dataTag.getKeySet().iterator();

				while (iterator.hasNext()) {
					String s = (String) iterator.next();
					NBTBase nbtbase = this.dataTag.getTag(s);

					if (!s.equals("x") && !s.equals("y") && !s.equals("z"))
						nbttagcompound.setTag(s, nbtbase.copy());
				}

				tileentity.readFromNBT(nbttagcompound);
				tileentity.markDirty();
			}
		}
		return true;
	}
	return false;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:44,代码来源:EntityFallingEnchantedBlock.java

示例12: updateTrackedItems

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
private void updateTrackedItems() {
    if (trackedItemIds != null) {
        trackedItems.clear();
        for (Entity entity : getWorld().loadedEntityList) {
            if (trackedItemIds.contains(entity.getUniqueID()) && entity instanceof EntityItem) {
                trackedItems.add((EntityItem) entity);
            }
        }
        trackedItemIds = null;
    }
    Iterator<EntityItem> iterator = trackedItems.iterator();
    while (iterator.hasNext()) {
        EntityItem item = iterator.next();
        if (item.world != getWorld() || item.isDead) {
            iterator.remove();
        } else {
            Map<BlockPos, EnumFacing> positions = new HashMap<>();
            double range = 0.2;
            for (EnumFacing d : EnumFacing.VALUES) {
                double posX = item.posX + d.getFrontOffsetX() * range;
                double posY = item.posY + d.getFrontOffsetY() * range;
                double posZ = item.posZ + d.getFrontOffsetZ() * range;
                positions   .put(new BlockPos((int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ)), d.getOpposite());
            }
            for (Entry<BlockPos, EnumFacing> entry : positions.entrySet()) {
                BlockPos pos = entry.getKey();
                TileEntity te = getWorld().getTileEntity(pos);
                if (te == null) continue;
                IItemHandler inv = IOHelper.getInventoryForTE(te, entry.getValue());
                ItemStack remainder = ItemHandlerHelper.insertItem(inv, item.getItem(), false);
                if (!remainder.isEmpty()) {
                    item.setItem(remainder);
                } else {
                    item.setDead();
                    iterator.remove();
                    lastInsertingInventory = te.getPos();
                    lastInsertingInventorySide = entry.getValue();
                    break;
                }
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:44,代码来源:TileEntityAirCannon.java

示例13: dispenseStack

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
    World world = source.getWorld();
    double d0 = source.getX() + (double)enumfacing.getFrontOffsetX() * 1.125D;
    double d1 = Math.floor(source.getY()) + (double)enumfacing.getFrontOffsetY();
    double d2 = source.getZ() + (double)enumfacing.getFrontOffsetZ() * 1.125D;
    BlockPos blockpos = source.getBlockPos().offset(enumfacing);
    IBlockState iblockstate = world.getBlockState(blockpos);
    BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
    double d3;

    if (BlockRailBase.isRailBlock(iblockstate))
    {
        if (blockrailbase$enumraildirection.isAscending())
        {
            d3 = 0.6D;
        }
        else
        {
            d3 = 0.1D;
        }
    }
    else
    {
        if (iblockstate.getBlock().getMaterial() != Material.air || !BlockRailBase.isRailBlock(world.getBlockState(blockpos.down())))
        {
            return this.behaviourDefaultDispenseItem.dispense(source, stack);
        }

        IBlockState iblockstate1 = world.getBlockState(blockpos.down());
        BlockRailBase.EnumRailDirection blockrailbase$enumraildirection1 = iblockstate1.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate1.getValue(((BlockRailBase)iblockstate1.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;

        if (enumfacing != EnumFacing.DOWN && blockrailbase$enumraildirection1.isAscending())
        {
            d3 = -0.4D;
        }
        else
        {
            d3 = -0.9D;
        }
    }

    EntityMinecart entityminecart = EntityMinecart.func_180458_a(world, d0, d1 + d3, d2, ((ItemMinecart)stack.getItem()).minecartType);

    if (stack.hasDisplayName())
    {
        entityminecart.setCustomNameTag(stack.getDisplayName());
    }

    world.spawnEntityInWorld(entityminecart);
    stack.splitStack(1);
    return stack;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:55,代码来源:ItemMinecart.java

示例14: getWorldEventDataFrom

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
private int getWorldEventDataFrom(EnumFacing facingIn)
{
    return facingIn.getFrontOffsetX() + 1 + (facingIn.getFrontOffsetZ() + 1) * 3;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:5,代码来源:BehaviorDefaultDispenseItem.java

示例15: trySleep

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public EntityPlayer.SleepResult trySleep(BlockPos bedLocation)
{
    EnumFacing enumfacing = (EnumFacing)this.world.getBlockState(bedLocation).getValue(BlockHorizontal.FACING);

    if (!this.world.isRemote)
    {
        if (this.isPlayerSleeping() || !this.isEntityAlive())
        {
            return EntityPlayer.SleepResult.OTHER_PROBLEM;
        }

        if (!this.world.provider.isSurfaceWorld())
        {
            return EntityPlayer.SleepResult.NOT_POSSIBLE_HERE;
        }

        if (this.world.isDaytime())
        {
            return EntityPlayer.SleepResult.NOT_POSSIBLE_NOW;
        }

        if (!this.func_190774_a(bedLocation, enumfacing))
        {
            return EntityPlayer.SleepResult.TOO_FAR_AWAY;
        }

        double d0 = 8.0D;
        double d1 = 5.0D;
        List<EntityMob> list = this.world.<EntityMob>getEntitiesWithinAABB(EntityMob.class, new AxisAlignedBB((double)bedLocation.getX() - 8.0D, (double)bedLocation.getY() - 5.0D, (double)bedLocation.getZ() - 8.0D, (double)bedLocation.getX() + 8.0D, (double)bedLocation.getY() + 5.0D, (double)bedLocation.getZ() + 8.0D));

        if (!list.isEmpty())
        {
            return EntityPlayer.SleepResult.NOT_SAFE;
        }
    }

    if (this.isRiding())
    {
        this.dismountRidingEntity();
    }

    this.setSize(0.2F, 0.2F);

    if (this.world.isBlockLoaded(bedLocation))
    {
        float f1 = 0.5F + (float)enumfacing.getFrontOffsetX() * 0.4F;
        float f = 0.5F + (float)enumfacing.getFrontOffsetZ() * 0.4F;
        this.setRenderOffsetForSleep(enumfacing);
        this.setPosition((double)((float)bedLocation.getX() + f1), (double)((float)bedLocation.getY() + 0.6875F), (double)((float)bedLocation.getZ() + f));
    }
    else
    {
        this.setPosition((double)((float)bedLocation.getX() + 0.5F), (double)((float)bedLocation.getY() + 0.6875F), (double)((float)bedLocation.getZ() + 0.5F));
    }

    this.sleeping = true;
    this.sleepTimer = 0;
    this.bedLocation = bedLocation;
    this.motionX = 0.0D;
    this.motionY = 0.0D;
    this.motionZ = 0.0D;

    if (!this.world.isRemote)
    {
        this.world.updateAllPlayersSleepingFlag();
    }

    return EntityPlayer.SleepResult.OK;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:70,代码来源:EntityPlayer.java


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