ClayCache
store items. drop them. shatter them. i don't care!
A simple, vanilla-friendly mod that turns Minecraft's Decorated Pots from static decorative blocks into fully functional, physics-based containers.
Features
-
Dynamic Storage: Decorated Pots now feature a 9-slot inventory (using a familiar Dispenser-style UI). You can pipe items in with hoppers, store your valuables, and hear a cute pop sound when opening them.
-
Shulker-Style Tooltips: Safely pick up a pot and hover over it in your inventory to see exactly what's inside! The tooltip displays a beautifully color-coded list of its applied sherds and the items stored within, just like a Shulker Box.
-
The Perfect Multiplayer Crate: Because they are incredibly cheap to craft, hold 9 stacks of items, and can be safely transported, Decorated Pots make fantastic, immersive crates for player trading and economies in multiplayer servers.
-
Custom Crafting & Swappable Sherds: Craft an "Unfired Decorated Pot" out of clay balls (arranged like a cauldron), then smelt or blast it. Want to decorate it? Place a naked pot in the center of a crafting table. The Top, Bottom, Left, and Right slots correspond to the faces of the pot, letting you choose exactly which face gets which sherd!
- Note: To remove a sherd, you have to shatter the pot! Don't worry, you are always guaranteed to get your exact sherds and equivalent bricks back.
-
Physics & Gravity: Decorated Pots now obey gravity just like Sand and Anvils. If a pot falls from too high, it will dynamically shatter upon impact, spilling its contents and sherds everywhere. If it lands safely, it preserves all its inventory and sherd data!
-
Interactive Shattering: Breaking a pot with a sword, axe, or pickaxe will shatter it instantly (just like vanilla). Want to move it safely? Break it with an empty hand, a Silk Touch tool, or in Creative mode to pick it up intact with all its items still inside.
-
Projectile Piercing: Arrows, tridents, and other projectiles will punch right through pots, shattering them on impact. Projectiles lose a percentage of their velocity as they pierce through, meaning a single arrow can punch through a whole row of pots before finally stopping.
-
Crush & Stomp Mechanics: Falling anvils will crush pots dynamically mid-air. Even better, if you (the player) fall from a high enough distance and land on a pot, your weight will crush it beneath your feet!
-
Flower Pot recipe: You might notice a random recipe for an "Unfired Flower Pot" in your recipe book. Right now the recipe is replaced like the Decorated Pots, i have plans for them, let me know if you want to add to those plans!
How to Use
Make sure you have Forge installed. Drop the .jar file into your mods folder.
- Craft an Unfired Decorated Pot using 7 Clay Balls in a U-shape (like a cauldron) in a crafting table.
- Smelt or Blast it to harden it.
- Place it down, right-click to open its inventory, and store your items.
- Apply sherds to it in a crafting table, or just use it as a storage crate!
- Shoot it with an arrow, drop it off a cliff, or smash it with a sword to get your items back! (Or just right-click it again).
Compatibility
-
Modded Projectiles: The mod includes a highly configurable fragileProjectiles list. Things like Snowballs, Eggs, or modded tomatoes will safely bounce off pots instead of shattering them.
-
Optimization Mods: The custom item models and rendering techniques are explicitly designed to be 100% compatible with rendering overhauls like Embeddium, Rubidium, and Sodium. No invisible faces or texture stretching.
-
Inventory Tweaks: The pot's UI uses standard Forge SlotItemHandler mechanics, meaning it plays perfectly with inventory sorting mods (like MouseTweaks or Inventory Sorter) without duplicating or deleting items.
Technicals
This mod tackles some notoriously difficult mechanics in Minecraft modding—dynamic block-to-entity swapping, persistent NBT across state changes, and custom physics interactions. Here's a look under the hood:
The Inventory System (DecoratedPotInventoryProvider.java & ModCapabilities.java): Instead of hardcoding a custom BlockEntity, the mod subscribes to Forge's AttachCapabilitiesEvent. When a vanilla DecoratedPotBlockEntity is placed, we attach our own ICapabilityProvider exposing an IItemHandler (a 9-slot ItemStackHandler). This ensures 100% compatibility with vanilla hoppers, modded pipes, and automation systems.
Block-to-Entity Swapping (FallingDecoratedPotBlock.java & CustomFallingBlockEntity.java): When a pot needs to fall, we can't just use vanilla's FallingBlockEntity because it drops BlockEntity NBT data. Instead, we intercept the fall, serialize the pot's capability data and sherd decorations into a CompoundTag, and inject it into a CustomFallingBlockEntity. When the entity lands safely, it re-places the vanilla pot block and deserializes the NBT back into it.
The Rendering Magic (CustomFallingBlockRenderer.java): Rendering a falling block that has complex BlockEntity data (like 4 different pottery sherds) is tricky. We solve this by keeping a "dummy" DecoratedPotBlockEntity inside our custom EntityRenderer. Every frame, we feed the falling entity's NBT data into this dummy pot, apply the correct Y-axis rotation math to match its blockstate facing direction, and pass it to the vanilla DecoratedPotRenderer.
Physics & Mixins (FallingBlockEntityMixin.java & WorldInteractionEvents.java):
-
Anvil Crushing: A Mixin into FallingBlockEntity#tick projects the Anvil's AABB downward along its DeltaMovement vector. If the math detects the anvil will intersect a pot during that exact tick, it shatters the pot dynamically before the anvil even registers a collision.
-
Arrow Piercing: When a projectile hits a pot, we cancel the impact event, reduce the projectile's velocity, and force a server-to-client impulse sync. Crucially, we predictively remove the pot on the client-side (level.removeBlock(pos, false)) to prevent the arrow from stuttering against a "ghost block" while waiting for the server's block-break packet.
The Loot Context Hack (ShatterCache.java & PotInventoryModifier.java): Forge's loot context occasionally loses BlockEntity capability data after a block is destroyed (especially during explosions). To guarantee items drop safely, we use a ConcurrentHashMap keyed by BlockPos.asLong() to temporarily cache the inventory NBT the moment the block breaks. A Global Loot Modifier (GLM) intercepts the drop generation, retrieves the NBT from the cache, and injects the items into the world. The cache is safely flushed at the end of every ServerTickEvent to prevent memory leaks.