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

The following examples show how to use net.minecraft.world.World#markBlockForUpdate() . These examples are extracted from open source projects. 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
public int onWandRightClick(World world, ItemStack wandstack, EntityPlayer player, int x, int y, int z, int side, int md) {
    if (!world.isRemote) {
        this.drop = false;
        world.setBlock(x, y, z, ConfigBlocks.blockAiry, 0, 3);
        TileExtendedNode tn = (TileExtendedNode) world.getTileEntity(x, y, z);
        if (tn != null) {
            tn.setAspects(getAspects());
            tn.setNodeModifier(getNodeModifier());
            tn.setNodeType(getNodeType());
            tn.setExtendedNodeType(getExtendedNodeType());
            new Injector(tn, TileNode.class).setField("id", getId());
            tn.readBehaviorSnapshot(getBehaviorSnapshot());
            world.markBlockForUpdate(x, y, z);
            tn.markDirty();
        }
    }
    world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(ConfigBlocks.blockJar) + 61440);
    player.worldObj.playSound(x + 0.5D, y + 0.5D, z + 0.5D, "random.glass", 1.0F, 0.9F + player.worldObj.rand.nextFloat() * 0.2F, false);
    player.swingItem();
    return 0;
}
 
Example 2
Source Project: Translocators   File: ItemTranslocator.java    License: 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 3
Source Project: GardenCollection   File: BlockLargePot.java    License: MIT License 6 votes vote down vote up
@Override
protected boolean applySubstrateToGarden (World world, int x, int y, int z, EntityPlayer player, int slot, ItemStack itemStack) {
    if (getGardenSubstrate(world, x, y, z, slot) != null)
        return false;

    if (itemStack.getItem() == Items.water_bucket) {
        TileEntityGarden garden = getTileEntity(world, x, y, z);
        garden.setSubstrate(new ItemStack(Blocks.water));
        garden.markDirty();

        if (player != null && !player.capabilities.isCreativeMode)
            player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.bucket));

        world.markBlockForUpdate(x, y, z);
        return true;
    }

    return super.applySubstrateToGarden(world, x, y, z, player, slot, itemStack);
}
 
Example 4
Source Project: GardenCollection   File: BlockLargePot.java    License: MIT License 6 votes vote down vote up
protected boolean applyHoeToSubstrate (World world, int x, int y, int z, TileEntityGarden tile, EntityPlayer player) {
    Block substrate = Block.getBlockFromItem(tile.getSubstrate().getItem());
    if (substrate == Blocks.dirt || substrate == Blocks.grass)
        tile.setSubstrate(new ItemStack(Blocks.farmland, 1, 7), new ItemStack(Blocks.dirt, 1, tile.getSubstrate().getItemDamage()));
    else if (substrate == ModBlocks.gardenSoil)
        tile.setSubstrate(new ItemStack(ModBlocks.gardenFarmland), new ItemStack(ModBlocks.gardenSoil));
    else
        return false;

    tile.markDirty();

    world.markBlockForUpdate(x, y, z);
    world.playSoundEffect(x + .5f, y + .5f, z + .5f, Blocks.farmland.stepSound.getStepResourcePath(),
        (Blocks.farmland.stepSound.getVolume() + 1) / 2f, Blocks.farmland.stepSound.getPitch() * .8f);

    return true;
}
 
Example 5
Source Project: GardenCollection   File: BlockGarden.java    License: MIT License 6 votes vote down vote up
protected boolean applyTestKitToGarden (World world, int x, int y, int z, int slot, ItemStack testKit) {
    if (testKit == null || testKit.getItem() != ModItems.usedSoilTestKit)
        return false;

    ItemStack substrateStack = getGardenSubstrate(world, x, y, z, slot);
    if (substrateStack == null || substrateStack.getItem() == null)
        return false;

    TileEntityGarden tileEntity = getTileEntity(world, x, y, z);
    if (tileEntity == null)
        return false;

    tileEntity.setBiomeData(testKit.getItemDamage());
    world.markBlockForUpdate(x, y, z);

    for (int i = 0; i < 5; i++) {
        double d0 = world.rand.nextGaussian() * 0.02D;
        double d1 = world.rand.nextGaussian() * 0.02D;
        double d2 = world.rand.nextGaussian() * 0.02D;
        world.spawnParticle("happyVillager", x + world.rand.nextFloat(), y + .5f + world.rand.nextFloat(), z + world.rand.nextFloat(), d0, d1, d2);
    }

    return true;
}
 
Example 6
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) {
    if(world.getBlockMetadata(x, y, z) != 1) {
        Block up = world.getBlock(x, y + 1, z);
        return up != null && up instanceof BlockAuraPylon && up.onBlockActivated(world, x, y + 1, z, player, side, par7, par8, par9);
    }
    ItemStack heldItem = player.getHeldItem();
    if(!world.isRemote && heldItem != null && heldItem.getItem() instanceof ItemWandCasting &&
            ResearchManager.isResearchComplete(player.getCommandSenderName(), Gadomancy.MODID.toUpperCase() + ".AURA_PYLON")) {
        TileAuraPylon tileAuraPylon = (TileAuraPylon) world.getTileEntity(x, y - 1, z);
        if(MultiblockHelper.isMultiblockPresent(world, x, y, z, RegisteredMultiblocks.auraPylonPattern) &&
                !tileAuraPylon.isPartOfMultiblock() &&
                ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsAuraPylonMultiblock, true)) {
            PacketStartAnimation pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, x, y, z);
            NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32);
            PacketHandler.INSTANCE.sendToAllAround(pkt, point);
            TileAuraPylon ta = (TileAuraPylon) world.getTileEntity(x, y - 1, z);
            ta.setTileInformation(true, false);
            ta = (TileAuraPylon) world.getTileEntity(x, y - 3, z);
            ta.setTileInformation(false, true);
            int count = 1;
            TileEntity iter = world.getTileEntity(x, y - count, z);
            while(iter != null && iter instanceof TileAuraPylon) {
                ((TileAuraPylon) iter).setPartOfMultiblock(true);
                world.markBlockForUpdate(x, y - count, z);
                iter.markDirty();
                pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, x, y - count, z);
                PacketHandler.INSTANCE.sendToAllAround(pkt, point);
                count++;
                iter = world.getTileEntity(x, y - count, z);
            }
        }
    }
    return false;
}
 
Example 7
public void breakThisBlock(World world, int x, int y, int z) {
    if(world.isRemote) return;
    ArrayList<ItemStack> stacks = getDrops(world, x, y, z, 0, 0);
    for(ItemStack i : stacks) {
        EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, i);
        world.spawnEntityInWorld(item);
    }

    world.removeTileEntity(x, y, z);
    world.setBlockToAir(x, y, z);
    world.markBlockForUpdate(x, y, z);
}
 
Example 8
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    ForgeDirection dir = ForgeDirection.getOrientation(side);
    x += dir.offsetX;
    y += dir.offsetY;
    z += dir.offsetZ;

    if(placeRandomNode(world, x, y, z)) {
        int metadata = stack.getItemDamage();
        TileNode node = (TileNode) world.getTileEntity(x, y, z);

        if(metadata == 0) {
            node.setNodeType(NodeType.NORMAL);
            node.setNodeModifier(NodeModifier.BRIGHT);

            AspectList aspects = new AspectList();
            for(Aspect primal : Aspect.getPrimalAspects()) {
                aspects.add(primal, 500);
            }
            node.setAspects(aspects);
            node.markDirty();
            world.markBlockForUpdate(x, y, z);
        } else {
            node.setNodeType(NodeType.values()[metadata]);
        }

        return true;
    }
    return false;
}
 
Example 9
Source Project: qcraft-mod   File: BlockQuantumLogic.java    License: 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 10
@Override
protected void generate(World world, int x, int y, int z) {
	System.out.println("Making grid dungeon at " + x + "," + y + "," + z);
	int w = 10;
	for (int ax = 0; ax < w; ax++) {
		for (int az = 0; az < w; az++) {
			world.setBlock(x+ax, y+0, z+az, Block.getBlockById(7));
			world.markBlockForUpdate(x+ax, y+0, z+az);
		}
	}
	for (int ax = 0; ax < w; ax++) {
		world.setBlock(x+ax, y+0, z+0, Block.getBlockById(7));
		world.setBlock(x+ax, y+1, z+0, Block.getBlockById(7));
		world.setBlock(x+ax, y+2, z+0, Block.getBlockById(7));
		world.setBlock(x+ax, y+0, z+w, Block.getBlockById(7));
		world.setBlock(x+ax, y+1, z+w, Block.getBlockById(7));
		world.setBlock(x+ax, y+2, z+w, Block.getBlockById(7));
	}	

	for (int az = 0; az < w; az++) {
		world.setBlock(x+0, y+0, z+az, Block.getBlockById(7));
		world.setBlock(x+0, y+1, z+az, Block.getBlockById(7));
		world.setBlock(x+0, y+2, z+az, Block.getBlockById(7));
		world.setBlock(x+w, y+0, z+az, Block.getBlockById(7));
		world.setBlock(x+w, y+1, z+az, Block.getBlockById(7));
		world.setBlock(x+w, y+2, z+az, Block.getBlockById(7));
	}
	world.setBlock(x + w-1, y+0, z+ w-1, Block.getBlockById(41));


}
 
Example 11
Source Project: OpenPeripheral-Addons   File: BlockPIM.java    License: MIT License 5 votes vote down vote up
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
	world.markBlockForUpdate(x, y, z);
	if (!world.isRemote && entity instanceof EntityPlayer) {
		TileEntityPIM pi = getTileEntity(world, x, y, z, TileEntityPIM.class);
		if (pi != null) pi.trySetPlayer((EntityPlayer)entity);
	}
}
 
Example 12
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
	super.onBlockPlacedBy(world, x, y, z, player, stack);
	int heading = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
	TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z);
	world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3);
	te.setRotation(heading);
	te.findConnections();
	if (te.isConnected()) {
		TileEntityPresent other = te.getConnection();
		other.setRotation(heading);
	}
	world.markBlockForUpdate(x, y, z);
}
 
Example 13
Source Project: GardenCollection   File: BlockWindowBox.java    License: MIT License 5 votes vote down vote up
@Override
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
    TileEntityWindowBox te = (TileEntityWindowBox) world.getTileEntity(x, y, z);
    if (te == null || te.getDirection() != 0)
        return;

    int quadrant = MathHelper.floor_double((entity.rotationYaw * 4f / 360f) + .5) & 3;
    switch (quadrant) {
        case 0:
            te.setDirection(3);
            break;
        case 1:
            te.setDirection(4);
            break;
        case 2:
            te.setDirection(2);
            break;
        case 3:
            te.setDirection(5);
            break;
    }

    if (world.isRemote) {
        te.invalidate();
        world.markBlockForUpdate(x, y, z);
    }
}
 
Example 14
Source Project: GardenCollection   File: BlockLargePot.java    License: MIT License 5 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)
        return false;

    TileEntityGarden garden = getTileEntity(world, x, y, z);

    if (garden.getSubstrate() != null) {
        if (item.getItem() == Items.bucket) {
            if (Block.getBlockFromItem(garden.getSubstrate().getItem()) == Blocks.water) {
                player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.water_bucket));
                garden.setSubstrate(null);
                garden.markDirty();
                world.markBlockForUpdate(x, y, z);
            }
            return true;
        }

        if (item.getItem() == Items.water_bucket) {
            applyWaterToSubstrate(world, x, y, z, garden, player);
            return true;
        }
        else if (item.getItem() instanceof ItemHoe) {
            applyHoeToSubstrate(world, x, y, z, garden, player);
            return true;
        }
    }

    return super.applyItemToGarden(world, x, y, z, player, itemStack, hitX, hitY, hitZ, hitValid);
}
 
Example 15
Source Project: GardenCollection   File: BlockLargePot.java    License: MIT License 5 votes vote down vote up
protected void applyWaterToSubstrate (World world, int x, int y, int z, TileEntityGarden tile, EntityPlayer player) {
    if (Block.getBlockFromItem(tile.getSubstrate().getItem()) == Blocks.dirt) {
        tile.setSubstrate(new ItemStack(Blocks.farmland, 1, 7), new ItemStack(Blocks.dirt, 1, tile.getSubstrate().getItemDamage()));
        tile.markDirty();

        world.markBlockForUpdate(x, y, z);
    }
}
 
Example 16
@Override
public void onHackFinished(World world, int x, int y, int z, EntityPlayer player){
    if(!world.isRemote) {
        NBTTagCompound tag = new NBTTagCompound();
        TileEntity te = world.getTileEntity(x, y, z);
        te.writeToNBT(tag);
        tag.setShort("RequiredPlayerRange", (short)0);
        te.readFromNBT(tag);
        world.markBlockForUpdate(x, y, z);
    }

}
 
Example 17
Source Project: GardenCollection   File: BlockCompostBin.java    License: MIT License 5 votes vote down vote up
public static void updateBlockState (World world, int x, int y, int z) {
    TileEntityCompostBin te = (TileEntityCompostBin) world.getTileEntity(x, y, z);
    if (te == null)
        return;

    world.markBlockForUpdate(x, y, z);
    //world.func_147479_m(x, y, z);
}
 
Example 18
Source Project: GardenCollection   File: BlockCandelabra.java    License: MIT License 5 votes vote down vote up
@Override
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
    TileEntityCandelabra te = (TileEntityCandelabra) world.getTileEntity(x, y, z);
    if (te == null || te.isDirectionInitialized())
        return;

    int quadrant = MathHelper.floor_double((entity.rotationYaw * 4f / 360f) + .5) & 3;
    switch (quadrant) {
        case 0:
            te.setDirection(3);
            break;
        case 1:
            te.setDirection(4);
            break;
        case 2:
            te.setDirection(2);
            break;
        case 3:
            te.setDirection(5);
            break;
    }

    if (world.isRemote) {
        te.invalidate();
        world.markBlockForUpdate(x, y, z);
    }
}
 
Example 19
@Override
protected void generate(World world, int x, int y, int z) {
	System.out.println("Making maze1 dungeon at " + x + "," + y + "," + z);
	
	int internalWidth = 12;
	int w = internalWidth+1;
	
	// floor
	for (int ax = 0; ax <= w; ax++) {
		for (int az = 0; az <= w; az++) {
			world.setBlock(x+ax, y+0, z+az, Block.getBlockById(7));

			world.setBlock(x+ax, y-1, z+az, Block.getBlockById(152));
			world.setBlock(x+ax, y-2, z+az, Block.getBlockById(123));


			world.markBlockForUpdate(x+ax, y+0, z+az);
			world.markBlockForUpdate(x+ax, y-1, z+az);
		}
	}

	// walls
	for (int ax = 0; ax <= w; ax++) {
		world.setBlock(x+ax, y+0, z+0, Block.getBlockById(7));
		world.setBlock(x+ax, y+1, z+0, Block.getBlockById(7));
		world.setBlock(x+ax, y+2, z+0, Block.getBlockById(7));
		world.setBlock(x+ax, y+0, z+w, Block.getBlockById(7));
		world.setBlock(x+ax, y+1, z+w, Block.getBlockById(7));
		world.setBlock(x+ax, y+2, z+w, Block.getBlockById(7));
	}	
	for (int az = 0; az <= w; az++) {
		world.setBlock(x+0, y+0, z+az, Block.getBlockById(7));
		world.setBlock(x+0, y+1, z+az, Block.getBlockById(7));
		world.setBlock(x+0, y+2, z+az, Block.getBlockById(7));
		world.setBlock(x+w, y+0, z+az, Block.getBlockById(7));
		world.setBlock(x+w, y+1, z+az, Block.getBlockById(7));
		world.setBlock(x+w, y+2, z+az, Block.getBlockById(7));
	}
	
	// goal
	world.setBlock(x + 1, y+0, z+ w-1, Block.getBlockById(41));
	
	// maze
	String mazeMap = "001000111010" +
					 "000010010010" +
					 "001000100112" +
					 "011121001000" +
					 "100000001011" +
					 "101110101000" +
					 "100011101211" +
					 "111010100001" +
					 "001200111101" +
					 "010010100002" +
					 "000010101210" +
					 "000010001000";
	
	for (int ax = 1; ax <= internalWidth; ax++) {
		for (int az = 1; az <= internalWidth; az++) {
			int tZ = az-1; // 0 to internalWidth-1
			int mZ = internalWidth-tZ-1; // internalWidth-1 to 0
			int tX = ax-1; // 0 to internalWidth-1
			int mX = internalWidth-tX-1; // internalWidth-1 to 0
			if (mazeMap.charAt(mZ*internalWidth + mX) == '1') {
				world.setBlock(x+ax, y+0, z+az, Block.getBlockById(7));
				world.setBlock(x+ax, y+1, z+az, Block.getBlockById(7));
				world.setBlock(x+ax, y+2, z+az, Block.getBlockById(7));
				//world.setBlock(x+ax, y+3, z+az, Block.getBlockById(7));
				//world.setBlock(x+ax, y+3, z+az, Block.getBlockById(50));
			} else if (mazeMap.charAt(mZ*internalWidth + mX) == '2') {
				world.setBlock(x+ax, y+1, z+az, BurlapCraft.burlapStone);
			} else {
				// do nothing
			}
		}
	}
	


}
 
Example 20
@Override
protected void generate(World world, int x, int y, int z) {
	System.out.println("Making maze0 dungeon at " + x + "," + y + "," + z);
	
	int internalWidth = 12;
	int w = internalWidth+1;
	
	// floor
	for (int ax = 0; ax <= w; ax++) {
		for (int az = 0; az <= w; az++) {
			world.setBlock(x+ax, y+0, z+az, Block.getBlockById(7));
			world.markBlockForUpdate(x+ax, y+0, z+az);
		}
	}
	
	// walls
	for (int ax = 0; ax <= w; ax++) {
		world.setBlock(x+ax, y+0, z+0, Block.getBlockById(7));
		world.setBlock(x+ax, y+1, z+0, Block.getBlockById(7));
		world.setBlock(x+ax, y+2, z+0, Block.getBlockById(7));
		world.setBlock(x+ax, y+0, z+w, Block.getBlockById(7));
		world.setBlock(x+ax, y+1, z+w, Block.getBlockById(7));
		world.setBlock(x+ax, y+2, z+w, Block.getBlockById(7));
	}	
	for (int az = 0; az <= w; az++) {
		world.setBlock(x+0, y+0, z+az, Block.getBlockById(7));
		world.setBlock(x+0, y+1, z+az, Block.getBlockById(7));
		world.setBlock(x+0, y+2, z+az, Block.getBlockById(7));
		world.setBlock(x+w, y+0, z+az, Block.getBlockById(7));
		world.setBlock(x+w, y+1, z+az, Block.getBlockById(7));
		world.setBlock(x+w, y+2, z+az, Block.getBlockById(7));
	}
	
	// goal
	world.setBlock(x + 1, y+0, z+ w-1, Block.getBlockById(41));
	
	// maze
	String mazeMap = "001000111010" +
					 "000010010010" +
					 "001000100110" +
					 "011101001000" +
					 "100000001011" +
					 "101110101000" +
					 "100011101011" +
					 "111010100001" +
					 "001000111101" +
					 "010010100000" +
					 "000010101010" +
					 "000010001000";
	
	for (int ax = 1; ax <= internalWidth; ax++) {
		for (int az = 1; az <= internalWidth; az++) {
			int tZ = az-1; // 0 to internalWidth-1
			int mZ = internalWidth-tZ-1; // internalWidth-1 to 0
			int tX = ax-1; // 0 to internalWidth-1
			int mX = internalWidth-tX-1; // internalWidth-1 to 0
			if (mazeMap.charAt(mZ*internalWidth + mX) == '1') {
				world.setBlock(x+ax, y+0, z+az, Block.getBlockById(7));
				world.setBlock(x+ax, y+1, z+az, Block.getBlockById(7));
				world.setBlock(x+ax, y+2, z+az, Block.getBlockById(7));
			} else if (mazeMap.charAt(mZ*internalWidth + mX) == '2') {
				world.setBlock(x+ax, y+1, z+az, BurlapCraft.burlapStone);
			} else {
				// do nothing
			}
		}
	}
	


}