Compare commits

..

3 Commits

7 changed files with 98 additions and 5 deletions

View File

@ -52,6 +52,8 @@ public class ModConfig {
"Clouds height modifier, goes from 0.0, meaning the default 108 blocks height, to 1.0, meaning a 324 blocks height.");
public static final Option<Boolean> ENABLE_COAL_AND_REDSTONE_BLOCKS_RECIPE = make("Enable Coal and Redstone Blocks Recipe", false,
"Allows crafting coal and redstone as blocks for better storage");
public static final Option<Boolean> DISABLE_EATING_WHEN_MAX_HP = make("Disable eating when at max HP", false,
"Makes it so players can no longer eat if they're at max HP so they don't accidently waste food");
public static final Option<Boolean> FIX_BOW_MODEL = make("Fix bow model", true,
"Makes the box model held by players and skeletons bigger and facing forward");
@ -81,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);
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,22 @@
package xyz.pixelatedw.finalbeta.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemInstance;
import net.minecraft.item.food.FoodItem;
import net.minecraft.level.Level;
import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(FoodItem.class)
public class FoodItemMixin {
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
public void use(ItemInstance stack, Level level, Player player, CallbackInfoReturnable<ItemInstance> cir) {
if (ModConfig.DISABLE_EATING_WHEN_MAX_HP.get() && player.health >= 20) {
cir.setReturnValue(stack);
}
}
}

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

@ -0,0 +1,32 @@
package xyz.pixelatedw.finalbeta.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
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.level.Level;
import net.minecraft.tile.PressurePlateTile;
import net.minecraft.tile.Tile;
@Mixin(PressurePlateTile.class)
public class PressurePlateTileMixin {
@Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true)
public void canPlaceAt(Level level, int x, int y, int z, CallbackInfoReturnable<Boolean> cir) {
int tileId = level.getTileId(x, y - 1, z);
if (tileId == Tile.FENCE.id) {
cir.setReturnValue(true);
return;
}
}
@Inject(method = "method_1609", at = @At("HEAD"), cancellable = true)
public void canSurviveAt(Level level, int x, int y, int z, int i1, CallbackInfo ci) {
int tileId = level.getTileId(x, y - 1, z);
if (tileId == Tile.FENCE.id) {
ci.cancel();
return;
}
}
}

View File

@ -44,7 +44,10 @@
"SlimeMixin",
"DimensionMixin",
"TranslationStorageMixin",
"RecipeRegistryAccessor"
"RecipeRegistryAccessor",
"FoodItemMixin",
"ItemTypeAccessor",
"PressurePlateTileMixin"
],
"injectors": {
"defaultRequire": -1