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

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

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

World.setTileEntity介绍

暂无

代码示例

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

  1. /**
  2. * Set a tile entity at the given location.
  3. *
  4. * @param world the world
  5. * @param position the position
  6. * @param clazz the tile entity class
  7. * @param tag the tag for the tile entity (may be null to not set NBT data)
  8. */
  9. static void setTileEntity(World world, BlockVector3 position, Class<? extends TileEntity> clazz, @Nullable NBTTagCompound tag) {
  10. checkNotNull(world);
  11. checkNotNull(position);
  12. checkNotNull(clazz);
  13. TileEntity tileEntity = constructTileEntity(world, position, clazz);
  14. if (tileEntity == null) {
  15. return;
  16. }
  17. if (tag != null) {
  18. // Set X, Y, Z
  19. updateForSet(tag, position);
  20. tileEntity.readFromNBT(tag);
  21. }
  22. world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
  23. }

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

  1. /**
  2. * Set a tile entity at the given location using the tile entity ID from
  3. * the tag.
  4. *
  5. * @param world the world
  6. * @param position the position
  7. * @param tag the tag for the tile entity (may be null to do nothing)
  8. */
  9. static void setTileEntity(World world, BlockVector3 position, @Nullable NBTTagCompound tag) {
  10. if (tag != null) {
  11. updateForSet(tag, position);
  12. TileEntity tileEntity = TileEntity.create(world, tag);
  13. if (tileEntity != null) {
  14. world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
  15. }
  16. }
  17. }

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

  1. /**
  2. * Changes this tile to the TESR version if any of the parts require dynamic rendering.
  3. */
  4. protected void updateTileSetting()
  5. {
  6. if( this.getCableBus().isRequiresDynamicRender() )
  7. {
  8. try
  9. {
  10. final TileCableBus tcb = (TileCableBus) BlockCableBus.getTesrTile().newInstance();
  11. tcb.copyFrom( this );
  12. this.getWorld().setTileEntity( this.pos, tcb );
  13. }
  14. catch( final Throwable ignored )
  15. {
  16. }
  17. }
  18. }

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

  1. /**
  2. * Changes this tile to the non-TESR version, if none of the parts require dynamic rendering.
  3. */
  4. @Override
  5. protected void updateTileSetting()
  6. {
  7. if( !this.getCableBus().isRequiresDynamicRender() )
  8. {
  9. try
  10. {
  11. final TileCableBus tcb = (TileCableBus) BlockCableBus.getNoTesrTile().newInstance();
  12. tcb.copyFrom( this );
  13. this.getWorld().setTileEntity( this.pos, tcb );
  14. }
  15. catch( final Throwable ignored )
  16. {
  17. }
  18. }
  19. }
  20. }

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

  1. @Override
  2. public void setTileEntity(@Nonnull BlockPos pos, @Nullable TileEntity tileEntityIn) {
  3. wrapped.setTileEntity(pos, tileEntityIn);
  4. }

代码示例来源:origin: GregTechCE/GregTech

  1. public void apply(World world, BlockPos pos) {
  2. world.setBlockState(pos, blockState);
  3. if(tileEntity != null) {
  4. world.setTileEntity(pos, tileEntity);
  5. }
  6. }
  7. }

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

  1. @SubscribeEvent
  2. public void onWorldTick(WorldTickEvent event) {
  3. if(!delayedUpdates.containsKey(event.world) || event.phase == Phase.START)
  4. return;
  5. List<Pair<BlockPos, TileEntity>> delays = delayedUpdates.get(event.world);
  6. if(delays.isEmpty())
  7. return;
  8. for(Pair<BlockPos, TileEntity> delay : delays) {
  9. event.world.setTileEntity(delay.getLeft(), delay.getRight());
  10. delay.getRight().updateContainingBlockInfo();
  11. }
  12. delays.clear();
  13. }

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

  1. @Override
  2. public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
  3. {
  4. super.onBlockAdded(worldIn, pos, state);
  5. worldIn.setTileEntity(pos, this.createTileEntity(worldIn, state));
  6. }

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

  1. public void setState(World worldIn, BlockPos pos, IBlockState state, int flag) {
  2. TileEntity te = worldIn.getTileEntity(pos);
  3. worldIn.setBlockState(pos, state, flag);
  4. if(te != null) {
  5. te.validate();
  6. worldIn.setTileEntity(pos, te);
  7. if(te instanceof TileCustomChest)
  8. ((TileCustomChest) te).adjacentChestChecked = false;
  9. }
  10. }

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

  1. @Override
  2. public void setTileEntity(BlockPos pos, TileEntity tile) {
  3. if (part.getPartPos().equals(pos)) {
  4. if (tile.hasCapability(MCMPCapabilities.MULTIPART_TILE, null)) {
  5. part.setTile(tile.getCapability(MCMPCapabilities.MULTIPART_TILE, null));
  6. } else {
  7. throw new IllegalArgumentException("The specified TileEntity is not a multipart!");
  8. }
  9. } else {
  10. getActualWorld().setTileEntity(pos, tile);
  11. }
  12. }

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

  1. if(tile != null) {
  2. tile.setPos(pos);
  3. entity.world.setTileEntity(pos, tile);

代码示例来源:origin: GregTechCE/GregTech

  1. @Override
  2. protected void onActiveModeChange(World world, BlockPos pos, boolean isActiveNow, boolean isInitialChange) {
  3. TileEntityFluidPipe oldTileEntity = (TileEntityFluidPipe) world.getTileEntity(pos);
  4. if (!(oldTileEntity instanceof TileEntityFluidPipeActive) && isActiveNow) {
  5. TileEntityFluidPipeActive newTileEntity = new TileEntityFluidPipeActive();
  6. newTileEntity.transferDataFrom(oldTileEntity);
  7. newTileEntity.setActive(true);
  8. world.setTileEntity(pos, newTileEntity);
  9. } else if (oldTileEntity instanceof TileEntityFluidPipeActive) {
  10. ((TileEntityFluidPipeActive) oldTileEntity).setActive(isActiveNow);
  11. }
  12. }

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

  1. @Override
  2. public boolean generate(World world, Random random, BlockPos pos) {
  3. if (isWorldValid(world) && random.nextFloat() < chance && world.setBlockState(pos, MatterOverdrive.BLOCKS.gravitational_anomaly.getDefaultState())) {
  4. TileEntityGravitationalAnomaly anomaly = new TileEntityGravitationalAnomaly(minMatter + random.nextInt(maxMatter - minMatter));
  5. world.setTileEntity(pos, anomaly);
  6. GenPositionWorldData data = MOWorldGen.getWorldPositionData(world);
  7. data.addPosition(name, new WorldPosition2D(pos.getX(), pos.getZ()));
  8. }
  9. return false;
  10. }

代码示例来源:origin: vadis365/TheErebus

  1. public static void setState(World world, BlockPos pos, IBlockState state, boolean powered) {
  2. if (!world.isRemote) {
  3. TileEntityLiquifier tile = (TileEntityLiquifier) world.getTileEntity(pos);
  4. state = state.withProperty(POWERED, powered);
  5. world.setBlockState(pos, state, 3);
  6. tile.setActive(powered);
  7. if (tile != null) {
  8. tile.validate();
  9. world.setTileEntity(pos, tile);
  10. }
  11. }
  12. }

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

  1. world.setTileEntity(pos_, newTile);

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

  1. @Override
  2. public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  3. if(worldIn.getTileEntity(pos) instanceof TileEntityEnchantmentTable)
  4. worldIn.setTileEntity(pos, createNewTileEntity(worldIn, 0));
  5. playerIn.openGui(Quark.instance, LibGuiIDs.MATRIX_ENCHANTING, worldIn, pos.getX(), pos.getY(), pos.getZ());
  6. return true;
  7. }

代码示例来源:origin: GregTechCE/GregTech

  1. @Override
  2. public IPipeTile<PipeType, NodeDataType> setSupportsTicking() {
  3. if(supportsTicking()) {
  4. return this;
  5. }
  6. //create new tickable tile entity, transfer data, and replace it
  7. IPipeTile<PipeType, NodeDataType> newTile = getPipeBlock().createNewTileEntity(true);
  8. newTile.transferDataFrom(this);
  9. getWorld().setTileEntity(getPos(), (TileEntity) newTile);
  10. return newTile;
  11. }

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

  1. @Override
  2. public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  3. ItemStack heldItem = playerIn.getHeldItem(hand);
  4. if (BlockCandle.lightingItems.contains(heldItem.getItem())) {
  5. IBlockState activatedState = ModuleApiculture.getBlocks().candle.getDefaultState().withProperty(BlockCandle.STATE, BlockCandle.State.ON);
  6. worldIn.setBlockState(pos, activatedState, Constants.FLAG_BLOCK_SYNC);
  7. TileCandle tc = new TileCandle();
  8. tc.setColour(16777215); // default to white
  9. tc.setLit(true);
  10. worldIn.setTileEntity(pos, tc);
  11. return true;
  12. }
  13. return false;
  14. }

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

  1. ote.writeToNBT( data );
  2. nte.readFromNBT( data.copy() );
  3. world.setTileEntity( d, nte );

代码示例来源:origin: vadis365/TheErebus

  1. public static void setState(boolean active, World world, BlockPos pos) {
  2. IBlockState iblockstate = world.getBlockState(pos);
  3. TileEntity tileentity = world.getTileEntity(pos);
  4. keepInventory = true;
  5. if (active)
  6. world.setBlockState(pos, ModBlocks.UMBER_FURNACE_ACTIVE.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
  7. else
  8. world.setBlockState(pos, ModBlocks.UMBER_FURNACE.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
  9. keepInventory = false;
  10. if (tileentity != null) {
  11. tileentity.validate();
  12. world.setTileEntity(pos, tileentity);
  13. }
  14. }

相关文章

World类方法