@Override public boolean isValidOrientation( final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up ) { return this.canPlaceAt( w, pos, up.getOpposite() ); }
public void setTexture( TextureAtlasSprite texture ) { for( EnumFacing face : EnumFacing.values() ) { this.textures.put( face, texture ); } }
public int getChannelsOnSide( EnumFacing side ) { if( !this.powered ) { return 0; } return this.channelsOnSide[side.ordinal()]; }
public static EnumFacing crossProduct( final EnumFacing forward, final EnumFacing up ) { final int west_x = forward.getFrontOffsetY() * up.getFrontOffsetZ() - forward.getFrontOffsetZ() * up.getFrontOffsetY(); final int west_y = forward.getFrontOffsetZ() * up.getFrontOffsetX() - forward.getFrontOffsetX() * up.getFrontOffsetZ(); final int west_z = forward.getFrontOffsetX() * up.getFrontOffsetY() - forward.getFrontOffsetY() * up.getFrontOffsetX(); switch( west_x + west_y * 2 + west_z * 3 ) { case 1: return EnumFacing.EAST; case -1: return EnumFacing.WEST; case 2: return EnumFacing.UP; case -2: return EnumFacing.DOWN; case 3: return EnumFacing.SOUTH; case -3: return EnumFacing.NORTH; } // something is better then nothing? return EnumFacing.NORTH; }
if( ( this.mask & ( 1 << this.quad.orientation.ordinal() ) ) != 0 ) AxisDirection dir = this.quad.orientation.getAxisDirection(); Vertex[] vertices = this.quad.vertices; switch( this.quad.orientation.getAxis() )
for( EnumFacing a : EnumFacing.values() ) if( a == side || a == side.getOpposite() ) if( ( side.getAxis() != EnumFacing.Axis.Y ) && ( a == EnumFacing.NORTH || a == EnumFacing.EAST || a == EnumFacing.WEST || a == EnumFacing.SOUTH ) ) else if( side.getAxis() == EnumFacing.Axis.Y && ( a == EnumFacing.EAST || a == EnumFacing.WEST ) ) EnumFacing perpendicular = a.rotateAround( side.getAxis() ); for( EnumFacing cornerCandidate : EnumSet.of( perpendicular, perpendicular.getOpposite() ) )
@Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { IBlockState state = this.getStateFromMeta(meta); if(facing.getHorizontalIndex() != -1) { return state.withProperty(FACING, facing.getOpposite()); } return state; }
@Override public void update() { int tier = 1; final EnumSet<EnumFacing> validEnergyReceivers = EnumSet.noneOf( EnumFacing.class ); for( EnumFacing facing : EnumFacing.values() ) { final TileEntity te = this.getWorld().getTileEntity( this.getPos().offset( facing ) ); if( te instanceof TileEnergyGenerator ) { tier++; } if( te != null && te.hasCapability( CapabilityEnergy.ENERGY, facing.getOpposite() ) ) { validEnergyReceivers.add( facing ); } } final int energyToInsert = IntMath.pow( BASE_ENERGY, tier ); for( EnumFacing facing : validEnergyReceivers ) { final TileEntity te = this.getWorld().getTileEntity( this.getPos().offset( facing ) ); final IEnergyStorage cap = te.getCapability( CapabilityEnergy.ENERGY, facing.getOpposite() ); if( cap.canReceive() ) { cap.receiveEnergy( energyToInsert, false ); } } }
@Nonnull @Override public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side) { return side.getAxis() == EnumFacing.Axis.Y ? BlockFaceShape.CENTER_BIG : BlockFaceShape.MIDDLE_POLE_THICK; } }
private static EnumMap<EnumFacing, List<Vec3d>> generateCornersForFacings() { EnumMap<EnumFacing, List<Vec3d>> result = new EnumMap<>( EnumFacing.class ); for( EnumFacing facing : EnumFacing.values() ) { List<Vec3d> corners; float offset = ( facing.getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE ) ? 0 : 1; switch( facing.getAxis() ) { default: case X: corners = Lists.newArrayList( new Vec3d( offset, 1, 1 ), new Vec3d( offset, 0, 1 ), new Vec3d( offset, 0, 0 ), new Vec3d( offset, 1, 0 ) ); break; case Y: corners = Lists.newArrayList( new Vec3d( 1, offset, 1 ), new Vec3d( 1, offset, 0 ), new Vec3d( 0, offset, 0 ), new Vec3d( 0, offset, 1 ) ); break; case Z: corners = Lists.newArrayList( new Vec3d( 0, 1, offset ), new Vec3d( 0, 0, offset ), new Vec3d( 1, 0, offset ), new Vec3d( 1, 1, offset ) ); break; } if( facing.getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE ) { corners = Lists.reverse( corners ); } result.put( facing, ImmutableList.copyOf( corners ) ); } return result; }
@Override protected void onImpact(@Nonnull RayTraceResult var1) { if(!world.isRemote) { if(var1 != null) { EnumFacing dir = var1.sideHit; if(dir != null && dir.getAxis() != EnumFacing.Axis.Y) { BlockPos pos = var1.getBlockPos().offset(dir); while(pos.getY() > 0) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if(block.isAir(state, world, pos)) { IBlockState stateSet = ModBlocks.solidVines.getDefaultState().withProperty(propMap.get(dir.getOpposite()), true); world.setBlockState(pos, stateSet, 1 | 2); world.playEvent(2001, pos, Block.getStateId(stateSet)); pos = pos.down(); } else break; } } } this.world.setEntityState(this, (byte)3); setDead(); } }
protected CCModel rotateFacing(CCModel group, EnumFacing frontFacing) { double angle = Math.PI / 2d * (frontFacing.getAxis() == EnumFacing.Axis.Y ? frontFacing.getFrontOffsetY() : -((frontFacing.getHorizontalIndex() + 2) & 3)); return group.apply(new Rotation(angle, frontFacing.getAxis() == EnumFacing.Axis.Y ? 1 : 0, frontFacing.getAxis() != EnumFacing.Axis.Y ? 1 : 0, 0).at(Vector3.center)); } }
@Override public int getMetaFromState(IBlockState state) { return state.getValue(BotaniaStateProps.CARDINALS).getIndex(); }
EnumFacing rotationDir = EnumFacing.fromAngle(player.rotationYaw); boolean axisX = rotationDir.getAxis() == Axis.X; boolean axisZ = rotationDir.getAxis() == Axis.Z; for(int y = 0; y < yOff * 2 + 1; y++) { for(int z = -zOff; z < zOff + 1; z++) { int xp = pos.getX() + x + dir.getXOffset(); int yp = pos.getY() + y + dir.getYOffset(); int zp = pos.getZ() + z + dir.getZOffset();
@Override public int getMetaFromState(IBlockState state) { return state.getValue(BotaniaStateProps.CARDINALS).getHorizontalIndex(); }
@Override protected void updateFacingWithBoundingBox(EnumFacing facingDirectionIn) { Validate.notNull(facingDirectionIn); this.realFacingDirection = facingDirectionIn; this.facingDirection = realFacingDirection.getAxis() == EnumFacing.Axis.Y ? EnumFacing.SOUTH : realFacingDirection; this.rotationYaw = realFacingDirection.getAxis() == EnumFacing.Axis.Y ? 0 : (float)(this.realFacingDirection.getHorizontalIndex() * 90); this.rotationPitch = realFacingDirection.getAxis() == EnumFacing.Axis.Y ? (realFacingDirection == EnumFacing.UP ? -90.0F : 90.0F) : 0F; this.prevRotationYaw = this.rotationYaw; this.updateBoundingBox(); }
float f1 = enumfacing.getAxisDirection().getOffset(); float secondary = (rand.nextFloat() - rand.nextFloat()) * 0.1F; // Botania - Make and use secondary movement variables below float secondary2 = (rand.nextFloat() - rand.nextFloat()) * 0.1F; if (enumfacing.getAxis() == EnumFacing.Axis.X) motionZ = secondary2; else if (enumfacing.getAxis() == EnumFacing.Axis.Y) motionZ = secondary2; else if (enumfacing.getAxis() == EnumFacing.Axis.Z)
@Override public EnumFacing getForward() { if( this.getUp().getFrontOffsetY() == 0 ) { return EnumFacing.UP; } return EnumFacing.SOUTH; }
/** * Move the current coordinate system to the center of the given block face, assuming that the origin is currently * at the center of a block. */ public static void moveToFace( EnumFacing face ) { GlStateManager.translate( face.getFrontOffsetX() * 0.50, face.getFrontOffsetY() * 0.50, face.getFrontOffsetZ() * 0.50 ); }
@Override public boolean canPlaceBlockOnSide(World world, BlockPos pos, EnumFacing side) { return side.getHorizontalIndex() != -1 && world.isSideSolid(pos.offset(side.getOpposite()), side, true); }