net.minecraft.world.World.markAndNotifyBlock()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(184)

本文整理了Java中net.minecraft.world.World.markAndNotifyBlock()方法的一些代码示例,展示了World.markAndNotifyBlock()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.markAndNotifyBlock()方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:markAndNotifyBlock

World.markAndNotifyBlock介绍

暂无

代码示例

代码示例来源:origin: EngineHub/WorldEdit

  1. world.markAndNotifyBlock(pos, chunk, old, newState, UPDATE | NOTIFY);

代码示例来源:origin: SleepyTrousers/EnderIO

  1. @Override
  2. public void markAndNotifyBlock(@Nonnull BlockPos pos, @Nullable Chunk chunk, @Nonnull IBlockState iblockstate, @Nonnull IBlockState newState, int flags) {
  3. wrapped.markAndNotifyBlock(pos, chunk, iblockstate, newState, flags);
  4. }

代码示例来源:origin: blay09/CookingForBlockheads

  1. @Override
  2. protected void onContentsChanged(int slot) {
  3. markDirty();
  4. IBlockState blockState = world.getBlockState(pos);
  5. world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), blockState, blockState, 1 | 2);
  6. }
  7. };

代码示例来源:origin: blay09/CookingForBlockheads

  1. @Override
  2. protected void onContentsChanged(int slot) {
  3. markDirty();
  4. IBlockState blockState = world.getBlockState(pos);
  5. world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), blockState, blockState, 1 | 2);
  6. }
  7. };

代码示例来源:origin: blay09/CookingForBlockheads

  1. @Override
  2. protected void onContentsChanged(int slot) {
  3. markDirty();
  4. IBlockState blockState = world.getBlockState(pos);
  5. world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), blockState, blockState, 1 | 2);
  6. }
  7. };

代码示例来源:origin: blay09/CookingForBlockheads

  1. public void setHasPowerUpgrade(boolean hasPowerUpgrade) {
  2. this.hasPowerUpgrade = hasPowerUpgrade;
  3. markDirty();
  4. IBlockState state = world.getBlockState(pos);
  5. world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), state, state, 3);
  6. }

代码示例来源:origin: blay09/CookingForBlockheads

  1. public void markDirtyAndUpdate() {
  2. IBlockState state = world.getBlockState(pos);
  3. world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), state, state, 3);
  4. markDirty();
  5. }

代码示例来源:origin: blay09/CookingForBlockheads

  1. @Override
  2. public void setDyedColor(EnumDyeColor color) {
  3. this.color = color;
  4. IBlockState state = world.getBlockState(pos);
  5. world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), state, state, 3);
  6. markDirty();
  7. }

代码示例来源:origin: blay09/CookingForBlockheads

  1. @Override
  2. public void setDyedColor(EnumDyeColor color) {
  3. this.color = color;
  4. IBlockState state = world.getBlockState(pos);
  5. world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), state, state, 3);
  6. markDirty();
  7. }

代码示例来源:origin: blay09/CookingForBlockheads

  1. @Override
  2. public void setDyedColor(EnumDyeColor color) {
  3. this.color = color;
  4. IBlockState state = world.getBlockState(pos);
  5. world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), state, state, 3);
  6. markDirty();
  7. }
  8. }

代码示例来源:origin: blay09/CookingForBlockheads

  1. @Override
  2. public void setDyedColor(EnumDyeColor color) {
  3. this.color = color;
  4. IBlockState state = world.getBlockState(pos);
  5. world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), state, state, 3);
  6. markDirty();
  7. }
  8. }

代码示例来源:origin: WayofTime/BloodMagic

  1. @Override
  2. public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  3. boolean success = FluidUtil.interactWithFluidHandler(player, hand, world, blockPos, side);
  4. if (success) {
  5. world.checkLight(blockPos);
  6. world.updateComparatorOutputLevel(blockPos, this);
  7. world.markAndNotifyBlock(blockPos, world.getChunkFromBlockCoords(blockPos), state, state, 3);
  8. return true;
  9. }
  10. return true;
  11. }

代码示例来源:origin: blay09/CookingForBlockheads

  1. @Override
  2. public boolean receiveClientEvent(int id, int type) {
  3. if (id == 0) {
  4. world.playSound(null, pos, ModSounds.toasterStart, SoundCategory.BLOCKS, 1f, 1f);
  5. return true;
  6. } else if (id == 1) {
  7. world.playSound(null, pos, ModSounds.toasterStop, SoundCategory.BLOCKS, 1f, 1f);
  8. return true;
  9. } else if (id == 2) {
  10. IBlockState state = world.getBlockState(pos);
  11. world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), state, state, 3);
  12. return true;
  13. }
  14. return super.receiveClientEvent(id, type);
  15. }

代码示例来源:origin: MCTCP/TerrainControl

  1. @Override
  2. public void setBlock(int x, int y, int z, LocalMaterialData material) {
  3. /*
  4. * This method usually breaks on every Minecraft update. Always check
  5. * whether the names are still correct. Often, you'll also need to
  6. * rewrite parts of this method for newer block place logic.
  7. */
  8. if (y < TerrainControl.WORLD_DEPTH || y >= TerrainControl.WORLD_HEIGHT) {
  9. return;
  10. }
  11. BlockFalling.fallInstantly=true;
  12. IBlockState newState = ((ForgeMaterialData) material).internalBlock();
  13. // Get chunk from (faster) custom cache
  14. Chunk chunk = this.getChunk(x, y, z);
  15. if (chunk == null) {
  16. // Chunk is unloaded
  17. return;
  18. }
  19. BlockPos pos = new BlockPos(x, y, z);
  20. IBlockState oldState = chunk.setBlockState(pos, newState);
  21. if (oldState == null) {
  22. return;
  23. }
  24. // Notify world: (2 | 16) == update client, don't update observers
  25. this.world.markAndNotifyBlock(pos, chunk, oldState, newState, 2 | 16);
  26. BlockFalling.fallInstantly=false;
  27. }

代码示例来源:origin: blay09/CookingForBlockheads

  1. public void setActive(boolean active) {
  2. this.active = active;
  3. if (active) {
  4. toastTicks = TOAST_TICKS;
  5. world.addBlockEvent(pos, ModBlocks.toaster, 0, 0);
  6. } else {
  7. toastTicks = 0;
  8. world.addBlockEvent(pos, ModBlocks.toaster, 1, 0);
  9. }
  10. IBlockState state = world.getBlockState(pos);
  11. world.addBlockEvent(pos, ModBlocks.toaster, 2, 0);
  12. world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), state, ModBlocks.toaster.getActualState(state, world, pos), 3);
  13. markDirty();
  14. }

代码示例来源:origin: WayofTime/BloodMagic

  1. @Override
  2. public void onBlockPlacedBy(World world, BlockPos pos, IBlockState blockState, EntityLivingBase placer, ItemStack stack) {
  3. TileEntity tile = world.getTileEntity(pos);
  4. if (tile instanceof TileBloodTank) {
  5. TileBloodTank bloodTank = (TileBloodTank) tile;
  6. NBTTagCompound tag = stack.getTagCompound();
  7. if (stack.hasTagCompound() && stack.getTagCompound().hasKey("Fluid")) {
  8. FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("Fluid"));
  9. bloodTank.getTank().setFluid(fluidStack);
  10. }
  11. }
  12. world.checkLight(pos);
  13. world.updateComparatorOutputLevel(pos, this);
  14. world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), blockState, blockState, 3);
  15. }

代码示例来源:origin: RS485/LogisticsPipes

  1. @Override
  2. protected void updateWorldState() {
  3. //super.updateWorldState();
  4. LPTickHandler.getWorldInfo(getWorld()).setSkipBlockUpdateForWorld(true);
  5. IBlockState prevSt = this.getWorld().getBlockState(this.getPos());
  6. IBlockState st = this.getWorld().getBlockState(this.getPos());
  7. this.getWorld().markAndNotifyBlock(this.getPos(), (Chunk)null, prevSt, st, 1);
  8. this.getWorld().checkLight(this.getPos());
  9. LPTickHandler.getWorldInfo(getWorld()).setSkipBlockUpdateForWorld(true);
  10. }

代码示例来源:origin: RS485/LogisticsPipes

  1. @SubscribeEvent
  2. public void onPlayerLeftClickBlock(final PlayerInteractEvent.LeftClickBlock event) {
  3. if (MainProxy.isServer(event.getEntityPlayer().world)) {
  4. final TileEntity tile = event.getEntityPlayer().world.getTileEntity(event.getPos());
  5. if (tile instanceof LogisticsTileGenericPipe) {
  6. if (((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe) {
  7. if (!((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).canBeDestroyedByPlayer(event.getEntityPlayer())) {
  8. event.setCanceled(true);
  9. event.getEntityPlayer().sendMessage(new TextComponentTranslation("lp.chat.permissiondenied"));
  10. ((LogisticsTileGenericPipe) tile).scheduleNeighborChange();
  11. World world = event.getEntityPlayer().world;
  12. BlockPos pos = tile.getPos();
  13. IBlockState state = world.getBlockState(pos);
  14. world.markAndNotifyBlock(tile.getPos(), world.getChunkFromBlockCoords(pos), state, state, 2);
  15. ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).delayTo = System.currentTimeMillis() + 200;
  16. ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).repeatFor = 10;
  17. } else {
  18. ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).setDestroyByPlayer();
  19. }
  20. }
  21. }
  22. }
  23. }

代码示例来源:origin: amadornes/MCMultiPart

  1. getWorld().markAndNotifyBlock(getPos(), null, prevSt, st, 1); // Only cause a block update, clients are notified through a packet
  2. getWorld().checkLight(getPos());

代码示例来源:origin: RS485/LogisticsPipes

  1. private static void cacheTileToPreventRemoval(CoreUnroutedPipe pipe) {
  2. final World worldCache = pipe.getWorld();
  3. final BlockPos posCache = pipe.getPos();
  4. final TileEntity tileCache = pipe.container;
  5. final CoreUnroutedPipe fPipe = pipe;
  6. fPipe.setPreventRemove(true);
  7. QueuedTasks.queueTask(() -> {
  8. if (!fPipe.preventRemove()) {
  9. return null;
  10. }
  11. boolean changed = false;
  12. if (worldCache.getBlockState(posCache) != null || worldCache.getBlockState(posCache).getBlock() != LPBlocks.pipe) {
  13. worldCache.setBlockState(posCache, LPBlocks.pipe.getDefaultState());
  14. changed = true;
  15. }
  16. if (worldCache.getTileEntity(posCache) != tileCache) {
  17. worldCache.setTileEntity(posCache, tileCache);
  18. changed = true;
  19. }
  20. if (changed) {
  21. worldCache.markAndNotifyBlock(posCache, worldCache.getChunkFromBlockCoords(posCache), worldCache.getBlockState(posCache), worldCache.getBlockState(posCache), 3);
  22. }
  23. fPipe.setPreventRemove(false);
  24. return null;
  25. });
  26. }

相关文章

World类方法