Java Code Examples for net.minecraft.block.BlockFence

The following are top voted examples for showing how to use net.minecraft.block.BlockFence. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: DecompiledMinecraft   File: EntityPlayerMP.java   View source code 6 votes vote down vote up
/**
 * process player falling based on movement packet
 */
public void handleFalling(double p_71122_1_, boolean p_71122_3_)
{
    int i = MathHelper.floor_double(this.posX);
    int j = MathHelper.floor_double(this.posY - 0.20000000298023224D);
    int k = MathHelper.floor_double(this.posZ);
    BlockPos blockpos = new BlockPos(i, j, k);
    Block block = this.worldObj.getBlockState(blockpos).getBlock();

    if (block.getMaterial() == Material.air)
    {
        Block block1 = this.worldObj.getBlockState(blockpos.down()).getBlock();

        if (block1 instanceof BlockFence || block1 instanceof BlockWall || block1 instanceof BlockFenceGate)
        {
            blockpos = blockpos.down();
            block = this.worldObj.getBlockState(blockpos).getBlock();
        }
    }

    super.updateFallState(p_71122_1_, p_71122_3_, block, blockpos);
}
 
Example 2
Project: DecompiledMinecraft   File: ItemLead.java   View source code 6 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block instanceof BlockFence)
    {
        if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            attachToFence(playerIn, worldIn, pos);
            return true;
        }
    }
    else
    {
        return false;
    }
}
 
Example 3
Project: DecompiledMinecraft   File: EntityPlayerMP.java   View source code 6 votes vote down vote up
/**
 * process player falling based on movement packet
 */
public void handleFalling(double p_71122_1_, boolean p_71122_3_)
{
    int i = MathHelper.floor_double(this.posX);
    int j = MathHelper.floor_double(this.posY - 0.20000000298023224D);
    int k = MathHelper.floor_double(this.posZ);
    BlockPos blockpos = new BlockPos(i, j, k);
    Block block = this.worldObj.getBlockState(blockpos).getBlock();

    if (block.getMaterial() == Material.air)
    {
        Block block1 = this.worldObj.getBlockState(blockpos.down()).getBlock();

        if (block1 instanceof BlockFence || block1 instanceof BlockWall || block1 instanceof BlockFenceGate)
        {
            blockpos = blockpos.down();
            block = this.worldObj.getBlockState(blockpos).getBlock();
        }
    }

    super.updateFallState(p_71122_1_, p_71122_3_, block, blockpos);
}
 
Example 4
Project: DecompiledMinecraft   File: ItemLead.java   View source code 6 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block instanceof BlockFence)
    {
        if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            attachToFence(playerIn, worldIn, pos);
            return true;
        }
    }
    else
    {
        return false;
    }
}
 
Example 5
Project: BaseClient   File: EntityPlayerMP.java   View source code 6 votes vote down vote up
/**
 * process player falling based on movement packet
 */
public void handleFalling(double p_71122_1_, boolean p_71122_3_)
{
    int i = MathHelper.floor_double(this.posX);
    int j = MathHelper.floor_double(this.posY - 0.20000000298023224D);
    int k = MathHelper.floor_double(this.posZ);
    BlockPos blockpos = new BlockPos(i, j, k);
    Block block = this.worldObj.getBlockState(blockpos).getBlock();

    if (block.getMaterial() == Material.air)
    {
        Block block1 = this.worldObj.getBlockState(blockpos.down()).getBlock();

        if (block1 instanceof BlockFence || block1 instanceof BlockWall || block1 instanceof BlockFenceGate)
        {
            blockpos = blockpos.down();
            block = this.worldObj.getBlockState(blockpos).getBlock();
        }
    }

    super.updateFallState(p_71122_1_, p_71122_3_, block, blockpos);
}
 
Example 6
Project: BaseClient   File: ItemLead.java   View source code 6 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block instanceof BlockFence)
    {
        if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            attachToFence(playerIn, worldIn, pos);
            return true;
        }
    }
    else
    {
        return false;
    }
}
 
Example 7
Project: BaseClient   File: EntityPlayerMP.java   View source code 6 votes vote down vote up
/**
 * process player falling based on movement packet
 */
public void handleFalling(double p_71122_1_, boolean p_71122_3_)
{
    int i = MathHelper.floor_double(this.posX);
    int j = MathHelper.floor_double(this.posY - 0.20000000298023224D);
    int k = MathHelper.floor_double(this.posZ);
    BlockPos blockpos = new BlockPos(i, j, k);
    Block block = this.worldObj.getBlockState(blockpos).getBlock();

    if (block.getMaterial() == Material.air)
    {
        Block block1 = this.worldObj.getBlockState(blockpos.down()).getBlock();

        if (block1 instanceof BlockFence || block1 instanceof BlockWall || block1 instanceof BlockFenceGate)
        {
            blockpos = blockpos.down();
            block = this.worldObj.getBlockState(blockpos).getBlock();
        }
    }

    super.updateFallState(p_71122_1_, p_71122_3_, block, blockpos);
}
 
Example 8
Project: BaseClient   File: ItemLead.java   View source code 6 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block instanceof BlockFence)
    {
        if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            attachToFence(playerIn, worldIn, pos);
            return true;
        }
    }
    else
    {
        return false;
    }
}
 
Example 9
Project: Zombe-Modpack   File: EntityPlayerMP.java   View source code 6 votes vote down vote up
/**
 * process player falling based on movement packet
 */
public void handleFalling(double y, boolean onGroundIn)
{
    int i = MathHelper.floor(this.posX);
    int j = MathHelper.floor(this.posY - 0.20000000298023224D);
    int k = MathHelper.floor(this.posZ);
    BlockPos blockpos = new BlockPos(i, j, k);
    IBlockState iblockstate = this.world.getBlockState(blockpos);

    if (iblockstate.getMaterial() == Material.AIR)
    {
        BlockPos blockpos1 = blockpos.down();
        IBlockState iblockstate1 = this.world.getBlockState(blockpos1);
        Block block = iblockstate1.getBlock();

        if (block instanceof BlockFence || block instanceof BlockWall || block instanceof BlockFenceGate)
        {
            blockpos = blockpos1;
            iblockstate = iblockstate1;
        }
    }

    super.updateFallState(y, onGroundIn, iblockstate, blockpos);
}
 
Example 10
Project: Backmemed   File: EntityPlayerMP.java   View source code 6 votes vote down vote up
/**
 * process player falling based on movement packet
 */
public void handleFalling(double y, boolean onGroundIn)
{
    int i = MathHelper.floor(this.posX);
    int j = MathHelper.floor(this.posY - 0.20000000298023224D);
    int k = MathHelper.floor(this.posZ);
    BlockPos blockpos = new BlockPos(i, j, k);
    IBlockState iblockstate = this.world.getBlockState(blockpos);

    if (iblockstate.getMaterial() == Material.AIR)
    {
        BlockPos blockpos1 = blockpos.down();
        IBlockState iblockstate1 = this.world.getBlockState(blockpos1);
        Block block = iblockstate1.getBlock();

        if (block instanceof BlockFence || block instanceof BlockWall || block instanceof BlockFenceGate)
        {
            blockpos = blockpos1;
            iblockstate = iblockstate1;
        }
    }

    super.updateFallState(y, onGroundIn, iblockstate, blockpos);
}
 
Example 11
Project: Backmemed   File: ItemLead.java   View source code 6 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    Block block = playerIn.getBlockState(worldIn).getBlock();

    if (!(block instanceof BlockFence))
    {
        return EnumActionResult.PASS;
    }
    else
    {
        if (!playerIn.isRemote)
        {
            attachToFence(stack, playerIn, worldIn);
        }

        return EnumActionResult.SUCCESS;
    }
}
 
Example 12
Project: CustomWorldGen   File: EntityPlayerMP.java   View source code 6 votes vote down vote up
/**
 * process player falling based on movement packet
 */
public void handleFalling(double y, boolean onGroundIn)
{
    int i = MathHelper.floor_double(this.posX);
    int j = MathHelper.floor_double(this.posY - 0.20000000298023224D);
    int k = MathHelper.floor_double(this.posZ);
    BlockPos blockpos = new BlockPos(i, j, k);
    IBlockState iblockstate = this.worldObj.getBlockState(blockpos);

    if (iblockstate.getBlock().isAir(iblockstate, this.worldObj, blockpos))
    {
        BlockPos blockpos1 = blockpos.down();
        IBlockState iblockstate1 = this.worldObj.getBlockState(blockpos1);
        Block block = iblockstate1.getBlock();

        if (block instanceof BlockFence || block instanceof BlockWall || block instanceof BlockFenceGate)
        {
            blockpos = blockpos1;
            iblockstate = iblockstate1;
        }
    }

    super.updateFallState(y, onGroundIn, iblockstate, blockpos);
}
 
Example 13
Project: CustomWorldGen   File: ItemLead.java   View source code 6 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (!(block instanceof BlockFence))
    {
        return EnumActionResult.PASS;
    }
    else
    {
        if (!worldIn.isRemote)
        {
            attachToFence(playerIn, worldIn, pos);
        }

        return EnumActionResult.SUCCESS;
    }
}
 
Example 14
Project: fencing   File: FenceBlock.java   View source code 6 votes vote down vote up
protected boolean canConnectTo(IBlockAccess blockAccess, int x, int y, int z) {
	Block block = blockAccess.getBlock(x, y, z);
	if (block == null) {
		return false;
	} else if (block.getMaterial().isOpaque()
			&& block.renderAsNormalBlock()) {
		// We'll connect against full 1x1x1 blocks.
		return true;
	} else if (block instanceof FenceBlock || block instanceof BlockFence
			|| block instanceof BlockPane || block instanceof BlockWall) {
		// Of course we connect to our own.
		// And to vanilla fences, iron bars, glass panes and walls.
		return true;
	}
	return false;
}
 
Example 15
Project: MineFantasy   File: BlockFoodPrep.java   View source code 6 votes vote down vote up
/**
 * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
 * their own) Args: x, y, z, neighbor blockID
 */
public void onNeighborBlockChange(World world, int x, int y, int z, int neighbor)
{
    boolean flag = false;

    if (!world.doesBlockHaveSolidTopSurface(x, y - 1, z) && !BlockFence.isIdAFence(world.getBlockId(x, y - 1, z)))
    {
        flag = true;
    }

    if (flag)
    {
        this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
        world.setBlockToAir(x, y, z);
    }
}
 
Example 16
Project: RTM   File: BlockPressureBlockWIP.java   View source code 6 votes vote down vote up
/**
 * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
 * their own) Args: x, y, z, neighbor Block
 */
public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_)
{
    boolean flag = false;

    if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) && !BlockFence.func_149825_a(world.getBlock(x, y - 1, z)))
    {
        flag = true;
    }

    if (flag)
    {
        this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
        world.setBlockToAir(x, y, z);
    }
}
 
Example 17
Project: ExpandedRailsMod   File: EntityPlayerMP.java   View source code 6 votes vote down vote up
/**
 * process player falling based on movement packet
 */
public void handleFalling(double y, boolean onGroundIn)
{
    int i = MathHelper.floor_double(this.posX);
    int j = MathHelper.floor_double(this.posY - 0.20000000298023224D);
    int k = MathHelper.floor_double(this.posZ);
    BlockPos blockpos = new BlockPos(i, j, k);
    IBlockState iblockstate = this.worldObj.getBlockState(blockpos);

    if (iblockstate.getBlock().isAir(iblockstate, this.worldObj, blockpos))
    {
        BlockPos blockpos1 = blockpos.down();
        IBlockState iblockstate1 = this.worldObj.getBlockState(blockpos1);
        Block block = iblockstate1.getBlock();

        if (block instanceof BlockFence || block instanceof BlockWall || block instanceof BlockFenceGate)
        {
            blockpos = blockpos1;
            iblockstate = iblockstate1;
        }
    }

    super.updateFallState(y, onGroundIn, iblockstate, blockpos);
}
 
Example 18
Project: ExpandedRailsMod   File: ItemLead.java   View source code 6 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (!(block instanceof BlockFence))
    {
        return EnumActionResult.PASS;
    }
    else
    {
        if (!worldIn.isRemote)
        {
            attachToFence(playerIn, worldIn, pos);
        }

        return EnumActionResult.SUCCESS;
    }
}
 
Example 19
Project: ZeldaSwordSkills   File: ItemCustomEgg.java   View source code 6 votes vote down vote up
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
	if (world.isRemote) {
		return true;
	} else {
		IBlockState state = world.getBlockState(pos);
		pos = pos.offset(side);
		double dy = 0.0D;
		if (side == EnumFacing.UP && state.getBlock() instanceof BlockFence) {
			dy = 0.5D;
		}
		Entity entity = spawnCreature(world, stack.getItemDamage(), pos.getX() + 0.5D, pos.getY() + dy, pos.getZ() + 0.5D);
		if (entity != null) {
			if (entity instanceof EntityLivingBase && stack.hasDisplayName()) {
				entity.setCustomNameTag(stack.getDisplayName());
			}

			if (!player.capabilities.isCreativeMode) {
				--stack.stackSize;
			}
		}
		return true;
	}
}
 
Example 20
Project: fencing   File: FenceBlock.java   View source code 6 votes vote down vote up
protected boolean canConnectTo(IBlockAccess blockAccess, int x, int y, int z) {
	Block block = blockAccess.getBlock(x, y, z);
	if (block == null) {
		return false;
	} else if (block.getMaterial().isOpaque()
			&& block.renderAsNormalBlock()) {
		// We'll connect against full 1x1x1 blocks.
		return true;
	} else if (block instanceof FenceBlock || block instanceof BlockFence
			|| block instanceof BlockPane || block instanceof BlockWall) {
		// Of course we connect to our own.
		// And to vanilla fences, iron bars, glass panes and walls.
		return true;
	}
	return false;
}
 
Example 21
Project: EnderIO   File: BlockPaintedFence.java   View source code 6 votes vote down vote up
@Override
public boolean canConnectTo(@Nonnull IBlockAccess worldIn, @Nonnull BlockPos pos) {
  if (super.canConnectTo(worldIn, pos)) {
    return true;
  }
  final IBlockState blockState2 = worldIn.getBlockState(pos);
  final Block block = blockState2.getBlock();
  if (block instanceof BlockPaintedFence) {
    return true;
  }
  if (block instanceof IPaintable.IBlockPaintableBlock) {
    final IBlockState paintSource = ((IPaintable.IBlockPaintableBlock) block).getPaintSource(blockState2, worldIn, pos);
    return paintSource != null && paintSource.getBlock() instanceof BlockFence && paintSource.getMaterial() == blockMaterial;
  }
  return false;
}
 
Example 22
Project: EnderIO   File: BlockPaintedFence.java   View source code 6 votes vote down vote up
@SideOnly(Side.CLIENT)
private List<IBakedModel> mapRender(IBlockState state, @Nullable IBlockState paint) {
  List<IBakedModel> result = new ArrayList<IBakedModel>();

  result.add(PaintRegistry.getModel(IBakedModel.class, "fence_post", paint, null));

  if (state.getValue(BlockFence.NORTH)) {
    result.add(PaintRegistry.getModel(IBakedModel.class, "fence_side", paint, new UVLock(null)));
  }
  if (state.getValue(BlockFence.EAST)) {
    result.add(PaintRegistry.getModel(IBakedModel.class, "fence_side", paint, new UVLock(ModelRotation.X0_Y90)));
  }
  if (state.getValue(BlockFence.SOUTH)) {
    result.add(PaintRegistry.getModel(IBakedModel.class, "fence_side", paint, new UVLock(ModelRotation.X0_Y180)));
  }
  if (state.getValue(BlockFence.WEST)) {
    result.add(PaintRegistry.getModel(IBakedModel.class, "fence_side", paint, new UVLock(ModelRotation.X0_Y270)));
  }

  return result;
}
 
Example 23
Project: Bewitchment   File: BlockScornedBrickFence.java   View source code 5 votes vote down vote up
@Override
public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing) {
	Block connector = world.getBlockState(pos.offset(facing)).getBlock();

	if (connector instanceof BlockFence) {
		if (this != Blocks.NETHER_BRICK_FENCE && connector == Blocks.NETHER_BRICK_FENCE) {
			return false;
		} else if (this == Blocks.NETHER_BRICK_FENCE && connector != Blocks.NETHER_BRICK_FENCE) {
			return false;
		}
		return true;
	}
	return false;
}
 
Example 24
Project: Bewitchment   File: BlockFakeIceFence.java   View source code 5 votes vote down vote up
@Override
public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing) {
	Block connector = world.getBlockState(pos.offset(facing)).getBlock();

	if (connector instanceof BlockFence) {
		if (this != Blocks.NETHER_BRICK_FENCE && connector == Blocks.NETHER_BRICK_FENCE) {
			return false;
		} else if (this == Blocks.NETHER_BRICK_FENCE && connector != Blocks.NETHER_BRICK_FENCE) {
			return false;
		}
		return true;
	}
	return false;
}
 
Example 25
Project: Backmemed   File: WalkNodeProcessor.java   View source code 5 votes vote down vote up
private PathNodeType getPathNodeTypeRaw(IBlockAccess p_189553_1_, int p_189553_2_, int p_189553_3_, int p_189553_4_)
{
    BlockPos blockpos = new BlockPos(p_189553_2_, p_189553_3_, p_189553_4_);
    IBlockState iblockstate = p_189553_1_.getBlockState(blockpos);
    Block block = iblockstate.getBlock();
    Material material = iblockstate.getMaterial();
    return material == Material.AIR ? PathNodeType.OPEN : (block != Blocks.TRAPDOOR && block != Blocks.IRON_TRAPDOOR && block != Blocks.WATERLILY ? (block == Blocks.FIRE ? PathNodeType.DAMAGE_FIRE : (block == Blocks.CACTUS ? PathNodeType.DAMAGE_CACTUS : (block instanceof BlockDoor && material == Material.WOOD && !((Boolean)iblockstate.getValue(BlockDoor.OPEN)).booleanValue() ? PathNodeType.DOOR_WOOD_CLOSED : (block instanceof BlockDoor && material == Material.IRON && !((Boolean)iblockstate.getValue(BlockDoor.OPEN)).booleanValue() ? PathNodeType.DOOR_IRON_CLOSED : (block instanceof BlockDoor && ((Boolean)iblockstate.getValue(BlockDoor.OPEN)).booleanValue() ? PathNodeType.DOOR_OPEN : (block instanceof BlockRailBase ? PathNodeType.RAIL : (!(block instanceof BlockFence) && !(block instanceof BlockWall) && (!(block instanceof BlockFenceGate) || ((Boolean)iblockstate.getValue(BlockFenceGate.OPEN)).booleanValue()) ? (material == Material.WATER ? PathNodeType.WATER : (material == Material.LAVA ? PathNodeType.LAVA : (block.isPassable(p_189553_1_, blockpos) ? PathNodeType.OPEN : PathNodeType.BLOCKED))) : PathNodeType.FENCE))))))) : PathNodeType.TRAPDOOR);
}
 
Example 26
Project: CustomWorldGen   File: WalkNodeProcessor.java   View source code 5 votes vote down vote up
private PathNodeType getPathNodeTypeRaw(IBlockAccess p_189553_1_, int p_189553_2_, int p_189553_3_, int p_189553_4_)
{
    BlockPos blockpos = new BlockPos(p_189553_2_, p_189553_3_, p_189553_4_);
    IBlockState iblockstate = p_189553_1_.getBlockState(blockpos);
    Block block = iblockstate.getBlock();
    Material material = iblockstate.getMaterial();
    return material == Material.AIR ? PathNodeType.OPEN : (block != Blocks.TRAPDOOR && block != Blocks.IRON_TRAPDOOR && block != Blocks.WATERLILY ? (block == Blocks.FIRE ? PathNodeType.DAMAGE_FIRE : (block == Blocks.CACTUS ? PathNodeType.DAMAGE_CACTUS : (block instanceof BlockDoor && material == Material.WOOD && !((Boolean)iblockstate.getValue(BlockDoor.OPEN)).booleanValue() ? PathNodeType.DOOR_WOOD_CLOSED : (block instanceof BlockDoor && material == Material.IRON && !((Boolean)iblockstate.getValue(BlockDoor.OPEN)).booleanValue() ? PathNodeType.DOOR_IRON_CLOSED : (block instanceof BlockDoor && ((Boolean)iblockstate.getValue(BlockDoor.OPEN)).booleanValue() ? PathNodeType.DOOR_OPEN : (block instanceof BlockRailBase ? PathNodeType.RAIL : (!(block instanceof BlockFence) && !(block instanceof BlockWall) && (!(block instanceof BlockFenceGate) || ((Boolean)iblockstate.getValue(BlockFenceGate.OPEN)).booleanValue()) ? (material == Material.WATER ? PathNodeType.WATER : (material == Material.LAVA ? PathNodeType.LAVA : (block.isPassable(p_189553_1_, blockpos) ? PathNodeType.OPEN : PathNodeType.BLOCKED))) : PathNodeType.FENCE))))))) : PathNodeType.TRAPDOOR);
}
 
Example 27
Project: 4Space-5   File: EntityFlag.java   View source code 5 votes vote down vote up
@Override
public void onUpdate()
{
    super.onUpdate();

    if ((this.ticksExisted - 1) % 20 == 0 && this.worldObj.isRemote)
    {
        this.flagData = ClientUtil.updateFlagData(this.getOwner(), Minecraft.getMinecraft().thePlayer.getDistanceToEntity(this) < 50.0D);
    }

    Vector3 vec = new Vector3(this.posX, this.posY, this.posZ);
    vec = vec.translate(new Vector3(0, -1, 0));
    final Block blockAt = vec.getBlock(this.worldObj);

    if (blockAt != null)
    {
        if (blockAt instanceof BlockFence)
        {

        }
        else if (blockAt.isAir(this.worldObj, vec.intX(), vec.intY(), vec.intZ()))
        {
            this.motionY -= 0.02F;
        }
    }

    this.moveEntity(this.motionX, this.motionY, this.motionZ);
}
 
Example 28
Project: Gravestone-mod-Extended   File: ItemGSMonsterPlacer.java   View source code 5 votes vote down vote up
/**
 * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
 * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
 */
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack item = player.getHeldItem(hand);

    if (world.isRemote) {
        return EnumActionResult.SUCCESS;
    } else {
        IBlockState block = world.getBlockState(blockPos);
        double d0 = 0;
        if (facing == EnumFacing.UP && block instanceof BlockFence) {
            d0 = 0.5;
        }

        blockPos = blockPos.offset(facing);
        net.minecraft.entity.Entity entity = spawnCreature(world, item.getItemDamage(), blockPos.getX() + 0.5, blockPos.getY() + d0, blockPos.getZ() + 0.5);
        if (entity != null) {
            if (entity instanceof EntityLivingBase && item.hasDisplayName()) {
                entity.setCustomNameTag(item.getDisplayName());
            }

            if (!player.capabilities.isCreativeMode) {
                item.setCount(item.getCount() - 1);
            }
        }

        return EnumActionResult.SUCCESS;
    }
}
 
Example 29
Project: DynamicSurroundings   File: FootstepsRegistry.java   View source code 5 votes vote down vote up
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) {
				this.registerBlocks("#beets", blockName);
			} else if (blockName.equals("minecraft:wheat")) {
				this.registerBlocks("#wheat", blockName);
			} else if (crop.getMaxAge() == 7) {
				this.registerBlocks("#crop", blockName);
			}
		} else if (block instanceof BlockSapling) {
			this.registerBlocks("#sapling", blockName);
		} else if (block instanceof BlockReed) {
			this.registerBlocks("#reed", blockName);
		} else if (block instanceof BlockFence) {
			this.registerBlocks("#fence", blockName);
		} else if (block instanceof BlockFlower || block instanceof BlockMushroom) {
			this.registerBlocks("NOT_EMITTER", blockName);
		} else if (block instanceof BlockLog || block instanceof BlockPlanks) {
			this.registerBlocks("wood", blockName);
		} else if (block instanceof BlockDoor) {
			this.registerBlocks("bluntwood", blockName);
		} else if (block instanceof BlockLeaves) {
			this.registerBlocks("leaves", blockName);
		} else if (block instanceof BlockOre) {
			this.registerBlocks("ore", blockName);
		} else if (block instanceof BlockIce) {
			this.registerBlocks("ice", blockName);
		}
	}
}
 
Example 30
Project: Factorization   File: TileEntityWaterWheel.java   View source code 5 votes vote down vote up
private boolean isFenceish(Coord fenceLocation) {
    final Block block = fenceLocation.getBlock();
    if (block instanceof BlockFence) return true;
    if (block instanceof BlockWall) return true;
    if (block instanceof BlockLog) return true;
    if (block.getMaterial() == Material.iron) return true;
    return false;
}
 
Example 31
Project: Factorization   File: TileEntityWindMill.java   View source code 5 votes vote down vote up
private boolean isFenceish(Coord fenceLocation) {
    final Block block = fenceLocation.getBlock();
    if (block instanceof BlockFence) return true;
    if (block instanceof BlockWall) return true;
    if (block instanceof BlockLog) return true;
    if (block.getMaterial() == Material.iron) {
        BlockPos pos = fenceLocation.toBlockPos();
        if (block.isBeaconBase(worldObj, pos, pos)) {
            return true;
        }
    }
    return false;
}
 
Example 32
Project: FusionWarfare   File: BlockNetworkBeacon.java   View source code 5 votes vote down vote up
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighborBlock) {
	
	boolean flag = false;

	if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z)	&& !BlockFence.func_149825_a(world.getBlock(x, y - 1, z))) {
		flag = true;
	}

	if (flag) {
		this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
		world.setBlockToAir(x, y, z);
	}
}
 
Example 33
Project: Minestrappolation-4   File: BlockRope.java   View source code 5 votes vote down vote up
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
	return worldIn.isSideSolid(pos.offset(EnumFacing.UP), EnumFacing.DOWN, true)
		       || worldIn.getBlockState(pos.offset(EnumFacing.UP)) == MBlocks.rope.getDefaultState() || worldIn
			                                                                                                .getBlockState(
				                                                                                                pos.offset(
					                                                                                                EnumFacing.UP))
			                                                                                                .getBlock() instanceof BlockFence;
}
 
Example 34
Project: Minestrappolation-4   File: BlockRope.java   View source code 5 votes vote down vote up
protected boolean canBlockStay(World worldIn, BlockPos pos, EnumFacing facing)
{
	return worldIn.isSideSolid(pos.offset(facing), facing.getOpposite(), true)
		       || worldIn.getBlockState(pos.offset(EnumFacing.UP)) == MBlocks.rope.getDefaultState() || worldIn
			                                                                                                .getBlockState(
				                                                                                                pos.offset(
					                                                                                                EnumFacing.UP))
			                                                                                                .getBlock() instanceof BlockFence;
}
 
Example 35
Project: Sophisticated-wolves   File: ItemWolfEgg.java   View source code 5 votes vote down vote up
/**
 * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
 * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
 */
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack item = player.getHeldItem(hand);

    if (world.isRemote) {
        return EnumActionResult.SUCCESS;
    } else {
        IBlockState block = world.getBlockState(blockPos);
        double d0 = 0;
        if (facing == EnumFacing.UP && block instanceof BlockFence) {
            d0 = 0.5;
        }

        blockPos = blockPos.offset(facing);
        Entity entity = spawnCreature(world, item.getItemDamage(), blockPos.getX() + 0.5, blockPos.getY() + d0, blockPos.getZ() + 0.5);
        if (entity != null) {
            if (entity instanceof EntityLivingBase && item.hasDisplayName()) {
                entity.setCustomNameTag(item.getDisplayName());
            }

            if (!player.capabilities.isCreativeMode) {
                item.shrink(1);
            }
        }

        return EnumActionResult.SUCCESS;
    }
}
 
Example 36
Project: ZeldaSwordSkills   File: EntityWhip.java   View source code 5 votes vote down vote up
/**
 * Returns true if the whip can grapple the block at the position
 */
protected boolean canGrabBlock(Block block, BlockPos pos, EnumFacing face) {
	if (block instanceof IWhipBlock) {
		return ((IWhipBlock) block).canGrabBlock(getType(), getThrower(), worldObj, pos, face);
	}
	switch (getType()) {
	case WHIP_MAGIC:
		// this excludes things like dirt, most plants, etc.
		if (block instanceof BlockSandStone || block instanceof BlockHugeMushroom || 
				(block.getMaterial().blocksMovement() && block.getBlockHardness(worldObj, pos) > 1.0F)) {
			return true;
		} // otherwise, fall through to standard case:
	case WHIP_SHORT:
	case WHIP_LONG:
		int clear = 0;
		if (isSideClear(pos.east()) && isSideClear(pos.west())) {
			++clear;
		}
		if (isSideClear(pos.up()) && isSideClear(pos.down())) {
			++clear;
		}
		if (isSideClear(pos.south()) && isSideClear(pos.north())) {
			++clear;
		}
		return (clear > 1 && (block instanceof BlockFence || block instanceof BlockLog ||
				block instanceof BlockLever || block instanceof BlockSign ||
				block instanceof BlockLadder));
	}
	return false;
}
 
Example 37
Project: RuneCraftery   File: BlockBasePressurePlate.java   View source code 5 votes vote down vote up
public void func_71863_a(World p_71863_1_, int p_71863_2_, int p_71863_3_, int p_71863_4_, int p_71863_5_) {
   boolean var6 = false;
   if(!p_71863_1_.func_72797_t(p_71863_2_, p_71863_3_ - 1, p_71863_4_) && !BlockFence.func_72249_c(p_71863_1_.func_72798_a(p_71863_2_, p_71863_3_ - 1, p_71863_4_))) {
      var6 = true;
   }

   if(var6) {
      this.func_71897_c(p_71863_1_, p_71863_2_, p_71863_3_, p_71863_4_, p_71863_1_.func_72805_g(p_71863_2_, p_71863_3_, p_71863_4_), 0);
      p_71863_1_.func_94571_i(p_71863_2_, p_71863_3_, p_71863_4_);
   }

}
 
Example 38
Project: RuneCraftery   File: RenderBlocks.java   View source code 5 votes vote down vote up
public boolean func_78612_b(Block p_78612_1_, int p_78612_2_, int p_78612_3_, int p_78612_4_) {
   int var5 = p_78612_1_.func_71857_b();
   if(var5 == -1) {
      return false;
   } else {
      p_78612_1_.func_71902_a(this.field_78669_a, p_78612_2_, p_78612_3_, p_78612_4_);
      this.func_83018_a(p_78612_1_);
      return var5 == 0?this.func_78570_q(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 4?this.func_78621_p(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 31?this.func_78581_r(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 1?this.func_78620_l(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 2?this.func_78572_c(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 20?this.func_78598_k(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 11?this.func_78582_a((BlockFence)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 39?this.func_96445_r(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 5?this.func_78589_i(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 13?this.func_78584_s(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 9?this.func_78586_a((BlockRailBase)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 19?this.func_78603_m(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 23?this.func_78566_o(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 6?this.func_78614_n(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 3?this.func_78590_h((BlockFire)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 8?this.func_78576_j(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 7?this.func_78601_u(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 10?this.func_78565_t((BlockStairs)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 27?this.func_78618_a((BlockDragonEgg)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 32?this.func_82779_a((BlockWall)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 12?this.func_78594_e(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 29?this.func_78577_f(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 30?this.func_78619_g(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 14?this.func_78574_w(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 15?this.func_78610_x((BlockRedstoneRepeater)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 36?this.func_94176_a((BlockRedstoneLogic)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 37?this.func_94171_a((BlockComparator)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 16?this.func_78593_b(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_, false):(var5 == 17?this.func_78608_c(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_, true):(var5 == 18?this.func_78592_a((BlockPane)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 21?this.func_78580_a((BlockFenceGate)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 24?this.func_78615_a((BlockCauldron)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 33?this.func_82780_a((BlockFlowerPot)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 35?this.func_82775_a((BlockAnvil)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 25?this.func_78585_a((BlockBrewingStand)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 26?this.func_78567_v((BlockEndPortalFrame)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 28?this.func_78616_a((BlockCocoa)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 34?this.func_82778_a((BlockBeacon)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):(var5 == 38?this.func_94172_a((BlockHopper)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_):false))))))))))))))))))))))))))))))))))))));
   }
}
 
Example 39
Project: OpenBlocks   File: BlockFlag.java   View source code 5 votes vote down vote up
private boolean isBaseSolidForFlag(World world, BlockPos pos) {
	final IBlockState belowState = world.getBlockState(pos.down());
	final Block belowBlock = belowState.getBlock();
	if (belowBlock instanceof BlockFence) return true;
	if (belowBlock == this && isFlagOnGround(belowState)) return true;

	return false;
}
 
Example 40
Project: OpenBlocks   File: MagnetWhitelists.java   View source code 5 votes vote down vote up
public void initTesters() {
	entityWhitelist.addTester(new ClassTester<Entity>(EntityItem.class));
	entityWhitelist.addTester(new ClassTester<Entity>(EntityBoat.class));
	entityWhitelist.addTester(new ClassTester<Entity>(EntityMinecart.class));
	MinecraftForge.EVENT_BUS.post(new EntityRegisterEvent(entityWhitelist));

	blockWhitelist.addTester(o -> {
		float hardness = o.blockState.getBlockHardness(o.world, o);
		return (hardness < 0)? Result.REJECT : Result.CONTINUE;
	});

	blockWhitelist.addTester(o -> o.blockState.getRenderType() == EnumBlockRenderType.MODEL? Result.ACCEPT : Result.CONTINUE);

	blockWhitelist.addTester(createBlockClassTester(BlockSand.class));
	blockWhitelist.addTester(createBlockClassTester(BlockStairs.class));
	blockWhitelist.addTester(createBlockClassTester(BlockFence.class));
	blockWhitelist.addTester(createBlockClassTester(BlockFenceGate.class));
	blockWhitelist.addTester(createBlockIdentityTester(Blocks.CACTUS));
	MinecraftForge.EVENT_BUS.post(new BlockRegisterEvent(blockWhitelist));

	tileEntityWhitelist
			.addTester(new ClassTester<TileEntity>(TileEntityBeacon.class))
			.addTester(new ClassTester<TileEntity>(TileEntityBrewingStand.class))
			.addTester(new ClassTester<TileEntity>(TileEntityChest.class))
			.addTester(new ClassTester<TileEntity>(TileEntityCommandBlock.class))
			.addTester(new ClassTester<TileEntity>(TileEntityDispenser.class))
			.addTester(new ClassTester<TileEntity>(TileEntityEnchantmentTable.class))
			.addTester(new ClassTester<TileEntity>(TileEntityEnderChest.class))
			.addTester(new ClassTester<TileEntity>(TileEntityFurnace.class))
			.addTester(new ClassTester<TileEntity>(TileEntityHopper.class))
			.addTester(new ClassTester<TileEntity>(TileEntityNote.class))
			.addTester(new ClassTester<TileEntity>(TileEntityJukebox.class));
}