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


Java Axis类代码示例

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


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

示例1: onBlockPlacedBy

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
/**
 * Called when the block is placed in the world.
 */
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entityLiving, ItemStack iStack) {
    super.onBlockPlacedBy(world, pos, state, entityLiving, iStack);
    EnumFacing rotation = getRotation(world, pos);
    if (rotation.getAxis() == Axis.Y) {
        TileEntity te = world.getTileEntity(pos);
        if (te instanceof TileEntityAphorismTile) {
            TileEntityAphorismTile teAT = (TileEntityAphorismTile) te;
            float yaw = entityLiving.rotationYaw; if (yaw < 0) yaw += 360;
            teAT.textRotation = (((int) yaw + 45) / 90 + 2) % 4;
            if (rotation.getFrontOffsetY() > 0 && (teAT.textRotation == 1 || teAT.textRotation == 3)) {
                // fudge - reverse rotation if placing above, and player is facing on east/west axis
                teAT.textRotation = 4 - teAT.textRotation;
            }
        }
    }
    if (world.isRemote && entityLiving instanceof EntityPlayer) {
        ((EntityPlayer) entityLiving).openGui(PneumaticCraftRepressurized.instance, EnumGuiId.APHORISM_TILE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
        sendEditorMessage((EntityPlayer) entityLiving);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:25,代码来源:BlockAphorismTile.java

示例2: rotateBlock

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
@Override
  public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis)
  {
TileEntity te = world.getTileEntity(pos);
      if(te !=null && te instanceof TileCrate){
      	TileCrate tile = (TileCrate)te;
      	if(axis == tile.facing && axis.getAxis() == Axis.Y){
      		tile.rotation++;
      		tile.rotation%=4;
          	BlockUtil.markBlockForUpdate(world, pos);
          	return true;
      	}
      	int next = tile.getFacing();
      	next++;
      	next%=6;
      	tile.setFacing(next);
      	tile.rotation = 0;
      	BlockUtil.markBlockForUpdate(world, pos);
      	return true;
      }
      return false;
  }
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:23,代码来源:BlockCrate.java

示例3: travel

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
public void travel(Entity entity){
	if(entity.getEntityWorld().isRemote)return;
	if(otherPortalPos !=null){
		World world = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(otherPortalDim);
		if(world !=null){
			TileEntity tile = world.getTileEntity(otherPortalPos);
			if(tile !=null && tile instanceof TileTelePortal){
				TileTelePortal otherPortal = (TileTelePortal)tile;
				Vector3d motion = new Vector3d(entity.motionX, entity.motionY, entity.motionZ);
				double ejectPower = 0.0;
				if(facing.getAxis() == Axis.X){
					ejectPower = Math.abs(motion.x);
				}
				if(facing.getAxis() == Axis.Y){
					ejectPower = Math.abs(motion.y);
				}
				if(facing.getAxis() == Axis.Z){
					ejectPower = Math.abs(motion.z);
				}
				teleportTo(entity, otherPortal, ejectPower);
			}
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:25,代码来源:TileTelePortal.java

示例4: fixFace

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
@Override
public EnumFacing fixFace(EnumFacing side){
	EnumFacing fixedDir = side;
	
	if(facing == EnumFacing.SOUTH.ordinal()){
		if(side !=EnumFacing.UP && side !=EnumFacing.DOWN)fixedDir = side.getOpposite();
	}
	
	if(facing == EnumFacing.WEST.ordinal()){
		if(side !=EnumFacing.UP && side !=EnumFacing.DOWN)fixedDir = side.rotateAround(Axis.Y);
	}
	
	if(facing == EnumFacing.EAST.ordinal()){
		if(side !=EnumFacing.UP && side !=EnumFacing.DOWN)fixedDir = side.getOpposite().rotateAround(Axis.Y);
	}
	
	if(facing == EnumFacing.UP.ordinal()){
		fixedDir = side.rotateAround(Axis.X);
	}
	
	if(facing == EnumFacing.DOWN.ordinal()){
		if(side == EnumFacing.WEST || side == EnumFacing.EAST)fixedDir = side.rotateAround(Axis.X);
		else fixedDir = side.getOpposite().rotateAround(Axis.X);
	}
	return fixedDir;
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:27,代码来源:TileEntityBattery.java

示例5: placeBlockAt

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
  if(!super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState)) {
    return false;
  }
  if(side.getAxis() == Axis.Y)return false;
  
  TileEntity te = world.getTileEntity(pos);
  if(te instanceof IFacingTile) {
  	IFacingTile tile = (IFacingTile) te;
  	EnumFacing face = side;
  	tile.setFacing(face.getHorizontalIndex());
  	BlockUtil.markBlockForUpdate(world, pos);
  }
  return true;
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:17,代码来源:ItemBlockShieldRack.java

示例6: drawStairBorder

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
private boolean drawStairBorder(int length) {
  boolean somethingDrawn = false;

  block = STAIRS_SOUTH;
  somethingDrawn = drawLine(Axis.X, length) || somethingDrawn;

  block = STAIRS_WEST;
  somethingDrawn = drawLine(Axis.Z, length) || somethingDrawn;

  block = STAIRS_NORTH;
  somethingDrawn = drawLine(Axis.X, -length) || somethingDrawn;

  block = STAIRS_EAST;
  somethingDrawn = drawLine(Axis.Z, -length) || somethingDrawn;

  return somethingDrawn;
}
 
开发者ID:ToroCraft,项目名称:ToroChess,代码行数:18,代码来源:CheckerBoardGenerator.java

示例7: drawLine

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
private boolean drawLine(Axis axis, int length) {
  int l = computeTravelDistance(length);
  boolean isPositive = length >= 0;
  boolean somethingDrawn = false;
  for (int i = 0; i < l; i++) {
    placeBlock();
    if (i < l - 1) {
      if (isPositive) {
        incrementAxis(axis, 1);
      } else {
        incrementAxis(axis, -1);
      }
    }

    somethingDrawn = somethingDrawn || blockWasDrawable;
  }

  return somethingDrawn;
}
 
开发者ID:ToroCraft,项目名称:ToroChess,代码行数:20,代码来源:CheckerBoardGenerator.java

示例8: line

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
@Override
public void line(Axis axis, int length) {
	int l = computeTravelDistance(length);
	boolean isPositive = length >= 0;
	for (int i = 0; i < l; i++) {
		strokeBlock();
		if (i < l - 1) {
			if (isPositive) {
				incrementAxis(axis, 1);
			} else {
				incrementAxis(axis, -1);
			}
		}

	}
}
 
开发者ID:ToroCraft,项目名称:ToroQuest,代码行数:17,代码来源:Canvas.java

示例9: getRenderBoundingBox

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()
{
    if (this.blueprint != null && this.cachedBB == null)
    {
        if (BlockMultiblockBase.getFacing(this.meta).getAxis() == Axis.Z)
        {
            this.cachedBB = new AxisAlignedBB(
                    this.pos.add(-this.multiblock.getOffsetX(), -this.multiblock.getOffsetY(),
                            -this.multiblock.getOffsetZ()),
                    this.pos.add(this.multiblock.getWidth(), this.multiblock.getHeight(),
                            this.multiblock.getLength()));
        }
        else
            this.cachedBB = new AxisAlignedBB(
                    this.pos.add(-this.multiblock.getOffsetZ(), -this.multiblock.getOffsetY(),
                            -this.multiblock.getOffsetX()),
                    this.pos.add(this.multiblock.getLength(), this.multiblock.getHeight(),
                            this.multiblock.getWidth()));
    }
    if (this.cachedBB != null)
        return this.cachedBB;
    return super.getRenderBoundingBox();
}
 
开发者ID:OPMCorp,项目名称:Qbar,代码行数:26,代码来源:TileStructure.java

示例10: internalGetCoreOffset

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
private BlockPos internalGetCoreOffset(EnumFacing facing)
{
    BlockPos rtn = BlockPos.ORIGIN;

    if (this.getLength() % 2 == 0 || this.getWidth() % 2 == 0)
    {
        if (this.getWidth() % 2 == 0 && facing.getAxis() == Axis.Z
                && facing.getAxisDirection() == AxisDirection.NEGATIVE)
            rtn = rtn.add(-1, 0, 0);
        if (this.getWidth() % 2 == 0 && facing.getAxis() == Axis.X
                && facing.getAxisDirection() == AxisDirection.POSITIVE)
            rtn = rtn.add(0, 0, -1);
        if (this.getLength() % 2 == 0 && facing.getAxis() == Axis.Z
                && facing.getAxisDirection() == AxisDirection.NEGATIVE)
            rtn = rtn.add(0, 0, -1);
        if (this.getLength() % 2 == 0 && facing.getAxis() == Axis.X
                && facing.getAxisDirection() == AxisDirection.NEGATIVE)
            rtn = rtn.add(-1, 0, 0);
    }
    return rtn;
}
 
开发者ID:OPMCorp,项目名称:Qbar,代码行数:22,代码来源:MultiblockComponent.java

示例11: getAllInBox

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
public Iterable<BlockPos> getAllInBox(BlockPos pos, final EnumFacing facing)
{
    Iterable<BlockPos> searchables = null;

    pos = pos.add(this.getCoreOffset(facing));
    if (facing.getAxis() == Axis.Z)
        searchables = BlockPos.getAllInBox(
                pos.subtract(new Vec3i(this.getOffsetX(), this.getOffsetY(), this.getOffsetZ())),
                pos.add(this.getWidth() - 1 - this.getOffsetX(), this.getHeight() - 1 - this.getOffsetY(),
                        this.getLength() - 1 - this.getOffsetZ()));
    else
        searchables = BlockPos.getAllInBox(
                pos.subtract(new Vec3i(this.getOffsetZ(), this.getOffsetY(), this.getOffsetX())),
                pos.add(this.getLength() - 1 - this.getOffsetZ(), this.getHeight() - 1 - this.getOffsetY(),
                        this.getWidth() - 1 - this.getOffsetX()));
    return searchables;
}
 
开发者ID:OPMCorp,项目名称:Qbar,代码行数:18,代码来源:MultiblockComponent.java

示例12: findControllerBlock

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
public static ControlBlockLocation findControllerBlock(World world, BlockPos pos, SizerFactory sizerFactory) {
	Size size = sizerFactory.get(world, pos, Axis.X);

	ControlBlockLocation loc = new ControlBlockLocation();

	if (size.isValid()) {
		loc.pos = size.getBottomLeft();
		loc.axis = Axis.X;
		return loc;
	}

	size = sizerFactory.get(world, pos, Axis.Z);

	if (size.isValid()) {
		loc.pos = size.getBottomLeft();
		loc.axis = Axis.Z;
		return loc;
	}

	return null;
}
 
开发者ID:ToroCraft,项目名称:TeleToro,代码行数:22,代码来源:ItemTeletoryPortalLinker.java

示例13: trySpawnPortal

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
public boolean trySpawnPortal(World worldIn, BlockPos pos) {
	Size size = getSizer(worldIn, pos, EnumFacing.Axis.X);

	if (size.isValid() && size.portalBlockCount == 0) {
		size.placePortalBlocks();
		return true;
	} else {
		Size size1 = getSizer(worldIn, pos, EnumFacing.Axis.Z);

		if (size1.isValid() && size1.portalBlockCount == 0) {
			size1.placePortalBlocks();
			return true;
		} else {
			return false;
		}
	}
}
 
开发者ID:ToroCraft,项目名称:TeleToro,代码行数:18,代码来源:BlockAbstractPortal.java

示例14: withRotation

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
/**
 * Returns the blockstate with the given rotation from the passed
 * blockstate. If inapplicable, returns the passed blockstate.
 */
public IBlockState withRotation(IBlockState state, Rotation rot) {
	switch (rot) {
	case COUNTERCLOCKWISE_90:
	case CLOCKWISE_90:

		switch ((EnumFacing.Axis) state.getValue(AXIS)) {
		case X:
			return state.withProperty(AXIS, EnumFacing.Axis.Z);
		case Z:
			return state.withProperty(AXIS, EnumFacing.Axis.X);
		default:
			return state;
		}

	default:
		return state;
	}
}
 
开发者ID:ToroCraft,项目名称:TeleToro,代码行数:23,代码来源:BlockAbstractPortal.java

示例15: placeChest

import net.minecraft.util.EnumFacing.Axis; //导入依赖的package包/类
protected boolean placeChest(World world, StructureBoundingBox box, Random rand, int x, int y, int z, EnumFacing f, boolean a) {
	int i1 = this.getXWithOffset(x, z);
	int j1 = this.getYWithOffset(y);
	int k1 = this.getZWithOffset(x, z);
	BlockPos pos = new BlockPos(i1, j1, k1);
	if (f.getAxis() == Axis.Y)
		f = EnumFacing.NORTH;
	if (box.isVecInside(pos) && (world.getBlockState(pos).getBlock() != Blocks.CHEST)) {
		world.setBlockState(pos, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, f), 2);
		TileEntity tile = world.getTileEntity(pos);
		if (tile instanceof TileEntityChest)
			((TileEntityChest) tile).setLootTable(a ? loot2 : rand.nextInt(10) < 2 ? lootB : loot, rand.nextLong());
		return true;
	} else
		return false;
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:17,代码来源:VillageHouseScientist.java


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