mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-24 00:26:16 +02:00
add api for recipe changes
This commit is contained in:
parent
8914369d38
commit
b3cc234ef3
6 changed files with 95 additions and 19 deletions
|
|
@ -132,12 +132,12 @@ class AnvilResultListener : Listener {
|
|||
val amount = CustomRecipeUtil.getCustomRecipeAmount(recipe, leftItem, rightItem)
|
||||
val xpCost = recipe.determineCost(amount, leftItem, output)
|
||||
val finalCost =
|
||||
if (recipe.removeExactXp) xpCost
|
||||
if (recipe.removeExactLinearXp) xpCost
|
||||
else AnvilXpUtil.calculateLevelForXp(xpCost)
|
||||
|
||||
CustomAnvil.log("gamemode: ${player.gameMode != GameMode.CREATIVE}, cost: $finalCost, level: ${player.level}, result: ${player.totalExperience < finalCost} ${player.level < finalCost}")
|
||||
if (player.gameMode != GameMode.CREATIVE){
|
||||
if(recipe.removeExactXp){
|
||||
if(recipe.removeExactLinearXp){
|
||||
if(player.totalExperience < finalCost) return
|
||||
}else if(player.level < finalCost) return
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ class AnvilResultListener : Listener {
|
|||
|
||||
// Handle not creative middle click...
|
||||
if (event.click != ClickType.MIDDLE &&
|
||||
!handleCustomCraftClick(event, recipe, inventory, player, leftItem, rightItem, amount, finalCost, recipe.removeExactXp)
|
||||
!handleCustomCraftClick(event, recipe, inventory, player, leftItem, rightItem, amount, finalCost, recipe.removeExactLinearXp)
|
||||
) return
|
||||
|
||||
// Finally, we add the item to the player
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class PrepareAnvilListener : Listener {
|
|||
val xpCost = recipe.determineCost(amount, first, resultItem)
|
||||
|
||||
val levelCost =
|
||||
if (recipe.removeExactXp) AnvilXpUtil.calculateMinimumLevelForXp(xpCost)
|
||||
if (recipe.removeExactLinearXp) AnvilXpUtil.calculateMinimumLevelForXp(xpCost)
|
||||
else AnvilXpUtil.calculateLevelForXp(xpCost)
|
||||
|
||||
AnvilXpUtil.setAnvilInvXp(inventory, event.view, player, levelCost, true)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class AnvilCustomRecipe(
|
|||
var levelCostPerCraft: Int,
|
||||
|
||||
var XpCostPerCraft: Int,
|
||||
var removeExactXp: Boolean,
|
||||
var removeExactLinearXp: Boolean,
|
||||
|
||||
var leftItem: ItemStack?,
|
||||
var rightItem: ItemStack?,
|
||||
|
|
@ -96,7 +96,7 @@ class AnvilCustomRecipe(
|
|||
|
||||
fileConfig["$name.$XP_LEVEL_COST_CONFIG"] = levelCostPerCraft
|
||||
fileConfig["$name.$LINEAR_XP_COST_CONFIG"] = XpCostPerCraft
|
||||
fileConfig["$name.$REMOVE_EXACT_XP_CONFIG"] = removeExactXp
|
||||
fileConfig["$name.$REMOVE_EXACT_XP_CONFIG"] = removeExactLinearXp
|
||||
|
||||
fileConfig["$name.$LEFT_ITEM_CONFIG"] = leftItem
|
||||
fileConfig["$name.$RIGHT_ITEM_CONFIG"] = rightItem
|
||||
|
|
@ -132,7 +132,7 @@ class AnvilCustomRecipe(
|
|||
DEFAULT_LINEAR_XP_COST_CONFIG
|
||||
)
|
||||
|
||||
this.removeExactXp = ConfigHolder.CUSTOM_RECIPE_HOLDER.config.getBoolean(
|
||||
this.removeExactLinearXp = ConfigHolder.CUSTOM_RECIPE_HOLDER.config.getBoolean(
|
||||
"$name.$REMOVE_EXACT_XP_CONFIG",
|
||||
DEFAULT_REMOVE_EXACT_XP_CONFIG
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue