Search in sources :

Example 11 with Orientation

use of pl.asie.charset.lib.utils.Orientation in project Charset by CharsetMC.

the class TileReflector method onPlacedBy.

@Override
public void onPlacedBy(EntityLivingBase placer, @Nullable EnumFacing face, ItemStack stack, float hitX, float hitY, float hitZ) {
    color = LaserColor.VALUES[stack.getItemDamage() & 7];
    Orientation orientation = SpaceUtils.getOrientation(getWorld(), getPos(), placer, face, hitX, hitY, hitZ);
    EnumFacing rotation = null;
    switch(orientation) {
        case FACE_UP_POINT_NORTH:
        case FACE_NORTH_POINT_UP:
        case FACE_DOWN_POINT_SOUTH:
        case FACE_SOUTH_POINT_DOWN:
            rotation = EnumFacing.WEST;
            break;
        case FACE_DOWN_POINT_NORTH:
        case FACE_NORTH_POINT_DOWN:
        case FACE_UP_POINT_SOUTH:
        case FACE_SOUTH_POINT_UP:
            rotation = EnumFacing.EAST;
            break;
        case FACE_WEST_POINT_UP:
        case FACE_UP_POINT_WEST:
        case FACE_EAST_POINT_DOWN:
        case FACE_DOWN_POINT_EAST:
            rotation = EnumFacing.SOUTH;
            break;
        case FACE_WEST_POINT_DOWN:
        case FACE_DOWN_POINT_WEST:
        case FACE_EAST_POINT_UP:
        case FACE_UP_POINT_EAST:
            rotation = EnumFacing.NORTH;
            break;
        case FACE_WEST_POINT_NORTH:
        case FACE_NORTH_POINT_WEST:
        case FACE_EAST_POINT_SOUTH:
        case FACE_SOUTH_POINT_EAST:
            rotation = EnumFacing.UP;
            break;
        case FACE_EAST_POINT_NORTH:
        case FACE_NORTH_POINT_EAST:
        case FACE_WEST_POINT_SOUTH:
        case FACE_SOUTH_POINT_WEST:
            rotation = EnumFacing.DOWN;
            break;
    }
    world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockReflector.ROTATION, rotation));
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) Orientation(pl.asie.charset.lib.utils.Orientation)

Aggregations

Orientation (pl.asie.charset.lib.utils.Orientation)11 EnumFacing (net.minecraft.util.EnumFacing)4 ItemStack (net.minecraft.item.ItemStack)3 IBlockState (net.minecraft.block.state.IBlockState)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 LaserColor (pl.asie.charset.api.laser.LaserColor)2 BlockStainedGlass (net.minecraft.block.BlockStainedGlass)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 Frustum (net.minecraft.client.renderer.culling.Frustum)1 ICamera (net.minecraft.client.renderer.culling.ICamera)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 DefaultVertexFormats (net.minecraft.client.renderer.vertex.DefaultVertexFormats)1 VertexFormat (net.minecraft.client.renderer.vertex.VertexFormat)1