Advertisement
TheOnlyTails

Custom dispenser behavior

Aug 8th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. DefaultDispenseItemBehavior dispenserBehavior = new DefaultDispenseItemBehavior() {
  2.     @Override
  3.     protected @NotNull ItemStack dispenseStack(@NotNull IBlockSource source, @NotNull ItemStack stack) {
  4.         Direction direction = source.getBlockState().get(DispenserBlock.FACING);
  5.         EntityType<?> type = ((SpawnEggItem) stack.getItem()).getType(stack.getTag());
  6.         type.spawn(source.getWorld(), stack, null, source.getBlockPos(), SpawnReason.DISPENSER, direction != Direction.UP, false);
  7.         stack.shrink(1);
  8.         return stack;
  9.     }
  10. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement