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

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

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

World.getRedstonePower介绍

暂无

代码示例

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

  1. @Override
  2. public void update() {
  3. boolean redstone = false;
  4. for(EnumFacing dir : EnumFacing.VALUES) {
  5. int redstoneSide = world.getRedstonePower(pos.offset(dir), dir);
  6. if(redstoneSide > 0)
  7. redstone = true;
  8. }
  9. if(!redstone) {
  10. TileEntity tile = world.getTileEntity(pos.up());
  11. if(tile instanceof TileSpreader) {
  12. TileSpreader spreader = (TileSpreader) tile;
  13. spreader.rotationX += speed * (backwards ? -1 : 1);
  14. if(spreader.rotationX >= 360F)
  15. spreader.rotationX -= 360F;
  16. if(!world.isRemote)
  17. spreader.checkForReceiver();
  18. }
  19. }
  20. }

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

  1. @Override
  2. public void onUpdate() {
  3. super.onUpdate();
  4. linkPool();
  5. if(linkedPool != null && isValidBinding()) {
  6. IManaPool pool = (IManaPool) linkedPool;
  7. int manaInPool = pool.getCurrentMana();
  8. int manaMissing = getMaxMana() - mana;
  9. int manaToRemove = Math.min(manaMissing, manaInPool);
  10. pool.recieveMana(-manaToRemove);
  11. addMana(manaToRemove);
  12. }
  13. if(acceptsRedstone()) {
  14. redstoneSignal = 0;
  15. for(EnumFacing dir : EnumFacing.VALUES) {
  16. int redstoneSide = supertile.getWorld().getRedstonePower(supertile.getPos().offset(dir), dir);
  17. redstoneSignal = Math.max(redstoneSignal, redstoneSide);
  18. }
  19. }
  20. if(supertile.getWorld().isRemote) {
  21. double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F;
  22. Color color = new Color(getColor());
  23. if(Math.random() > particleChance)
  24. BotaniaAPI.internalHandler.sparkleFX(supertile.getWorld(), supertile.getPos().getX() + 0.3 + Math.random() * 0.5, supertile.getPos().getY() + 0.5 + Math.random() * 0.5, supertile.getPos().getZ() + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
  25. }
  26. }

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

  1. @Override
  2. public void update() {
  3. if (world.isRemote)
  4. return;
  5. boolean redstone = false;
  6. for(EnumFacing dir : EnumFacing.VALUES) {
  7. int redstoneSide = world.getRedstonePower(pos.offset(dir), dir);
  8. if(redstoneSide > 0) {
  9. redstone = true;
  10. break;
  11. }
  12. }
  13. if(canEject()) {
  14. ItemStack stack = itemHandler.getStackInSlot(0);
  15. if(!stack.isEmpty())
  16. eject(stack, redstone);
  17. }
  18. }

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

  1. @Override
  2. public void update() {
  3. enabled = true;
  4. for(EnumFacing dir : EnumFacing.VALUES) {
  5. int redstoneSide = world.getRedstonePower(pos.offset(dir), dir);
  6. if(redstoneSide > 0) {
  7. enabled = false;
  8. break;
  9. }
  10. }
  11. ItemStack stack = itemHandler.getStackInSlot(0);
  12. if(!stack.isEmpty() && stack.getItem() instanceof IAvatarWieldable) {
  13. IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem();
  14. wieldable.onAvatarUpdate(this, stack);
  15. }
  16. if(enabled)
  17. ticksElapsed++;
  18. }

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

  1. hasRedstone = false;
  2. for(EnumFacing dir : EnumFacing.VALUES) {
  3. int redstoneSide = world.getRedstonePower(pos.offset(dir), dir);
  4. if(redstoneSide > 0) {
  5. hasRedstone = true;

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

  1. @Override
  2. public int getRedstonePower(@Nonnull BlockPos pos, @Nonnull EnumFacing facing) {
  3. return wrapped.getRedstonePower(pos, facing);
  4. }

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

  1. redstoneSignal = 0;
  2. for(EnumFacing dir : EnumFacing.VALUES) {
  3. int redstoneSide = supertile.getWorld().getRedstonePower(supertile.getPos().offset(dir), dir);
  4. redstoneSignal = Math.max(redstoneSignal, redstoneSide);

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

  1. public int getPowerLevelClient() {
  2. // int powerLevel = this.worldObj.isBlockIndirectlyGettingPowered(this.pos); // if input can come from any side, use this line
  3. int maxPowerFound = 0;
  4. for (EnumFacing whichFace : EnumFacing.HORIZONTALS) {
  5. BlockPos neighborPos = pos.offset(whichFace);
  6. int powerLevel = this.world.getRedstonePower(neighborPos, whichFace);
  7. maxPowerFound = Math.max(powerLevel, maxPowerFound);
  8. }
  9. return maxPowerFound;
  10. }

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

  1. private int getPowerLevelInput(World world, BlockPos pos) {
  2. // int powerLevel = world.isBlockIndirectlyGettingPowered(pos); // if input can come from any side, use this line
  3. int maxPowerFound = 0;
  4. for (EnumFacing whichFace : EnumFacing.HORIZONTALS) {
  5. BlockPos neighborPos = pos.offset(whichFace);
  6. int powerLevel = world.getRedstonePower(neighborPos, whichFace);
  7. maxPowerFound = Math.max(powerLevel, maxPowerFound);
  8. }
  9. return maxPowerFound;
  10. }

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

  1. @Override
  2. public int getRedstonePower(BlockPos pos, EnumFacing facing) {
  3. return getActualWorld().getRedstonePower(pos, facing);
  4. }

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

  1. private int getInputStrength(World world, BlockPos pos, EnumFacing side) {
  2. return world.getRedstonePower(pos.offset(side), side);
  3. }

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

  1. private int getInputStrength(World world, BlockPos pos, EnumFacing side) {
  2. return world.getRedstonePower(pos.offset(side), side);
  3. }

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

  1. int redstoneSide = world.getRedstonePower(pos.offset(dir), dir);
  2. if(redstoneSide > 0)
  3. redstone = true;

代码示例来源:origin: MightyPirates/TIS-3D

  1. /**
  2. * Compute the <em>accumulative</em> redstone power applied to the controller.
  3. *
  4. * @return the accumulative redstone signal.
  5. */
  6. private int computePower() {
  7. int acc = 0;
  8. for (final EnumFacing facing : EnumFacing.VALUES) {
  9. acc += Math.max(0, Math.min(15, getWorld().getRedstonePower(getPos().offset(facing), facing)));
  10. }
  11. return acc;
  12. }

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

  1. protected int calculateInputStrength(World worldIn, BlockPos pos, IBlockState state) {
  2. EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
  3. BlockPos blockpos = pos.offset(enumfacing);
  4. int i = worldIn.getRedstonePower(blockpos, enumfacing);
  5. if(i >= 15)
  6. return i;
  7. else {
  8. IBlockState iblockstate = worldIn.getBlockState(blockpos);
  9. return Math.max(i, iblockstate.getBlock() == Blocks.REDSTONE_WIRE ? ((Integer)iblockstate.getValue(BlockRedstoneWire.POWER)).intValue() : 0);
  10. }
  11. }

代码示例来源:origin: raoulvdberge/refinedstorage

  1. @Override
  2. public int getRedstoneStrength() {
  3. return world.getRedstonePower(pos.offset(getDirection()), getDirection());
  4. }

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

  1. @Override
  2. public int readRedstoneIn(@Nonnull BlockSide side) {
  3. EnumFacing facing = side.getSide();
  4. BlockPos p = getAdjacentPosition(side);
  5. if (p == null) {
  6. return 0;
  7. }
  8. return getWorld().getRedstonePower(p.offset(facing), facing);
  9. }

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

  1. public static int isBlockIndirectlyGettingPoweredIfLoaded(@Nonnull World world, @Nonnull BlockPos pos) {
  2. int i = 0;
  3. NNIterator<EnumFacing> iterator = NNList.FACING.iterator();
  4. while (iterator.hasNext()) {
  5. EnumFacing enumfacing = iterator.next();
  6. final BlockPos offset = pos.offset(enumfacing);
  7. if (world.isBlockLoaded(offset)) {
  8. int j = world.getRedstonePower(offset, enumfacing);
  9. if (j >= 15) {
  10. return 15;
  11. }
  12. if (j > i) {
  13. i = j;
  14. }
  15. }
  16. }
  17. return i;
  18. }

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

  1. @Override
  2. public boolean cancelTask(IFarmLogic logic, FarmDirection direction) {
  3. for (EnumFacing facing : new EnumFacing[]{EnumFacing.UP, EnumFacing.DOWN, direction.getFacing()}) {
  4. BlockPos pos = tile.getPos();
  5. World world = tile.getWorldObj();
  6. IBlockState blockState = world.getBlockState(pos.offset(facing));
  7. if (!(blockState.getBlock() instanceof BlockFarm) && world.getRedstonePower(pos, facing) > 0) {
  8. return true;
  9. }
  10. }
  11. return false;
  12. }
  13. }

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

  1. protected int getExternalPowerLevel(@Nonnull EnumFacing dir) {
  2. World world = getBundle().getBundleworld();
  3. BlockPos loc = getBundle().getLocation().offset(dir);
  4. int res = 0;
  5. if (world.isBlockLoaded(loc)) {
  6. int strong = world.getStrongPower(loc, dir);
  7. if (strong > 0) {
  8. return strong;
  9. }
  10. res = world.getRedstonePower(loc, dir);
  11. IBlockState bs = world.getBlockState(loc);
  12. Block block = bs.getBlock();
  13. if (res <= 15 && block == Blocks.REDSTONE_WIRE) {
  14. int wireIn = bs.getValue(BlockRedstoneWire.POWER);
  15. res = Math.max(res, wireIn);
  16. }
  17. }
  18. return res;
  19. }

相关文章

World类方法