Fixed bows not having any durability

master
Wynd 2024-09-11 14:49:42 +03:00
parent 3262546727
commit 7494d3e514
5 changed files with 40 additions and 5 deletions

View File

@ -83,6 +83,8 @@ public class ModConfig {
"Givs two slabs for every block, since 1 block = 2 slabs => 3 blocks = 6 slabs (instead of 3)");
public static final Option<Boolean> FIX_SLIME_SPLITS = make("Fix Slime Splits", true,
"Fixes slimes not splitting if their HP is not exactly zero");
public static final Option<Boolean> FIX_BOW_DURABILITY = make("Bow Durability", true,
"Enables durability stat on bows (385 uses)");
private static ModConfig instance = new ModConfig();
public static final ModConfig instance() {

View File

@ -115,7 +115,7 @@ public class WyHelper {
// player.dropItem(new ItemInstance(Tile.SLAB, 64));
// player.dropItem(new ItemInstance(ItemType.minecart, 1));
// player.dropItem(new ItemInstance(ItemType.minecartFurnace, 1));
player.dropItem(new ItemInstance(ItemType.hatchetDiamond, 1));
player.dropItem(new ItemInstance(ItemType.bow, 1));
// player.dropItem(new ItemInstance(Tile.GOLDEN_RAIL, 64));
// player.dropItem(new ItemInstance(Tile.COBBLESTONE, 64));

View File

@ -2,20 +2,37 @@ package xyz.pixelatedw.finalbeta.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemInstance;
import net.minecraft.item.ItemType;
import net.minecraft.item.tool.BowItem;
import net.minecraft.level.Level;
import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(BowItem.class)
public class BowItemMixin {
@Inject(method = "<init>(I)V", at = @At("TAIL"))
public void init(int i, CallbackInfo ci) {
if(ModConfig.FIX_BOW_MODEL.get()) {
ItemType item = ((ItemType) (Object) this);
if (ModConfig.FIX_BOW_MODEL.get()) {
item.method_466();
}
if (ModConfig.FIX_BOW_DURABILITY.get()) {
((ItemTypeAccessor) item).setDurability(385);
}
}
@Inject(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/level/Level;spawnEntity(Lnet/minecraft/entity/Entity;)Z", shift = Shift.AFTER))
public void use(ItemInstance stack, Level level, Player player, CallbackInfoReturnable<ItemInstance> cir) {
if (ModConfig.FIX_BOW_DURABILITY.get()) {
stack.applyDamage(1, player);
}
}
}

View File

@ -0,0 +1,15 @@
package xyz.pixelatedw.finalbeta.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.item.ItemType;
@Mixin(ItemType.class)
public interface ItemTypeAccessor {
@Accessor("field_402")
public int getDurability();
@Accessor("field_402")
public void setDurability(int durability);
}

View File

@ -45,7 +45,8 @@
"DimensionMixin",
"TranslationStorageMixin",
"RecipeRegistryAccessor",
"FoodItemMixin"
"FoodItemMixin",
"ItemTypeAccessor"
],
"injectors": {
"defaultRequire": -1