Java Code Examples for net.minecraft.world.World#notifyBlocksOfNeighborChange()

The following examples show how to use net.minecraft.world.World#notifyBlocksOfNeighborChange() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemTranslocator.java    From Translocators with MIT License 6 votes vote down vote up
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
    Block block = world.getBlock(x, y, z);
    if (block != field_150939_a) {
        if (!world.canPlaceEntityOnSide(field_150939_a, x, y, z, false, side, null, stack))
            return false;

        if (!super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))
            return false;
    }

    TileTranslocator ttrans = (TileTranslocator) world.getTileEntity(x, y, z);
    if (ttrans.attachments[side ^ 1] != null)
        return false;

    ttrans.createAttachment(side ^ 1);
    world.notifyBlocksOfNeighborChange(x, y, z, block);
    world.markBlockForUpdate(x, y, z);
    return true;
}
 
Example 2
Source File: BlockDecorativePot.java    From GardenCollection with MIT License 6 votes vote down vote up
@Override
protected boolean applyItemToGarden (World world, int x, int y, int z, EntityPlayer player, ItemStack itemStack, float hitX, float hitY, float hitZ, boolean hitValid) {
    ItemStack item = (itemStack == null) ? player.inventory.getCurrentItem() : itemStack;

    if (item != null && item.getItem() == Items.flint_and_steel) {
        ItemStack substrate = getGardenSubstrate(world, x, y, z, Slot2Profile.SLOT_CENTER);
        if (substrate != null && substrate.getItem() == Item.getItemFromBlock(Blocks.netherrack)) {
            if (world.isAirBlock(x, y + 1, z)) {
                world.playSoundEffect(x + .5, y + .5, z + .5, "fire.ignite", 1, world.rand.nextFloat() * .4f + .8f);
                world.setBlock(x, y + 1, z, ModBlocks.smallFire);

                world.notifyBlocksOfNeighborChange(x, y, z, this);
                world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
            }

            item.damageItem(1, player);
            return true;
        }
    }

    return super.applyItemToGarden(world, x, y, z, player, itemStack, hitX, hitY, hitZ, hitValid);
}
 
Example 3
Source File: BlockLaserBeamSource.java    From Artifacts with MIT License 6 votes vote down vote up
public void notifyNeighborOfChange(World world, int x, int y, int z, int meta)
{
	int side = meta&3;
    world.notifyBlocksOfNeighborChange(x, y, z, this.instance);

    if (side == 3)
    {
        world.notifyBlocksOfNeighborChange(x - 1, y, z, this.instance);
    }
    else if (side == 1)
    {
        world.notifyBlocksOfNeighborChange(x + 1, y, z, this.instance);
    }
    else if (side == 0)
    {
        world.notifyBlocksOfNeighborChange(x, y, z - 1, this.instance);
    }
    else if (side == 2)
    {
        world.notifyBlocksOfNeighborChange(x, y, z + 1, this.instance);
    }
}
 
Example 4
Source File: BlockQuantumLogic.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
private void updateOutput( World world, int x, int y, int z )
{
    if( world.isRemote )
    {
        return;
    }

    // Redetermine subtype
    int metadata = world.getBlockMetadata( x, y, z );
    int direction = getDirection( metadata );
    int subType = getSubType( metadata );
    int newSubType = evaluateInput( world, x, y, z ) ? SubType.ObserverOn : SubType.ObserverOff;
    if( newSubType != subType )
    {
        // Set new subtype
        setDirectionAndSubType( world, x, y, z, direction, newSubType );
        subType = newSubType;

        // Notify
        world.markBlockForUpdate( x, y, z );
        world.notifyBlocksOfNeighborChange( x, y, z, this );
    }

    // Observe
    int facing = Facing.oppositeSide[ Direction.directionToFacing[ direction ] ];
    observe( world, x, y, z, facing, subType == SubType.ObserverOn );
}
 
Example 5
Source File: BlockDecorativePot.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public void breakBlock (World world, int x, int y, int z, Block block, int data) {
    if (isSconceLit(world, x, y, z)) {
        world.notifyBlocksOfNeighborChange(x, y, z, this);
        world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
    }

    super.breakBlock(world, x, y, z, block, data);
}
 
Example 6
Source File: BlockDecorativePot.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public void onNeighborBlockChange (World world, int x, int y, int z, Block block) {
    super.onNeighborBlockChange(world, x, y, z, block);

    if (block == ModBlocks.smallFire && world.getBlock(x, y + 1, z) != ModBlocks.smallFire) {
        world.notifyBlocksOfNeighborChange(x, y, z, this);
        world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
    }
}
 
Example 7
Source File: BlockLantern.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public void breakBlock (World world, int x, int y, int z, Block block, int data) {
    if (getRedstoneSource(world, x, y, z) != null) {
        world.notifyBlocksOfNeighborChange(x, y, z, this);
        world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
    }

    super.breakBlock(world, x, y, z, block, data);
}
 
Example 8
Source File: BlockLaserBeam.java    From Artifacts with MIT License 5 votes vote down vote up
private void notifyNeighborOfChange(World par1World, int par2, int par3, int par4)
{
    par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.instance);

    par1World.notifyBlocksOfNeighborChange(par2 - 1, par3, par4, this.instance);
    par1World.notifyBlocksOfNeighborChange(par2 + 1, par3, par4, this.instance);
    par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - 1, this.instance);
    par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + 1, this.instance);
}
 
Example 9
Source File: BlockWallPlate.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
protected void func_150064_a_(World world, int x, int y, int z)
{
	world.notifyBlocksOfNeighborChange(x+1, y, z, this);
	world.notifyBlocksOfNeighborChange(x-1, y, z, this);
	world.notifyBlocksOfNeighborChange(x, y, z+1, this);
	world.notifyBlocksOfNeighborChange(x, y, z-1, this);
	world.notifyBlocksOfNeighborChange(x, y, z, this);
}
 
Example 10
Source File: BlockLaserBeamSource.java    From Artifacts with MIT License 4 votes vote down vote up
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta)
{
    int l1 = meta & 3;
    boolean flag1 = (meta & 8) == 8;
    int offsetX = Direction.offsetX[l1];
    int offsetZ = Direction.offsetZ[l1];
    int l2;
    int i3;
    Block j3;
    int k3;
    boolean quitEarly = false;
    for (i3 = 1; i3 < 16 && !quitEarly; ++i3)
    {
    	l2 = x + offsetX * i3;
        k3 = z + offsetZ * i3;
        j3 = world.getBlock(l2, y, k3);
        if(j3 == BlockLaserBeam.instance) {
        	//world.setBlock(l2, y, k3, BlockLaserBeam.instance.blockID, 0, 3);
        	//world.scheduleBlockUpdate(l2, y, k3, this.blockID, 1);
        	world.setBlockToAir(l2, y, k3);
        	//System.out.println(l2 + "," + k3);
        }
        /*else if(world.isBlockOpaqueCube(l2, y, k3)) {
        	quitEarly = true;
        }
        else {
        	
        }*/
    }
    if (flag1)
    {
        world.notifyBlocksOfNeighborChange(x, y, z, this.instance);
        int j1 = meta & 3;

        if (j1 == 3)
        {
            world.notifyBlocksOfNeighborChange(x - 1, y, z, this.instance);
        }
        else if (j1 == 1)
        {
            world.notifyBlocksOfNeighborChange(x + 1, y, z, this.instance);
        }
        else if (j1 == 0)
        {
            world.notifyBlocksOfNeighborChange(x, y, z - 1, this.instance);
        }
        else if (j1 == 2)
        {
            world.notifyBlocksOfNeighborChange(x, y, z + 1, this.instance);
        }
    }
    super.breakBlock(world, x, y, z, block, meta);
}