Java Code Examples for net.minecraft.world.World.updateComparatorOutputLevel()

The following are Jave code examples for showing how to use updateComparatorOutputLevel() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Randores2   File: CraftiniumForge.java   Source Code and License Vote up 6 votes
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    if (!keepInventory) {
        TileEntity tileEntity = worldIn.getTileEntity(pos);
        if (tileEntity instanceof CraftiniumForgeTileEntity) {
            CraftiniumForgeTileEntity entity = (CraftiniumForgeTileEntity) tileEntity;
            InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), entity.getFuel().getStackInSlot(0));
            InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), entity.getOutput().getStackInSlot(0));
            InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), entity.getInput().getStackInSlot(0));

            if(!entity.isBrokenByCreative()) {
                List<ItemStack> drops = this.getDrops(worldIn, pos, state, 0);
                for (ItemStack stack : drops) {
                    spawnAsEntity(worldIn, pos, stack);
                }
            }
            worldIn.updateComparatorOutputLevel(pos, this);
        }
    }

    super.breakBlock(worldIn, pos, state);
}
 
Example 2
Project: Backmemed   File: BlockFurnace.java   Source Code and License Vote up 6 votes
/**
 * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
 */
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    if (!keepInventory)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityFurnace)
        {
            InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityFurnace)tileentity);
            worldIn.updateComparatorOutputLevel(pos, this);
        }
    }

    super.breakBlock(worldIn, pos, state);
}
 
Example 3
Project: Thermionics   File: BlockMachineBase.java   Source Code and License Vote up 6 votes
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
       TileEntity tileentity = worldIn.getTileEntity(pos);
       
       if (tileentity!=null && tileentity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
       	IItemHandler inventory = tileentity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
       	for (int i=0; i<inventory.getSlots(); i++) {
               ItemStack itemstack = inventory.getStackInSlot(i);

               if (!itemstack.isEmpty()) {
                   InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), itemstack);
               }
           }
       	worldIn.updateComparatorOutputLevel(pos, this);
       }
       super.breakBlock(worldIn, pos, state);
   }
 
Example 4
Project: interactionwheel   File: InventoryHelper.java   Source Code and License Vote up 5 votes
public static void emptyInventoryInWorld(World world, BlockPos pos, Block block, IInventory inventory) {
        for (int i = 0; i < inventory.getSizeInventory(); ++i) {
            ItemStack itemstack = inventory.getStackInSlot(i);
            spawnItemStack(world, pos, itemstack);
            inventory.setInventorySlotContents(i, ItemStackTools.getEmptyStack());
        }

        world.updateComparatorOutputLevel(pos, block);
//        world.func_147453_f(x, y, z, block);
    }
 
Example 5
Project: GardenStuff   File: BlockBloomeryFurnace.java   Source Code and License Vote up 5 votes
@Override
public void breakBlock (World world, BlockPos pos, IBlockState state) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileBloomeryFurnace) {
        InventoryHelper.dropInventoryItems(world, pos, (TileBloomeryFurnace)tile);
        world.updateComparatorOutputLevel(pos, this);
    }

    super.breakBlock(world, pos, state);
}
 
Example 6
Project: Backmemed   File: BlockChest.java   Source Code and License Vote up 5 votes
/**
 * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
 */
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof IInventory)
    {
        InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileentity);
        worldIn.updateComparatorOutputLevel(pos, this);
    }

    super.breakBlock(worldIn, pos, state);
}
 
Example 7
Project: BaseClient   File: BlockRailDetector.java   Source Code and License Vote up 5 votes
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 8
Project: DecompiledMinecraft   File: BlockRailDetector.java   Source Code and License Vote up 5 votes
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 9
Project: CustomWorldGen   File: BlockHopper.java   Source Code and License Vote up 5 votes
/**
 * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
 */
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityHopper)
    {
        InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityHopper)tileentity);
        worldIn.updateComparatorOutputLevel(pos, this);
    }

    super.breakBlock(worldIn, pos, state);
}
 
Example 10
Project: DecompiledMinecraft   File: BlockHopper.java   Source Code and License Vote up 5 votes
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityHopper)
    {
        InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityHopper)tileentity);
        worldIn.updateComparatorOutputLevel(pos, this);
    }

    super.breakBlock(worldIn, pos, state);
}
 
Example 11
Project: Clef   File: BlockInstrumentPlayer.java   Source Code and License Vote up 5 votes
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityInstrumentPlayer)
    {
        InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityInstrumentPlayer)tileentity);
        worldIn.updateComparatorOutputLevel(pos, this);
    }

    super.breakBlock(worldIn, pos, state);
}
 
Example 12
Project: DecompiledMinecraft   File: BlockDispenser.java   Source Code and License Vote up 5 votes
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityDispenser)
    {
        InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityDispenser)tileentity);
        worldIn.updateComparatorOutputLevel(pos, this);
    }

    super.breakBlock(worldIn, pos, state);
}
 
Example 13
Project: Mods   File: BlockAmmoFurnace.java   Source Code and License Vote up 5 votes
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
	TileEntity tileentity = worldIn.getTileEntity(pos);

	if (tileentity instanceof TileEntityAmmoFurnace) {
		InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityAmmoFurnace) tileentity);
		worldIn.updateComparatorOutputLevel(pos, this);
	}

	super.breakBlock(worldIn, pos, state);
}
 
Example 14
Project: BaseClient   File: BlockDispenser.java   Source Code and License Vote up 5 votes
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityDispenser)
    {
        InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityDispenser)tileentity);
        worldIn.updateComparatorOutputLevel(pos, this);
    }

    super.breakBlock(worldIn, pos, state);
}
 
Example 15
Project: CustomWorldGen   File: BlockDispenser.java   Source Code and License Vote up 5 votes
/**
 * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
 */
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityDispenser)
    {
        InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityDispenser)tileentity);
        worldIn.updateComparatorOutputLevel(pos, this);
    }

    super.breakBlock(worldIn, pos, state);
}
 
Example 16
Project: BaseClient   File: BlockFurnace.java   Source Code and License Vote up 5 votes
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    if (!keepInventory)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityFurnace)
        {
            InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityFurnace)tileentity);
            worldIn.updateComparatorOutputLevel(pos, this);
        }
    }

    super.breakBlock(worldIn, pos, state);
}
 
Example 17
Project: morefurnaces   File: BlockMoreFurnaces.java   Source Code and License Vote up 5 votes
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
    TileEntity te = world.getTileEntity(pos);
    if (te instanceof IInventory)
    {
        InventoryHelper.dropInventoryItems(world, pos, (IInventory) te);
        world.updateComparatorOutputLevel(pos, this);
    }

    super.breakBlock(world, pos, state);
}
 
Example 18
Project: Backmemed   File: BlockCauldron.java   Source Code and License Vote up 4 votes
public void setWaterLevel(World worldIn, BlockPos pos, IBlockState state, int level)
{
    worldIn.setBlockState(pos, state.withProperty(LEVEL, Integer.valueOf(MathHelper.clamp(level, 0, 3))), 2);
    worldIn.updateComparatorOutputLevel(pos, this);
}
 
Example 19
Project: CustomWorldGen   File: ItemEnderEye.java   Source Code and License Vote up 4 votes
/**
 * 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)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && iblockstate.getBlock() == Blocks.END_PORTAL_FRAME && !((Boolean)iblockstate.getValue(BlockEndPortalFrame.EYE)).booleanValue())
    {
        if (worldIn.isRemote)
        {
            return EnumActionResult.SUCCESS;
        }
        else
        {
            worldIn.setBlockState(pos, iblockstate.withProperty(BlockEndPortalFrame.EYE, Boolean.valueOf(true)), 2);
            worldIn.updateComparatorOutputLevel(pos, Blocks.END_PORTAL_FRAME);
            --stack.stackSize;

            for (int i = 0; i < 16; ++i)
            {
                double d0 = (double)((float)pos.getX() + (5.0F + itemRand.nextFloat() * 6.0F) / 16.0F);
                double d1 = (double)((float)pos.getY() + 0.8125F);
                double d2 = (double)((float)pos.getZ() + (5.0F + itemRand.nextFloat() * 6.0F) / 16.0F);
                double d3 = 0.0D;
                double d4 = 0.0D;
                double d5 = 0.0D;
                worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
            }

            BlockPattern.PatternHelper blockpattern$patternhelper = BlockEndPortalFrame.getOrCreatePortalShape().match(worldIn, pos);

            if (blockpattern$patternhelper != null)
            {
                BlockPos blockpos = blockpattern$patternhelper.getFrontTopLeft().add(-3, 0, -3);

                for (int j = 0; j < 3; ++j)
                {
                    for (int k = 0; k < 3; ++k)
                    {
                        worldIn.setBlockState(blockpos.add(j, 0, k), Blocks.END_PORTAL.getDefaultState(), 2);
                    }
                }
            }

            return EnumActionResult.SUCCESS;
        }
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
 
Example 20
Project: Backmemed   File: BlockCommandBlock.java   Source Code and License Vote up 4 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (!worldIn.isRemote)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityCommandBlock)
        {
            TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)tileentity;
            CommandBlockBaseLogic commandblockbaselogic = tileentitycommandblock.getCommandBlockLogic();
            boolean flag = !StringUtils.isNullOrEmpty(commandblockbaselogic.getCommand());
            TileEntityCommandBlock.Mode tileentitycommandblock$mode = tileentitycommandblock.getMode();
            boolean flag1 = !tileentitycommandblock.isConditional() || this.isNextToSuccessfulCommandBlock(worldIn, pos, state);
            boolean flag2 = tileentitycommandblock.isConditionMet();
            boolean flag3 = false;

            if (tileentitycommandblock$mode != TileEntityCommandBlock.Mode.SEQUENCE && flag2 && flag)
            {
                commandblockbaselogic.trigger(worldIn);
                flag3 = true;
            }

            if (tileentitycommandblock.isPowered() || tileentitycommandblock.isAuto())
            {
                if (tileentitycommandblock$mode == TileEntityCommandBlock.Mode.SEQUENCE && flag1 && flag)
                {
                    commandblockbaselogic.trigger(worldIn);
                    flag3 = true;
                }

                if (tileentitycommandblock$mode == TileEntityCommandBlock.Mode.AUTO)
                {
                    worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));

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

            if (!flag3)
            {
                commandblockbaselogic.setSuccessCount(0);
            }

            tileentitycommandblock.setConditionMet(flag1);
            worldIn.updateComparatorOutputLevel(pos, this);
        }
    }
}