Java Code Examples for net.minecraft.block.state.IBlockState

The following are top voted examples for showing how to use net.minecraft.block.state.IBlockState. 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: Infernum   File: BlockPedestal.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
		EnumFacing side, float hitX, float hitY, float hitZ) {

	if (!world.isRemote && world.getTileEntity(pos) instanceof TilePedestal) {
		TilePedestal pedestal = (TilePedestal) world.getTileEntity(pos);
		if (pedestal.getStack().func_190926_b()) {
			if (!player.getHeldItem(hand).func_190926_b()) {
				pedestal.setStack(player.getHeldItem(hand));
				player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.field_190927_a);
				player.openContainer.detectAndSendChanges();
			}
		} else {
			ItemStack stack = pedestal.getStack();
			pedestal.setStack(ItemStack.field_190927_a);
			if (!player.inventory.addItemStackToInventory(stack)) {
				EntityItem entityItem = new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), stack);
				world.spawnEntity(entityItem);
			} else {
				player.openContainer.detectAndSendChanges();
			}
		}
	}

	return true;
}
 
Example 2
Project: CustomWorldGen   File: ForgeHooks.java   Source Code and License 6 votes vote down vote up
public static float blockStrength(IBlockState state, EntityPlayer player, World world, BlockPos pos)
{
    float hardness = state.getBlockHardness(world, pos);
    if (hardness < 0.0F)
    {
        return 0.0F;
    }

    if (!canHarvestBlock(state.getBlock(), player, world, pos))
    {
        return player.getDigSpeed(state, pos) / hardness / 100F;
    }
    else
    {
        return player.getDigSpeed(state, pos) / hardness / 30F;
    }
}
 
Example 3
Project: ExPetrum   File: BlockSnow.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,	EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
	ItemStack itm = playerIn.getHeldItemMainhand();
	if (!itm.isEmpty() && itm.getItem() instanceof ItemBlock && Block.getBlockFromItem(itm.getItem()) == this && state.getValue(LAYERS) < 8)
	{
		if (!playerIn.capabilities.isCreativeMode)
		{
			itm.shrink(1);
		}
		
		worldIn.setBlockState(pos, state.cycleProperty(LAYERS));
		return true;
	}
	
	return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
 
Example 4
Project: BetterBeginningsReborn   File: BlockCampfire.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
    ItemStack heldItem = player.getHeldItem(hand);
    
    if (heldItem != ItemStack.EMPTY)
    {
        Item item = heldItem.getItem();

        if (item instanceof ItemFlintAndSteel || item instanceof ItemFireBow)
        {
            return false;
        }
    }

    player.openGui(ModMain.modInstance, BBGuiHandler.CAMPFIRE_ID, world, pos.getX(), pos.getY(), pos.getZ());

    return true;
}
 
Example 5
Project: CustomWorldGen   File: BlockTorch.java   Source Code and License 6 votes vote down vote up
/**
 * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
 * IBlockstate
 */
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
    if (this.canPlaceAt(worldIn, pos, facing))
    {
        return this.getDefaultState().withProperty(FACING, facing);
    }
    else
    {
        for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
        {
            if (worldIn.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true))
            {
                return this.getDefaultState().withProperty(FACING, enumfacing);
            }
        }

        return this.getDefaultState();
    }
}
 
Example 6
Project: BaseClient   File: BlockRailBase.java   Source Code and License 6 votes vote down vote up
private BlockRailBase.Rail findRailAt(BlockPos pos) {
	IBlockState iblockstate = this.world.getBlockState(pos);

	if (BlockRailBase.isRailBlock(iblockstate)) {
		return BlockRailBase.this.new Rail(this.world, pos, iblockstate);
	} else {
		BlockPos lvt_2_1_ = pos.up();
		iblockstate = this.world.getBlockState(lvt_2_1_);

		if (BlockRailBase.isRailBlock(iblockstate)) {
			return BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate);
		} else {
			lvt_2_1_ = pos.down();
			iblockstate = this.world.getBlockState(lvt_2_1_);
			return BlockRailBase.isRailBlock(iblockstate)
					? BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate) : null;
		}
	}
}
 
Example 7
Project: CustomWorldGen   File: BlockBanner.java   Source Code and License 6 votes vote down vote up
@Nullable
private ItemStack getTileDataItemStack(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityBanner)
    {
        ItemStack itemstack = new ItemStack(Items.BANNER, 1, ((TileEntityBanner)tileentity).getBaseColor());
        NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
        nbttagcompound.removeTag("x");
        nbttagcompound.removeTag("y");
        nbttagcompound.removeTag("z");
        nbttagcompound.removeTag("id");
        itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
        return itemstack;
    }
    else
    {
        return null;
    }
}
 
Example 8
Project: uniquecrops   File: EntityLivingBlock.java   Source Code and License 6 votes vote down vote up
@Override
public void onImpact(RayTraceResult result) {

	if (fallingTile == null) {
		this.setDead();
		return;
	}
	BlockPos pos = new BlockPos(result.hitVec);
	if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
		IBlockState state = worldObj.getBlockState(pos);
		if (!(state.getBlock() instanceof BlockCrops)) {
			worldObj.setBlockState(pos.offset(result.sideHit), fallingTile, 3);
			this.setDead();
			return;
		}
	}
	else this.setDead();
}
 
Example 9
Project: ModularMachinery   File: ItemConstructTool.java   Source Code and License 6 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if(!worldIn.isRemote && player.isCreative() && worldIn.getMinecraftServer().getPlayerList().canSendCommands(player.getGameProfile())) {
        IBlockState clicked = worldIn.getBlockState(pos);
        Block block = clicked.getBlock();
        if(block.equals(BlocksMM.blockController)) {
            PlayerStructureSelectionHelper.finalizeSelection(clicked.getValue(BlockController.FACING), worldIn, pos, player);

            PlayerStructureSelectionHelper.purgeSelection(player);
            PlayerStructureSelectionHelper.sendSelection(player);
        } else {
            PlayerStructureSelectionHelper.toggleInSelection(player, pos);
            PlayerStructureSelectionHelper.sendSelection(player);
        }
    }
    return EnumActionResult.SUCCESS;
}
 
Example 10
Project: ForgeHax   File: Markers.java   Source Code and License 6 votes vote down vote up
@Override
public void onBlockRenderInLoop(final RenderChunk renderChunk, final Block block, final IBlockState state, final BlockPos pos) {
    if(renderers != null) try {
        renderers.computeIfPresent(renderChunk, (chk, info) -> info.compute(() -> {
            GeometryTessellator tess = info.getTessellator();
            if (tess != null && FastReflection.Fields.BufferBuilder_isDrawing.get(tess.getBuffer(), false)) {
                BlockEntry blockEntry = options.get(state);
                if(blockEntry != null
                        && blockEntry.getReadableProperty(BoundProperty.class).isWithinBoundaries(pos.getY())) {
                    AxisAlignedBB bb = state.getSelectedBoundingBox(Helper.getWorld(), pos);
                    GeometryTessellator.drawLines(
                            tess.getBuffer(),
                            bb.minX, bb.minY, bb.minZ,
                            bb.maxX, bb.maxY, bb.maxZ,
                            GeometryMasks.Line.ALL,
                            blockEntry.getReadableProperty(ColorProperty.class).getAsBuffer()
                    );
                    info.incrementRenderCount();
                }
            }
        }));
    } catch (Exception e) {
        handleException(renderChunk, e);
    }
}
 
Example 11
Project: BaseClient   File: EntityLivingBase.java   Source Code and License 5 votes vote down vote up
protected void updateFallState(double y, boolean onGroundIn, Block blockIn, BlockPos pos)
{
    if (!this.isInWater())
    {
        this.handleWaterMovement();
    }

    if (!this.worldObj.isRemote && this.fallDistance > 3.0F && onGroundIn)
    {
        IBlockState iblockstate = this.worldObj.getBlockState(pos);
        Block block = iblockstate.getBlock();
        float f = (float)MathHelper.ceiling_float_int(this.fallDistance - 3.0F);

        if (block.getMaterial() != Material.air)
        {
            double d0 = (double)Math.min(0.2F + f / 15.0F, 10.0F);

            if (d0 > 2.5D)
            {
                d0 = 2.5D;
            }

            int i = (int)(150.0D * d0);
            ((WorldServer)this.worldObj).spawnParticle(EnumParticleTypes.BLOCK_DUST, this.posX, this.posY, this.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] {Block.getStateId(iblockstate)});
        }
    }

    super.updateFallState(y, onGroundIn, blockIn, pos);
}
 
Example 12
Project: ExPetrum   File: BlockLog.java   Source Code and License 5 votes vote down vote up
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list)
{
	for (int i = 0; i < 5; ++i)
	{
		IBlockState state = this.getDefaultState().withProperty(ExPBlockProperties.TREE_TYPE, EnumTreeType.values()[this.logIndex * 5 + i]);
		int meta = this.getMetaFromState(state);
		list.add(new ItemStack(this, 1, meta));
	}
}
 
Example 13
Project: CustomWorldGen   File: BlockFrostedIce.java   Source Code and License 5 votes vote down vote up
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
{
    if (blockIn == this)
    {
        int i = this.countNeighbors(worldIn, pos);

        if (i < 2)
        {
            this.turnIntoWater(worldIn, pos);
        }
    }
}
 
Example 14
Project: Thermionics   File: ItemHammer.java   Source Code and License 5 votes vote down vote up
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) {
	if (!(entityLiving instanceof EntityPlayer)) return super.onBlockDestroyed(stack, world, state, pos, entityLiving);
	EntityPlayer player = (EntityPlayer)entityLiving;
	
       if (!world.isRemote && state.getBlockHardness(world, pos) != 0) {
           stack.damageItem(1, player);
           
           ArrayList<BlockPos> crushGroup = new ArrayList<>();
           
           //check and break anything nearby of equal or lower hardness
           for(int z=-1; z<=1; z++) {
           	for(int y=-1; y<=1; y++) {
           		for(int x=-1; x<=1; x++) {
           			if (x==0 && y==0 && z==0) continue;
           			BlockPos crushLocation = pos.add(x, y, z);
           			IBlockState toCrush = world.getBlockState(crushLocation);
           			
           			if (toCrush.getBlockHardness(world, crushLocation) <= state.getBlockHardness(world, pos)) {
           				if (!BLACKLIST.contains(toCrush.getBlock())) {
            				crushGroup.add(crushLocation);
            				stack.damageItem(1, entityLiving);
           				}
           			}
           		}
           	}
           }
           
           for(BlockPos cur : crushGroup) {
           	if (player instanceof EntityPlayerMP) { //Should be true any time we reach this part of the code
   				ToolHelper.auxHarvestBlock(world, cur, (EntityPlayerMP)player);
   			}
           }
       }
       
       return true;
   }
 
Example 15
Project: CustomWorldGen   File: BlockRedstoneTorch.java   Source Code and License 5 votes vote down vote up
/**
 * Called after the block is set in the Chunk data, but before the Tile Entity is set
 */
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
    if (this.isOn)
    {
        for (EnumFacing enumfacing : EnumFacing.values())
        {
            worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this);
        }
    }
}
 
Example 16
Project: Bewitchment   File: BlockRagingGrass.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) {
	if (entityIn instanceof EntityLivingBase && (((EntityLivingBase) entityIn).getCreatureAttribute() == EnumCreatureAttribute.ARTHROPOD)) {
		entityIn.attackEntityFrom(DamageSource.MAGIC, 4);
	}
	if (entityIn instanceof EntityLivingBase && (((EntityLivingBase) entityIn).getCreatureAttribute() == EnumCreatureAttribute.UNDEAD)) {
		entityIn.attackEntityFrom(DamageSource.MAGIC, 4);
	}
}
 
Example 17
Project: Backmemed   File: TileEntityEndGateway.java   Source Code and License 5 votes vote down vote up
private static BlockPos findHighestBlock(World p_184308_0_, BlockPos p_184308_1_, int p_184308_2_, boolean p_184308_3_)
{
    BlockPos blockpos = null;

    for (int i = -p_184308_2_; i <= p_184308_2_; ++i)
    {
        for (int j = -p_184308_2_; j <= p_184308_2_; ++j)
        {
            if (i != 0 || j != 0 || p_184308_3_)
            {
                for (int k = 255; k > (blockpos == null ? 0 : blockpos.getY()); --k)
                {
                    BlockPos blockpos1 = new BlockPos(p_184308_1_.getX() + i, k, p_184308_1_.getZ() + j);
                    IBlockState iblockstate = p_184308_0_.getBlockState(blockpos1);

                    if (iblockstate.isBlockNormalCube() && (p_184308_3_ || iblockstate.getBlock() != Blocks.BEDROCK))
                    {
                        blockpos = blockpos1;
                        break;
                    }
                }
            }
        }
    }

    return blockpos == null ? p_184308_1_ : blockpos;
}
 
Example 18
Project: HardVox   File: OpLightUpdates.java   Source Code and License 5 votes vote down vote up
private int immediateLightCheck(Region region, PositionIterator chunk, World world, Chunk c, MutableVectorMap<IBlockState> hitMap) {
    int yMax = region.getMaximum().getY();
    // reset precipitation map
    for (int i = 0; i < 16; i++) {
        for (int j = 0; j < 16; j++) {
            BlockPos pos = new BlockPos((c.x << 4) + i, yMax, (c.z << 4) + j);
            c.setBlockState(pos, c.getBlockState(pos));
        }
    }
    // consume iterator
    int ops = chunk.forEachRemaining((x, y, z) -> {
        if (!hitMap.get(x, y, z).isPresent()) {
            return 0;
        }
        int opsIn = 0;
        for (int i = -16; i <= 16; i++) {
            for (int j = -16; j <= 16; j++) {
                for (int k = -16; k <= 16; k++) {
                    opsIn += enlightenBlocks(x + i, y + j, z + k, world) ? 1 : 0;
                }
            }
        }
        return opsIn;
    });

    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            ops += relightSky(region, c, i, j) ? CHUNK_SIZE : 0;
        }
    }

    return CHUNK_SIZE + ops;
}
 
Example 19
Project: harshencastle   File: PontusEmeraldOre.java   Source Code and License 5 votes vote down vote up
@Override
public boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, ParticleManager manager) {
	if(world != null && pos != null)
	if (world instanceof WorldServer)
		((WorldServer)world).spawnParticle(EnumParticleTypes.SMOKE_NORMAL, false, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 6,  0.5, 0.5, 0.6, 0, new int[EnumParticleTypes.SMOKE_NORMAL.getArgumentCount()]);
	return super.addHitEffects(state, worldObj, target, manager);
}
 
Example 20
Project: BaseClient   File: BlockPistonBase.java   Source Code and License 5 votes vote down vote up
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote && worldIn.getTileEntity(pos) == null)
    {
        this.checkForMove(worldIn, pos, state);
    }
}
 
Example 21
Project: CharcoalPit   File: BlockPotteryKiln.java   Source Code and License 5 votes vote down vote up
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
	if(state.getValue(TYPE)==EnumKilnTypes.EMPTY)
		return AABB_EMPTY;
	if(state.getValue(TYPE)==EnumKilnTypes.THATCH)
		return AABB_THATCH;
	return FULL_BLOCK_AABB;
}
 
Example 22
Project: BaseClient   File: BlockRedstoneComparator.java   Source Code and License 5 votes vote down vote up
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (this.isRepeaterPowered)
    {
        worldIn.setBlockState(pos, this.getUnpoweredState(state).withProperty(POWERED, Boolean.valueOf(true)), 4);
    }

    this.onStateChange(worldIn, pos, state);
}
 
Example 23
Project: BaseClient   File: BlockRailDetector.java   Source Code and License 5 votes vote down vote up
private void updatePoweredState(World worldIn, BlockPos pos, IBlockState state)
{
    boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue();
    boolean flag1 = false;
    List<EntityMinecart> list = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[0]);

    if (!list.isEmpty())
    {
        flag1 = true;
    }

    if (flag1 && !flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (!flag1 && flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)), 3);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (flag1)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }

    worldIn.updateComparatorOutputLevel(pos, this);
}
 
Example 24
Project: BaseClient   File: BlockBeacon.java   Source Code and License 5 votes vote down vote up
public static void updateColorAsync(final World worldIn, final BlockPos glassPos)
{
    HttpUtil.field_180193_a.submit(new Runnable()
    {
        public void run()
        {
            Chunk chunk = worldIn.getChunkFromBlockCoords(glassPos);

            for (int i = glassPos.getY() - 1; i >= 0; --i)
            {
                final BlockPos blockpos = new BlockPos(glassPos.getX(), i, glassPos.getZ());

                if (!chunk.canSeeSky(blockpos))
                {
                    break;
                }

                IBlockState iblockstate = worldIn.getBlockState(blockpos);

                if (iblockstate.getBlock() == Blocks.beacon)
                {
                    ((WorldServer)worldIn).addScheduledTask(new Runnable()
                    {
                        public void run()
                        {
                            TileEntity tileentity = worldIn.getTileEntity(blockpos);

                            if (tileentity instanceof TileEntityBeacon)
                            {
                                ((TileEntityBeacon)tileentity).updateBeacon();
                                worldIn.addBlockEvent(blockpos, Blocks.beacon, 1, 0);
                            }
                        }
                    });
                }
            }
        }
    });
}
 
Example 25
Project: Got-Wood   File: BlockBambooLog.java   Source Code and License 5 votes vote down vote up
protected final void checkAndDropBlock(World world, BlockPos pos, IBlockState state) {
	boolean drop = world.getBlockState(pos.down()).getBlock() != this && !world.getBlockState(pos.down()).isNormalCube();
	if (drop && !world.isRemote) {
		world.destroyBlock(pos, true);
		breakBlock(world, pos, state);
	}
}
 
Example 26
Project: Solar   File: BlockQimranut.java   Source Code and License 5 votes vote down vote up
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
	getTile(TileQimranut.class, world, pos).ifPresent(qimranut -> {
		ItemStack stack = getItem(world, pos, state);
		spawnAsEntity(world, pos, stack);
	});
	super.breakBlock(world, pos, state);
}
 
Example 27
Project: CustomWorldGen   File: StructureComponent.java   Source Code and License 5 votes vote down vote up
protected IBlockState getBlockStateFromPos(World worldIn, int x, int y, int z, StructureBoundingBox boundingboxIn)
{
    int i = this.getXWithOffset(x, z);
    int j = this.getYWithOffset(y);
    int k = this.getZWithOffset(x, z);
    BlockPos blockpos = new BlockPos(i, j, k);
    return !boundingboxIn.isVecInside(blockpos) ? Blocks.AIR.getDefaultState() : worldIn.getBlockState(blockpos);
}
 
Example 28
Project: BaseClient   File: BlockFurnace.java   Source Code and License 5 votes vote down vote up
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote)
    {
        Block block = worldIn.getBlockState(pos.north()).getBlock();
        Block block1 = worldIn.getBlockState(pos.south()).getBlock();
        Block block2 = worldIn.getBlockState(pos.west()).getBlock();
        Block block3 = worldIn.getBlockState(pos.east()).getBlock();
        EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);

        if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
        {
            enumfacing = EnumFacing.SOUTH;
        }
        else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
        {
            enumfacing = EnumFacing.NORTH;
        }
        else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
        {
            enumfacing = EnumFacing.EAST;
        }
        else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
        {
            enumfacing = EnumFacing.WEST;
        }

        worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
    }
}
 
Example 29
Project: BaseClient   File: BlockNewLeaf.java   Source Code and License 5 votes vote down vote up
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
 
Example 30
Project: Bewitchment   File: BlockRagingGrass.java   Source Code and License 5 votes vote down vote up
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) {
	if (state.getBlock() == this) {
		IBlockState soil = worldIn.getBlockState(pos.down());
		return soil.getBlock().canSustainPlant(soil, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this);
	}
	return this.canSustainBush(worldIn.getBlockState(pos.down()));
}
 
Example 31
Project: Backmemed   File: BlockDoublePlant.java   Source Code and License 5 votes vote down vote up
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
    {
        return worldIn.getBlockState(pos.down()).getBlock() == this;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos.up());
        return iblockstate.getBlock() == this && super.canBlockStay(worldIn, pos, iblockstate);
    }
}
 
Example 32
Project: Backmemed   File: BlockCommandBlock.java   Source Code and License 5 votes vote down vote up
/**
 * Called by ItemBlocks after a block is set in the world, to allow post-place logic
 */
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityCommandBlock)
    {
        TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)tileentity;
        CommandBlockBaseLogic commandblockbaselogic = tileentitycommandblock.getCommandBlockLogic();

        if (stack.hasDisplayName())
        {
            commandblockbaselogic.setName(stack.getDisplayName());
        }

        if (!worldIn.isRemote)
        {
            NBTTagCompound nbttagcompound = stack.getTagCompound();

            if (nbttagcompound == null || !nbttagcompound.hasKey("BlockEntityTag", 10))
            {
                commandblockbaselogic.setTrackOutput(worldIn.getGameRules().getBoolean("sendCommandFeedback"));
                tileentitycommandblock.setAuto(this == Blocks.CHAIN_COMMAND_BLOCK);
            }

            if (tileentitycommandblock.getMode() == TileEntityCommandBlock.Mode.SEQUENCE)
            {
                boolean flag = worldIn.isBlockPowered(pos);
                tileentitycommandblock.setPowered(flag);
            }
        }
    }
}
 
Example 33
Project: Backmemed   File: BlockEndPortal.java   Source Code and License 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
    if (!entityIn.isRiding() && !entityIn.isBeingRidden() && entityIn.isNonBoss() && !worldIn.isRemote && entityIn.getEntityBoundingBox().intersectsWith(state.getBoundingBox(worldIn, pos).offset(pos)))
    {
        entityIn.changeDimension(1);
    }
}
 
Example 34
Project: Backmemed   File: Template.java   Source Code and License 4 votes vote down vote up
public BlockInfo(BlockPos posIn, IBlockState stateIn, @Nullable NBTTagCompound compoundIn)
{
    this.pos = posIn;
    this.blockState = stateIn;
    this.tileentityData = compoundIn;
}
 
Example 35
Project: BaseClient   File: BlockRedstoneDiode.java   Source Code and License 4 votes vote down vote up
/**
 * Called randomly when setTickRandomly is set to true (used by e.g. crops to grow, etc.)
 */
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
{
}
 
Example 36
Project: Got-Wood   File: BlockWoodDoor.java   Source Code and License 4 votes vote down vote up
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
	return new ItemStack(getDoorItem());
}
 
Example 37
Project: Anima-Mundi   File: EntityBlockSuck.java   Source Code and License 4 votes vote down vote up
@Override
protected void entityInit()
{
	this.dataManager.register(STATE, Optional.<IBlockState>absent());
}
 
Example 38
Project: ExPetrum   File: BlockLeaf.java   Source Code and License 4 votes vote down vote up
@Override
public PathNodeType getAiPathNodeType(IBlockState state, IBlockAccess world, BlockPos pos)
{
	return PathNodeType.OPEN;
}
 
Example 39
Project: Firma   File: LeafBlock.java   Source Code and License 4 votes vote down vote up
@Override
public boolean isFullyOpaque(IBlockState state) {
	return false;
}
 
Example 40
Project: Zombe-Modpack   File: BlockFire.java   Source Code and License 4 votes vote down vote up
/**
 * Used to determine ambient occlusion and culling when rebuilding chunks for render
 */
public boolean isOpaqueCube(IBlockState state)
{
    return false;
}
 
Example 41
Project: BaseClient   File: EntityMinecart.java   Source Code and License 4 votes vote down vote up
public void func_174899_a(IBlockState p_174899_1_)
{
    this.getDataWatcher().updateObject(20, Integer.valueOf(Block.getStateId(p_174899_1_)));
    this.setHasDisplayTile(true);
}
 
Example 42
Project: BaseClient   File: BlockModelRenderer.java   Source Code and License 4 votes vote down vote up
public boolean renderModelAmbientOcclusion(IBlockAccess p_renderModelAmbientOcclusion_1_, IBakedModel p_renderModelAmbientOcclusion_2_, Block p_renderModelAmbientOcclusion_3_, IBlockState p_renderModelAmbientOcclusion_4_, BlockPos p_renderModelAmbientOcclusion_5_, WorldRenderer p_renderModelAmbientOcclusion_6_, boolean p_renderModelAmbientOcclusion_7_)
{
    boolean flag = false;
    RenderEnv renderenv = null;

    for (EnumFacing enumfacing : EnumFacing.VALUES)
    {
        List list = p_renderModelAmbientOcclusion_2_.getFaceQuads(enumfacing);

        if (!list.isEmpty())
        {
            BlockPos blockpos = p_renderModelAmbientOcclusion_5_.offset(enumfacing);

            if (!p_renderModelAmbientOcclusion_7_ || p_renderModelAmbientOcclusion_3_.shouldSideBeRendered(p_renderModelAmbientOcclusion_1_, blockpos, enumfacing))
            {
                if (renderenv == null)
                {
                    renderenv = RenderEnv.getInstance(p_renderModelAmbientOcclusion_1_, p_renderModelAmbientOcclusion_4_, p_renderModelAmbientOcclusion_5_);
                }

                if (!renderenv.isBreakingAnimation(list) && Config.isBetterGrass())
                {
                    list = BetterGrass.getFaceQuads(p_renderModelAmbientOcclusion_1_, p_renderModelAmbientOcclusion_3_, p_renderModelAmbientOcclusion_5_, enumfacing, list);
                }

                this.renderModelAmbientOcclusionQuads(p_renderModelAmbientOcclusion_1_, p_renderModelAmbientOcclusion_3_, p_renderModelAmbientOcclusion_5_, p_renderModelAmbientOcclusion_6_, list, renderenv);
                flag = true;
            }
        }
    }

    List list1 = p_renderModelAmbientOcclusion_2_.getGeneralQuads();

    if (list1.size() > 0)
    {
        if (renderenv == null)
        {
            renderenv = RenderEnv.getInstance(p_renderModelAmbientOcclusion_1_, p_renderModelAmbientOcclusion_4_, p_renderModelAmbientOcclusion_5_);
        }

        this.renderModelAmbientOcclusionQuads(p_renderModelAmbientOcclusion_1_, p_renderModelAmbientOcclusion_3_, p_renderModelAmbientOcclusion_5_, p_renderModelAmbientOcclusion_6_, list1, renderenv);
        flag = true;
    }

    if (renderenv != null && Config.isBetterSnow() && !renderenv.isBreakingAnimation() && BetterSnow.shouldRender(p_renderModelAmbientOcclusion_1_, p_renderModelAmbientOcclusion_3_, p_renderModelAmbientOcclusion_4_, p_renderModelAmbientOcclusion_5_))
    {
        IBakedModel ibakedmodel = BetterSnow.getModelSnowLayer();
        IBlockState iblockstate = BetterSnow.getStateSnowLayer();
        this.renderModelAmbientOcclusion(p_renderModelAmbientOcclusion_1_, ibakedmodel, iblockstate.getBlock(), iblockstate, p_renderModelAmbientOcclusion_5_, p_renderModelAmbientOcclusion_6_, true);
    }

    return flag;
}
 
Example 43
Project: Randores2   File: CraftiniumForge.java   Source Code and License 4 votes vote down vote up
@Override
public IBlockState withMirror(IBlockState state, Mirror mirrorIn) {
    return state.withRotation(mirrorIn.toRotation((EnumFacing) state.getValue(FACING)));
}
 
Example 44
Project: Bewitchment   File: BlockFakeIceSlab.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public boolean isBlockNormalCube(IBlockState state) {
	return false;
}
 
Example 45
Project: BaseClient   File: BlockWoodSlab.java   Source Code and License 4 votes vote down vote up
/**
 * Get the MapColor for this Block and the given BlockState
 */
public MapColor getMapColor(IBlockState state)
{
    return ((BlockPlanks.EnumType)state.getValue(VARIANT)).func_181070_c();
}
 
Example 46
Project: ExPetrum   File: BlockGenericShrubbery.java   Source Code and License 4 votes vote down vote up
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
{
    super.neighborChanged(state, worldIn, pos, blockIn, fromPos);
    this.checkGrowth(worldIn, pos);
}
 
Example 47
Project: Firma   File: ClayBlock.java   Source Code and License 4 votes vote down vote up
@Override
public IBlockState getStateFromMeta(int meta) {
	return getDefaultState().withProperty(properties, RockEnum.get(meta));
}
 
Example 48
Project: ExPetrum   File: BlockFarmland.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public IBlockState getStateFromMeta(int meta)
{
	return this.getDefaultState().withProperty(DIRT_CLASS, EnumDirtClass.values()[meta]);
}
 
Example 49
Project: BaseClient   File: BlockFlowerPot.java   Source Code and License 4 votes vote down vote up
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
    ItemStack itemstack = playerIn.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() instanceof ItemBlock)
    {
        TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);

        if (tileentityflowerpot == null)
        {
            return false;
        }
        else if (tileentityflowerpot.getFlowerPotItem() != null)
        {
            return false;
        }
        else
        {
            Block block = Block.getBlockFromItem(itemstack.getItem());

            if (!this.canNotContain(block, itemstack.getMetadata()))
            {
                return false;
            }
            else
            {
                tileentityflowerpot.setFlowerPotData(itemstack.getItem(), itemstack.getMetadata());
                tileentityflowerpot.markDirty();
                worldIn.markBlockForUpdate(pos);
                playerIn.triggerAchievement(StatList.field_181736_T);

                if (!playerIn.capabilities.isCreativeMode && --itemstack.stackSize <= 0)
                {
                    playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null);
                }

                return true;
            }
        }
    }
    else
    {
        return false;
    }
}
 
Example 50
Project: ModularMachinery   File: BlockFluidOutputHatch.java   Source Code and License 4 votes vote down vote up
@Override
public EnumBlockRenderType getRenderType(IBlockState state) {
    return EnumBlockRenderType.MODEL;
}
 
Example 51
Project: CustomWorldGen   File: BlockDragonEgg.java   Source Code and License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
{
    return true;
}
 
Example 52
Project: CustomWorldGen   File: BlockFurnace.java   Source Code and License 4 votes vote down vote up
/**
 * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
{
    return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
}
 
Example 53
Project: PurificatiMagicae   File: BlockAbstractWallIfTablet.java   Source Code and License 4 votes vote down vote up
private static boolean canAttachToBlock(World world, BlockPos pos, EnumFacing facing)
{
    IBlockState state = world.getBlockState(pos);
    return facing.getHorizontalIndex() != -1 && !isExceptBlockForAttachWithPiston(state.getBlock()) && state.getBlockFaceShape(world, pos, facing) == BlockFaceShape.SOLID;
}
 
Example 54
Project: ArcaneMagic   File: BlockModSlab.java   Source Code and License 4 votes vote down vote up
@Override
public int getMetaFromState(IBlockState state)
{
	return state.getValue(VARIANT).getMeta();
}
 
Example 55
Project: CustomWorldGen   File: BlockRedstoneDiode.java   Source Code and License 4 votes vote down vote up
public boolean isSameDiode(IBlockState state)
{
    Block block = state.getBlock();
    return block == this.getPoweredState(this.getDefaultState()).getBlock() || block == this.getUnpoweredState(this.getDefaultState()).getBlock();
}
 
Example 56
Project: CustomWorldGen   File: BlockEvent.java   Source Code and License 4 votes vote down vote up
@Deprecated
public MultiPlaceEvent(List<BlockSnapshot> blockSnapshots, IBlockState placedAgainst, EntityPlayer player)
{
    this(blockSnapshots, placedAgainst, player, null);
}
 
Example 57
Project: CustomWorldGen   File: BlockChorusFlower.java   Source Code and License 4 votes vote down vote up
/**
 * Convert the given metadata into a BlockState for this Block
 */
public IBlockState getStateFromMeta(int meta)
{
    return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
}
 
Example 58
Project: Backmemed   File: BlockStone.java   Source Code and License 4 votes vote down vote up
/**
 * Convert the BlockState into the correct metadata value
 */
public int getMetaFromState(IBlockState state)
{
    return ((BlockStone.EnumType)state.getValue(VARIANT)).getMetadata();
}
 
Example 59
Project: CustomWorldGen   File: BlockStem.java   Source Code and License 4 votes vote down vote up
/**
 * Convert the BlockState into the correct metadata value
 */
public int getMetaFromState(IBlockState state)
{
    return ((Integer)state.getValue(AGE)).intValue();
}
 
Example 60
Project: Randores2   File: RandoresItemArmor.java   Source Code and License 4 votes vote down vote up
@Override
public float getStrVsBlock(ItemStack stack, IBlockState state) {
    return this.delegate(stack, i -> i.getStrVsBlock(stack, state), () -> super.getStrVsBlock(stack, state));
}