Advertisement
Guest User

Minecraft 1.12.2(MCP デコンパイル) 修正

a guest
Nov 22nd, 2017
1,641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.29 KB | None | 0 0
  1.  
  2.     //村人AI(EntityVillager.java)
  3.     protected void updateAITasks()
  4.     {
  5.         if (--this.randomTickDivider <= 0) //ランダムティックが0までカウントされたら
  6.         {
  7.             BlockPos blockpos = new BlockPos(this); //村人の位置
  8.             this.world.getVillageCollection().addToVillagerPositionList(blockpos); //村人位置リストにセット
  9.             this.randomTickDivider = 70 + this.rand.nextInt(50); //ランダムティックのタイマーを再セット
  10.             this.village = this.world.getVillageCollection().getNearestVillage(blockpos, 32); //いちばん近い村を取得
  11.  
  12.             if (this.village == null) //村がねえだ
  13.             {
  14.                 this.detachHome(); //村から脱退
  15.             }
  16.             else
  17.             {
  18.                 BlockPos blockpos1 = this.village.getCenter(); //村の中心を取得
  19.                 this.setHomePosAndDistance(blockpos1, this.village.getVillageRadius()); //村の位置と半径をセット
  20.  
  21.                 if (this.isLookingForHome) //帰宅中フラグ
  22.                 {
  23.                     this.isLookingForHome = false; //帰宅おわり
  24.                     this.village.setDefaultPlayerReputation(5); //村の評判値を5に
  25.                 }
  26.             }
  27.         }
  28.  
  29.         if (!this.isTrading() && this.timeUntilReset > 0) //取引中ではない且つ商品の更新タイマーが0位上
  30.         {
  31.             --this.timeUntilReset; //タイマー更新
  32.  
  33.             if (this.timeUntilReset <= 0) //タイマーが0になった
  34.             {
  35.                 if (this.needsInitilization) //取引後の更新が必要
  36.                 {
  37.                     for (MerchantRecipe merchantrecipe : this.buyingList)
  38.                     {
  39.                         if (merchantrecipe.isRecipeDisabled())
  40.                         {
  41.                             merchantrecipe.increaseMaxTradeUses(this.rand.nextInt(6) + this.rand.nextInt(6) + 2);
  42.                         }
  43.                     }
  44.  
  45.                     this.populateBuyingList();
  46.                     this.needsInitilization = false;
  47.  
  48.                     if (this.village != null && this.lastBuyingPlayer != null)
  49.                     {
  50.                         this.world.setEntityState(this, (byte)14);
  51.                         this.village.modifyPlayerReputation(this.lastBuyingPlayer, 1); //評判アップ
  52.                     }
  53.                 }
  54.  
  55.                 this.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 200, 0)); //くさそうなぐるぐる表示
  56.             }
  57.         }
  58.  
  59.         super.updateAITasks();
  60.     }
  61.  
  62.     //村人AIでの過疎チェック
  63.     private boolean checkSufficientDoorsPresentForNewVillager()
  64.     {
  65.         if (!this.village.isMatingSeason()) //やる時間か?(村全体で村人のインベントリ消費タイマーチェック)
  66.         {
  67.             return false;
  68.         }
  69.         else
  70.         {
  71.             int i = (int)((double)((float)this.village.getNumVillageDoors()) * 0.35D); //ドアの数×0.35
  72.             return this.village.getNumVillagers() < i; //村人の数が(ドアの数×0.35)未満なら、過疎フラグ
  73.         }
  74.     }
  75.  
  76.     //村人が一番近くの村を探す処理(VillageCollection.java)
  77.     public Village getNearestVillage(BlockPos doorBlock, int radius)
  78.     {
  79.         Village village = null;
  80.         double d0 = 0x7F7FFFFF; //デフォの距離doubleの最大値
  81.  
  82.         for (Village village1 : this.villageList) //村リスト(ワールド全部)を検索
  83.         {
  84.             double d1 = village1.getCenter().distanceSq(doorBlock); //村の中心から村人の距離(distanseSq()平方根返すので球形)
  85.  
  86.             if (d1 < d0) //前回より近いか?
  87.             {
  88.                 float f = (float)(radius + village1.getVillageRadius()); //村の半径取得
  89.  
  90.                 if (d1 <= (double)(f * f)) //村の半径に入ってる?
  91.                 {
  92.                     village = village1; //みっけ!
  93.                     d0 = d1;
  94.                 }
  95.             }
  96.         }
  97.  
  98.         return village;
  99.     }
  100.  
  101.  
  102.     //村のティックタイマー
  103.     public void tick()
  104.     {
  105.         ++this.tickCounter;
  106.  
  107.         for (Village village : this.villageList)
  108.         {
  109.             village.tick(this.tickCounter);
  110.         }
  111.  
  112.         this.removeAnnihilatedVillages(); //無効な村を削除
  113.         this.dropOldestVillagerPosition(); //村人の位置をいったん初期化&ドアの存在チェック
  114.         this.addNewDoorsToVillageOrCreateVillage(); //村の再ロード
  115.  
  116.         if (this.tickCounter % 400 == 0)
  117.         {
  118.             this.markDirty();
  119.         }
  120.     }
  121.  
  122.   //村人の位置をいったん初期化&ドアの存在チェック
  123.     private void dropOldestVillagerPosition()
  124.     {
  125.         if (!this.villagerPositionsList.isEmpty()) //村人リストが空っぽじゃないなら
  126.         {
  127.             this.addDoorsAround(this.villagerPositionsList.remove(0)); //村人位置からドアチェック&村人の位置を削除
  128.         }
  129.     }
  130.  
  131.  
  132.     //村人の周りにドアが存在するかチェック(VillageCollection.java)
  133.     private void addDoorsAround(BlockPos central)
  134.     {
  135.         int i = 16;
  136.         int j = 4;
  137.         int k = 16;
  138.  
  139.         for (int l = -16; l < 16; ++l) //X
  140.         {
  141.             for (int i1 = -4; i1 < 4; ++i1) //Y
  142.             {
  143.                 for (int j1 = -16; j1 < 16; ++j1) //Z
  144.                 {
  145.                     BlockPos blockpos = central.add(l, i1, j1); //中心からの相対位置(X Y Z)から絶対位置を取得
  146.  
  147.                     if (this.isWoodDoor(blockpos)) //ここにドアがあるならば
  148.                     {
  149.                         VillageDoorInfo villagedoorinfo = this.checkDoorExistence(blockpos); //既知のドアか?
  150.  
  151.                         if (villagedoorinfo == null) //ちゃう
  152.                         {
  153.                             this.addToNewDoorsList(blockpos); //追加しとこ
  154.                         }
  155.                         else
  156.                         {
  157.                             villagedoorinfo.setLastActivityTimestamp(this.tickCounter); //村はいきとるで
  158.                         }
  159.                     }
  160.                 }
  161.             }
  162.         }
  163.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement