Pig Cannon Sync
作者:rebot | 分类:模组
Minecraft 版本: 26.2
平台: fabric
标签: game-mechanics utility
Pig Cannon Sync
A tiny, server-side Fabric mod for Minecraft Java Edition 26.2. It fixes the
client-side invisibility that can occur when a pig remains logically mounted to
a minecart in a distant lazy chunk while the pig itself is brought near a
player.
The mod hooks Minecraft's own per-player entity tracker. When a pig changes from
unseen to seen for a player, but its logical vehicle is still not tracked by
that player, the mod briefly removes and re-adds the pig. This makes the server
resend the normal vanilla spawn, metadata, passenger, and velocity packets. It
does not teleport the pig, change its momentum, dismount it, load the distant
chunk, or alter the cannon's mechanics.
AI Usage Disclosure
This project was created using AI. I've reviewed game mechanics and tested it myself,
but cannot give performance/correctness guaruntees. There may be edge cases that I have
not considered. This is just a throwaway side project, feel free to repurpose/improve the
code as you see fit.
Commands
/pig-cannon-sync version reports the installed mod version.
/pig-cannon-sync debug checks every pig entity tracker in the player's current
dimension, lets vanilla determine which pigs should be visible, and starts or
restarts a monitored remove/re-add cycle for every match. It is a broad
diagnostic scan that deliberately ignores mounting state and the vehicle
tracker. It reports detailed progress to the player and the server log, and can
be run once every five seconds per player.
The pig_cannon_sync:command.pig_cannon_sync.debug permission is allowed by
default, so no permission manager is required. Servers with a Fabric-compatible
permission provider can override it to restrict the debug command. The version
command is unrestricted.
Synchronization behavior
When the mod detects that a pig has become tracked by a player while its vehicle
remains untracked, it immediately removes and re-adds the pig for that player.
The debug command also starts or restarts this initial refresh for every pig its
scan matches. While the pig continues moving, the mod supplies the absolute
position packets that vanilla omits for passengers because their position would
normally come from the vehicle. It sends those packets only when the pig is
tracked by a player but its vehicle is not. One final refresh happens after the
pig remains stationary for 20 ticks, and the pair then stays on a passive watch
until the pig dismounts or its vehicle becomes tracked normally.
Whenever the saddle equipment slot changes, the mod resends that slot to every
player whose server-side entity tracker currently includes the pig. The hook
runs at the slot mutation itself because a pig held in a lazy chunk may never
receive vanilla's later equipment-detection tick. This is event-driven: it does
not poll the pig's equipment every tick.
This is proportional only to active affected pig/player pairs. A moving pair
adds at most one small vanilla position-sync packet per server tick—the same
class of traffic an independently moving entity normally produces. A stationary
pair performs only a position comparison and tracker lookup each tick. Vanilla
has no packet by which a client acknowledges that an entity was actually
rendered, so that final client-side fact cannot be verified by a server-side mod.
Requirements
- Minecraft Java Edition 26.2
- Fabric Loader 0.19.3 or newer
- Fabric API for 26.2
- Java 25
For multiplayer, install Pig Cannon Sync and Fabric API on the server; vanilla
clients can connect without Pig Cannon Sync. For singleplayer, install Pig
Cannon Sync and Fabric API in the Minecraft instance's mods directory so the
mod can run on the integrated server. The mod contains no client-side
synchronization logic.
Building
Run ./gradlew build with Java 25. The distributable JAR is written to
build/libs/. With Nix installed, nix run .#build provides the pinned Java 25
toolchain and runs a clean build.
License
MIT.
请登录后举报
暂无评论,抢个沙发吧~