diff --git a/gradle.properties b/gradle.properties index d689b95..e08ce47 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=b1.7.3-build.2 loader_version=0.14.24-babric.1 # Mod Properties -mod_version=2.2.0 +mod_version=2.3.0 maven_group=com.github.telvarost archives_base_name=AnnoyanceFix @@ -17,6 +17,6 @@ archives_base_name=AnnoyanceFix stapi_version=2.0-alpha.1.1 # Extra Dependencies -gcapi_version=1.2.0 +gcapi_version=2.0.1 howmanyitems_version=5.1.1 modmenu_version=dcef643 \ No newline at end of file diff --git a/src/main/java/com/github/telvarost/annoyancefix/BoatCollisionEnum.java b/src/main/java/com/github/telvarost/annoyancefix/BoatCollisionEnum.java new file mode 100644 index 0000000..80ebb75 --- /dev/null +++ b/src/main/java/com/github/telvarost/annoyancefix/BoatCollisionEnum.java @@ -0,0 +1,22 @@ +package com.github.telvarost.annoyancefix; + +public enum BoatCollisionEnum { + VANILLA("Vanilla"), + DROP_BOAT("Drop Boat"), + INVINCIBLE("Invincible"); + + final String stringValue; + + BoatCollisionEnum() { + this.stringValue = "Vanilla"; + } + + BoatCollisionEnum(String stringValue) { + this.stringValue = stringValue; + } + + @Override + public String toString() { + return stringValue; + } +} \ No newline at end of file diff --git a/src/main/java/com/github/telvarost/annoyancefix/BoatCollisionEnumFactory.java b/src/main/java/com/github/telvarost/annoyancefix/BoatCollisionEnumFactory.java new file mode 100644 index 0000000..01fb29b --- /dev/null +++ b/src/main/java/com/github/telvarost/annoyancefix/BoatCollisionEnumFactory.java @@ -0,0 +1,40 @@ +package com.github.telvarost.annoyancefix; + +import blue.endless.jankson.JsonElement; +import blue.endless.jankson.JsonPrimitive; +import com.google.common.collect.ImmutableMap; +import net.glasslauncher.mods.api.gcapi.api.ConfigFactoryProvider; +import net.glasslauncher.mods.api.gcapi.api.MaxLength; +import net.glasslauncher.mods.api.gcapi.impl.NonFunction; +import net.glasslauncher.mods.api.gcapi.impl.config.ConfigEntry; +import net.glasslauncher.mods.api.gcapi.impl.config.entry.EnumConfigEntry; + +import java.lang.reflect.*; +import java.util.function.*; + +public class BoatCollisionEnumFactory implements ConfigFactoryProvider { + @Override + public void provideLoadFactories(ImmutableMap.Builder>> immutableBuilder) { + immutableBuilder.put(BoatCollisionEnum.class, ((id, name, description, parentField, parentObject, isMultiplayerSynced, enumOrOrdinal, defaultEnum, maxLength) -> + { + int enumOrdinal; + if(enumOrOrdinal instanceof Integer ordinal) { + enumOrdinal = ordinal; + } + else { + enumOrdinal = ((BoatCollisionEnum) enumOrOrdinal).ordinal(); + } + return new EnumConfigEntry(id, name, description, parentField, parentObject, isMultiplayerSynced, enumOrdinal, ((BoatCollisionEnum) defaultEnum).ordinal(), BoatCollisionEnum.class); + })); + } + + @Override + public void provideSaveFactories(ImmutableMap.Builder> immutableBuilder) { + immutableBuilder.put(BoatCollisionEnum.class, enumEntry -> new JsonPrimitive(((BoatCollisionEnum) enumEntry).ordinal())); + } + + @Override + public void provideLoadTypeAdapterFactories(@SuppressWarnings("rawtypes") ImmutableMap.Builder immutableBuilder) { + immutableBuilder.put(BoatCollisionEnum.class, Integer.class); + } +} diff --git a/src/main/java/com/github/telvarost/annoyancefix/Config.java b/src/main/java/com/github/telvarost/annoyancefix/Config.java index ef93ad5..d48f092 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/Config.java +++ b/src/main/java/com/github/telvarost/annoyancefix/Config.java @@ -1,110 +1,165 @@ package com.github.telvarost.annoyancefix; import blue.endless.jankson.Comment; -import net.glasslauncher.mods.api.gcapi.api.ConfigCategory; -import net.glasslauncher.mods.api.gcapi.api.ConfigName; -import net.glasslauncher.mods.api.gcapi.api.GConfig; -import net.glasslauncher.mods.api.gcapi.api.MaxLength; +import net.glasslauncher.mods.api.gcapi.api.*; public class Config { - @GConfig(value = "config", visibleName = "AnnoyanceFix Config") + @GConfig(value = "config", visibleName = "AnnoyanceFix") public static ConfigFields config = new ConfigFields(); public static class AxesConfig { @ConfigName("Effective On Workbench") - public static Boolean enableAxesEffectiveOnWorkbench = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enableAxesEffectiveOnWorkbench = true; @ConfigName("Effective On Noteblock") - public static Boolean enableAxesEffectiveOnNoteblock = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enableAxesEffectiveOnNoteblock = true; @ConfigName("Effective On Wood Door") - public static Boolean enableAxesEffectiveOnWoodDoor = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enableAxesEffectiveOnWoodDoor = true; @ConfigName("Effective On Ladders") - public static Boolean enableAxesEffectiveOnLadders = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enableAxesEffectiveOnLadders = true; @ConfigName("Effective On Signs") - public static Boolean enableAxesEffectiveOnSigns = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enableAxesEffectiveOnSigns = true; @ConfigName("Effective On Wood Pressure Plate") - public static Boolean enableAxesEffectiveOnWoodPressurePlate = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enableAxesEffectiveOnWoodPressurePlate = true; @ConfigName("Effective On Jukebox") - public static Boolean enableAxesEffectiveOnJukebox = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enableAxesEffectiveOnJukebox = true; @ConfigName("Effective On Wood Stairs") - public static Boolean enableAxesEffectiveOnWoodStairs = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enableAxesEffectiveOnWoodStairs = true; @ConfigName("Effective On Fence") - public static Boolean enableAxesEffectiveOnFence = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enableAxesEffectiveOnFence = true; @ConfigName("Effective On Pumpkin") - public static Boolean enableAxesEffectiveOnPumpkin = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enableAxesEffectiveOnPumpkin = true; @ConfigName("Effective On Jack o Lantern") - public static Boolean enableAxesEffectiveOnJackOLantern = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enableAxesEffectiveOnJackOLantern = true; @ConfigName("Effective On Trapdoor") - public static Boolean enableAxesEffectiveOnTrapdoor = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enableAxesEffectiveOnTrapdoor = true; } public static class PickaxesConfig { @ConfigName("Effective On Dispenser") - public static Boolean enablePickaxesEffectiveOnDispenser = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnDispenser = true; @ConfigName("Effective On Normal Rails") - public static Boolean enablePickaxesEffectiveOnNormalRails = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnNormalRails = true; @ConfigName("Effective On Detector Rails") - public static Boolean enablePickaxesEffectiveOnDetectorRails = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnDetectorRails = true; @ConfigName("Effective On Golden Rails") - public static Boolean enablePickaxesEffectiveOnGoldenRails = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnGoldenRails = true; @ConfigName("Effective On Furnace") - public static Boolean enablePickaxesEffectiveOnFurnace = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnFurnace = true; @ConfigName("Effective On Furnace Lit") - public static Boolean enablePickaxesEffectiveOnFurnaceLit = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnFurnaceLit = true; @ConfigName("Effective On Cobblestone Stairs") - public static Boolean enablePickaxesEffectiveOnCobblestoneStairs = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnCobblestoneStairs = true; @ConfigName("Effective On Stone Pressure Plate") - public static Boolean enablePickaxesEffectiveOnStonePressurePlate = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnStonePressurePlate = true; @ConfigName("Effective On Iron Door") - public static Boolean enablePickaxesEffectiveOnIronDoor = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnIronDoor = true; @ConfigName("Effective On Redstone Ore") - public static Boolean enablePickaxesEffectiveOnRedstoneOre = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnRedstoneOre = true; @ConfigName("Effective On Redstone Ore Lit") - public static Boolean enablePickaxesEffectiveOnRedstoneOreLit = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnRedstoneOreLit = true; @ConfigName("Effective On Stone Button") - public static Boolean enablePickaxesEffectiveOnStoneButton = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnStoneButton = true; @ConfigName("Effective On Bricks") - public static Boolean enablePickaxesEffectiveOnBricks = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnBricks = true; @ConfigName("Effective On Mob Spawner") - public static Boolean enablePickaxesEffectiveOnMobSpawner = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean enablePickaxesEffectiveOnMobSpawner = true; } public static class RecipesConfig { @ConfigName("Crafting: Repair Armor") - public static Boolean recipesRepairArmorEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean recipesRepairArmorEnabled = true; @ConfigName("Crafting: Repair Tools") - public static Boolean recipesRepairToolsEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean recipesRepairToolsEnabled = true; @ConfigName("Furnace: Add More Wood Items As Fuel") - public static Boolean recipesAdditionalWoodFuelsEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean recipesAdditionalWoodFuelsEnabled = true; } @@ -112,55 +167,81 @@ public static class ConfigFields { @ConfigCategory("Config: Axes Are Effective Against") @Comment("Options here require restart to take effect") - public static final AxesConfig AXES_CONFIG = new AxesConfig(); + public final AxesConfig AXES_CONFIG = new AxesConfig(); @ConfigCategory("Config: Pickaxes Are Effective Against") @Comment("Options here require restart to take effect") - public static final PickaxesConfig PICKAXES_CONFIG = new PickaxesConfig(); + public final PickaxesConfig PICKAXES_CONFIG = new PickaxesConfig(); @ConfigCategory("Config: Recipes/Fuels For Crafting/Furnaces") @Comment("Options here require restart to take effect") - public static final RecipesConfig RECIPES_CONFIG = new RecipesConfig(); + public final RecipesConfig RECIPES_CONFIG = new RecipesConfig(); @ConfigName("Boat Drop Fixes Enabled") - public static Boolean boatDropFixesEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean boatDropFixesEnabled = true; @ConfigName("Boat Speed Collision Behavior") - @MaxLength(3) - @Comment("0 = vanilla, 1 = drop boat, 2 = invincible") - public static Integer boatCollisionBehavior = 2; + @MultiplayerSynced + @ValueOnVanillaServer(integerValue = 0) + public BoatCollisionEnum boatCollisionBehavior = BoatCollisionEnum.INVINCIBLE; @ConfigName("Bookshelf Fixes Enabled") - public static Boolean bookshelfFixesEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean bookshelfFixesEnabled = true; @ConfigName("Cobweb Fixes Enabled") - public static Boolean cobwebFixesEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean cobwebFixesEnabled = true; @ConfigName("Fence Placement Fixes Enabled") - public static Boolean fenceFixesEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean fenceFixesEnabled = true; @ConfigName("Fence Shape Fixes Enabled") - public static Boolean fenceShapeFixesEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean fenceShapeFixesEnabled = true; @ConfigName("Flint and Steel Fixes Enabled") - public static Boolean flintAndSteelFixesEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean flintAndSteelFixesEnabled = true; @ConfigName("Lava Fixes Enabled") - public static Boolean lavaFixesEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean lavaFixesEnabled = true; @ConfigName("Pick Block Fixes Enabled") - public static Boolean pickBlockFixesEnabled = true; + @Comment("Only searches hotbar on multiplayer") + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean pickBlockFixesEnabled = true; @ConfigName("Pig Fixes Enabled") - public static Boolean pigFixesEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean pigFixesEnabled = true; @ConfigName("Stair Fixes Enabled") - public static Boolean stairFixesEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean stairFixesEnabled = true; @ConfigName("Water Fixes Enabled") - public static Boolean waterFixesEnabled = true; + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean waterFixesEnabled = true; @ConfigName("Wood Slab Fixes Enabled (Experimental)") - public static Boolean woodenSlabFixesEnabled = false; + @Comment("Does not work in multiplayer") + @MultiplayerSynced + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean woodenSlabFixesEnabled = false; } } diff --git a/src/main/java/com/github/telvarost/annoyancefix/events/ItemUsedInCraftingListener.java b/src/main/java/com/github/telvarost/annoyancefix/events/ItemUsedInCraftingListener.java index 7df3863..1afb201 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/events/ItemUsedInCraftingListener.java +++ b/src/main/java/com/github/telvarost/annoyancefix/events/ItemUsedInCraftingListener.java @@ -24,8 +24,8 @@ public void combineDurability(ItemUsedInCraftingEvent event) { && (true == event.itemCrafted.hasDurability()) ) { - if ( (Config.RecipesConfig.recipesRepairArmorEnabled) - || (Config.RecipesConfig.recipesRepairToolsEnabled) + if ( (Config.config.RECIPES_CONFIG.recipesRepairArmorEnabled) + || (Config.config.RECIPES_CONFIG.recipesRepairToolsEnabled) ) { int craftedItemMaxDurability = event.itemCrafted.getDurability(); int durabilityToAdd = event.itemUsed.getDurability() - event.itemUsed.getDamage(); diff --git a/src/main/java/com/github/telvarost/annoyancefix/events/init/RecipeListener.java b/src/main/java/com/github/telvarost/annoyancefix/events/init/RecipeListener.java index c4983d8..b034c7a 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/events/init/RecipeListener.java +++ b/src/main/java/com/github/telvarost/annoyancefix/events/init/RecipeListener.java @@ -17,7 +17,7 @@ public void registerRecipes(RecipeRegisterEvent event) { Identifier type = event.recipeId; if (type == RecipeRegisterEvent.Vanilla.SMELTING.type()) { - if (Config.RecipesConfig.recipesAdditionalWoodFuelsEnabled) { + if (Config.config.RECIPES_CONFIG.recipesAdditionalWoodFuelsEnabled) { /** - 60 second fuel duration */ FuelRegistry.addFuelItem(ItemBase.boat, 1200); @@ -41,7 +41,7 @@ public void registerRecipes(RecipeRegisterEvent event) { } if (type == RecipeRegisterEvent.Vanilla.CRAFTING_SHAPELESS.type()) { - if (Config.RecipesConfig.recipesRepairArmorEnabled) { + if (Config.config.RECIPES_CONFIG.recipesRepairArmorEnabled) { /** - Armour Repair */ CraftingRegistry.addShapelessRecipe(new ItemInstance(ItemBase.leatherHelmet.id, 1, ItemBase.leatherHelmet.getDurability()), new ItemInstance(ItemBase.leatherHelmet.id, 1, -1), new ItemInstance(ItemBase.leatherHelmet.id, 1, -1)); CraftingRegistry.addShapelessRecipe(new ItemInstance(ItemBase.leatherChestplate.id, 1, ItemBase.leatherChestplate.getDurability()), new ItemInstance(ItemBase.leatherChestplate.id, 1, -1), new ItemInstance(ItemBase.leatherChestplate.id, 1, -1)); @@ -69,7 +69,7 @@ public void registerRecipes(RecipeRegisterEvent event) { CraftingRegistry.addShapelessRecipe(new ItemInstance(ItemBase.goldBoots.id, 1, ItemBase.goldBoots.getDurability()), new ItemInstance(ItemBase.goldBoots.id, 1, -1), new ItemInstance(ItemBase.goldBoots.id, 1, -1)); } - if (Config.RecipesConfig.recipesRepairToolsEnabled) { + if (Config.config.RECIPES_CONFIG.recipesRepairToolsEnabled) { /** - Tool Repair */ CraftingRegistry.addShapelessRecipe(new ItemInstance(ItemBase.woodAxe.id, 1, ItemBase.woodAxe.getDurability()), new ItemInstance(ItemBase.woodAxe.id, 1, -1), new ItemInstance(ItemBase.woodAxe.id, 1, -1)); CraftingRegistry.addShapelessRecipe(new ItemInstance(ItemBase.woodHoe.id, 1, ItemBase.woodHoe.getDurability()), new ItemInstance(ItemBase.woodHoe.id, 1, -1), new ItemInstance(ItemBase.woodHoe.id, 1, -1)); diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/BoatMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/BoatMixin.java index 763cb94..758e903 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/BoatMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/BoatMixin.java @@ -25,7 +25,7 @@ public BoatMixin(Level level) { constant = @Constant(intValue = 3) ) private int annoyanceFix_skipPlanksDrop(int constant) { - if (Config.ConfigFields.boatDropFixesEnabled) { + if (Config.config.boatDropFixesEnabled) { return 0; } else { return 3; @@ -37,7 +37,7 @@ private int annoyanceFix_skipPlanksDrop(int constant) { constant = @Constant(intValue = 2) ) private int annoyanceFix_skipSticksDrop(int constant) { - if (Config.ConfigFields.boatDropFixesEnabled) { + if (Config.config.boatDropFixesEnabled) { return 0; } else { return 2; @@ -52,7 +52,7 @@ private int annoyanceFix_skipSticksDrop(int constant) { ) ) private void annoyanceFix_dropBoat(EntityBase attacker, int damage, CallbackInfoReturnable cir) { - if (Config.ConfigFields.boatDropFixesEnabled) { + if (Config.config.boatDropFixesEnabled) { dropItem(ItemBase.boat.id, 1, 0); } } @@ -62,7 +62,7 @@ private void annoyanceFix_dropBoat(EntityBase attacker, int damage, CallbackInfo constant = @Constant(intValue = 3) ) private int annoyanceFix_skipPlanksDropOnCollision(int constant) { - if (0 < Config.ConfigFields.boatCollisionBehavior) { + if (0 < Config.config.boatCollisionBehavior.ordinal()) { return 0; } else { return 3; @@ -78,7 +78,7 @@ private int annoyanceFix_skipPlanksDropOnCollision(int constant) { ) ) private Item annoyanceFix_skipSticksDropOnCollision(Boat instance, int i, int j, float f) { - if (0 < Config.ConfigFields.boatCollisionBehavior) { + if (0 < Config.config.boatCollisionBehavior.ordinal()) { return null; } else { return instance.dropItem(i, j, f); @@ -93,7 +93,7 @@ private Item annoyanceFix_skipSticksDropOnCollision(Boat instance, int i, int j, ) ) private void annoyanceFix_dropBoatOnCollision(CallbackInfo ci) { - if (0 < Config.ConfigFields.boatCollisionBehavior) { + if (0 < Config.config.boatCollisionBehavior.ordinal()) { dropItem(ItemBase.boat.id, 1, 0); } } @@ -107,7 +107,7 @@ private void annoyanceFix_dropBoatOnCollision(CallbackInfo ci) { ) ) private boolean annoyanceFix_stopBoatBreaking(Boat instance) { - if (1 < Config.ConfigFields.boatCollisionBehavior) { + if (1 < Config.config.boatCollisionBehavior.ordinal()) { return false; } else { return this.field_1624; diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/BookshelfMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/BookshelfMixin.java index 990fed9..29f44cf 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/BookshelfMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/BookshelfMixin.java @@ -23,7 +23,7 @@ public BookshelfMixin(int i, Material arg) { constant = @Constant(intValue = 0) ) private int annoyanceFix_getDropCount(int constant) { - if (Config.ConfigFields.bookshelfFixesEnabled) { + if (Config.config.bookshelfFixesEnabled) { return 3; } else { return 0; @@ -32,7 +32,7 @@ private int annoyanceFix_getDropCount(int constant) { @Override public int getDropId(int i, Random random) { - if (Config.ConfigFields.bookshelfFixesEnabled) { + if (Config.config.bookshelfFixesEnabled) { return ItemBase.book.id; } else { return this.id; diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/CobwebMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/CobwebMixin.java index f1c6ea9..45dc0af 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/CobwebMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/CobwebMixin.java @@ -1,13 +1,14 @@ package com.github.telvarost.annoyancefix.mixin; - import com.github.telvarost.annoyancefix.Config; import net.minecraft.block.BlockBase; import net.minecraft.block.Cobweb; import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerBase; import net.minecraft.item.ItemBase; -import net.modificationstation.stationapi.api.entity.player.PlayerHelper; +import net.minecraft.level.Level; +import net.minecraft.stat.Stats; +import org.checkerframework.common.aliasing.qual.Unique; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -18,25 +19,42 @@ @Mixin(Cobweb.class) class CobwebMixin extends BlockBase { + @Unique + private boolean brokenByShears = false; + public CobwebMixin(int i, Material arg) { super(i, arg); } + @Override + public void afterBreak(Level arg, PlayerBase player, int i, int j, int k, int l) { + + if (Config.config.cobwebFixesEnabled) { + brokenByShears = false; + + if ( (null != player) + && (null != player.inventory) + && (null != player.inventory.getHeldItem()) + && (ItemBase.shears.id == player.inventory.getHeldItem().itemId) + ) + { + brokenByShears = true; + } + } + + player.increaseStat(Stats.mineBlock[this.id], 1); + this.drop(arg, i, j, k, l); + } + @Inject(at = @At("HEAD"), method = "getDropId", cancellable = true) public void annoyanceFix_getDropId(int i, Random random, CallbackInfoReturnable cir) { - if (!Config.ConfigFields.cobwebFixesEnabled) { + if (!Config.config.cobwebFixesEnabled) { return; } - PlayerBase player = PlayerHelper.getPlayerFromGame(); - - if ( (null != player) - && (null != player.inventory) - && (null != player.inventory.getHeldItem()) - && (ItemBase.shears.id == player.inventory.getHeldItem().itemId) - ) - { + if (brokenByShears) { cir.setReturnValue(id); + brokenByShears = false; } } } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/FenceMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/FenceMixin.java index dca15ef..11cb747 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/FenceMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/FenceMixin.java @@ -25,7 +25,7 @@ public FenceMixin(int i, Material arg) { cancellable = true ) private void annoyanceFix_canPlaceAt(Level arg, int i, int j, int k, CallbackInfoReturnable cir) { - if (Config.ConfigFields.fenceFixesEnabled) { + if (Config.config.fenceFixesEnabled) { cir.setReturnValue(true); } } @@ -61,7 +61,7 @@ private Box annoyanceFix_customFenceBox(Level level, int x, int y, int z, boolea @Inject(method = "getCollisionShape", at = @At("RETURN"), cancellable = true) public void annoyanceFix_getCollisionShape(Level level, int x, int y, int z, CallbackInfoReturnable cir) { - if (Config.ConfigFields.fenceShapeFixesEnabled) { + if (Config.config.fenceShapeFixesEnabled) { cir.setReturnValue(annoyanceFix_customFenceBox(level, x, y, z, true)); } } @@ -71,7 +71,7 @@ public void annoyanceFix_getCollisionShape(Level level, int x, int y, int z, Cal @Override public Box getOutlineShape(Level level, int x, int y, int z) { - if (Config.ConfigFields.fenceShapeFixesEnabled) { + if (Config.config.fenceShapeFixesEnabled) { FenceMixin.level = level; return annoyanceFix_customFenceBox(level, x, y, z, false); } @@ -82,7 +82,7 @@ public Box getOutlineShape(Level level, int x, int y, int z) { @Override public void updateBoundingBox(BlockView blockView, int x, int y, int z) { - if (Config.ConfigFields.fenceShapeFixesEnabled) { + if (Config.config.fenceShapeFixesEnabled) { if (level == null) return; Box box = annoyanceFix_customFenceBox(level, x, y, z); diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/FlintAndSteelMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/FlintAndSteelMixin.java index 33fbc54..1e8ac51 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/FlintAndSteelMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/FlintAndSteelMixin.java @@ -30,7 +30,7 @@ public FlintAndSteelMixin(int i) { constant = @Constant(intValue = 1, ordinal = 1) ) private int annoyanceFix_skipFlintDamage(int constant) { - if (Config.ConfigFields.flintAndSteelFixesEnabled) { + if (Config.config.flintAndSteelFixesEnabled) { return 0; } else { return 1; @@ -45,7 +45,7 @@ private int annoyanceFix_skipFlintDamage(int constant) { ) ) private void annoyanceFix_useOnTile(ItemInstance arg, PlayerBase arg2, Level arg3, int i, int j, int k, int l, CallbackInfoReturnable cir) { - if (!Config.ConfigFields.flintAndSteelFixesEnabled) { + if (!Config.config.flintAndSteelFixesEnabled) { return; } @@ -64,7 +64,7 @@ private void annoyanceFix_useOnTile(ItemInstance arg, PlayerBase arg2, Level arg ) ) private void annoyanceFix_useOnTileApplyDamage(ItemInstance arg, PlayerBase arg2, Level arg3, int i, int j, int k, int l, CallbackInfoReturnable cir) { - if (!Config.ConfigFields.flintAndSteelFixesEnabled) { + if (!Config.config.flintAndSteelFixesEnabled) { return; } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/FlowingFluidMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/FlowingFluidMixin.java index bbd56c4..eecad66 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/FlowingFluidMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/FlowingFluidMixin.java @@ -41,7 +41,7 @@ public FlowingFluidMixin(int i, Material arg) { ) ) private Material annoyanceFix_allowLavaToDisappear(FlowingFluid instance) { - if (Config.ConfigFields.lavaFixesEnabled) { + if (Config.config.lavaFixesEnabled) { return Material.WATER; } else { return instance.material; @@ -56,7 +56,7 @@ private Material annoyanceFix_allowLavaToDisappear(FlowingFluid instance) { ) ) private int annoyanceFix_allowWaterSpringPropagation(Level arg, int i, int j, int k) { - if (Config.ConfigFields.waterFixesEnabled) { + if (Config.config.waterFixesEnabled) { return arg.getTileMeta(i, j - 1, k); } else { return arg.getTileMeta(i, j, k); diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/HatchetMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/HatchetMixin.java index 107a553..1d6264c 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/HatchetMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/HatchetMixin.java @@ -26,7 +26,7 @@ public HatchetMixin(int i, int j, ToolMaterial arg, BlockBase[] args) { @Override public boolean isEffectiveOn(BlockBase arg) { - if ( (Config.ConfigFields.woodenSlabFixesEnabled) + if ( (Config.config.woodenSlabFixesEnabled) && (ModHelper.BlockTypeEnum.SLAB_BLOCK_IS_WOODEN == ModHelper.ModHelperFields.blockType) ) { @@ -51,52 +51,52 @@ private static void annoyanceFix_appendExtraBlocks(CallbackInfo ci) { ArrayList effectiveBlockList = new ArrayList(); - if (Config.AxesConfig.enableAxesEffectiveOnWorkbench) { + if (Config.config.AXES_CONFIG.enableAxesEffectiveOnWorkbench) { effectiveBlockList.add(BlockBase.WORKBENCH); } - if (Config.AxesConfig.enableAxesEffectiveOnNoteblock) { + if (Config.config.AXES_CONFIG.enableAxesEffectiveOnNoteblock) { effectiveBlockList.add(BlockBase.NOTEBLOCK); } - if (Config.AxesConfig.enableAxesEffectiveOnWoodDoor) { + if (Config.config.AXES_CONFIG.enableAxesEffectiveOnWoodDoor) { effectiveBlockList.add(BlockBase.WOOD_DOOR); } - if (Config.AxesConfig.enableAxesEffectiveOnLadders) { + if (Config.config.AXES_CONFIG.enableAxesEffectiveOnLadders) { effectiveBlockList.add(BlockBase.LADDER); } - if (Config.AxesConfig.enableAxesEffectiveOnSigns) { + if (Config.config.AXES_CONFIG.enableAxesEffectiveOnSigns) { effectiveBlockList.add(BlockBase.STANDING_SIGN); effectiveBlockList.add(BlockBase.WALL_SIGN); } - if (Config.AxesConfig.enableAxesEffectiveOnWoodPressurePlate) { + if (Config.config.AXES_CONFIG.enableAxesEffectiveOnWoodPressurePlate) { effectiveBlockList.add(BlockBase.WOODEN_PRESSURE_PLATE); } - if (Config.AxesConfig.enableAxesEffectiveOnJukebox) { + if (Config.config.AXES_CONFIG.enableAxesEffectiveOnJukebox) { effectiveBlockList.add(BlockBase.JUKEBOX); } - if (Config.AxesConfig.enableAxesEffectiveOnWoodStairs) { + if (Config.config.AXES_CONFIG.enableAxesEffectiveOnWoodStairs) { effectiveBlockList.add(BlockBase.WOOD_STAIRS); } - if (Config.AxesConfig.enableAxesEffectiveOnFence) { + if (Config.config.AXES_CONFIG.enableAxesEffectiveOnFence) { effectiveBlockList.add(BlockBase.FENCE); } - if (Config.AxesConfig.enableAxesEffectiveOnPumpkin) { + if (Config.config.AXES_CONFIG.enableAxesEffectiveOnPumpkin) { effectiveBlockList.add(BlockBase.PUMPKIN); } - if (Config.AxesConfig.enableAxesEffectiveOnJackOLantern) { + if (Config.config.AXES_CONFIG.enableAxesEffectiveOnJackOLantern) { effectiveBlockList.add(BlockBase.JACK_O_LANTERN); } - if (Config.AxesConfig.enableAxesEffectiveOnTrapdoor) { + if (Config.config.AXES_CONFIG.enableAxesEffectiveOnTrapdoor) { effectiveBlockList.add(BlockBase.TRAPDOOR); } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ItemBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ItemBaseMixin.java index 3fd5a94..9704196 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ItemBaseMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ItemBaseMixin.java @@ -18,7 +18,7 @@ public class ItemBaseMixin { cancellable = true ) private void annoyanceFix_isEffectiveOn(BlockBase par1, CallbackInfoReturnable cir) { - if (!Config.ConfigFields.woodenSlabFixesEnabled) { + if (!Config.config.woodenSlabFixesEnabled) { return; } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/MinecraftMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/MinecraftMixin.java index 51ad7cb..063d516 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/MinecraftMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/MinecraftMixin.java @@ -58,7 +58,7 @@ class MinecraftMixin { index = 1 ) private int annoyanceFix_pickBlock(int vanillaItemId) { - if (!Config.ConfigFields.pickBlockFixesEnabled) { + if (!Config.config.pickBlockFixesEnabled) { return vanillaItemId; } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/MultiPlayerClientInteractionManagerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/MultiPlayerClientInteractionManagerMixin.java index 6ab17e6..55b3ae3 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/MultiPlayerClientInteractionManagerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/MultiPlayerClientInteractionManagerMixin.java @@ -1,69 +1,69 @@ -package com.github.telvarost.annoyancefix.mixin; - -import com.github.telvarost.annoyancefix.Config; -import com.github.telvarost.annoyancefix.ModHelper; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.block.BlockBase; -import net.minecraft.client.BaseClientInteractionManager; -import net.minecraft.client.Minecraft; -import net.minecraft.client.MultiPlayerClientInteractionManager; -import net.minecraft.network.ClientPlayNetworkHandler; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Environment(EnvType.CLIENT) -@Mixin(MultiPlayerClientInteractionManager.class) -public class MultiPlayerClientInteractionManagerMixin extends BaseClientInteractionManager { - @Shadow - ClientPlayNetworkHandler networkHandler; - - public MultiPlayerClientInteractionManagerMixin(Minecraft minecraft, ClientPlayNetworkHandler arg) { - super(minecraft); - this.networkHandler = arg; - } - - /** - * When any clicked tile has a metadata value of 2 axes effective against slabs becomes true temporarily. - * This would occur even when tiles like wool with a metadata value of 2 are clicked, - * but nothing would happen for those as they are not slabs so the variable would have no effect. - * - * @param i - tile's x location - * @param j - tile's y location - * @param k - tile's z location - * @param l - unknown - * @param ci - callback info to allow cancelling the method - */ - @Inject( - method = "method_1707", - at = @At("HEAD") - ) - public void annoyanceFix_clickBlock(int i, int j, int k, int l, CallbackInfo ci) { - if (!Config.ConfigFields.woodenSlabFixesEnabled) { - return; - } - - int blockId = this.minecraft.level.getTileId(i, j, k); - int blockMetaData = this.minecraft.level.getTileMeta(i, j, k); - - /** - Save some information on block type */ - if ( (BlockBase.STONE_SLAB.id == blockId) - || (BlockBase.DOUBLE_STONE_SLAB.id == blockId) - ) - { - if (2 == blockMetaData) { - ModHelper.ModHelperFields.blockType = ModHelper.BlockTypeEnum.SLAB_BLOCK_IS_WOODEN; - } - else { - ModHelper.ModHelperFields.blockType = ModHelper.BlockTypeEnum.SLAB_BLOCK_IS_NOT_WOODEN; - } - } - else - { - ModHelper.ModHelperFields.blockType = ModHelper.BlockTypeEnum.BLOCK_IS_NOT_A_SLAB; - } - } -} \ No newline at end of file +//package com.github.telvarost.annoyancefix.mixin; +// +//import com.github.telvarost.annoyancefix.Config; +//import com.github.telvarost.annoyancefix.ModHelper; +//import net.fabricmc.api.EnvType; +//import net.fabricmc.api.Environment; +//import net.minecraft.block.BlockBase; +//import net.minecraft.client.BaseClientInteractionManager; +//import net.minecraft.client.Minecraft; +//import net.minecraft.client.MultiPlayerClientInteractionManager; +//import net.minecraft.network.ClientPlayNetworkHandler; +//import org.spongepowered.asm.mixin.Mixin; +//import org.spongepowered.asm.mixin.Shadow; +//import org.spongepowered.asm.mixin.injection.At; +//import org.spongepowered.asm.mixin.injection.Inject; +//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +// +//@Environment(EnvType.CLIENT) +//@Mixin(MultiPlayerClientInteractionManager.class) +//public class MultiPlayerClientInteractionManagerMixin extends BaseClientInteractionManager { +// @Shadow +// ClientPlayNetworkHandler networkHandler; +// +// public MultiPlayerClientInteractionManagerMixin(Minecraft minecraft, ClientPlayNetworkHandler arg) { +// super(minecraft); +// this.networkHandler = arg; +// } +// +// /** +// * When any clicked tile has a metadata value of 2 axes effective against slabs becomes true temporarily. +// * This would occur even when tiles like wool with a metadata value of 2 are clicked, +// * but nothing would happen for those as they are not slabs so the variable would have no effect. +// * +// * @param i - tile's x location +// * @param j - tile's y location +// * @param k - tile's z location +// * @param l - unknown +// * @param ci - callback info to allow cancelling the method +// */ +// @Inject( +// method = "method_1707", +// at = @At("HEAD") +// ) +// public void annoyanceFix_clickBlock(int i, int j, int k, int l, CallbackInfo ci) { +// if (!Config.config.woodenSlabFixesEnabled) { +// return; +// } +// +// int blockId = this.minecraft.level.getTileId(i, j, k); +// int blockMetaData = this.minecraft.level.getTileMeta(i, j, k); +// +// /** - Save some information on block type */ +// if ( (BlockBase.STONE_SLAB.id == blockId) +// || (BlockBase.DOUBLE_STONE_SLAB.id == blockId) +// ) +// { +// if (2 == blockMetaData) { +// ModHelper.ModHelperFields.blockType = ModHelper.BlockTypeEnum.SLAB_BLOCK_IS_WOODEN; +// } +// else { +// ModHelper.ModHelperFields.blockType = ModHelper.BlockTypeEnum.SLAB_BLOCK_IS_NOT_WOODEN; +// } +// } +// else +// { +// ModHelper.ModHelperFields.blockType = ModHelper.BlockTypeEnum.BLOCK_IS_NOT_A_SLAB; +// } +// } +//} \ No newline at end of file diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PickaxeMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PickaxeMixin.java index cb9e614..a0b3118 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PickaxeMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PickaxeMixin.java @@ -36,59 +36,59 @@ private static void annoyanceFix_appendExtraBlocks(CallbackInfo ci) { ArrayList effectiveBlockList = new ArrayList(); - if (Config.PickaxesConfig.enablePickaxesEffectiveOnDispenser) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnDispenser) { effectiveBlockList.add(BlockBase.DISPENSER); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnNormalRails) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnNormalRails) { effectiveBlockList.add(BlockBase.RAIL); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnGoldenRails) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnGoldenRails) { effectiveBlockList.add(BlockBase.GOLDEN_RAIL); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnDetectorRails) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnDetectorRails) { effectiveBlockList.add(BlockBase.DETECTOR_RAIL); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnFurnace) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnFurnace) { effectiveBlockList.add(BlockBase.FURNACE); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnFurnaceLit) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnFurnaceLit) { effectiveBlockList.add(BlockBase.FURNACE_LIT); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnCobblestoneStairs) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnCobblestoneStairs) { effectiveBlockList.add(BlockBase.COBBLESTONE_STAIRS); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnStonePressurePlate) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnStonePressurePlate) { effectiveBlockList.add(BlockBase.STONE_PRESSURE_PLATE); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnIronDoor) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnIronDoor) { effectiveBlockList.add(BlockBase.IRON_DOOR); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnRedstoneOre) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnRedstoneOre) { effectiveBlockList.add(BlockBase.REDSTONE_ORE); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnRedstoneOreLit) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnRedstoneOreLit) { effectiveBlockList.add(BlockBase.REDSTONE_ORE_LIT); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnStoneButton) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnStoneButton) { effectiveBlockList.add(BlockBase.BUTTON); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnBricks) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnBricks) { effectiveBlockList.add(BlockBase.BRICKS); } - if (Config.PickaxesConfig.enablePickaxesEffectiveOnMobSpawner) { + if (Config.config.PICKAXES_CONFIG.enablePickaxesEffectiveOnMobSpawner) { effectiveBlockList.add(BlockBase.MOB_SPAWNER); } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PigMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PigMixin.java index ec27cb3..202d567 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PigMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PigMixin.java @@ -33,7 +33,7 @@ protected void getDrops() { this.dropItem(var1, 1); } - if ( (Config.ConfigFields.pigFixesEnabled) + if ( (Config.config.pigFixesEnabled) && (this.isSaddled()) ) { diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java new file mode 100644 index 0000000..5188d34 --- /dev/null +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java @@ -0,0 +1,88 @@ +//package com.github.telvarost.annoyancefix.mixin; +// +//import net.minecraft.entity.EntityBase; +//import net.minecraft.entity.Living; +//import net.minecraft.entity.player.PlayerBase; +//import net.minecraft.entity.player.PlayerContainer; +//import net.minecraft.item.ItemInstance; +//import net.minecraft.util.io.CompoundTag; +//import org.objectweb.asm.Opcodes; +//import org.spongepowered.asm.mixin.Mixin; +//import org.spongepowered.asm.mixin.Unique; +//import org.spongepowered.asm.mixin.injection.At; +//import org.spongepowered.asm.mixin.injection.Inject; +//import org.spongepowered.asm.mixin.injection.Redirect; +//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +// +//@Mixin(PlayerBase.class) +//public class PlayerBaseMixin { +// +// @Unique +// private String _vehicleName = null; +// @Unique +// private boolean _playerInVehicle = false; +// @Unique +// private double _vehicleX = 0; +// @Unique +// private double _vehicleY = 70; +// @Unique +// private double _vehicleZ = 0; +// +// @Redirect( +// method = "interactWith", +// at = @At( +// value = "INVOKE", +// target = "Lnet/minecraft/entity/EntityBase;interact(Lnet/minecraft/entity/player/PlayerBase;)Z" +// ) +// ) +// public boolean interactWith(EntityBase instance, PlayerBase playerBase) { +// boolean canInteract = instance.interact(playerBase); +// +// if (canInteract) { +// _playerInVehicle = (instance.passenger != null); +// +// if (instance.passenger != null) { +// _vehicleName = instance.getClass().toString(); +// _vehicleX = Math.floor(instance.x); +// _vehicleY = Math.floor(instance.y); +// _vehicleZ = Math.floor(instance.z); +// } +// } +// +// return canInteract; +// } +// +// +// +// @Inject(method = "writeCustomDataToTag", at = @At("HEAD")) +// private void betaTweaks_writeCustomDataToTag(CompoundTag tag, CallbackInfo info) { +// if (!true) { +// return; +// } +// +// tag.put("PlayerInVehicle", _playerInVehicle); +// +// if (_playerInVehicle) { +// tag.put("VehicleName", _vehicleName); +// tag.put("VehicleX", _vehicleX); +// tag.put("VehicleY", _vehicleY); +// tag.put("VehicleZ", _vehicleZ); +// } +// } +// +// @Inject(method = "readCustomDataFromTag", at = @At("HEAD")) +// private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info) { +// if (!true) { +// return; +// } +// +// _playerInVehicle = tag.getBoolean("PlayerInVehicle"); +// +// if (_playerInVehicle) { +// _vehicleName = tag.getString("VehicleName"); +// _vehicleX = tag.getDouble("VehicleX"); +// _vehicleY = tag.getDouble("VehicleY"); +// _vehicleZ = tag.getDouble("VehicleZ"); +// } +// } +//} diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerInventoryMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerInventoryMixin.java index 7adb076..b058571 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerInventoryMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerInventoryMixin.java @@ -33,7 +33,12 @@ class PlayerInventoryMixin { locals = LocalCapture.CAPTURE_FAILHARD ) private void annoyanceFix_setSelectedItemWithID(int itemID, boolean unused, CallbackInfo ci, int slotWithItem) { - if (!Config.ConfigFields.pickBlockFixesEnabled) { + if (!Config.config.pickBlockFixesEnabled) { + return; + } + + // Don't modify inventory on server (because the server will reject the change) + if (player.level.isServerSide) { return; } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/SinglePlayerClientInteractionManagerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/SinglePlayerClientInteractionManagerMixin.java index f79e56f..38a0231 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/SinglePlayerClientInteractionManagerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/SinglePlayerClientInteractionManagerMixin.java @@ -37,7 +37,7 @@ public SinglePlayerClientInteractionManagerMixin(Minecraft minecraft) { at = @At("HEAD") ) public void annoyanceFix_clickBlock(int i, int j, int k, int l, CallbackInfo ci) { - if (!Config.ConfigFields.woodenSlabFixesEnabled) { + if (!Config.config.woodenSlabFixesEnabled) { return; } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/StairsMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/StairsMixin.java index 409b28d..16f18ff 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/StairsMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/StairsMixin.java @@ -27,7 +27,7 @@ public StairsMixin(int i, Material arg) { cancellable = true ) private void annoyanceFix_onBlockRemoved(Level level, int i, int j, int k, CallbackInfo ci) { - if (Config.ConfigFields.stairFixesEnabled) { + if (Config.config.stairFixesEnabled) { ci.cancel(); } } @@ -38,14 +38,14 @@ private void annoyanceFix_onBlockRemoved(Level level, int i, int j, int k, Callb cancellable = true ) private void annoyanceFix_onDestroyedByExplosion(Level level, int i, int j, int k, CallbackInfo ci) { - if (Config.ConfigFields.stairFixesEnabled) { + if (Config.config.stairFixesEnabled) { ci.cancel(); } } @Inject(at = @At("HEAD"), method = "getDropId", cancellable = true) public void annoyanceFix_getDropId(int i, Random random, CallbackInfoReturnable cir) { - if (Config.ConfigFields.stairFixesEnabled) { + if (Config.config.stairFixesEnabled) { cir.setReturnValue(id); } } @@ -56,7 +56,7 @@ public void annoyanceFix_getDropId(int i, Random random, CallbackInfoReturnable< cancellable = true ) private void annoyanceFix_beforeDestroyedByExplosion(Level arg, int i, int j, int k, int l, float f, CallbackInfo ci) { - if (Config.ConfigFields.stairFixesEnabled) { + if (Config.config.stairFixesEnabled) { super.beforeDestroyedByExplosion(arg, i, j, k, l, f); ci.cancel(); } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ToolBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ToolBaseMixin.java index 07f60cd..fe07845 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ToolBaseMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ToolBaseMixin.java @@ -37,7 +37,7 @@ public ToolBaseMixin(int i, int j, ToolMaterial arg, BlockBase[] args) { cancellable = true ) public void annoyanceFix_getStrengthOnBlock(ItemInstance arg, BlockBase arg2, CallbackInfoReturnable cir) { - if (!Config.ConfigFields.woodenSlabFixesEnabled) + if (!Config.config.woodenSlabFixesEnabled) { return; } diff --git a/src/main/resources/annoyancefix.mixins.json b/src/main/resources/annoyancefix.mixins.json index ae5d8b5..b035f16 100644 --- a/src/main/resources/annoyancefix.mixins.json +++ b/src/main/resources/annoyancefix.mixins.json @@ -14,17 +14,16 @@ "HatchetMixin", "ItemBaseMixin", "MinecraftMixin", - "MultiPlayerClientInteractionManagerMixin", "PickaxeMixin", "PigMixin", - "PlayerInventoryMixin", - "SinglePlayerClientInteractionManagerMixin", "StairsMixin", "ToolBaseMixin" ], "server": [ ], "client": [ + "PlayerInventoryMixin", + "SinglePlayerClientInteractionManagerMixin" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2727f69..dabd51d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,6 +30,9 @@ ], "gcapi": [ "com.github.telvarost.annoyancefix.Config" + ], + "gcapi:factory_provider": [ + "com.github.telvarost.annoyancefix.BoatCollisionEnumFactory" ] }, "mixins": [