Package appeng.hooks

Source Code of appeng.hooks.DispenserBlockTool

package appeng.hooks;

import net.minecraft.block.BlockDispenser;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import appeng.util.Platform;

final public class DispenserBlockTool extends BehaviorDefaultDispenseItem
{

  @Override
  protected ItemStack dispenseStack(IBlockSource dispenser, ItemStack dispensedItem)
  {
    Item i = dispensedItem.getItem();
    if ( i instanceof IBlockTool )
    {
      EnumFacing enumfacing = BlockDispenser.func_149937_b( dispenser.getBlockMetadata() );
      IBlockTool tm = (IBlockTool) i;

      World w = dispenser.getWorld();
      if ( w instanceof WorldServer )
      {
        int x = dispenser.getXInt() + enumfacing.getFrontOffsetX();
        int y = dispenser.getYInt() + enumfacing.getFrontOffsetY();
        int z = dispenser.getZInt() + enumfacing.getFrontOffsetZ();

        tm.onItemUse( dispensedItem, Platform.getPlayer( (WorldServer) w ), w, x, y, z, enumfacing.ordinal(), 0.5f, 0.5f, 0.5f );
      }
    }
    return dispensedItem;
  }
}
TOP

Related Classes of appeng.hooks.DispenserBlockTool

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.