0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Minecraft 1.12.2 鍛冶場チェストを大量に試行するメモ

Last updated at Posted at 2018-09-21

環境

  • 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個とかいうチェストも出てくるかもしれない。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?