Search in sources :

Example 1 with BlockLog

use of net.minecraft.block.BlockLog in project SpongeCommon by SpongePowered.

the class MixinBlock method onConstruction.

@Inject(method = "<init>*", at = @At("RETURN"))
public void onConstruction(CallbackInfo ci) {
    // Determine which blocks can avoid executing un-needed event logic
    // This will allow us to avoid running event logic for blocks that do nothing such as grass collisions
    // -- blood
    this.hasCollideLogic = true;
    this.hasCollideWithStateLogic = true;
    // onEntityCollidedWithBlock
    try {
        String mapping = SpongeImplHooks.isDeobfuscatedEnvironment() ? "onEntityWalk" : "func_176199_a";
        Class<?>[] argTypes = { net.minecraft.world.World.class, BlockPos.class, Entity.class };
        Class<?> clazz = this.getClass().getMethod(mapping, argTypes).getDeclaringClass();
        if (clazz.equals(Block.class)) {
            this.hasCollideLogic = false;
        }
    } catch (Throwable ex) {
    // ignore
    }
    // onEntityCollidedWithBlock (IBlockState)
    try {
        String mapping = SpongeImplHooks.isDeobfuscatedEnvironment() ? "onEntityCollidedWithBlock" : "func_180634_a";
        Class<?>[] argTypes = { net.minecraft.world.World.class, BlockPos.class, IBlockState.class, Entity.class };
        Class<?> clazz = this.getClass().getMethod(mapping, argTypes).getDeclaringClass();
        if (clazz.equals(Block.class)) {
            this.hasCollideWithStateLogic = false;
        }
    } catch (Throwable ex) {
    // ignore
    }
    Block block = (Block) (Object) this;
    if (block instanceof BlockLeaves || block instanceof BlockLog || block instanceof BlockGrass || block instanceof BlockLiquid) {
        this.requiresBlockCapture = false;
    }
}
Also used : BlockLeaves(net.minecraft.block.BlockLeaves) BlockLiquid(net.minecraft.block.BlockLiquid) BlockGrass(net.minecraft.block.BlockGrass) Block(net.minecraft.block.Block) IMixinBlock(org.spongepowered.common.interfaces.block.IMixinBlock) BlockLog(net.minecraft.block.BlockLog) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with BlockLog

use of net.minecraft.block.BlockLog in project ForestryMC by ForestryMC.

the class BlockHumus method isEnrooted.

private static boolean isEnrooted(World world, BlockPos pos) {
    for (int i = -1; i < 2; i++) {
        for (int j = -1; j < 2; j++) {
            if (i == 0 && j == 0) {
                // We are not returning true if we are the base of a sapling.
                continue;
            }
            BlockPos blockPos = pos.add(i, 1, j);
            IBlockState state = world.getBlockState(blockPos);
            Block block = state.getBlock();
            if (block instanceof BlockLog || block instanceof IGrowable) {
                return true;
            }
        }
    }
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IGrowable(net.minecraft.block.IGrowable) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) BlockLog(net.minecraft.block.BlockLog)

Example 3 with BlockLog

use of net.minecraft.block.BlockLog in project MC-Prefab by Brian-Wuest.

the class BuildBlock method setComparable.

private static Comparable setComparable(Comparable<?> comparable, Block foundBlock, IProperty<?> property, StructureConfiguration configuration, BuildBlock block, EnumFacing assumedNorth, Optional<?> propertyValue, EnumFacing vineFacing, EnumAxis logFacing, Axis boneFacing, BlockQuartz.EnumType quartzFacing, EnumOrientation leverOrientation, Structure structure) {
    if (property.getName().equals("facing") && !(foundBlock instanceof BlockLever)) {
        // Facing properties should be relative to the configuration facing.
        EnumFacing facing = EnumFacing.byName(propertyValue.get().toString());
        // Cannot rotate verticals.
        if (facing != null && facing != EnumFacing.UP && facing != EnumFacing.DOWN) {
            if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateY()) {
                facing = facing.rotateY();
            } else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().getOpposite()) {
                facing = facing.getOpposite();
            } else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateYCCW()) {
                facing = facing.rotateYCCW();
            }
        }
        comparable = facing;
        block.setHasFacing(true);
    } else if (property.getName().equals("facing") && foundBlock instanceof BlockLever) {
        comparable = leverOrientation;
        block.setHasFacing(true);
    } else if (property.getName().equals("rotation")) {
        // 0 = South
        // 4 = West
        // 8 = North
        // 12 = East
        int rotation = (Integer) propertyValue.get();
        EnumFacing facing = rotation == 0 ? EnumFacing.SOUTH : rotation == 4 ? EnumFacing.WEST : rotation == 8 ? EnumFacing.NORTH : EnumFacing.EAST;
        if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateY()) {
            facing = facing.rotateY();
        } else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().getOpposite()) {
            facing = facing.getOpposite();
        } else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateYCCW()) {
            facing = facing.rotateYCCW();
        }
        rotation = facing == EnumFacing.SOUTH ? 0 : facing == EnumFacing.WEST ? 4 : facing == EnumFacing.NORTH ? 8 : 12;
        comparable = rotation;
        block.setHasFacing(true);
    } else if (foundBlock instanceof BlockVine) {
        // Vines have a special state. There is 1 property for each "facing".
        if (property.getName().equals(vineFacing.getName2())) {
            comparable = true;
            block.setHasFacing(true);
        } else {
            comparable = false;
        }
    } else if (foundBlock instanceof BlockWall) {
        if (!property.getName().equals("variant")) {
            if (property.getName().equals(vineFacing.getName2()) || property.getName().equals(vineFacing.getOpposite().getName2())) {
                comparable = true;
                block.setHasFacing(true);
            } else {
                comparable = false;
            }
        }
    } else if (foundBlock instanceof BlockLog) {
        // logs have a special state. There is a property called axis and it only has 3 directions.
        if (property.getName().equals("axis")) {
            comparable = logFacing;
        }
    } else if (foundBlock instanceof BlockBone) {
        // bones have a special state. There is a property called axis and it only has 3 directions.
        if (property.getName().equals("axis")) {
            comparable = boneFacing;
        }
    } else if (foundBlock instanceof BlockQuartz) {
        if (property.getName().equals("variant") && quartzFacing != BlockQuartz.EnumType.DEFAULT) {
            comparable = quartzFacing;
        }
    }
    return comparable;
}
Also used : BlockLever(net.minecraft.block.BlockLever) BlockVine(net.minecraft.block.BlockVine) BlockWall(net.minecraft.block.BlockWall) EnumFacing(net.minecraft.util.EnumFacing) BlockLog(net.minecraft.block.BlockLog) BlockBone(net.minecraft.block.BlockBone) BlockQuartz(net.minecraft.block.BlockQuartz)

Example 4 with BlockLog

use of net.minecraft.block.BlockLog in project DynamicSurroundings by OreCruncher.

the class FootstepsRegistry method seedMap.

private void seedMap() {
    // Iterate through the blockmap looking for known pattern types.
    // Though they probably should all be registered with Forge
    // dictionary it's not a requirement.
    final Iterator<Block> itr = Block.REGISTRY.iterator();
    while (itr.hasNext()) {
        final Block block = itr.next();
        final String blockName = MCHelper.nameOf(block);
        if (block instanceof BlockCrops) {
            final BlockCrops crop = (BlockCrops) block;
            if (crop.getMaxAge() == 3) {
                registerBlocks("#beets", blockName);
            } else if (blockName.equals("minecraft:wheat")) {
                registerBlocks("#wheat", blockName);
            } else if (crop.getMaxAge() == 7) {
                registerBlocks("#crop", blockName);
            }
        } else if (block instanceof BlockSapling) {
            registerBlocks("#sapling", blockName);
        } else if (block instanceof BlockReed) {
            registerBlocks("#reed", blockName);
        } else if (block instanceof BlockFence) {
            registerBlocks("#fence", blockName);
        } else if (block instanceof BlockFlower || block instanceof BlockMushroom) {
            registerBlocks("NOT_EMITTER", blockName);
        } else if (block instanceof BlockLog || block instanceof BlockPlanks) {
            registerBlocks("wood", blockName);
        } else if (block instanceof BlockDoor) {
            registerBlocks("bluntwood", blockName);
        } else if (block instanceof BlockLeaves) {
            registerBlocks("leaves", blockName);
        } else if (block instanceof BlockOre) {
            registerBlocks("ore", blockName);
        } else if (block instanceof BlockIce) {
            registerBlocks("ice", blockName);
        }
    }
}
Also used : BlockMushroom(net.minecraft.block.BlockMushroom) BlockCrops(net.minecraft.block.BlockCrops) BlockIce(net.minecraft.block.BlockIce) BlockOre(net.minecraft.block.BlockOre) BlockLog(net.minecraft.block.BlockLog) BlockReed(net.minecraft.block.BlockReed) BlockFlower(net.minecraft.block.BlockFlower) BlockPlanks(net.minecraft.block.BlockPlanks) BlockDoor(net.minecraft.block.BlockDoor) BlockLeaves(net.minecraft.block.BlockLeaves) BlockSapling(net.minecraft.block.BlockSapling) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) BlockFence(net.minecraft.block.BlockFence)

Example 5 with BlockLog

use of net.minecraft.block.BlockLog in project BetterWithAddons by DaedalusGame.

the class WorldGenBigTrees method limb.

void limb(BlockPos pos1, BlockPos pos2) {
    BlockPos blockpos = pos2.add(-pos1.getX(), -pos1.getY(), -pos1.getZ());
    int i = this.getGreatestDistance(blockpos);
    float f = (float) blockpos.getX() / (float) i;
    float f1 = (float) blockpos.getY() / (float) i;
    float f2 = (float) blockpos.getZ() / (float) i;
    for (int j = 0; j <= i; ++j) {
        BlockPos blockpos1 = pos1.add((double) (0.5F + (float) j * f), (double) (0.5F + (float) j * f1), (double) (0.5F + (float) j * f2));
        BlockLog.EnumAxis blocklog$enumaxis = this.getLogAxis(pos1, blockpos1);
        this.setBlockAndNotifyAdequately(this.world, blockpos1, log.withProperty(BlockLog.LOG_AXIS, blocklog$enumaxis));
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) BlockLog(net.minecraft.block.BlockLog)

Aggregations

BlockLog (net.minecraft.block.BlockLog)9 BlockPos (net.minecraft.util.math.BlockPos)5 Block (net.minecraft.block.Block)4 BlockLeaves (net.minecraft.block.BlockLeaves)3 IBlockState (net.minecraft.block.state.IBlockState)2 ToolMetaItem (gregtech.api.items.toolitem.ToolMetaItem)1 MetaToolValueItem (gregtech.api.items.toolitem.ToolMetaItem.MetaToolValueItem)1 BlockBone (net.minecraft.block.BlockBone)1 BlockCrops (net.minecraft.block.BlockCrops)1 BlockDoor (net.minecraft.block.BlockDoor)1 BlockFence (net.minecraft.block.BlockFence)1 BlockFlower (net.minecraft.block.BlockFlower)1 BlockGrass (net.minecraft.block.BlockGrass)1 BlockIce (net.minecraft.block.BlockIce)1 BlockLever (net.minecraft.block.BlockLever)1 BlockLiquid (net.minecraft.block.BlockLiquid)1 EnumAxis (net.minecraft.block.BlockLog.EnumAxis)1 BlockMushroom (net.minecraft.block.BlockMushroom)1 BlockOre (net.minecraft.block.BlockOre)1 BlockPlanks (net.minecraft.block.BlockPlanks)1