Magnes

Quick rating

Community listing page, reviews here may not be monitored by the author.

Magnes

No reviews yet

Carry a magnet, and dropped items and experience orbs within reach come to you instead of having to be walked over. It works from anywhere in the inventory or a Curios slot, and a right-click switches it off and on.

Mod Loaders
Minecraft

About

Description

Magnes adds a magnet. Carry one, and dropped items and experience orbs within reach come to you instead of waiting to be walked over. It works from anywhere in the inventory — the point of it is not having to hold it — and a right-click switches it off and on.

The magnet

Four iron ingots and a block of redstone, laid out as the thing it is:

I I
I I
 R

It is drawn in colour while it is on and grey while it is off, and the click sounds higher for on than for off, so the two are told apart without looking. The tooltip says how far it reaches.

With Curios installed it can be worn in a charm slot as well, and a worn magnet counts as held. Curios is optional.

Nothing happens without one. If every player being magnetic is what you want, set needed = false under [magnet] and the item becomes decoration.

What it will not take

An item still inside its pickup delay is left alone. That delay is what makes dropping something possible at all — without it, a magnet would take back everything you threw the instant you threw it — and it is also what keeps another player's fresh death drop out of reach. A magnet that pulled a stranger's inventory across the room would be a grief tool rather than a convenience.

Settings

All on the server, and every one read on the tick it is used:

  • reach — 6 blocks by default, from 1 to 32
  • modeTAKEN puts things straight into the inventory; DRAWN pushes them toward you to be picked up the ordinary way, which is better to watch and can miss
  • experience — whether orbs are pulled as well as items
  • held only — whether the magnet has to be in a hand rather than anywhere in the inventory (a worn one still counts)
  • tick interval — how often the sweep runs, for a busy server that wants to turn it down

Under it

The pull is decided on the server and nowhere else. Where a dropped item is, is world state, and a client that moved items on its own would disagree with the server about who picked up what.

Nothing here reimplements picking something up. Items and orbs already know how to give themselves to a player, through playerTouch, which handles the pickup delay, whose the item is, the sound, the advancement, the pickup events other mods listen for, and, for an orb, mending before experience. The mod only decides what is in reach; everything after that is vanilla's own. One consequence: orbs are absorbed at the rate the game absorbs them when walked over, so a magnet gathers experience without hurrying it.

Requirements

NeoForge on Minecraft 1.21.1. Curios is optional. MIT licensed.


日本語

Magnes は磁石を追加します。持ち歩くと、届く範囲に落ちたアイテムと経験値オーブが、歩いて触れるのを待たずに寄ってきます。 インベントリのどこにあっても効き(手に持たなくてよいことが要点です)、右クリックでオンとオフを切り替えます。

磁石

鉄インゴット4個とレッドストーンブロック1個を、磁石の形そのままに並べます。

I I
I I
 R

オンのときはカラー、オフのときはグレーで描かれ、切り替えの音もオンは高く、オフは低く鳴るので、見なくても区別できます。 ツールチップには届く距離が出ます。

Curios が入っていれば charm スロットに身に着けることもでき、身に着けた磁石は手に持っているものとして数えます。Curios は任意です。

磁石が無ければ何も起きません。 全プレイヤーに磁力を持たせたいなら、[magnet]needed = false を設定してください。 その場合、アイテムは飾りになります。

取らないもの

拾えるまでの待ち時間がまだ残っているアイテムには手を出しません。この待ち時間があるからこそ、そもそもアイテムを捨てられます。 これを無視すると、投げた瞬間にすべて取り返してしまいます。死んだばかりの他のプレイヤーのドロップに手が届かないのも、この待ち時間のおかげです。 部屋の向こうから他人の持ち物を引き寄せる磁石は、便利道具ではなく嫌がらせの道具になってしまいます。

設定

すべてサーバー側の設定で、どれも使うそのティックに読みます。

  • 届く距離:既定は6ブロック、1〜32
  • 引き寄せ方TAKEN はインベントリへ直接入れます。DRAWN はプレイヤーの方へ飛ばして通常どおり拾わせます。 見栄えは良いものの、取りこぼすことがあります
  • 経験値:アイテムに加えてオーブも引き寄せるか
  • 手に持つときだけ:インベントリのどこでもではなく、手にあるときだけ効かせるか(身に着けた磁石は効きます)
  • 走査の間隔:負荷を下げたいサーバー向けに、走査の頻度を落とせます

中身

引き寄せはサーバーだけで決めます。落ちているアイテムの位置はワールドの状態で、クライアントが独自に動かすと、 誰が何を拾ったかでサーバーと食い違うためです。

拾う処理は自前で書いていません。アイテムもオーブも playerTouch を通じて自分をプレイヤーに渡す方法を既に持っていて、 そこで拾えるまでの待ち時間、持ち主、効果音、進捗、他の Mod が聞いている拾得イベント、オーブなら経験値より先の修繕が扱われます。 この Mod が決めるのは「何が届く範囲にあるか」だけで、その先はすべてバニラの処理です。 そのため、オーブは歩いて触れたときと同じ速さで吸収されます。磁石は経験値を集めはしますが、急がせはしません。

動作環境

Minecraft 1.21.1 の NeoForge。Curios は任意。MIT ライセンス。