2016-03-08 09:15:34 +01:00
|
|
|
package techreborn.dispenser;
|
|
|
|
|
|
|
|
import net.minecraft.block.BlockDispenser;
|
|
|
|
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
|
|
|
import net.minecraft.dispenser.IBlockSource;
|
|
|
|
import net.minecraft.dispenser.IPosition;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2016-06-25 16:25:04 +02:00
|
|
|
import net.minecraft.tileentity.TileEntityDispenser;
|
2016-03-08 09:15:34 +01:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-06-25 16:25:04 +02:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2016-03-08 09:15:34 +01:00
|
|
|
import techreborn.api.ScrapboxList;
|
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public class BehaviorDispenseScrapbox extends BehaviorDefaultDispenseItem {
|
2016-03-08 09:15:34 +01:00
|
|
|
|
|
|
|
@Override
|
2016-10-08 21:46:16 +02:00
|
|
|
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
|
2016-03-08 09:15:34 +01:00
|
|
|
int random = source.getWorld().rand.nextInt(ScrapboxList.stacks.size());
|
|
|
|
ItemStack out = ScrapboxList.stacks.get(random).copy();
|
|
|
|
float xOffset = source.getWorld().rand.nextFloat() * 0.8F + 0.1F;
|
|
|
|
float yOffset = source.getWorld().rand.nextFloat() * 0.8F + 0.1F;
|
|
|
|
float zOffset = source.getWorld().rand.nextFloat() * 0.8F + 0.1F;
|
|
|
|
stack.splitStack(1);
|
|
|
|
|
2016-06-25 16:25:04 +02:00
|
|
|
TileEntityDispenser tile = source.getBlockTileEntity();
|
|
|
|
EnumFacing enumfacing = tile.getWorld().getBlockState(new BlockPos(source.getX(), source.getY(), source.getZ())).getValue(BlockDispenser.FACING);
|
2016-03-08 09:15:34 +01:00
|
|
|
IPosition iposition = BlockDispenser.getDispensePosition(source);
|
|
|
|
doDispense(source.getWorld(), out, 6, enumfacing, iposition);
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|