Skip to content

Commit

Permalink
Re-add forge in 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
legobmw99 committed Jun 16, 2024
1 parent 0063a81 commit 1208c83
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 28 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
BetterThanMending 2.0.2
BetterThanMending 2.1.0
=========
[![ CurseForge](http://cf.way2muchnoise.eu/264738.svg)](https://minecraft.curseforge.com/projects/better-than-mending) [![Modrinth Downloads](https://img.shields.io/modrinth/dt/better-than-mending?color=00AF5C&label=downloads&style=flat-square&logo=modrinth)](https://modrinth.com/mod/better-than-mending) [![Build status](https://github.com/legobmw99/BetterThanMending/actions/workflows/build.yml/badge.svg)](https://github.com/legobmw99/BetterThanMending/actions)

A simple mod to improve Mending, allowing you to repair items by shift-right clicking and draining experience

This mod is currently updated for `Minecraft 1.20.6`.
This mod is currently updated for `Minecraft 1.21`.

Please verify and report any issues!
3 changes: 3 additions & 0 deletions buildSrc/src/main/groovy/multiloader-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ processResources {
"minecraft_version_range": minecraft_version_range,
"fabric_version": fabric_version,
"fabric_loader_version": fabric_loader_version,
"forge_version" : forge_version,
"forge_loader_version_range": forge_loader_version_range,
"forge_version_range" : forge_version_range,
"mod_name": mod_name,
"mod_author": mod_author,
"mod_id": mod_id,
Expand Down
14 changes: 7 additions & 7 deletions common/src/main/java/com/legobmw99/BetterThanMending/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ public static boolean willMend(Player player, ItemStack stack) {
return (player.isShiftKeyDown() && stack.isDamaged() && EnchantmentHelper.has(stack, EnchantmentEffectComponents.REPAIR_WITH_XP) && Utilities.getPlayerXP(player) > 2);
}

private static void repair(ServerPlayer player, ItemStack stack, int xp) {
int amt = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.serverLevel(), stack, xp);
amt = Math.min(amt, stack.getDamageValue());
stack.setDamageValue(stack.getDamageValue() - amt);
private static void repair(ServerPlayer player, ItemStack stack, int xp, float ratio) {
int couldRepair = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.serverLevel(), stack, (int) (xp * ratio));
int toRepair = Math.min(couldRepair, stack.getDamageValue());
stack.setDamageValue(stack.getDamageValue() - toRepair);
Utilities.addPlayerXP(player, -xp);
}

public static void doMend(ServerPlayer player, ItemStack stack) {
public static void doMend(ServerPlayer player, ItemStack stack, float ratio) {
int playerXP = Utilities.getPlayerXP(player);
if (playerXP >= 30 && stack.getDamageValue() >= 40) {
// fast track
repair(player, stack, 20);
repair(player, stack, 20, ratio);
} else if (playerXP >= 2) {
repair(player, stack, 2);
repair(player, stack, 2, ratio);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void onInitialize() {
ItemStack stack = player.getItemInHand(hand);
if (Common.willMend(player, stack)) {
if (player instanceof ServerPlayer splayer) {
Common.doMend(splayer, stack);
Common.doMend(splayer, stack, 1.0f);
}
return InteractionResultHolder.success(stack);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.legobmw99.BetterThanMending;

import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -28,7 +29,7 @@ public void onItemUse(final PlayerInteractEvent.RightClickItem event) {
ItemStack stack = event.getItemStack();
if (Common.willMend(player, stack)) {
if (player instanceof ServerPlayer splayer) {
Common.doMend(splayer, stack);
Common.doMend(splayer, stack, 1.0f);
}
event.setCancellationResult(InteractionResult.SUCCESS);
event.setCanceled(true);
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fabric_version=0.100.1+1.21
fabric_loader_version=0.15.11
# Forge
# https://files.minecraftforge.net/net/minecraftforge/forge/
forge_version=50.0.5
forge_loader_version_range=[50,)
forge_version_range=[50,)
forge_version=51.0.8
forge_loader_version_range=[51,)
forge_version_range=[51,)
# NeoForge
# https://projects.neoforged.net/neoforged/neoforge
neoforge_version=21.0.8-beta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void onItemUse(final PlayerInteractEvent.RightClickItem event) {
ItemStack stack = event.getItemStack();
if (Common.willMend(player, stack)) {
if (player instanceof ServerPlayer splayer) {
Common.doMend(splayer, stack);
Common.doMend(splayer, stack, stack.getXpRepairRatio());
}
event.setCancellationResult(InteractionResult.SUCCESS);
event.setCanceled(true);
Expand Down
26 changes: 13 additions & 13 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ pluginManagement {
includeGroup("fabric-loom")
}
}
// exclusiveContent {
// forRepository {
// maven {
// name = 'Forge'
// url = uri("https://maven.minecraftforge.net")
// }
// }
// filter {
// includeGroupAndSubgroups("net.minecraftforge")
// }
// }
exclusiveContent {
forRepository {
maven {
name = 'Forge'
url = uri("https://maven.minecraftforge.net")
}
}
filter {
includeGroupAndSubgroups("net.minecraftforge")
}
}
exclusiveContent {
forRepository {
maven {
Expand All @@ -46,7 +46,7 @@ pluginManagement {
}
filter {
includeGroupAndSubgroups("org.spongepowered")
includeGroup("net.minecraftforge")
// includeGroup("net.minecraftforge")
}
}
}
Expand All @@ -60,5 +60,5 @@ plugins {
rootProject.name = 'BetterThanMending'
include("common")
include("fabric")
//include("forge")
include("forge")
include("neoforge")

0 comments on commit 1208c83

Please sign in to comment.