net.minecraft.util.EnumFacing.random()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(103)

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

EnumFacing.random介绍

暂无

代码示例

代码示例来源:origin: squeek502/VeganOption

@Override
// passive and very subtle soil building
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
{
  super.updateTick(world, pos, state, rand);
  // skip ForgeDirection.DOWN
  EnumFacing randomDirection = EnumFacing.DOWN;
  while (randomDirection == EnumFacing.DOWN)
  {
    randomDirection = EnumFacing.random(rand);
  }
  attemptSoilBuilding(world, pos.offset(randomDirection), random, randomDirection == EnumFacing.UP);
}

代码示例来源:origin: TeamLapen/Vampirism

private static boolean blockWeaponTableFluids(TestInfo info) {
  info.world.setBlockState(info.pos, ModBlocks.weapon_table.getDefaultState());
  info.player.setHeldItem(info.player.getActiveHand(), new ItemStack(Items.LAVA_BUCKET));
  IBlockState block = info.world.getBlockState(info.pos);
  block.getBlock().onBlockActivated(info.world, info.pos, block, info.player, info.player.getActiveHand(), EnumFacing.random(info.world.rand), 0, 0, 0);
  block = info.world.getBlockState(info.pos);
  assert info.player.getHeldItem(info.player.getActiveHand()).getItem().equals(Items.BUCKET) : "Incorrect Fluid Container Handling";
  log("Block lava level: %s", block.getValue(BlockWeaponTable.LAVA));
  assert (block.getValue(BlockWeaponTable.LAVA) * BlockWeaponTable.MB_PER_META) == Fluid.BUCKET_VOLUME : "Incorrect Fluid Transaction";
  return true;
}

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

/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
  if (Netherfish.this.getAttackTarget() != null) {
    return false;
  } else if (!Netherfish.this.getNavigator().noPath()) {
    return false;
  } else {
    Random random = Netherfish.this.getRNG();
    if (Configs.isEnabled(NetherfishSpawnConfig.class) && random.nextInt(10) == 0) {
      this.field_179483_b = EnumFacing.random(random);
      BlockPos blockpos = (new BlockPos(Netherfish.this.posX, Netherfish.this.posY + 0.5D, Netherfish.this.posZ)).offset(this.field_179483_b);
      int meta = NetherfishSpawn.getInstance().getMetadataFromBlock(Netherfish.this.world.getBlockState(blockpos).getBlock());
      if (meta >= 0) {
        this.field_179484_c = true;
        return true;
      }
    }
    this.field_179484_c = false;
    return super.shouldExecute();
  }
}

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

@Override
public boolean shouldExecute() {
  if(!endermite.getEntityWorld().getGameRules().getBoolean("mobGriefing"))
    return false;
  else if(endermite.getAttackTarget() != null)
    return false;
  else if(!endermite.getNavigator().noPath())
    return false;
  else {
    Random random = endermite.getRNG();
    if(random.nextInt(EndermitesIntoShulkers.chance) == 0) {
      facing = EnumFacing.random(random);
      BlockPos blockpos = (new BlockPos(endermite.posX, endermite.posY + 0.5D, endermite.posZ)).offset(facing);
      IBlockState iblockstate = endermite.getEntityWorld().getBlockState(blockpos);
      if(iblockstate.getBlock() == Blocks.PURPUR_BLOCK) {
        doMerge = true;
        return true;
      }
    }
    doMerge = false;
    return super.shouldExecute();
  }
}

代码示例来源:origin: TeamLapen/Vampirism

private static boolean bloodFluidHandler(TestInfo info) {
  info.world.setBlockState(info.pos, ModBlocks.blood_container.getDefaultState());
  TileEntity t = info.world.getTileEntity(info.pos);
  IFluidHandler handler = t.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.random(info.world.rand));
  handler.fill(new FluidStack(ModFluids.blood, 10000000), true);
  int blood = BloodHelper.getBlood(handler);
  assert blood > 0 : "Could not fill blood container";
  ItemStack bloodBottle1 = new ItemStack(ModItems.blood_bottle);
  ItemStack bloodBottle2 = new ItemStack(ModItems.blood_bottle);
  FluidActionResult result1 = FluidUtil.tryFillContainer(bloodBottle1, handler, Integer.MAX_VALUE, null, true);
  assert result1.isSuccess() : "Transaction 1 failed";
  bloodBottle1 = result1.getResult();
  FluidActionResult result2 = FluidUtil.tryFillContainer(bloodBottle2, handler, Integer.MAX_VALUE, null, true);
  assert result2.isSuccess() : "Transaction 2 failed";
  bloodBottle2 = result2.getResult();
  assert BloodHelper.getBlood(handler) < blood : "Failed to drain from container into bottles";
  FluidActionResult result3 = FluidUtil.tryEmptyContainer(bloodBottle1, handler, Integer.MAX_VALUE, null, true);
  assert result3.isSuccess() : "Transaction 3 failed";
  bloodBottle1 = result3.getResult();
  FluidActionResult result4 = FluidUtil.tryEmptyContainer(bloodBottle2, handler, Integer.MAX_VALUE, null, true);
  assert result4.isSuccess() : "Transaction 4 failed";
  bloodBottle2 = result4.getResult();
  log("%d %d", BloodHelper.getBlood(handler), blood);
  assert BloodHelper.getBlood(handler) == blood : "Lost blood somewhere";
  return true;
}

相关文章