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


Java BlockPos.equals方法代码示例

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


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

示例1: getNextCables

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public BlockPos[] getNextCables(IBlockAccess world, BlockPos pos, BlockPos fromBlock) {
	IBlockState thisBlock = world.getBlockState(pos);
	
	ArrayList<BlockPos> viableCables = new ArrayList<BlockPos>();
	for (EnumFacing dir : this.getSurroundingPositions()) {
		BlockPos adj = pos.offset(dir);
		
		if (fromBlock != null && adj.equals(fromBlock))
			continue;
		
		if (!this.cableType.canConnectTo(world, pos, thisBlock, dir, adj))
			continue;

		viableCables.add(adj);
	}
	
	return viableCables.toArray(new BlockPos[viableCables.size()]);
}
 
开发者ID:astronautlabs,项目名称:rezolve,代码行数:19,代码来源:CableNetwork.java

示例2: onBlockActivated

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (this.blockMaterial == Material.IRON)
    {
        return false; //Allow items to interact with the door
    }
    else
    {
        BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
        IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos);

        if (iblockstate.getBlock() != this)
        {
            return false;
        }
        else
        {
            state = iblockstate.cycleProperty(OPEN);
            worldIn.setBlockState(blockpos, state, 10);
            worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
            worldIn.playEvent(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? this.getOpenSound() : this.getCloseSound(), pos, 0);
            return true;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:BlockDoor.java

示例3: onBlockActivated

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (this.blockMaterial == Material.IRON)
    {
        return false;
    }
    else
    {
        BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
        IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos);

        if (iblockstate.getBlock() != this)
        {
            return false;
        }
        else
        {
            state = iblockstate.cycleProperty(OPEN);
            worldIn.setBlockState(blockpos, state, 10);
            worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
            worldIn.playEvent(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? this.getOpenSound() : this.getCloseSound(), pos, 0);
            return true;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:BlockDoor.java

示例4: setPortal

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
 * Marks the entity as being inside a portal, activating teleportation logic in onEntityUpdate() in the following
 * tick(s).
 */
public void setPortal(BlockPos pos)
{
    if (this.timeUntilPortal > 0)
    {
        this.timeUntilPortal = this.getPortalCooldown();
    }
    else
    {
        if (!this.worldObj.isRemote && !pos.equals(this.lastPortalPos))
        {
            this.lastPortalPos = new BlockPos(pos);
            BlockPattern.PatternHelper blockpattern$patternhelper = Blocks.PORTAL.createPatternHelper(this.worldObj, this.lastPortalPos);
            double d0 = blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? (double)blockpattern$patternhelper.getFrontTopLeft().getZ() : (double)blockpattern$patternhelper.getFrontTopLeft().getX();
            double d1 = blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? this.posZ : this.posX;
            d1 = Math.abs(MathHelper.pct(d1 - (double)(blockpattern$patternhelper.getForwards().rotateY().getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE ? 1 : 0), d0, d0 - (double)blockpattern$patternhelper.getWidth()));
            double d2 = MathHelper.pct(this.posY - 1.0D, (double)blockpattern$patternhelper.getFrontTopLeft().getY(), (double)(blockpattern$patternhelper.getFrontTopLeft().getY() - blockpattern$patternhelper.getHeight()));
            this.lastPortalVec = new Vec3d(d1, d2, 0.0D);
            this.teleportDirection = blockpattern$patternhelper.getForwards();
        }

        this.inPortal = true;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:28,代码来源:Entity.java

示例5: isHittingPosition

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private boolean isHittingPosition(BlockPos pos)
{
    ItemStack itemstack = this.mc.player.getHeldItemMainhand();
    boolean flag = this.currentItemHittingBlock.func_190926_b() && itemstack.func_190926_b();

    if (!this.currentItemHittingBlock.func_190926_b() && !itemstack.func_190926_b())
    {
        flag = itemstack.getItem() == this.currentItemHittingBlock.getItem() && ItemStack.areItemStackTagsEqual(itemstack, this.currentItemHittingBlock) && (itemstack.isItemStackDamageable() || itemstack.getMetadata() == this.currentItemHittingBlock.getMetadata());
    }

    return pos.equals(this.currentBlock) && flag;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:PlayerControllerMP.java

示例6: getPathToEntityLiving

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Nullable

    /**
     * Returns the path to the given EntityLiving. Args : entity
     */
    public Path getPathToEntityLiving(Entity entityIn)
    {
        if (!this.canNavigate())
        {
            return null;
        }
        else
        {
            BlockPos blockpos = new BlockPos(entityIn);

            if (this.currentPath != null && !this.currentPath.isFinished() && blockpos.equals(this.targetPos))
            {
                return this.currentPath;
            }
            else
            {
                this.targetPos = blockpos;
                float f = this.getPathSearchRange();
                this.worldObj.theProfiler.startSection("pathfind");
                BlockPos blockpos1 = (new BlockPos(this.theEntity)).up();
                int i = (int)(f + 16.0F);
                ChunkCache chunkcache = new ChunkCache(this.worldObj, blockpos1.add(-i, -i, -i), blockpos1.add(i, i, i), 0);
                Path path = this.pathFinder.findPath(chunkcache, this.theEntity, entityIn, f);
                this.worldObj.theProfiler.endSection();
                return path;
            }
        }
    }
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:34,代码来源:PathNavigate.java

示例7: detectAndSendChanges

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();
    for (int i = 0; i < lastValues.length; i++) {
        BlockPos newValue = GlobalVariableManager.getInstance().getPos(syncedVars.get(i));
        if (!newValue.equals(lastValues[i])) {
            lastValues[i] = newValue;
            for (Object o : listeners) {
                if (o instanceof EntityPlayerMP)
                    NetworkHandler.sendTo(new PacketSetGlobalVariable(syncedVars.get(i), newValue), (EntityPlayerMP) o);
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:15,代码来源:ContainerRemote.java

示例8: updateVariables

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private boolean updateVariables() {
    boolean varChanged = false;
    for (Map.Entry<String, BlockPos> entry : areaVariableStates.entrySet()) {
        BlockPos newValue = aiManager.getCoordinate(entry.getKey());
        if (!newValue.equals(entry.getValue())) {
            varChanged = true;
            entry.setValue(newValue);
        }
    }
    return varChanged;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:12,代码来源:ProgWidgetAreaItemBase.java

示例9: shouldOpen

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private boolean shouldOpen() {
    switch (redstoneMode) {
        case 0:
        case 1:
            int range = TileEntityConstants.RANGE_PNEUMATIC_DOOR_BASE + this.getUpgrades(EnumUpgrade.RANGE);
            AxisAlignedBB aabb = new AxisAlignedBB(getPos().getX() - range, getPos().getY() - range, getPos().getZ() - range, getPos().getX() + range + 1, getPos().getY() + range + 1, getPos().getZ() + range + 1);
            List<EntityPlayer> players = getWorld().getEntitiesWithinAABB(EntityPlayer.class, aabb);
            for (EntityPlayer player : players) {
                if (PneumaticCraftUtils.getProtectingSecurityStations(getWorld(), getPos(), player, false, false) == 0) {
                    if (redstoneMode == 0) {
                        return true;
                    } else {
                        ((BlockPneumaticDoor) Blockss.PNEUMATIC_DOOR).isTrackingPlayerEye = true;
                        BlockPos lookedPosition = PneumaticCraftUtils.getEntityLookedBlock(player, range * 1.41F); //max range = range * sqrt(2).
                        ((BlockPneumaticDoor) Blockss.PNEUMATIC_DOOR).isTrackingPlayerEye = false;
                        if (lookedPosition != null) {
                            if (lookedPosition.equals(new BlockPos(getPos().getX(), getPos().getY(), getPos().getZ()))) {
                                return true;
                            } else {
                                if (door != null) {
                                    if (lookedPosition.equals(new BlockPos(door.getPos().getX(), door.getPos().getY(), door.getPos().getZ())))
                                        return true;
                                    if (lookedPosition.equals(new BlockPos(door.getPos().getX(), door.getPos().getY() + (door.isTopDoor() ? -1 : 1), door.getPos().getZ())))
                                        return true;
                                }
                            }
                        }
                    }
                }
            }
            return false;
        case 2:
            return opening;
    }
    return false;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:37,代码来源:TileEntityPneumaticDoorBase.java

示例10: getPathToEntityLiving

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
 * Returns the path to the given EntityLiving. Args : entity
 */
@Nullable
public Path getPathToEntityLiving(Entity entityIn)
{
    if (!this.canNavigate())
    {
        return null;
    }
    else
    {
        BlockPos blockpos = new BlockPos(entityIn);

        if (this.currentPath != null && !this.currentPath.isFinished() && blockpos.equals(this.targetPos))
        {
            return this.currentPath;
        }
        else
        {
            this.targetPos = blockpos;
            float f = this.getPathSearchRange();
            this.worldObj.theProfiler.startSection("pathfind");
            BlockPos blockpos1 = (new BlockPos(this.theEntity)).up();
            int i = (int)(f + 16.0F);
            ChunkCache chunkcache = new ChunkCache(this.worldObj, blockpos1.add(-i, -i, -i), blockpos1.add(i, i, i), 0);
            Path path = this.pathFinder.findPath(chunkcache, this.theEntity, entityIn, f);
            this.worldObj.theProfiler.endSection();
            return path;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:33,代码来源:PathNavigate.java

示例11: getPathToPos

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Nullable

    /**
     * Returns path to given BlockPos
     */
    public Path getPathToPos(BlockPos pos)
    {
        if (!this.canNavigate())
        {
            return null;
        }
        else if (this.currentPath != null && !this.currentPath.isFinished() && pos.equals(this.targetPos))
        {
            return this.currentPath;
        }
        else
        {
            this.targetPos = pos;
            float f = this.getPathSearchRange();
            this.worldObj.theProfiler.startSection("pathfind");
            BlockPos blockpos = new BlockPos(this.theEntity);
            int i = (int)(f + 8.0F);
            ChunkCache chunkcache = new ChunkCache(this.worldObj, blockpos.add(-i, -i, -i), blockpos.add(i, i, i), 0);
            Path path = this.pathFinder.findPath(chunkcache, this.theEntity, this.targetPos, f);
            this.worldObj.theProfiler.endSection();
            return path;
        }
    }
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:29,代码来源:PathNavigate.java

示例12: positionInList

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private boolean positionInList(BlockPos pos)
{
    for (BlockPos blockpos : this.villagerPositionsList)
    {
        if (blockpos.equals(pos))
        {
            return true;
        }
    }

    return false;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:VillageCollection.java

示例13: isHittingPosition

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private boolean isHittingPosition(BlockPos pos)
{
    ItemStack itemstack = this.mc.thePlayer.getHeldItemMainhand();
    boolean flag = this.currentItemHittingBlock == null && itemstack == null;

    if (this.currentItemHittingBlock != null && itemstack != null)
    {
        flag = !net.minecraftforge.client.ForgeHooksClient.shouldCauseBlockBreakReset(this.currentItemHittingBlock, itemstack);
    }

    return pos.equals(this.currentBlock) && flag;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:13,代码来源:PlayerControllerMP.java

示例14: onBlockBreak

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent event) {
    World world = event.getWorld();
    IBlockState state = world.getBlockState(event.getPos());
    BlockPos pos = event.getPos();
    if (!state.getBlock().isWood(world, pos)) {
        return;
    }
    int radius = 16;
    int dirX = Math.max(-1, Math.min(1, pos.getX() - (int)Math.round(event.getPlayer().posX - 0.5)));
    int dirZ = Math.max(-1, Math.min(1, pos.getZ() - (int)Math.round(event.getPlayer().posZ - 0.5)));
    LinkedList<BlockPos> queue = new LinkedList<BlockPos>();
    HashMap<BlockPos, Integer> used = new HashMap<BlockPos, Integer>();
    queue.add(pos);
    int leaf = 5;
    used.put(pos, leaf);
    while (!queue.isEmpty()) {
        BlockPos top = queue.pollFirst();
        for (int dx = -1; dx <= 1; ++dx) {
            for (int dy = -1; dy <= 1; ++dy) {
                for (int dz = -1; dz <= 1; ++dz) {
                    BlockPos nPos = top.add(dx, dy, dz);
                    int step = used.get(top);
                    if (step <= 0 || nPos.distanceSq(pos) > radius * radius) {
                        continue;
                    }
                    IBlockState nState = world.getBlockState(nPos);
                    boolean log = nState.getBlock().isWood(world, nPos);
                    boolean leaves = nState.getBlock().isLeaves(nState, world, nPos);
                    if ((dy >= 0 && step == leaf && log) || leaves) {
                        step = step - (leaves ? 1 : 0);
                        if (!used.containsKey(nPos) || used.get(nPos) < step) {
                            used.put(nPos, step);
                            queue.push(nPos);
                        }
                    }
                }
            }
        }
    }
    for (Map.Entry<BlockPos, Integer> entry : used.entrySet()) {
        BlockPos blockPos = entry.getKey();
        if (!pos.equals(blockPos) && isDraggable(world, blockPos.add(0, -1, 0))) {
            int oy = blockPos.getY() - pos.getY();
            drop(world, blockPos, blockPos.add(oy * dirX, 0, oy * dirZ));
        }
    }
}
 
开发者ID:ternsip,项目名称:ChopDown,代码行数:49,代码来源:ChopDown.java

示例15: generateLeafNodeBases

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
 * Generates additional wood blocks to fill out the bases of different leaf nodes that would otherwise degrade.
 */
void generateLeafNodeBases()
{
    for (WorldGenBigTree.FoliageCoordinates worldgenbigtree$foliagecoordinates : this.foliageCoords)
    {
        int i = worldgenbigtree$foliagecoordinates.getBranchBase();
        BlockPos blockpos = new BlockPos(this.basePos.getX(), i, this.basePos.getZ());

        if (!blockpos.equals(worldgenbigtree$foliagecoordinates) && this.leafNodeNeedsBase(i - this.basePos.getY()))
        {
            this.limb(blockpos, worldgenbigtree$foliagecoordinates, Blocks.LOG);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:WorldGenBigTree.java


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