Search in sources :

Example 11 with Direction

use of net.minecraft.core.Direction in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelperImpl method ringBell.

@Override
public void ringBell(Bell block) {
    org.bukkit.block.data.type.Bell bellData = (org.bukkit.block.data.type.Bell) block.getBlockData();
    Direction face = Direction.byName(bellData.getFacing().name());
    Direction dir = Direction.NORTH;
    switch(bellData.getAttachment()) {
        case DOUBLE_WALL:
        case SINGLE_WALL:
            switch(face) {
                case NORTH:
                case SOUTH:
                    dir = Direction.EAST;
                    break;
            }
            break;
        case FLOOR:
            dir = face;
            break;
    }
    CraftBlock craftBlock = (CraftBlock) block.getBlock();
    ((BellBlock) Blocks.BELL).attemptToRing(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition(), dir);
}
Also used : BellBlock(net.minecraft.world.level.block.BellBlock) org.bukkit.block(org.bukkit.block) org.bukkit.craftbukkit.v1_17_R1.block(org.bukkit.craftbukkit.v1_17_R1.block) Direction(net.minecraft.core.Direction)

Example 12 with Direction

use of net.minecraft.core.Direction in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelperImpl method ringBell.

@Override
public void ringBell(Bell block) {
    org.bukkit.block.data.type.Bell bellData = (org.bukkit.block.data.type.Bell) block.getBlockData();
    Direction face = Direction.byName(bellData.getFacing().name());
    Direction dir = Direction.NORTH;
    switch(bellData.getAttachment()) {
        case DOUBLE_WALL:
        case SINGLE_WALL:
            switch(face) {
                case NORTH:
                case SOUTH:
                    dir = Direction.EAST;
                    break;
            }
            break;
        case FLOOR:
            dir = face;
            break;
    }
    CraftBlock craftBlock = (CraftBlock) block.getBlock();
    ((BellBlock) Blocks.BELL).attemptToRing(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition(), dir);
}
Also used : BellBlock(net.minecraft.world.level.block.BellBlock) org.bukkit.block(org.bukkit.block) org.bukkit.craftbukkit.v1_18_R1.block(org.bukkit.craftbukkit.v1_18_R1.block) Direction(net.minecraft.core.Direction)

Example 13 with Direction

use of net.minecraft.core.Direction in project MinecraftForge by MinecraftForge.

the class BlockStateProvider method stairsBlock.

public void stairsBlock(StairBlock block, ModelFile stairs, ModelFile stairsInner, ModelFile stairsOuter) {
    getVariantBuilder(block).forAllStatesExcept(state -> {
        Direction facing = state.getValue(StairBlock.FACING);
        Half half = state.getValue(StairBlock.HALF);
        StairsShape shape = state.getValue(StairBlock.SHAPE);
        // Stairs model is rotated 90 degrees clockwise for some reason
        int yRot = (int) facing.getClockWise().toYRot();
        if (shape == StairsShape.INNER_LEFT || shape == StairsShape.OUTER_LEFT) {
            // Left facing stairs are rotated 90 degrees clockwise
            yRot += 270;
        }
        if (shape != StairsShape.STRAIGHT && half == Half.TOP) {
            // Top stairs are rotated 90 degrees clockwise
            yRot += 90;
        }
        yRot %= 360;
        // Don't set uvlock for states that have no rotation
        boolean uvlock = yRot != 0 || half == Half.TOP;
        return ConfiguredModel.builder().modelFile(shape == StairsShape.STRAIGHT ? stairs : shape == StairsShape.INNER_LEFT || shape == StairsShape.INNER_RIGHT ? stairsInner : stairsOuter).rotationX(half == Half.BOTTOM ? 0 : 180).rotationY(yRot).uvLock(uvlock).build();
    }, StairBlock.WATERLOGGED);
}
Also used : DoubleBlockHalf(net.minecraft.world.level.block.state.properties.DoubleBlockHalf) Half(net.minecraft.world.level.block.state.properties.Half) StairsShape(net.minecraft.world.level.block.state.properties.StairsShape) Direction(net.minecraft.core.Direction)

Example 14 with Direction

use of net.minecraft.core.Direction in project MinecraftForge by MinecraftForge.

the class BlockStateProvider method buttonBlock.

public void buttonBlock(ButtonBlock block, ModelFile button, ModelFile buttonPressed) {
    getVariantBuilder(block).forAllStates(state -> {
        Direction facing = state.getValue(ButtonBlock.FACING);
        AttachFace face = state.getValue(ButtonBlock.FACE);
        boolean powered = state.getValue(ButtonBlock.POWERED);
        return ConfiguredModel.builder().modelFile(powered ? buttonPressed : button).rotationX(face == AttachFace.FLOOR ? 0 : (face == AttachFace.WALL ? 90 : 180)).rotationY((int) (face == AttachFace.CEILING ? facing : facing.getOpposite()).toYRot()).uvLock(face == AttachFace.WALL).build();
    });
}
Also used : AttachFace(net.minecraft.world.level.block.state.properties.AttachFace) Direction(net.minecraft.core.Direction)

Example 15 with Direction

use of net.minecraft.core.Direction in project MinecraftForge by MinecraftForge.

the class VertexLighterFlat method updateLightmap.

protected void updateLightmap(float[] normal, float[] lightmap, float x, float y, float z) {
    final float e1 = 1f - 1e-2f;
    final float e2 = 0.95f;
    boolean full = blockInfo.isFullCube();
    Direction side = null;
    if ((full || y < -e1) && normal[1] < -e2)
        side = Direction.DOWN;
    else if ((full || y > e1) && normal[1] > e2)
        side = Direction.UP;
    else if ((full || z < -e1) && normal[2] < -e2)
        side = Direction.NORTH;
    else if ((full || z > e1) && normal[2] > e2)
        side = Direction.SOUTH;
    else if ((full || x < -e1) && normal[0] < -e2)
        side = Direction.WEST;
    else if ((full || x > e1) && normal[0] > e2)
        side = Direction.EAST;
    int i = side == null ? 0 : side.ordinal() + 1;
    int brightness = blockInfo.getPackedLight()[i];
    lightmap[0] = LightTexture.block(brightness) / (float) 0xF;
    lightmap[1] = LightTexture.sky(brightness) / (float) 0xF;
}
Also used : Direction(net.minecraft.core.Direction)

Aggregations

Direction (net.minecraft.core.Direction)17 BlockPos (net.minecraft.core.BlockPos)4 Nonnull (javax.annotation.Nonnull)3 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)3 ItemStack (net.minecraft.world.item.ItemStack)3 Level (net.minecraft.world.level.Level)2 BellBlock (net.minecraft.world.level.block.BellBlock)2 DispenserBlockEntity (net.minecraft.world.level.block.entity.DispenserBlockEntity)2 org.bukkit.block (org.bukkit.block)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)1 Transformation (com.mojang.math.Transformation)1 Vector3f (com.mojang.math.Vector3f)1 Vector4f (com.mojang.math.Vector4f)1 Optional (java.util.Optional)1 Nullable (javax.annotation.Nullable)1 BlockElementFace (net.minecraft.client.renderer.block.model.BlockElementFace)1