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

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

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

World.notifyNeighborsOfStateChange介绍

暂无

代码示例

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

  1. @Override
  2. public Boolean call( final World world ) throws Exception
  3. {
  4. if( world.isBlockLoaded( this.pos ) )
  5. {
  6. world.notifyNeighborsOfStateChange( this.pos, Platform.AIR_BLOCK, true );
  7. }
  8. return true;
  9. }
  10. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void onPlayerDestroy(World world, BlockPos pos, IBlockState state) {
  3. // TE is already gone so best we can do is just notify everyone
  4. for(EnumFacing side : EnumFacing.VALUES) {
  5. world.notifyNeighborsOfStateChange(pos.offset(side), this, false);
  6. }
  7. super.onPlayerDestroy(world, pos, state);
  8. }

代码示例来源:origin: Vazkii/Botania

  1. private void rotateTo(int side) {
  2. if(rotating)
  3. return;
  4. currentRandomRotation = nextRandomRotation;
  5. int finalRotation = side * 90;
  6. double diff = (finalRotation - rotation % 360) % 360;
  7. if(diff < 0)
  8. diff = 360 + diff;
  9. rotationTicks = 4;
  10. anglePerTick = diff / rotationTicks;
  11. this.side = side;
  12. rotating = true;
  13. // tell neighbors that signal is off because we are rotating
  14. world.notifyNeighborsOfStateChange(getPos(), getBlockType(), false);
  15. for(EnumFacing e : EnumFacing.VALUES) {
  16. world.notifyNeighborsOfStateChange(getPos().offset(e), getBlockType(), false);
  17. }
  18. }

代码示例来源:origin: Vazkii/Botania

  1. public void onPlace(EntityLivingBase entity) {
  2. if(entity != null) {
  3. side = Arrays.asList(SIDES).indexOf(entity.getHorizontalFacing().getOpposite());
  4. }
  5. world.notifyNeighborsOfStateChange(getPos().offset(SIDES[side].getOpposite()), getBlockType(), false);
  6. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void update() {
  3. if(rotating) {
  4. lastTickRotation = rotation;
  5. rotation = (rotation + anglePerTick) % 360;
  6. rotationTicks--;
  7. if(rotationTicks <= 0) {
  8. rotating = false;
  9. // done rotating, tell neighbors
  10. world.notifyNeighborsOfStateChange(getPos(), getBlockType(), false);
  11. for(EnumFacing e : EnumFacing.VALUES) {
  12. world.notifyNeighborsOfStateChange(getPos().offset(e), getBlockType(), false);
  13. }
  14. }
  15. } else rotation = side * 90;
  16. if(world.isRemote) {
  17. int amt = rotating ? 3 : Math.random() < 0.1 ? 1 : 0;
  18. double x = getPos().getX() + 0.5 + Math.cos((rotation + 90) / 180.0 * Math.PI) * 0.35;
  19. double y = getPos().getY() + 0.2;
  20. double z = getPos().getZ() + 0.5 + Math.sin((rotation + 90) / 180.0 * Math.PI) * 0.35;
  21. for(int i = 0; i < amt; i++)
  22. world.spawnParticle(EnumParticleTypes.REDSTONE, x, y, z, 0.0D, 0.0D, 0.0D);
  23. }
  24. }

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

  1. public void openInventory( final EntityPlayer player )
  2. {
  3. if( !player.isSpectator() )
  4. {
  5. this.setPlayerOpen( this.getPlayerOpen() + 1 );
  6. this.world.addBlockEvent( this.pos, this.getBlockType(), 1, this.numPlayersUsing );
  7. this.world.notifyNeighborsOfStateChange( this.pos, this.getBlockType(), true );
  8. this.world.notifyNeighborsOfStateChange( this.pos.down(), this.getBlockType(), true );
  9. if( this.getPlayerOpen() == 1 )
  10. {
  11. this.getWorld()
  12. .playSound( player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_OPEN,
  13. SoundCategory.BLOCKS, 0.5F, this.getWorld().rand.nextFloat() * 0.1F + 0.9F );
  14. this.markForUpdate();
  15. }
  16. }
  17. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
  3. super.onBlockAdded(world, pos, state);
  4. if(!world.isRemote && world.getBlockState(pos.down()).getBlock() == Blocks.IRON_BARS && world.getBlockState(pos.down(2)).getBlock() == Blocks.IRON_BARS) {
  5. world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
  6. world.setBlockState(pos.down(), Blocks.AIR.getDefaultState(), 2);
  7. world.setBlockState(pos.down(2), Blocks.AIR.getDefaultState(), 2);
  8. EntityBlaze blaze = new EntityBlaze(world);
  9. blaze.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() - 1.95D, pos.getZ() + 0.5D, 0.0F, 0.0F);
  10. blaze.deathLootTable = LOOT_TABLE;
  11. blaze.onInitialSpawn(world.getDifficultyForLocation(pos), null);
  12. world.spawnEntity(blaze);
  13. world.notifyNeighborsOfStateChange(pos, Blocks.AIR, false);
  14. world.notifyNeighborsOfStateChange(pos.down(), Blocks.AIR, false);
  15. world.notifyNeighborsOfStateChange(pos.down(2), Blocks.AIR, false);
  16. }
  17. }

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

  1. public void closeInventory( final EntityPlayer player )
  2. {
  3. if( !player.isSpectator() )
  4. {
  5. this.setPlayerOpen( this.getPlayerOpen() - 1 );
  6. this.world.addBlockEvent( this.pos, this.getBlockType(), 1, this.numPlayersUsing );
  7. this.world.notifyNeighborsOfStateChange( this.pos, this.getBlockType(), true );
  8. this.world.notifyNeighborsOfStateChange( this.pos.down(), this.getBlockType(), true );
  9. if( this.getPlayerOpen() < 0 )
  10. {
  11. this.setPlayerOpen( 0 );
  12. }
  13. if( this.getPlayerOpen() == 0 )
  14. {
  15. this.getWorld()
  16. .playSound( player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_CLOSE,
  17. SoundCategory.BLOCKS, 0.5F, this.getWorld().rand.nextFloat() * 0.1F + 0.9F );
  18. this.markForUpdate();
  19. }
  20. }
  21. }

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

  1. @Override
  2. public void notifyNeighborsOfStateChange(@Nonnull BlockPos pos, @Nonnull Block blockType, boolean updateObservers) {
  3. wrapped.notifyNeighborsOfStateChange(pos, blockType, updateObservers);
  4. }

代码示例来源:origin: TheGreyGhost/MinecraftByExample

  1. @Override
  2. public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
  3. {
  4. final boolean CASCADE_UPDATE = false; // I'm not sure what this flag does, but vanilla always sets it to false
  5. // except for calls by World.setBlockState()
  6. worldIn.notifyNeighborsOfStateChange(pos, this, CASCADE_UPDATE);
  7. super.breakBlock(worldIn, pos, state);
  8. }

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

  1. cSrc.getWorld().notifyNeighborsOfStateChange( wc.getPos(), Platform.AIR_BLOCK, true );
  2. cSrc.getWorld().notifyNeighborsOfStateChange( wc.getPos(), Platform.AIR_BLOCK, true );

代码示例来源:origin: TheGreyGhost/MinecraftByExample

  1. public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
  2. {
  3. super.breakBlock(worldIn, pos, state);
  4. worldIn.removeTileEntity(pos);
  5. final boolean CASCADE_UPDATE = false; // I'm not sure what this flag does, but vanilla always sets it to false
  6. // except for calls by World.setBlockState()
  7. worldIn.notifyNeighborsOfStateChange(pos, this, CASCADE_UPDATE);
  8. }

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

  1. private void broadcastSignal() {
  2. initialized = true;
  3. world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true);
  4. }

代码示例来源:origin: ForestryMC/ForestryMC

  1. @Override
  2. public void onMachineBroken() {
  3. world.notifyNeighborsOfStateChange(getPos(), world.getBlockState(pos).getBlock(), false);
  4. markDirty();
  5. }

代码示例来源:origin: ForestryMC/ForestryMC

  1. @Override
  2. public void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord) {
  3. world.notifyNeighborsOfStateChange(getPos(), world.getBlockState(pos).getBlock(), false);
  4. markDirty();
  5. }

代码示例来源:origin: McJtyMods/DeepResonance

  1. protected void notifyAndMarkDirty(){
  2. if (WorldHelper.chunkLoaded(getWorld(), pos)){
  3. this.markDirty();
  4. this.getWorld().notifyNeighborsOfStateChange(pos, blockType, false);
  5. }
  6. }

代码示例来源:origin: Vazkii/Quark

  1. @Override
  2. public void openInventory(EntityPlayer player) {
  3. super.openInventory(player);
  4. if(!player.isSpectator() && getChestType() == VariedChests.CUSTOM_TYPE_QUARK_TRAP)
  5. world.notifyNeighborsOfStateChange(pos.down(), getBlockType(), false);
  6. }

代码示例来源:origin: ForestryMC/ForestryMC

  1. @Override
  2. public void onMachineBroken() {
  3. // Re-render this block on the client
  4. if (world.isRemote) {
  5. this.world.markBlockRangeForRenderUpdate(getPos(), getPos());
  6. }
  7. world.notifyNeighborsOfStateChange(getPos(), getBlockType(), false);
  8. markDirty();
  9. }

代码示例来源:origin: Ellpeck/ActuallyAdditions

  1. protected void onUpdateSent(){
  2. this.rangeBefore = this.range;
  3. this.boundPosBefore = this.boundPosition;
  4. this.boundBlockBefore = this.boundPosition == null ? null : this.world.getBlockState(this.boundPosition).getBlock();
  5. if(this.boundPosition != null){
  6. this.world.notifyNeighborsOfStateChange(this.pos, this.world.getBlockState(this.boundPosition).getBlock(), false);
  7. }
  8. this.sendUpdate();
  9. this.markDirty();
  10. }

代码示例来源:origin: CyclopsMC/IntegratedDynamics

  1. public void updateRedstoneInfo(EnumFacing side, boolean strongPower) {
  2. this.markDirty();
  3. if (getWorld().isBlockLoaded(getPos().offset(side))) {
  4. getWorld().neighborChanged(getPos().offset(side), getBlockType(), getPos());
  5. if (strongPower) {
  6. // When we are emitting a strong power, also update all neighbours of the target
  7. getWorld().notifyNeighborsOfStateChange(getPos().offset(side), getBlockType(), true);
  8. }
  9. }
  10. }

相关文章

World类方法