-
Notifications
You must be signed in to change notification settings - Fork 0
Dispenser Minecart
A new minecart entity that holds a 9-slot inventory and fires items when triggered by a powered activator rail.
Shapeless recipe: 1 Minecart + 1 Dispenser = 1 Dispenser Minecart.
Right-click a rail with the Dispenser Minecart item. The cart is placed facing the default direction for that rail. When placed by a player, standard face-away orientation applies (like the Furnace Minecart).
The cart has 9 slots, same layout as a vanilla dispenser. Right-click the cart to open a Dispenser UI.
The cart has a Flipped boolean that inverts the fire direction.
- Default: fires in the cart's yaw-forward direction.
- Flipped: fires in the opposite direction.
To toggle: shift-right-click the cart.
Useful for bi-directional rail setups where you want the same cart orientation but firing to a different side.
The cart does not fire on its own. Firing is triggered by the vanilla activateMinecart hook, which fires when the cart rolls over a powered activator rail.
On activation (and only when the rail is powered):
- If the cart's internal fire cooldown is 0: pick one random non-empty slot (reservoir sampling, unbiased), remove 1 item, spawn it as a dropped
ItemEntityat the cart's position offset in the (possibly flipped) yaw direction, and set the cooldown to 8 ticks. - If the cooldown is above 0: the rail trigger is ignored this tick. Cooldown decrements each tick.
The item is thrown as a loose ItemEntity, not processed through vanilla dispenser behaviours. So:
- Buckets will not auto-place liquids.
- TNT will not auto-prime.
- Mob spawn eggs will not spawn a mob.
This is a deliberate simplification from a full block dispenser. If a more complete implementation is needed later, it can be added without changing the existing firing contract (position, cooldown, slot selection).
The cart persists:
- Inventory contents (via the vanilla container entity save path).
-
Flippedboolean. - Current fire cooldown.
All three restore on world reload.
Dispenser minecarts can be attached as trailers in a Trains.
Uses the vanilla minecart renderer with a Dispenser block displayed inside the cart (via getDefaultDisplayBlockState). The display block is static and does not rotate to show the "firing" side.
Start Here
Systems
Mechanics