環境
forgeSrc-1.12.2-14.23.4.2705
背景
通常は村1個につきせいぜい2個くらいまでの鍛冶場しかないので鍛冶場にどんなアイテムが出現するかを調べるのは困難。
原理
次のコードをnet.minecraft.world.gen.structure.StructureVillagePieces.House2.addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
のthis.hasMadeChest = true;
の下あたりに埋め込むと大量に試行できる。
ArrayList<Tuple3<Long, String, Integer>> hash2 = new ArrayList<>();
for (long seed = 0; seed <= 0xffff; seed++) {
this.generateChest(worldIn, structureBoundingBoxIn, new Random(seed * 47861474789L), 5, 1, 5, LootTableList.CHESTS_VILLAGE_BLACKSMITH);
BlockPos blockpos = new BlockPos(this.getXWithOffset(5, 5), this.getYWithOffset(1), this.getZWithOffset(5, 5));
TileEntity tileEntity = worldIn.getTileEntity(blockpos);
if (tileEntity instanceof TileEntityChest) {
TileEntityChest tileEntity2 = (TileEntityChest) tileEntity;
HashMap<String, Integer> hash = new HashMap<>();
IntStream.range(0, tileEntity2.getSizeInventory())
.mapToObj(i -> tileEntity2.getStackInSlot(i))
.filter(s -> !s.isEmpty())
.forEach(s -> hash.put(s.getDisplayName(), hash.getOrDefault(s.getDisplayName(), 0) + s.getCount()));
hash2.add(new Tuple3<>(seed, hash.entrySet().stream()
.sorted((a, b) -> a.getKey().compareTo(b.getKey()))
.map(e -> e.getKey() + "*" + e.getValue())
.collect(Collectors.joining(",")), hash.getOrDefault("Diamond", 0)));
}
worldIn.setBlockState(blockpos, Blocks.AIR.getDefaultState(), 6);
}
hash2.stream()
.filter(t -> t._3() > 0)
.sorted((a, b) -> -a._3().compareTo(b._3()))
.forEach(t -> System.out.println(String.format("%s %s %s",
t._3(),
t._1(),
t._2())));
チェストの中身はgenerateChest
の中でrandomIn
から求められるシードをチェストに設定することで決定しているが、シードを設定しただけで実際のアイテムは設定されない。チェストの中身はgetStackInSlot
を呼び出したときに確定する。
追記:Tuple3
は多分Scalaのやつ。
実験条件
シードが0から65535までの範囲のチェストの中身を調べる。チェストの中身にはダイヤモンドの個数でソートして、上位10位までを見てみる。
結果
9 37210 Apple*1,Bread*3,Diamond*9,Gold Ingot*3,Iron Pickaxe*2
9 46216 Apple*4,Bread*5,Diamond*9,Diamond Horse Armor*1
9 51971 Apple*2,Diamond*9,Diamond Horse Armor*1,Iron Leggings*1,Oak Sapling*4
9 54626 Apple*2,Bread*3,Diamond*9,Iron Boots*1,Iron Chestplate*1,Iron Pickaxe*1
8 1955 Apple*6,Diamond*8,Diamond Horse Armor*1,Iron Sword*1
8 15514 Apple*3,Diamond*8,Iron Boots*2,Iron Pickaxe*1,Obsidian*3
8 18847 Diamond*8,Diamond Horse Armor*1,Iron Ingot*5,Obsidian*3,Saddle*1
8 57533 Apple*2,Diamond*8,Saddle*1
8 63605 Apple*10,Diamond*8
7 59266 Bread*2,Diamond*7,Iron Boots*1,Iron Pickaxe*1
65536個調べただけでもダイヤ9個という優良ドロップが存在する。上限が決められてるかどうかはよくわからないが、シードを48ビット分すべて調べたらもしかしたらダイヤ20個とかいうチェストも出てくるかもしれない。