Skip to content

Commit

Permalink
fix glass bottle removed
Browse files Browse the repository at this point in the history
fix #1276

glass bottle is no longer removed if a blood container has to less blood
  • Loading branch information
Cheaterpaul committed Dec 15, 2023
1 parent 3408cc5 commit c969ec6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,17 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level worldIn,
FluidUtil.getFluidHandler(worldIn, pos, hit.getDirection()).ifPresent((fluidHandler -> {
if (fluidHandler.getFluidInTank(0).getFluid().equals(ModFluids.BLOOD.get())) {
ItemStack glass = playerIn.getItemInHand(hand);
ItemStack bloodBottle = new ItemStack(ModItems.BLOOD_BOTTLE.get(), 1);
playerIn.setItemInHand(hand, bloodBottle);
bloodBottle = FluidUtil.tryFillContainer(bloodBottle, fluidHandler, Integer.MAX_VALUE, playerIn, true).getResult();
if (glass.getCount() > 1) {
glass.shrink(1);
playerIn.setItemInHand(hand, glass);
playerIn.addItem(bloodBottle);
ItemStack bloodBottle = FluidUtil.tryFillContainer(new ItemStack(ModItems.BLOOD_BOTTLE.get(), 1), fluidHandler, Integer.MAX_VALUE, playerIn, true).getResult();
if (bloodBottle.isEmpty()) {
playerIn.displayClientMessage(Component.translatable("text.vampirism.container.not_enough_blood"), true);
} else {
playerIn.setItemInHand(hand, bloodBottle);
if (glass.getCount() > 1) {
glass.shrink(1);
playerIn.setItemInHand(hand, glass);
playerIn.addItem(bloodBottle);
} else {
playerIn.setItemInHand(hand, bloodBottle);
}
}
}
}));
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/vampirism/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"text.vampirism.fog_diffuser.booting": "Starting up",
"text.vampirism.fog_diffuser.idle": "Inactive",
"text.vampirism.fog_diffuser.active": "Running",
"text.vampirism.container.not_enough_blood": "Not enough blood",
"__comment": "block interaction texts",
"text.vampirism.med_chair_other_faction": "You cannot become a Hunter since you already are a %s",
"__comment": "faction item texts",
Expand Down

0 comments on commit c969ec6

Please sign in to comment.