use of net.minecraft.core.Direction in project MinecraftForge by MinecraftForge.
the class DispenseFluidContainer method fillContainer.
/**
* Picks up fluid in front of a Dispenser and fills a container with it.
*/
@Nonnull
private ItemStack fillContainer(@Nonnull BlockSource source, @Nonnull ItemStack stack) {
Level world = source.getLevel();
Direction dispenserFacing = source.getBlockState().getValue(DispenserBlock.FACING);
BlockPos blockpos = source.getPos().relative(dispenserFacing);
FluidActionResult actionResult = FluidUtil.tryPickUpFluid(stack, null, world, blockpos, dispenserFacing.getOpposite());
ItemStack resultStack = actionResult.getResult();
if (!actionResult.isSuccess() || resultStack.isEmpty()) {
return super.execute(source, stack);
}
if (stack.getCount() == 1) {
return resultStack;
} else if (((DispenserBlockEntity) source.getEntity()).addItem(resultStack) < 0) {
this.dispenseBehavior.dispense(source, resultStack);
}
ItemStack stackCopy = stack.copy();
stackCopy.shrink(1);
return stackCopy;
}
use of net.minecraft.core.Direction in project MinecraftForge by MinecraftForge.
the class SidedInvWrapper method create.
@SuppressWarnings("unchecked")
public static LazyOptional<IItemHandlerModifiable>[] create(WorldlyContainer inv, Direction... sides) {
LazyOptional<IItemHandlerModifiable>[] ret = new LazyOptional[sides.length];
for (int x = 0; x < sides.length; x++) {
final Direction side = sides[x];
ret[x] = LazyOptional.of(() -> new SidedInvWrapper(inv, side));
}
return ret;
}
Aggregations