Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Adds drink XP feature #220

Open
wants to merge 1 commit into
base: 1.20
Choose a base branch
from

Conversation

kaique-lisboa
Copy link

Likewise it was in OpenBlocks the player could be able to consume the Liquid XP from the tanks by right-clicking into it.

This feature would help player to easily achieve the desired level for enchanting and other applications.

  • Works in Regular tanks and ender tanks
  • Works only on right clicking with empty main hand
  • Uses transactions to validate if liquidXP was successfully extracted from tank
  • Can disable this feature on Config

Comment on lines +48 to +63
transaction.addCloseCallback { _, result ->
if(result.wasAborted()) {
return@addCloseCallback
}
player.addExperience(convertMilibucketsToXp(liquidXpToExtract).toInt())
if(extractedAmount > 0) {
player.world.playSound(
null,
player.blockPos,
SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP,
SoundCategory.AMBIENT,
.5f,
player.world.random.nextBetween(3,9).toFloat() / 10)
}
}
transaction.commit()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very important step, validating on transaction success ensures that the XP was actually drained from tank before adding the experience levels to player.

XpDrain and XpShowerBlockEntity should use wasAborted or wasCommited methods of Transaction as well, as of today, if the fluid transfer fails for whatever reason, the XP will be drained / created either way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants