/FileExtraction/Java_unseen/Wind-Development_WindSpigot/WindSpigot-Server/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java
package org.bukkit.craftbukkit.block;

import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Dropper;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;

import net.minecraft.server.BlockDropper;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.Blocks;
import net.minecraft.server.TileEntityDropper;

public class CraftDropper extends CraftBlockState implements Dropper {
	private final CraftWorld world;
	private final TileEntityDropper dropper;

	public CraftDropper(final Block block) {
		super(block);

		world = (CraftWorld) block.getWorld();
		dropper = (TileEntityDropper) world.getTileEntityAt(getX(), getY(), getZ());
	}

	public CraftDropper(final Material material, TileEntityDropper te) {
		super(material);
		world = null;
		dropper = te;
	}

	@Override
	public Inventory getInventory() {
		return new CraftInventory(dropper);
	}

	@Override
	public void drop() {
		Block block = getBlock();

		if (block.getType() == Material.DROPPER) {
			BlockDropper drop = (BlockDropper) Blocks.DROPPER;

			drop.dispense(world.getHandle(), new BlockPosition(getX(), getY(), getZ()));
		}
	}

	@Override
	public boolean update(boolean force, boolean applyPhysics) {
		boolean result = super.update(force, applyPhysics);

		if (result) {
			dropper.update();
		}

		return result;
	}

	@Override
	public TileEntityDropper getTileEntity() {
		return dropper;
	}
}
