use of com.mrh0.createaddition.recipe.crude_burning.CrudeBurningRecipe in project createaddition by mrh0.
the class CrudeBurningCategory method setRecipe.
@Override
public void setRecipe(IRecipeLayout recipeLayout, CrudeBurningRecipe recipe, IIngredients ingredients) {
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
NonNullList<FluidIngredient> fluidIngredients = NonNullList.of(recipe.getFluidIngredient());
List<FluidStack> out = new ArrayList<FluidStack>();
fluidStacks.init(0, true, 81, 7);
fluidStacks.set(0, withImprovedVisibility(recipe.getFluidIngredient().getMatchingFluidStacks().stream().map(fluid -> {
out.add(fluid);
return fluid;
}).collect(Collectors.toList())));
addFluidTooltip(fluidStacks, fluidIngredients, out);
}
use of com.mrh0.createaddition.recipe.crude_burning.CrudeBurningRecipe in project createaddition by mrh0.
the class CrudeBurner method use.
@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (world.isClientSide())
return InteractionResult.SUCCESS;
BlockEntity tileentity = world.getBlockEntity(pos);
if (tileentity instanceof CrudeBurnerTileEntity) {
CrudeBurnerTileEntity cbte = (CrudeBurnerTileEntity) tileentity;
ItemStack held = player.getMainHandItem();
if (!(held.getItem() instanceof BucketItem))
return InteractionResult.CONSUME;
LazyOptional<IFluidHandlerItem> cap = held.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
if (!cap.isPresent())
return InteractionResult.CONSUME;
IFluidHandlerItem handler = cap.orElse(null);
if (handler.getFluidInTank(0).isEmpty())
return InteractionResult.CONSUME;
FluidStack stack = handler.getFluidInTank(0);
Optional<CrudeBurningRecipe> recipe = cbte.find(stack, world);
if (!recipe.isPresent())
return InteractionResult.CONSUME;
LazyOptional<IFluidHandler> tecap = cbte.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY);
if (!tecap.isPresent())
return InteractionResult.CONSUME;
IFluidHandler tehandler = tecap.orElse(null);
if (tehandler.getTankCapacity(0) - tehandler.getFluidInTank(0).getAmount() < 1000)
return InteractionResult.CONSUME;
tehandler.fill(new FluidStack(handler.getFluidInTank(0).getFluid(), 1000), FluidAction.EXECUTE);
if (!player.isCreative())
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.BUCKET, 1));
player.playSound(SoundEvents.BUCKET_EMPTY, 1f, 1f);
}
return InteractionResult.CONSUME;
}
Aggregations