Fixed bows not having any durability
parent
3262546727
commit
7494d3e514
|
@ -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)");
|
"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,
|
public static final Option<Boolean> FIX_SLIME_SPLITS = make("Fix Slime Splits", true,
|
||||||
"Fixes slimes not splitting if their HP is not exactly zero");
|
"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();
|
private static ModConfig instance = new ModConfig();
|
||||||
public static final ModConfig instance() {
|
public static final ModConfig instance() {
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class WyHelper {
|
||||||
// player.dropItem(new ItemInstance(Tile.SLAB, 64));
|
// player.dropItem(new ItemInstance(Tile.SLAB, 64));
|
||||||
// player.dropItem(new ItemInstance(ItemType.minecart, 1));
|
// player.dropItem(new ItemInstance(ItemType.minecart, 1));
|
||||||
// player.dropItem(new ItemInstance(ItemType.minecartFurnace, 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.GOLDEN_RAIL, 64));
|
||||||
// player.dropItem(new ItemInstance(Tile.COBBLESTONE, 64));
|
// player.dropItem(new ItemInstance(Tile.COBBLESTONE, 64));
|
||||||
|
|
||||||
|
|
|
@ -2,20 +2,37 @@ package xyz.pixelatedw.finalbeta.mixin;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
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.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
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.ItemType;
|
||||||
import net.minecraft.item.tool.BowItem;
|
import net.minecraft.item.tool.BowItem;
|
||||||
|
import net.minecraft.level.Level;
|
||||||
import xyz.pixelatedw.finalbeta.ModConfig;
|
import xyz.pixelatedw.finalbeta.ModConfig;
|
||||||
|
|
||||||
@Mixin(BowItem.class)
|
@Mixin(BowItem.class)
|
||||||
public class BowItemMixin {
|
public class BowItemMixin {
|
||||||
@Inject(method = "<init>(I)V", at = @At("TAIL"))
|
@Inject(method = "<init>(I)V", at = @At("TAIL"))
|
||||||
public void init(int i, CallbackInfo ci) {
|
public void init(int i, CallbackInfo ci) {
|
||||||
if(ModConfig.FIX_BOW_MODEL.get()) {
|
|
||||||
ItemType item = ((ItemType) (Object) this);
|
ItemType item = ((ItemType) (Object) this);
|
||||||
|
|
||||||
|
if (ModConfig.FIX_BOW_MODEL.get()) {
|
||||||
item.method_466();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -45,7 +45,8 @@
|
||||||
"DimensionMixin",
|
"DimensionMixin",
|
||||||
"TranslationStorageMixin",
|
"TranslationStorageMixin",
|
||||||
"RecipeRegistryAccessor",
|
"RecipeRegistryAccessor",
|
||||||
"FoodItemMixin"
|
"FoodItemMixin",
|
||||||
|
"ItemTypeAccessor"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": -1
|
"defaultRequire": -1
|
||||||
|
|
Loading…
Reference in New Issue