Search in sources :

Example 16 with BlockFenceGate

use of net.minecraft.block.BlockFenceGate in project Bewitchment by Um-Mitternacht.

the class BlockScornedBrickFence method canConnectTo.

public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos, EnumFacing p_176524_3_) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    BlockFaceShape blockfaceshape = iblockstate.getBlockFaceShape(worldIn, pos, p_176524_3_);
    Block block = iblockstate.getBlock();
    boolean flag = blockfaceshape == BlockFaceShape.MIDDLE_POLE && (iblockstate.getMaterial() == this.blockMaterial || block instanceof BlockFenceGate);
    return !isExcepBlockForAttachWithPiston(block) && blockfaceshape == BlockFaceShape.SOLID || flag;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockFenceGate(net.minecraft.block.BlockFenceGate) Block(net.minecraft.block.Block) BlockFaceShape(net.minecraft.block.state.BlockFaceShape)

Example 17 with BlockFenceGate

use of net.minecraft.block.BlockFenceGate in project Tropicraft by Tropicraft.

the class BlockTropicraftFence method canConnectTo.

@Override
public boolean canConnectTo(IBlockAccess world, BlockPos pos, EnumFacing facing) {
    IBlockState state = TCGenUtils.getBlockState(world, pos);
    Block block = state.getBlock();
    if (block != this && block != BlockRegistry.bambooFenceGate && block != BlockRegistry.palmFenceGate) {
        return block == Blocks.BARRIER ? false : ((!(block instanceof BlockFence) || state.getMaterial() != this.blockMaterial) && !(block instanceof BlockFenceGate) ? (state.getMaterial().isOpaque() && state.isFullCube() ? state.getMaterial() != Material.GOURD : false) : true);
    } else {
        return true;
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockFenceGate(net.minecraft.block.BlockFenceGate) Block(net.minecraft.block.Block) BlockFence(net.minecraft.block.BlockFence)

Example 18 with BlockFenceGate

use of net.minecraft.block.BlockFenceGate in project EnderIO by SleepyTrousers.

the class CapturedMob method spawn.

public boolean spawn(@Nullable World world, @Nullable BlockPos pos, @Nullable EnumFacing side, boolean clone) {
    if (world == null || pos == null) {
        return false;
    }
    @Nonnull EnumFacing theSide = side != null ? side : EnumFacing.UP;
    Entity entity = getEntity(world, pos, null, clone);
    if (entity == null) {
        return false;
    }
    Block blk = world.getBlockState(pos).getBlock();
    double spawnX = pos.getX() + theSide.getFrontOffsetX() + 0.5;
    double spawnY = pos.getY() + theSide.getFrontOffsetY();
    double spawnZ = pos.getZ() + theSide.getFrontOffsetZ() + 0.5;
    if (theSide == EnumFacing.UP && (blk instanceof BlockFence || blk instanceof BlockWall || blk instanceof BlockFenceGate)) {
        spawnY += 0.5;
    }
    entity.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0);
    if (!world.checkNoEntityCollision(entity.getEntityBoundingBox()) || !world.getCollisionBoxes(entity, entity.getEntityBoundingBox()).isEmpty()) {
        return false;
    }
    if (customName != null && entity instanceof EntityLiving) {
        ((EntityLiving) entity).setCustomNameTag(customName);
    }
    if (!world.spawnEntity(entity)) {
        entity.setUniqueId(MathHelper.getRandomUUID(world.rand));
        if (!world.spawnEntity(entity)) {
            return false;
        }
    }
    if (entity instanceof EntityLiving) {
        ((EntityLiving) entity).playLivingSound();
    }
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) BlockWall(net.minecraft.block.BlockWall) EntityLiving(net.minecraft.entity.EntityLiving) Nonnull(javax.annotation.Nonnull) BlockFenceGate(net.minecraft.block.BlockFenceGate) EnumFacing(net.minecraft.util.EnumFacing) Block(net.minecraft.block.Block) BlockFence(net.minecraft.block.BlockFence)

Example 19 with BlockFenceGate

use of net.minecraft.block.BlockFenceGate in project minecolonies by Minecolonies.

the class EntityAIGateInteract method getBlockFence.

/**
 * Returns a fenceBlock if available.
 *
 * @param pos the position to be searched.
 * @return fenceBlock or null.
 */
private BlockFenceGate getBlockFence(@NotNull final BlockPos pos) {
    final IBlockState blockState = CompatibilityUtils.getWorld(this.theEntity).getBlockState(pos);
    Block block = blockState.getBlock();
    if (!(block instanceof BlockFenceGate && blockState.getMaterial() == Material.WOOD)) {
        block = CompatibilityUtils.getWorld(this.theEntity).getBlockState(this.theEntity.getPosition()).getBlock();
        gatePosition = this.theEntity.getPosition();
    }
    return block instanceof BlockFenceGate && blockState.getMaterial() == Material.WOOD ? (BlockFenceGate) block : null;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockFenceGate(net.minecraft.block.BlockFenceGate) Block(net.minecraft.block.Block)

Example 20 with BlockFenceGate

use of net.minecraft.block.BlockFenceGate in project Minestuck by mraof.

the class ClientEditHandler method onRightClickEvent.

@SubscribeEvent(priority = EventPriority.NORMAL)
public void onRightClickEvent(PlayerInteractEvent.RightClickBlock event) {
    if (event.getWorld().isRemote && event.getEntityPlayer() == ClientProxy.getClientPlayer() && isActive()) {
        Block block = event.getWorld().getBlockState(event.getPos()).getBlock();
        ItemStack stack = event.getEntityPlayer().getHeldItemMainhand();
        event.setUseBlock((block instanceof BlockDoor || block instanceof BlockTrapDoor || block instanceof BlockFenceGate) ? Result.ALLOW : Result.DENY);
        if (event.getUseBlock() == Result.ALLOW)
            return;
        if (event.getHand().equals(EnumHand.OFF_HAND) || !ServerEditHandler.isBlockItem(stack.getItem())) {
            event.setCanceled(true);
            return;
        }
        GristSet cost;
        if (DeployList.containsItemStack(stack))
            if (givenItems[DeployList.getOrdinal(stack)])
                cost = DeployList.getSecondaryCost(stack);
            else
                cost = DeployList.getPrimaryCost(stack);
        else
            cost = GristRegistry.getGristConversion(stack);
        if (!GristHelper.canAfford(MinestuckPlayerData.getClientGrist(), cost)) {
            StringBuilder str = new StringBuilder();
            if (cost != null) {
                for (GristAmount grist : cost.getArray()) {
                    if (cost.getArray().indexOf(grist) != 0)
                        str.append(", ");
                    str.append(grist.getAmount() + " " + grist.getType().getDisplayName());
                }
                event.getEntityPlayer().sendMessage(new TextComponentTranslation("grist.missing", str.toString()));
            }
            event.setCanceled(true);
        }
        if (event.getUseItem() == Result.DEFAULT)
            event.setUseItem(Result.ALLOW);
    }
}
Also used : BlockDoor(net.minecraft.block.BlockDoor) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) BlockFenceGate(net.minecraft.block.BlockFenceGate) BlockTrapDoor(net.minecraft.block.BlockTrapDoor) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

BlockFenceGate (net.minecraft.block.BlockFenceGate)22 Block (net.minecraft.block.Block)20 IBlockState (net.minecraft.block.state.IBlockState)18 BlockFence (net.minecraft.block.BlockFence)7 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 BlockWall (net.minecraft.block.BlockWall)3 Entity (net.minecraft.entity.Entity)3 EnumFacing (net.minecraft.util.EnumFacing)3 BlockPos (net.minecraft.util.math.BlockPos)3 IELadderBlock (blusunrize.immersiveengineering.common.blocks.BlockIEBase.IELadderBlock)2 BlockDoor (net.minecraft.block.BlockDoor)2 BlockTrapDoor (net.minecraft.block.BlockTrapDoor)2 BlockFaceShape (net.minecraft.block.state.BlockFaceShape)2 CrashReport (net.minecraft.crash.CrashReport)2 CrashReportCategory (net.minecraft.crash.CrashReportCategory)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 MoverType (net.minecraft.entity.MoverType)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ItemStack (net.minecraft.item.ItemStack)2 ReportedException (net.minecraft.util.ReportedException)2