2014-03-02 09:35:11 +01:00
|
|
|
package appeng.hooks;
|
2014-02-27 08:10:45 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2014-05-26 10:26:37 +02:00
|
|
|
final public class DispenserBlockTool extends BehaviorDefaultDispenseItem
|
2014-02-27 08:10:45 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected ItemStack dispenseStack(IBlockSource dispenser, ItemStack dispensedItem)
|
|
|
|
{
|
|
|
|
Item i = dispensedItem.getItem();
|
2014-05-26 10:26:37 +02:00
|
|
|
if ( i instanceof IBlockTool )
|
2014-02-27 08:10:45 +01:00
|
|
|
{
|
|
|
|
EnumFacing enumfacing = BlockDispenser.func_149937_b( dispenser.getBlockMetadata() );
|
2014-05-26 10:26:37 +02:00
|
|
|
IBlockTool tm = (IBlockTool) i;
|
2014-02-27 08:10:45 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|