下面列出了net.minecraft.util.EnumFacing#ordinal ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected void attemptLink(EnumFacing dir, TileEntity tile) {
//If the pipe can inject or extract, add to the cache
//if(!(tile instanceof IFluidHandler))
//return;
//if(world.isRemote && tile instanceof TileEnergyPipe)
// connectedSides[dir.ordinal()]=true;
if(canExtract(dir, tile)) {
if(!world.isRemote) {
connectedSides[dir.ordinal()]=true;
getNetworkHandler().removeFromAllTypes(this, tile);
getNetworkHandler().addSource(this,tile,dir);
}
}
if(canInject(dir, tile)) {
if(!world.isRemote) {
connectedSides[dir.ordinal()]=true;
getNetworkHandler().removeFromAllTypes(this, tile);
getNetworkHandler().addSink(this, tile,dir);
}
}
}
protected void attemptLink(EnumFacing dir, TileEntity tile) {
//If the pipe can inject or extract, add to the cache
//if(!(tile instanceof IFluidHandler))
//return;
if(canExtract(dir, tile) && (world.isBlockIndirectlyGettingPowered(pos) > 0 || world.getStrongPower(pos) > 0)) {
if(world.isRemote)
connectedSides[dir.ordinal()]=true;
else {
getNetworkHandler().removeFromAllTypes(this, tile);
getNetworkHandler().addSource(this,tile,dir);
connectedSides[dir.ordinal()]=true;
}
}
if(canInject(dir, tile) && world.isBlockIndirectlyGettingPowered(pos) == 0 && world.getStrongPower(pos) == 0) {
if(world.isRemote)
connectedSides[dir.ordinal()]=true;
else {
getNetworkHandler().removeFromAllTypes(this, tile);
getNetworkHandler().addSink(this, tile,dir);
connectedSides[dir.ordinal()]=true;
}
}
}
private void renderBaseQuads(ITessellator tessellator, EnumFacing side, TextureAtlasSprite sprite) {
int index = side == null ? EnumFacing.values().length : side.ordinal();
boolean createQuads = false;
if (!cropQuads.containsKey(tessellator.getVertexFormat())) {
List<BakedQuad>[] lists = new List[EnumFacing.values().length + 1];
cropQuads.put(tessellator.getVertexFormat(), lists);
createQuads = true;
} else if (cropQuads.get(tessellator.getVertexFormat())[index] == null) {
createQuads = true;
}
if (createQuads) {
tessellator.translate(0, -3 * Constants.UNIT, 0);
tessellator.drawScaledPrism(2, 0, 2, 3, 16, 3, sprite);
tessellator.drawScaledPrism(13, 0, 2, 14, 16, 3, sprite);
tessellator.drawScaledPrism(13, 0, 13, 14, 16, 14, sprite);
tessellator.drawScaledPrism(2, 0, 13, 3, 16, 14, sprite);
tessellator.translate(0, 3 * Constants.UNIT, 0);
} else {
tessellator.addQuads(cropQuads.get(tessellator.getVertexFormat())[index]);
}
}
private static Vec3d applyCarpetProtocolHitVec(BlockPos pos, IBlockState state, Vec3d hitVecIn)
{
double x = hitVecIn.x;
double y = hitVecIn.y;
double z = hitVecIn.z;
Block block = state.getBlock();
EnumFacing facing = fi.dy.masa.malilib.util.BlockUtils.getFirstPropertyFacingValue(state);
if (facing != null)
{
x = facing.ordinal() + 2 + pos.getX();
}
if (block instanceof BlockRedstoneRepeater)
{
x += ((state.getValue(BlockRedstoneRepeater.DELAY)) - 1) * 10;
}
else if (block instanceof BlockTrapDoor && state.getValue(BlockTrapDoor.HALF) == BlockTrapDoor.DoorHalf.TOP)
{
x += 10;
}
else if (block instanceof BlockRedstoneComparator && state.getValue(BlockRedstoneComparator.MODE) == BlockRedstoneComparator.Mode.SUBTRACT)
{
x += 10;
}
else if (block instanceof BlockStairs && state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP)
{
x += 10;
}
return new Vec3d(x, y, z);
}
@PhysicsThreadOnly
@Override
public Optional<Double> getAngularVelocityRatioFor(EnumFacing side) {
PhysicsAssert.assertPhysicsThread();
assertInitialized();
return angularVelocityRatios[side.ordinal()];
}
@PhysicsThreadOnly
@Override
public void setAngularVelocityRatio(EnumFacing side, Optional<Double> newRatio) {
PhysicsAssert.assertPhysicsThread();
assertInitialized();
angularVelocityRatios[side.ordinal()] = newRatio;
}
@Override
public void update() {
super.update();
if (!this.getWorld().isRemote) {
Optional<Double>[] rotationNodeRatios = this.rotationNode
.connectedRotationRatiosUnsychronized();
for (EnumFacing facing : EnumFacing.values()) {
if (!this.rotationNode.isConnectedToSideUnsynchronized(facing)) {
rotationNodeRatios[facing.ordinal()] = Optional.empty();
}
}
connectedSidesRatios = rotationNodeRatios;
}
this.markDirty();
}
public void onPlaced() {
for(EnumFacing dir : EnumFacing.values()) {
TileEntity tile = world.getTileEntity(getPos().offset(dir));
if(tile != null) {
if(tile instanceof TilePipe && tile.getClass() == this.getClass()) {
TilePipe pipe = (TilePipe)tile;
if(this.destroyed)
continue;
if(isInitialized() && pipe.isInitialized() && pipe.getNetworkID() != networkID)
getNetworkHandler().mergeNetworks(networkID, pipe.getNetworkID());
else if(!isInitialized() && pipe.isInitialized()) {
initialize(pipe.getNetworkID());
}
connectedSides[dir.ordinal()] = true;
}
}
}
if(!isInitialized()) {
initialize(getNetworkHandler().getNewNetworkID());
}
linkSystems();
}
@Override
public void addCollisionBoxToList(final IBlockState bs, final World world, final BlockPos coord,
final AxisAlignedBB box, final List<AxisAlignedBB> collisionBoxList,
final Entity entity) {
final EnumFacing orientation = (EnumFacing) world.getBlockState(coord).getValue(FACING);
super.addCollisionBoxToList(coord, box, collisionBoxList, BOXES[orientation.ordinal()]);
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
TileEntity entity = source.getTileEntity(pos);
EnumFacing facing = (entity instanceof TileEntityBackpack)
? ((TileEntityBackpack)entity).facing
: EnumFacing.NORTH;
return _boundsFromFacing[facing.ordinal() - 2];
}
public void setSide(ItemStack stack, EnumFacing side) {
NBTTagCompound nbt = stack.getTagCompound();
if (nbt == null) {
stack.setTagCompound(nbt = new NBTTagCompound());
}
int target = -1;
if (side != null) {
target = side.ordinal();
}
nbt.setInteger("dir", target);
}
@Override
public Optional<Double> getAngularVelocityRatioForUnsynchronized(EnumFacing side) {
assertInitialized();
return angularVelocityRatios[side.ordinal()];
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
return IFWItem.super.onItemUse(player.getHeldItem(hand), player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ);
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
return IFWItem.super.onItemUse(player.getHeldItem(hand), player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ);
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
return ItemWrapperMethods.super.onItemUse(itemStack, player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ);
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
return ItemWrapperMethods.super.onItemUse(itemStack, player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ);
}
@Override
public AxisAlignedBB getBoundingBox(final IBlockState bs, final IBlockAccess world, final BlockPos coord) {
final EnumFacing orientation = (EnumFacing) bs.getValue(FACING);
return BOXES[orientation.ordinal()];
}