本文整理匯總了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()]);
}
示例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;
}
}
}
示例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;
}
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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));
}
}
}
示例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);
}
}
}