MCPcopy Create free account
hub / github.com/DGVPSH/SlackOpen / setBlockState

Method setBlockState

src/main/java/net/minecraft/world/World.java:357–406  ·  view source on GitHub ↗

Sets the block state at a given location. Flag 1 will cause a block update. Flag 2 will send the change to clients (you almost always want this). Flag 4 prevents the block from being re-rendered, if this is a client world. Flags can be added together. @param flags Flag 1 will cause a block update.

(BlockPos pos, IBlockState newState, int flags)

Source from the content-addressed store, hash-verified

355 * this). Flag 4 prevents the block from being re-rendered, if this is a client world. Flags can be added together.
356 */
357 public boolean setBlockState(BlockPos pos, IBlockState newState, int flags)
358 {
359 if (!this.isValid(pos))
360 {
361 return false;
362 }
363 else if (!this.isRemote && this.worldInfo.getTerrainType() == WorldType.DEBUG_WORLD)
364 {
365 return false;
366 }
367 else
368 {
369 Chunk chunk = this.getChunkFromBlockCoords(pos);
370 Block block = newState.getBlock();
371 IBlockState iblockstate = chunk.setBlockState(pos, newState);
372
373 if (iblockstate == null)
374 {
375 return false;
376 }
377 else
378 {
379 Block block1 = iblockstate.getBlock();
380
381 if (block.getLightOpacity() != block1.getLightOpacity() || block.getLightValue() != block1.getLightValue())
382 {
383 this.theProfiler.startSection("checkLight");
384 this.checkLight(pos);
385 this.theProfiler.endSection();
386 }
387
388 if ((flags & 2) != 0 && (!this.isRemote || (flags & 4) == 0) && chunk.isPopulated())
389 {
390 this.markBlockForUpdate(pos);
391 }
392
393 if (!this.isRemote && (flags & 1) != 0)
394 {
395 this.notifyNeighborsRespectDebug(pos, iblockstate.getBlock());
396
397 if (block.hasComparatorInputOverride())
398 {
399 this.updateComparatorOutputLevel(pos, block);
400 }
401 }
402
403 return true;
404 }
405 }
406 }
407
408 public boolean setBlockToAir(BlockPos pos)
409 {

Callers 15

dispenseStackMethod · 0.95
processCommandMethod · 0.95
processCommandMethod · 0.95
processCommandMethod · 0.95
setBlockToAirMethod · 0.95
updateTaskMethod · 0.95
updateTaskMethod · 0.95
updateTaskMethod · 0.95
startExecutingMethod · 0.95
updateTaskMethod · 0.95
updateTaskMethod · 0.95
onItemUseMethod · 0.45

Calls 15

isValidMethod · 0.95
getBlockMethod · 0.95
setBlockStateMethod · 0.95
getLightOpacityMethod · 0.95
getLightValueMethod · 0.95
checkLightMethod · 0.95
isPopulatedMethod · 0.95
markBlockForUpdateMethod · 0.95

Tested by

no test coverage detected