Vending Machine - OreCruncher/ThermalRecycling GitHub Wiki

One man’s trash is another man’s treasure.

Sometimes the best thing you can do with an unused item is to trade it to someone else for something you value. To assist in this endeavor I present the Vending Machine.

When placed it looks like an unused crate that has been place upright on it’s side. The first player that access the Vending Machine after placement will take ownership and their name will be displayed on the exterior surface. In the image above “OreCruncher” placed the Vending Machine and accessed it.

The Vending Machine can be configured for up to six different trades. Each trade is comprised of three different slots: two ask slots and one offer slot. The ask slots define what a player would give in return for the item(s) in the offer slot. In the image above a player can give one Gold Ingot and 5 Gold Nuggets and recieve 16 Obsidian in return. Also, if a player wanted that Bookshelf they can give some Iron Ingots.

Once a Vending Machine is configured the contents of the trades will be displayed inside Vending Machine rendering. This view would give traders an idea of what is being offered for trade as well as what is wanted in return without having to open up the Vending Machine. The item stack display is sensitive to how far away the player is away from the Vending Machine. At certain ranges the quantity information and the item stacks will not render.

If a non-owner opens up the Vending Machine they will be presented with the trade dialog above. If an owner wants to access the trade dialog they can shift + right click with an empty hand.

Configuring Trades

Configuration is pretty straight forward. The trade slots are ghost slots. Clicking on them with an item stack will set the slot to that item type and quantity. When the mouse cursor is over a slot several other short cuts methods for manipulating the slot content are available:

  • Wheel on the mouse. This will cause the quantity to go up/down depending on the direction the wheel is scrolled.
  • Left Click. Reduce the stack by one.
  • Shift+Left Click. Reduce the stack by half.
  • Right Click. Increment the stack by one.
  • Shift+Right Click. Double the stack size.

The region below the configuration slots is the Vending Machines inventory. Items that are to be handed out are placed into this inventory. Items that a player gives in return are also placed into this inventory. Make sure you leave empty space to hold incoming trade items. If there isn’t space a trade will not happen.

Trading Items

Trading is pretty easy. Just click on the item stack that is being offered for trade. The item(s) that are wanted in exchange are automatically taken from the player inventory and added to the Vending Machine inventory. The offered item will automatically be placed directly into the player inventory.

A trade could fail for several different reasons:

  • The Vending Machine ran out of a particular item to give out.
  • The Vending Machine does not have space in it’s inventory to accept items in return.
  • The player does not have space in their inventory to get the item.
  • The player does not have the right items to give in exchange.

Server Vending Machines

A Server Vending machine essentially has a bottomless inventory. It has infinite amount of items to hand out, and can accept an infinite amount of items in return. The operation is similar to Admin signs that are found on Bukkit servers.

To configure a Vending Machine for Server operation is pretty easy. As OP, equip a Signalum Security Lock from Thermal Expansion, and right click the Vending Machine with the lock. This will toggle the Vending Machine to admin mode. The name that is on the Vending Machine will change to “Server Shop”. Clicking on the Vending Machine again with the Signalum Security Lock will take it out of admin mode.

Setting Title Colors

As a Vending Machine owner, the color of the name displayed on the Vending Machine exterior can be customized. To change the color equip a piece of dye (as defined by the Forge OreDictionary “dye” entry, which includes the standard Minecraft dye items) and right click the Vending Machine. This will change the foreground color of the name to match the dye that was used.

Setting the background color is a little more complicated. By default the background color is black. To change this click on the Vending Machine twice with a piece of dye. First time will set the name foreground color, the second time will set the background color. You will then have to reset the foreground color to the desired color.

(Shift click is not possible with dye. That action is blocked down in the Minecraft code. :\)

Other Notes

  • A player can give items away for free by not setting the ask slots. The Vending Machine will keep giving out item stacks until it runs out of those items from it’s internal inventory.
  • A Server Vending Machine will give out an infinite supply of items if no ask slots are configured, so be careful.
  • Once ownership is established, the only player that can break a Vending Machine is the owner or someone that is OP.
  • By default transport pipes cannot connect to a Vending Machine. This is to prevent siphoning of items in unprotected regions. If a server has region protection in place transport pipe connection could be enabled to allow for automated inventory management.
  • Regardless of the transport pipe connection, Vending Machines that are configured for server operation, or are owned by [Thermal Recycling] will automatically block pipe connections.
  • The Vending Machine will not drop it’s inventory when in server mode or are owned by [Thermal Recycling].
  • The Vending Machine works well with mods that add types of currency, such as Minecraft Money.

Configuration Settings

vending {
    # Blocks connection of item transport pipes to a Vending Machine [default: true]
    B:"Disallow Pipe Connection"=true

    # Block range when items are rendered in a Vending Machine [range: 0 ~ 64, default: 6]
    I:"Item Render Range"=6

    # Block range when the name is rendered for a Vending Machine [range: 0 ~ 64, default: 8]
    I:"Name Render Range"=8

    # Block range when item quantities are rendered for a Vending Machine [range: 0 ~ 64, default: 4]
    I:"Quantity Render Range"=4
}
⚠️ **GitHub.com Fallback** ⚠️