From be8c3659bca3ccffe208ef7b7aa56749c616b409 Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Sun, 26 Nov 2023 01:05:58 +0100 Subject: [PATCH] Added and fixed tons of clientside fixes --- .../viafabricplus/ViaFabricPlus.java | 11 +- ...Renderer_1_8.java => BoatRenderer1_8.java} | 4 +- .../fixes/EntityHeightOffsetsPre1_20_2.java | 15 +- .../viafabricplus/fixes/Material1_19_4.java | 1100 +++++++++++++++++ .../fixes/tracker/WolfHealthTracker.java | 24 +- .../IEntity.java} | 21 +- .../injection/access/IItemStack.java | 30 + .../base/connect/MixinClientConnection.java | 2 +- ...ava => MixinDownloadingTerrainScreen.java} | 13 +- ...a => MixinAbstractClientPlayerEntity.java} | 25 +- .../entity/MixinAbstractDonkeyEntity.java | 96 -- .../minecraft/entity/MixinAnimalEntity.java | 5 +- .../minecraft/entity/MixinBoatEntity.java | 316 +++++ .../minecraft/entity/MixinCamelEntity.java | 14 +- .../entity/MixinClientPlayerEntity.java | 100 +- .../minecraft/entity/MixinCowEntity.java | 5 +- .../minecraft/entity/MixinCreeperEntity.java | 5 +- .../fixes/minecraft/entity/MixinEntity.java | 82 +- .../entity/MixinEntityPredicates.java | 43 - .../entity/MixinEntityRenderDispatcher.java | 9 +- .../minecraft/entity/MixinLivingEntity.java | 118 +- .../entity/MixinOtherClientPlayerEntity.java | 5 +- .../minecraft/entity/MixinPiglinEntity.java | 46 - .../minecraft/entity/MixinPlayerEntity.java | 155 ++- .../MixinPlayerEntityRenderer.java | 27 +- .../entity/MixinSkeletonHorseEntity.java | 28 + .../minecraft/entity/MixinSquidEntity.java | 5 +- .../minecraft/entity/MixinWolfEntity.java | 75 +- .../minecraft/input/MixinKeyboardInput.java | 5 +- .../fixes/minecraft/item/MixinArmorItem.java | 27 + .../fixes/minecraft/item/MixinAxeItem.java | 52 +- .../fixes/minecraft/item/MixinBlockItem.java | 9 +- .../fixes/minecraft/item/MixinBowItem.java | 48 + .../{ => item}/MixinDrawContext.java | 25 +- .../minecraft/item/MixinEnderPearlItem.java | 5 +- .../fixes/minecraft/item/MixinEquipment.java | 40 +- .../minecraft/item/MixinHeldItemRenderer.java | 6 +- .../fixes/minecraft/item/MixinHoeItem.java | 6 +- .../mixin/fixes/minecraft/item/MixinItem.java | 26 +- .../fixes/minecraft/item/MixinItemGroups.java | 5 +- .../item/MixinItemPlacementContext.java | 32 +- .../minecraft/item/MixinItemRenderer.java | 4 +- .../fixes/minecraft/item/MixinItemStack.java | 75 +- .../minecraft/item/MixinMiningToolItem.java | 45 - .../minecraft/item/MixinPickaxeItem.java | 42 +- .../fixes/minecraft/item/MixinShearsItem.java | 41 + .../fixes/minecraft/item/MixinShovelItem.java | 54 +- .../fixes/minecraft/item/MixinSwordItem.java | 19 +- .../fixes/minecraft/screen/MixinScreen.java | 2 +- .../MixinMetadataRewriter1_15To1_14_4.java | 3 +- .../protocolhack/ProtocolHack.java | 2 +- .../settings/impl/ExperimentalSettings.java | 1 - src/main/resources/viafabricplus.mixins.json | 26 +- 53 files changed, 2332 insertions(+), 647 deletions(-) rename src/main/java/de/florianmichael/viafabricplus/fixes/{BoatRenderer_1_8.java => BoatRenderer1_8.java} (95%) create mode 100644 src/main/java/de/florianmichael/viafabricplus/fixes/Material1_19_4.java rename src/main/java/de/florianmichael/viafabricplus/injection/{mixin/fixes/minecraft/item/MixinBrushItem.java => access/IEntity.java} (50%) create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/access/IItemStack.java rename src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/{MixinDownloadingTerrainScreenAndConnectScreen.java => MixinDownloadingTerrainScreen.java} (87%) rename src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/{MixinVexEntity.java => MixinAbstractClientPlayerEntity.java} (66%) delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractDonkeyEntity.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinBoatEntity.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityPredicates.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPiglinEntity.java rename src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/{ => entity}/MixinPlayerEntityRenderer.java (60%) create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinSkeletonHorseEntity.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBowItem.java rename src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/{ => item}/MixinDrawContext.java (60%) delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinMiningToolItem.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShearsItem.java diff --git a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java index 8d92e951..eb225bfc 100644 --- a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java +++ b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java @@ -21,13 +21,13 @@ package de.florianmichael.viafabricplus; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import de.florianmichael.viafabricplus.event.PostGameLoadCallback; +import de.florianmichael.viafabricplus.event.PreLoadCallback; import de.florianmichael.viafabricplus.fixes.ClientsideFixes; import de.florianmichael.viafabricplus.fixes.account.BedrockAccountHandler; import de.florianmichael.viafabricplus.fixes.account.ClassiCubeAccountHandler; import de.florianmichael.viafabricplus.fixes.classic.CustomClassicProtocolExtensions; import de.florianmichael.viafabricplus.fixes.classic.screen.ClassicItemSelectionScreen; -import de.florianmichael.viafabricplus.event.PostGameLoadCallback; -import de.florianmichael.viafabricplus.event.PreLoadCallback; import de.florianmichael.viafabricplus.mappings.CharacterMappings; import de.florianmichael.viafabricplus.mappings.ItemReleaseVersionMappings; import de.florianmichael.viafabricplus.mappings.PackFormatsMappings; @@ -53,7 +53,6 @@ import java.io.File; * - Bedrock scaffolding should be added as soon as ViaBedrock supports block placement (see https://github.com/ViaVersion/ViaFabricPlus/issues/204) * * TODO | Movement - * - Cobwebs in <= b1.7.3 are broken (movement has been changed) * - X/Z Face based jump movement in <= 1.13.2 is broken (https://github.com/ViaVersion/ViaFabricPlus/issues/189) * - Collision hit boxes has been changed (https://github.com/ViaVersion/ViaFabricPlus/issues/195) * - Blit-jump is not supported in <= 1.8.9 (https://github.com/ViaVersion/ViaFabricPlus/issues/225) @@ -66,6 +65,12 @@ import java.io.File; * - Recode config save base to support singleton Jsons * - Rebase fixes package / change all packages * - Fix auto detect to not be a huge mess + * - Fix MixinAbstractDonkeyEntity + * - Boats are probably broken. Check entity height offset fix + * - Check TO DO in MixinEntity + * - Sort injection methods in fixes package by version + * - Add setting for revertOnlyPlayerCramming + * - Add setting for MixinLockableContainerBlockEntity */ public class ViaFabricPlus { diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/BoatRenderer_1_8.java b/src/main/java/de/florianmichael/viafabricplus/fixes/BoatRenderer1_8.java similarity index 95% rename from src/main/java/de/florianmichael/viafabricplus/fixes/BoatRenderer_1_8.java rename to src/main/java/de/florianmichael/viafabricplus/fixes/BoatRenderer1_8.java index c88d5d6f..cf799b44 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/BoatRenderer_1_8.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/BoatRenderer1_8.java @@ -31,11 +31,11 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RotationAxis; -public class BoatRenderer_1_8 extends EntityRenderer { +public class BoatRenderer1_8 extends EntityRenderer { private static final Identifier TEXTURE = new Identifier("viafabricplus", "textures/boat_1_8.png"); private final BoatModel_1_8 model; - public BoatRenderer_1_8(EntityRendererFactory.Context ctx) { + public BoatRenderer1_8(EntityRendererFactory.Context ctx) { super(ctx); shadowRadius = 0.5F; model = new BoatModel_1_8(ctx.getPart(BoatModel_1_8.MODEL_LAYER)); diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/EntityHeightOffsetsPre1_20_2.java b/src/main/java/de/florianmichael/viafabricplus/fixes/EntityHeightOffsetsPre1_20_2.java index 01c28394..4c98ecde 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/EntityHeightOffsetsPre1_20_2.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/EntityHeightOffsetsPre1_20_2.java @@ -20,7 +20,10 @@ package de.florianmichael.viafabricplus.fixes; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import net.minecraft.entity.*; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityDimensions; +import net.minecraft.entity.EntityPose; +import net.minecraft.entity.EntityType; import net.minecraft.entity.boss.dragon.EnderDragonEntity; import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.entity.mob.*; @@ -141,9 +144,7 @@ public class EntityHeightOffsetsPre1_20_2 { } public static double getHeightOffset(final Entity entity) { - if (entity instanceof AllayEntity) { - return ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4) ? 0 : 0.4; - } else if (entity instanceof ArmorStandEntity armorStandEntity && !armorStandEntity.isMarker()) { + if (entity instanceof ArmorStandEntity armorStandEntity && !armorStandEntity.isMarker()) { return 0.1; } else if (entity instanceof EndermiteEntity) { return 0.1; @@ -153,7 +154,11 @@ public class EntityHeightOffsetsPre1_20_2 { return !(shulkerEntity.getVehicle() instanceof BoatEntity) && vehicleType != EntityType.MINECART ? 0 : 0.1875 - getMountedHeightOffset(shulkerEntity.getVehicle(), null).y; } else if (entity instanceof SilverfishEntity) { return 0.1; - } else if (entity instanceof VexEntity) { + } else if (entity instanceof AllayEntity || entity instanceof VexEntity) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) { + return 0D; + } + return 0.4; } else if (entity instanceof ZombifiedPiglinEntity zombifiedPiglinEntity) { return zombifiedPiglinEntity.isBaby() ? -0.05 : -0.45; diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/Material1_19_4.java b/src/main/java/de/florianmichael/viafabricplus/fixes/Material1_19_4.java new file mode 100644 index 00000000..24fbf8db --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/Material1_19_4.java @@ -0,0 +1,1100 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus + * Copyright (C) 2021-2023 FlorianMichael/EnZaXD + * Copyright (C) 2023 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.fixes; + +import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.ShulkerBoxBlock; +import net.raphimc.vialoader.util.VersionEnum; + +import java.util.HashMap; +import java.util.Map; + +public record Material1_19_4(boolean blocksMovement, boolean burnable, boolean liquid, boolean blocksLight, boolean replaceable, boolean solid) { + + public static final Material1_19_4 AIR = new Material1_19_4(false, false, false, false, true, false); + public static final Material1_19_4 STRUCTURE_VOID = new Material1_19_4(false, false, false, false, true, false); + public static final Material1_19_4 PORTAL = new Material1_19_4(false, false, false, false, false, false); + public static final Material1_19_4 CARPET = new Material1_19_4(false, true, false, false, false, false); + public static final Material1_19_4 PLANT = new Material1_19_4(false, false, false, false, false, false); + public static final Material1_19_4 UNDERWATER_PLANT = new Material1_19_4(false, false, false, false, false, false); + public static final Material1_19_4 REPLACEABLE_PLANT = new Material1_19_4(false, true, false, false, true, false); + public static final Material1_19_4 NETHER_SHOOTS = new Material1_19_4(false, false, false, false, true, false); + public static final Material1_19_4 REPLACEABLE_UNDERWATER_PLANT = new Material1_19_4(false, false, false, false, true, false); + public static final Material1_19_4 WATER = new Material1_19_4(false, false, true, false, true, false); + public static final Material1_19_4 BUBBLE_COLUMN = new Material1_19_4(false, false, true, false, true, false); + public static final Material1_19_4 LAVA = new Material1_19_4(false, false, true, false, true, false); + public static final Material1_19_4 SNOW_LAYER = new Material1_19_4(false, false, false, false, true, false); + public static final Material1_19_4 FIRE = new Material1_19_4(false, false, false, false, true, false); + public static final Material1_19_4 DECORATION = new Material1_19_4(false, false, false, false, false, false); + public static final Material1_19_4 COBWEB = new Material1_19_4(false, false, false, false, false, true); + public static final Material1_19_4 SCULK = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 REDSTONE_LAMP = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 ORGANIC_PRODUCT = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 SOIL = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 SOLID_ORGANIC = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 DENSE_ICE = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 AGGREGATE = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 SPONGE = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 SHULKER_BOX = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 WOOD = new Material1_19_4(true, true, false, true, false, true); + public static final Material1_19_4 NETHER_WOOD = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 BAMBOO_SAPLING = new Material1_19_4(false, true, false, true, false, true); + public static final Material1_19_4 BAMBOO = new Material1_19_4(true, true, false, true, false, true); + public static final Material1_19_4 WOOL = new Material1_19_4(true, true, false, true, false, true); + public static final Material1_19_4 TNT = new Material1_19_4(true, true, false, false, false, true); + public static final Material1_19_4 LEAVES = new Material1_19_4(true, true, false, false, false, true); + public static final Material1_19_4 GLASS = new Material1_19_4(true, false, false, false, false, true); + public static final Material1_19_4 ICE = new Material1_19_4(true, false, false, false, false, true); + public static final Material1_19_4 CACTUS = new Material1_19_4(true, false, false, false, false, true); + public static final Material1_19_4 STONE = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 METAL = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 SNOW_BLOCK = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 REPAIR_STATION = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 BARRIER = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 PISTON = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 MOSS_BLOCK = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 GOURD = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 EGG = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 CAKE = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 AMETHYST = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 POWDER_SNOW = new Material1_19_4(false, false, false, true, false, false); + public static final Material1_19_4 FROGSPAWN = new Material1_19_4(false, false, false, false, false, false); + public static final Material1_19_4 FROGLIGHT = new Material1_19_4(true, false, false, true, false, true); + public static final Material1_19_4 DECORATED_POT = new Material1_19_4(true, false, false, true, false, true); + + private static final Map MATERIALS = new HashMap<>(); + + static { + MATERIALS.put(Blocks.AIR, AIR); + MATERIALS.put(Blocks.STONE, STONE); + MATERIALS.put(Blocks.GRANITE, STONE); + MATERIALS.put(Blocks.POLISHED_GRANITE, STONE); + MATERIALS.put(Blocks.DIORITE, STONE); + MATERIALS.put(Blocks.POLISHED_DIORITE, STONE); + MATERIALS.put(Blocks.ANDESITE, STONE); + MATERIALS.put(Blocks.POLISHED_ANDESITE, STONE); + MATERIALS.put(Blocks.GRASS_BLOCK, SOLID_ORGANIC); + MATERIALS.put(Blocks.DIRT, SOIL); + MATERIALS.put(Blocks.COARSE_DIRT, SOIL); + MATERIALS.put(Blocks.PODZOL, SOIL); + MATERIALS.put(Blocks.COBBLESTONE, STONE); + MATERIALS.put(Blocks.OAK_PLANKS, WOOD); + MATERIALS.put(Blocks.SPRUCE_PLANKS, WOOD); + MATERIALS.put(Blocks.BIRCH_PLANKS, WOOD); + MATERIALS.put(Blocks.JUNGLE_PLANKS, WOOD); + MATERIALS.put(Blocks.ACACIA_PLANKS, WOOD); + MATERIALS.put(Blocks.CHERRY_PLANKS, WOOD); + MATERIALS.put(Blocks.DARK_OAK_PLANKS, WOOD); + MATERIALS.put(Blocks.MANGROVE_PLANKS, WOOD); + MATERIALS.put(Blocks.BAMBOO_PLANKS, WOOD); + MATERIALS.put(Blocks.BAMBOO_MOSAIC, WOOD); + MATERIALS.put(Blocks.OAK_SAPLING, PLANT); + MATERIALS.put(Blocks.SPRUCE_SAPLING, PLANT); + MATERIALS.put(Blocks.BIRCH_SAPLING, PLANT); + MATERIALS.put(Blocks.JUNGLE_SAPLING, PLANT); + MATERIALS.put(Blocks.ACACIA_SAPLING, PLANT); + MATERIALS.put(Blocks.CHERRY_SAPLING, PLANT); + MATERIALS.put(Blocks.DARK_OAK_SAPLING, PLANT); + MATERIALS.put(Blocks.MANGROVE_PROPAGULE, PLANT); + MATERIALS.put(Blocks.BEDROCK, STONE); + MATERIALS.put(Blocks.WATER, WATER); + MATERIALS.put(Blocks.LAVA, LAVA); + MATERIALS.put(Blocks.SAND, AGGREGATE); + MATERIALS.put(Blocks.SUSPICIOUS_SAND, AGGREGATE); + MATERIALS.put(Blocks.RED_SAND, AGGREGATE); + MATERIALS.put(Blocks.GRAVEL, AGGREGATE); + MATERIALS.put(Blocks.GOLD_ORE, STONE); + MATERIALS.put(Blocks.DEEPSLATE_GOLD_ORE, STONE); + MATERIALS.put(Blocks.IRON_ORE, STONE); + MATERIALS.put(Blocks.DEEPSLATE_IRON_ORE, STONE); + MATERIALS.put(Blocks.COAL_ORE, STONE); + MATERIALS.put(Blocks.DEEPSLATE_COAL_ORE, STONE); + MATERIALS.put(Blocks.NETHER_GOLD_ORE, STONE); + MATERIALS.put(Blocks.OAK_LOG, WOOD); + MATERIALS.put(Blocks.SPRUCE_LOG, WOOD); + MATERIALS.put(Blocks.BIRCH_LOG, WOOD); + MATERIALS.put(Blocks.JUNGLE_LOG, WOOD); + MATERIALS.put(Blocks.ACACIA_LOG, WOOD); + MATERIALS.put(Blocks.CHERRY_LOG, WOOD); + MATERIALS.put(Blocks.DARK_OAK_LOG, WOOD); + MATERIALS.put(Blocks.MANGROVE_LOG, WOOD); + MATERIALS.put(Blocks.MANGROVE_ROOTS, WOOD); + MATERIALS.put(Blocks.MUDDY_MANGROVE_ROOTS, SOIL); + MATERIALS.put(Blocks.BAMBOO_BLOCK, WOOD); + MATERIALS.put(Blocks.STRIPPED_SPRUCE_LOG, WOOD); + MATERIALS.put(Blocks.STRIPPED_BIRCH_LOG, WOOD); + MATERIALS.put(Blocks.STRIPPED_JUNGLE_LOG, WOOD); + MATERIALS.put(Blocks.STRIPPED_ACACIA_LOG, WOOD); + MATERIALS.put(Blocks.STRIPPED_CHERRY_LOG, WOOD); + MATERIALS.put(Blocks.STRIPPED_DARK_OAK_LOG, WOOD); + MATERIALS.put(Blocks.STRIPPED_OAK_LOG, WOOD); + MATERIALS.put(Blocks.STRIPPED_MANGROVE_LOG, WOOD); + MATERIALS.put(Blocks.STRIPPED_BAMBOO_BLOCK, WOOD); + MATERIALS.put(Blocks.OAK_WOOD, WOOD); + MATERIALS.put(Blocks.SPRUCE_WOOD, WOOD); + MATERIALS.put(Blocks.BIRCH_WOOD, WOOD); + MATERIALS.put(Blocks.JUNGLE_WOOD, WOOD); + MATERIALS.put(Blocks.ACACIA_WOOD, WOOD); + MATERIALS.put(Blocks.CHERRY_WOOD, WOOD); + MATERIALS.put(Blocks.DARK_OAK_WOOD, WOOD); + MATERIALS.put(Blocks.MANGROVE_WOOD, WOOD); + MATERIALS.put(Blocks.STRIPPED_OAK_WOOD, WOOD); + MATERIALS.put(Blocks.STRIPPED_SPRUCE_WOOD, WOOD); + MATERIALS.put(Blocks.STRIPPED_BIRCH_WOOD, WOOD); + MATERIALS.put(Blocks.STRIPPED_JUNGLE_WOOD, WOOD); + MATERIALS.put(Blocks.STRIPPED_ACACIA_WOOD, WOOD); + MATERIALS.put(Blocks.STRIPPED_CHERRY_WOOD, WOOD); + MATERIALS.put(Blocks.STRIPPED_DARK_OAK_WOOD, WOOD); + MATERIALS.put(Blocks.STRIPPED_MANGROVE_WOOD, WOOD); + MATERIALS.put(Blocks.OAK_LEAVES, LEAVES); + MATERIALS.put(Blocks.SPRUCE_LEAVES, LEAVES); + MATERIALS.put(Blocks.BIRCH_LEAVES, LEAVES); + MATERIALS.put(Blocks.JUNGLE_LEAVES, LEAVES); + MATERIALS.put(Blocks.ACACIA_LEAVES, LEAVES); + MATERIALS.put(Blocks.CHERRY_LEAVES, LEAVES); + MATERIALS.put(Blocks.DARK_OAK_LEAVES, LEAVES); + MATERIALS.put(Blocks.MANGROVE_LEAVES, LEAVES); + MATERIALS.put(Blocks.AZALEA_LEAVES, LEAVES); + MATERIALS.put(Blocks.FLOWERING_AZALEA_LEAVES, LEAVES); + MATERIALS.put(Blocks.SPONGE, SPONGE); + MATERIALS.put(Blocks.WET_SPONGE, SPONGE); + MATERIALS.put(Blocks.GLASS, GLASS); + MATERIALS.put(Blocks.LAPIS_ORE, STONE); + MATERIALS.put(Blocks.DEEPSLATE_LAPIS_ORE, STONE); + MATERIALS.put(Blocks.LAPIS_BLOCK, METAL); + MATERIALS.put(Blocks.DISPENSER, STONE); + MATERIALS.put(Blocks.SANDSTONE, STONE); + MATERIALS.put(Blocks.CHISELED_SANDSTONE, STONE); + MATERIALS.put(Blocks.CUT_SANDSTONE, STONE); + MATERIALS.put(Blocks.NOTE_BLOCK, WOOD); + MATERIALS.put(Blocks.WHITE_BED, WOOL); + MATERIALS.put(Blocks.ORANGE_BED, WOOL); + MATERIALS.put(Blocks.MAGENTA_BED, WOOL); + MATERIALS.put(Blocks.LIGHT_BLUE_BED, WOOL); + MATERIALS.put(Blocks.YELLOW_BED, WOOL); + MATERIALS.put(Blocks.LIME_BED, WOOL); + MATERIALS.put(Blocks.PINK_BED, WOOL); + MATERIALS.put(Blocks.GRAY_BED, WOOL); + MATERIALS.put(Blocks.LIGHT_GRAY_BED, WOOL); + MATERIALS.put(Blocks.CYAN_BED, WOOL); + MATERIALS.put(Blocks.PURPLE_BED, WOOL); + MATERIALS.put(Blocks.BLUE_BED, WOOL); + MATERIALS.put(Blocks.BROWN_BED, WOOL); + MATERIALS.put(Blocks.GREEN_BED, WOOL); + MATERIALS.put(Blocks.RED_BED, WOOL); + MATERIALS.put(Blocks.BLACK_BED, WOOL); + MATERIALS.put(Blocks.POWERED_RAIL, DECORATION); + MATERIALS.put(Blocks.DETECTOR_RAIL, DECORATION); + MATERIALS.put(Blocks.STICKY_PISTON, PISTON); + MATERIALS.put(Blocks.COBWEB, COBWEB); + MATERIALS.put(Blocks.GRASS, REPLACEABLE_PLANT); + MATERIALS.put(Blocks.FERN, REPLACEABLE_PLANT); + MATERIALS.put(Blocks.DEAD_BUSH, REPLACEABLE_PLANT); + MATERIALS.put(Blocks.SEAGRASS, REPLACEABLE_UNDERWATER_PLANT); + MATERIALS.put(Blocks.TALL_SEAGRASS, REPLACEABLE_UNDERWATER_PLANT); + MATERIALS.put(Blocks.PISTON, PISTON); + MATERIALS.put(Blocks.PISTON_HEAD, PISTON); + MATERIALS.put(Blocks.WHITE_WOOL, WOOL); + MATERIALS.put(Blocks.ORANGE_WOOL, WOOL); + MATERIALS.put(Blocks.MAGENTA_WOOL, WOOL); + MATERIALS.put(Blocks.LIGHT_BLUE_WOOL, WOOL); + MATERIALS.put(Blocks.YELLOW_WOOL, WOOL); + MATERIALS.put(Blocks.LIME_WOOL, WOOL); + MATERIALS.put(Blocks.PINK_WOOL, WOOL); + MATERIALS.put(Blocks.GRAY_WOOL, WOOL); + MATERIALS.put(Blocks.LIGHT_GRAY_WOOL, WOOL); + MATERIALS.put(Blocks.CYAN_WOOL, WOOL); + MATERIALS.put(Blocks.PURPLE_WOOL, WOOL); + MATERIALS.put(Blocks.BLUE_WOOL, WOOL); + MATERIALS.put(Blocks.BROWN_WOOL, WOOL); + MATERIALS.put(Blocks.GREEN_WOOL, WOOL); + MATERIALS.put(Blocks.RED_WOOL, WOOL); + MATERIALS.put(Blocks.BLACK_WOOL, WOOL); + MATERIALS.put(Blocks.MOVING_PISTON, PISTON); + MATERIALS.put(Blocks.DANDELION, PLANT); + MATERIALS.put(Blocks.TORCHFLOWER, PLANT); + MATERIALS.put(Blocks.POPPY, PLANT); + MATERIALS.put(Blocks.BLUE_ORCHID, PLANT); + MATERIALS.put(Blocks.ALLIUM, PLANT); + MATERIALS.put(Blocks.AZURE_BLUET, PLANT); + MATERIALS.put(Blocks.RED_TULIP, PLANT); + MATERIALS.put(Blocks.ORANGE_TULIP, PLANT); + MATERIALS.put(Blocks.WHITE_TULIP, PLANT); + MATERIALS.put(Blocks.PINK_TULIP, PLANT); + MATERIALS.put(Blocks.OXEYE_DAISY, PLANT); + MATERIALS.put(Blocks.CORNFLOWER, PLANT); + MATERIALS.put(Blocks.WITHER_ROSE, PLANT); + MATERIALS.put(Blocks.LILY_OF_THE_VALLEY, PLANT); + MATERIALS.put(Blocks.BROWN_MUSHROOM, PLANT); + MATERIALS.put(Blocks.RED_MUSHROOM, PLANT); + MATERIALS.put(Blocks.GOLD_BLOCK, METAL); + MATERIALS.put(Blocks.IRON_BLOCK, METAL); + MATERIALS.put(Blocks.BRICKS, STONE); + MATERIALS.put(Blocks.TNT, TNT); + MATERIALS.put(Blocks.BOOKSHELF, WOOD); + MATERIALS.put(Blocks.CHISELED_BOOKSHELF, WOOD); + MATERIALS.put(Blocks.MOSSY_COBBLESTONE, STONE); + MATERIALS.put(Blocks.OBSIDIAN, STONE); + MATERIALS.put(Blocks.TORCH, DECORATION); + MATERIALS.put(Blocks.WALL_TORCH, DECORATION); + MATERIALS.put(Blocks.FIRE, FIRE); + MATERIALS.put(Blocks.SOUL_FIRE, FIRE); + MATERIALS.put(Blocks.SPAWNER, STONE); + MATERIALS.put(Blocks.OAK_STAIRS, WOOD); + MATERIALS.put(Blocks.CHEST, WOOD); + MATERIALS.put(Blocks.REDSTONE_WIRE, DECORATION); + MATERIALS.put(Blocks.DIAMOND_ORE, STONE); + MATERIALS.put(Blocks.DEEPSLATE_DIAMOND_ORE, STONE); + MATERIALS.put(Blocks.DIAMOND_BLOCK, METAL); + MATERIALS.put(Blocks.CRAFTING_TABLE, WOOD); + MATERIALS.put(Blocks.WHEAT, PLANT); + MATERIALS.put(Blocks.FARMLAND, SOIL); + MATERIALS.put(Blocks.FURNACE, STONE); + MATERIALS.put(Blocks.OAK_SIGN, WOOD); + MATERIALS.put(Blocks.SPRUCE_SIGN, WOOD); + MATERIALS.put(Blocks.BIRCH_SIGN, WOOD); + MATERIALS.put(Blocks.ACACIA_SIGN, WOOD); + MATERIALS.put(Blocks.CHERRY_SIGN, WOOD); + MATERIALS.put(Blocks.JUNGLE_SIGN, WOOD); + MATERIALS.put(Blocks.DARK_OAK_SIGN, WOOD); + MATERIALS.put(Blocks.MANGROVE_SIGN, WOOD); + MATERIALS.put(Blocks.BAMBOO_SIGN, WOOD); + MATERIALS.put(Blocks.OAK_DOOR, WOOD); + MATERIALS.put(Blocks.LADDER, DECORATION); + MATERIALS.put(Blocks.RAIL, DECORATION); + MATERIALS.put(Blocks.COBBLESTONE_STAIRS, STONE); + MATERIALS.put(Blocks.OAK_WALL_SIGN, WOOD); + MATERIALS.put(Blocks.SPRUCE_WALL_SIGN, WOOD); + MATERIALS.put(Blocks.BIRCH_WALL_SIGN, WOOD); + MATERIALS.put(Blocks.ACACIA_WALL_SIGN, WOOD); + MATERIALS.put(Blocks.CHERRY_WALL_SIGN, WOOD); + MATERIALS.put(Blocks.JUNGLE_WALL_SIGN, WOOD); + MATERIALS.put(Blocks.DARK_OAK_WALL_SIGN, WOOD); + MATERIALS.put(Blocks.MANGROVE_WALL_SIGN, WOOD); + MATERIALS.put(Blocks.BAMBOO_WALL_SIGN, WOOD); + MATERIALS.put(Blocks.OAK_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.SPRUCE_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.BIRCH_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.ACACIA_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.CHERRY_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.JUNGLE_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.DARK_OAK_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.CRIMSON_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.WARPED_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.MANGROVE_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.BAMBOO_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.OAK_WALL_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.SPRUCE_WALL_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.BIRCH_WALL_HANGING_SIGN, AGGREGATE); + MATERIALS.put(Blocks.ACACIA_WALL_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.CHERRY_WALL_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.JUNGLE_WALL_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.DARK_OAK_WALL_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.MANGROVE_WALL_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.CRIMSON_WALL_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.WARPED_WALL_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.BAMBOO_WALL_HANGING_SIGN, WOOD); + MATERIALS.put(Blocks.LEVER, DECORATION); + MATERIALS.put(Blocks.STONE_PRESSURE_PLATE, STONE); + MATERIALS.put(Blocks.IRON_DOOR, METAL); + MATERIALS.put(Blocks.OAK_PRESSURE_PLATE, WOOD); + MATERIALS.put(Blocks.SPRUCE_PRESSURE_PLATE, WOOD); + MATERIALS.put(Blocks.BIRCH_PRESSURE_PLATE, WOOD); + MATERIALS.put(Blocks.JUNGLE_PRESSURE_PLATE, WOOD); + MATERIALS.put(Blocks.ACACIA_PRESSURE_PLATE, WOOD); + MATERIALS.put(Blocks.CHERRY_PRESSURE_PLATE, WOOD); + MATERIALS.put(Blocks.DARK_OAK_PRESSURE_PLATE, WOOD); + MATERIALS.put(Blocks.MANGROVE_PRESSURE_PLATE, WOOD); + MATERIALS.put(Blocks.BAMBOO_PRESSURE_PLATE, WOOD); + MATERIALS.put(Blocks.REDSTONE_ORE, STONE); + MATERIALS.put(Blocks.DEEPSLATE_REDSTONE_ORE, STONE); + MATERIALS.put(Blocks.REDSTONE_TORCH, DECORATION); + MATERIALS.put(Blocks.REDSTONE_WALL_TORCH, DECORATION); + MATERIALS.put(Blocks.STONE_BUTTON, DECORATION); + MATERIALS.put(Blocks.SNOW, SNOW_LAYER); + MATERIALS.put(Blocks.ICE, ICE); + MATERIALS.put(Blocks.SNOW_BLOCK, SNOW_BLOCK); + MATERIALS.put(Blocks.CACTUS, CACTUS); + MATERIALS.put(Blocks.CLAY, ORGANIC_PRODUCT); + MATERIALS.put(Blocks.SUGAR_CANE, PLANT); + MATERIALS.put(Blocks.JUKEBOX, WOOD); + MATERIALS.put(Blocks.OAK_FENCE, WOOD); + MATERIALS.put(Blocks.PUMPKIN, GOURD); + MATERIALS.put(Blocks.NETHERRACK, STONE); + MATERIALS.put(Blocks.SOUL_SAND, AGGREGATE); + MATERIALS.put(Blocks.SOUL_SOIL, SOIL); + MATERIALS.put(Blocks.BASALT, STONE); + MATERIALS.put(Blocks.POLISHED_BASALT, STONE); + MATERIALS.put(Blocks.SOUL_TORCH, DECORATION); + MATERIALS.put(Blocks.SOUL_WALL_TORCH, DECORATION); + MATERIALS.put(Blocks.GLOWSTONE, GLASS); + MATERIALS.put(Blocks.NETHER_PORTAL, PORTAL); + MATERIALS.put(Blocks.CARVED_PUMPKIN, GOURD); + MATERIALS.put(Blocks.JACK_O_LANTERN, GOURD); + MATERIALS.put(Blocks.CAKE, CAKE); + MATERIALS.put(Blocks.REPEATER, DECORATION); + MATERIALS.put(Blocks.WHITE_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.ORANGE_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.MAGENTA_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.LIGHT_BLUE_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.YELLOW_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.LIME_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.PINK_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.GRAY_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.LIGHT_GRAY_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.CYAN_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.PURPLE_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.BLUE_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.BROWN_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.GREEN_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.RED_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.BLACK_STAINED_GLASS, GLASS); + MATERIALS.put(Blocks.OAK_TRAPDOOR, WOOD); + MATERIALS.put(Blocks.SPRUCE_TRAPDOOR, WOOD); + MATERIALS.put(Blocks.BIRCH_TRAPDOOR, WOOD); + MATERIALS.put(Blocks.JUNGLE_TRAPDOOR, WOOD); + MATERIALS.put(Blocks.ACACIA_TRAPDOOR, WOOD); + MATERIALS.put(Blocks.CHERRY_TRAPDOOR, WOOD); + MATERIALS.put(Blocks.DARK_OAK_TRAPDOOR, WOOD); + MATERIALS.put(Blocks.MANGROVE_TRAPDOOR, WOOD); + MATERIALS.put(Blocks.BAMBOO_TRAPDOOR, WOOD); + MATERIALS.put(Blocks.STONE_BRICKS, STONE); + MATERIALS.put(Blocks.MOSSY_STONE_BRICKS, STONE); + MATERIALS.put(Blocks.CRACKED_STONE_BRICKS, STONE); + MATERIALS.put(Blocks.CHISELED_STONE_BRICKS, STONE); + MATERIALS.put(Blocks.PACKED_MUD, SOIL); + MATERIALS.put(Blocks.MUD_BRICKS, STONE); + MATERIALS.put(Blocks.INFESTED_STONE, ORGANIC_PRODUCT); + MATERIALS.put(Blocks.INFESTED_COBBLESTONE, ORGANIC_PRODUCT); + MATERIALS.put(Blocks.INFESTED_STONE_BRICKS, ORGANIC_PRODUCT); + MATERIALS.put(Blocks.INFESTED_MOSSY_STONE_BRICKS, ORGANIC_PRODUCT); + MATERIALS.put(Blocks.INFESTED_CRACKED_STONE_BRICKS, ORGANIC_PRODUCT); + MATERIALS.put(Blocks.INFESTED_CHISELED_STONE_BRICKS, ORGANIC_PRODUCT); + MATERIALS.put(Blocks.BROWN_MUSHROOM_BLOCK, WOOD); + MATERIALS.put(Blocks.RED_MUSHROOM_BLOCK, WOOD); + MATERIALS.put(Blocks.MUSHROOM_STEM, WOOD); + MATERIALS.put(Blocks.IRON_BARS, METAL); + MATERIALS.put(Blocks.CHAIN, METAL); + MATERIALS.put(Blocks.GLASS_PANE, GLASS); + MATERIALS.put(Blocks.MELON, GOURD); + MATERIALS.put(Blocks.ATTACHED_PUMPKIN_STEM, PLANT); + MATERIALS.put(Blocks.ATTACHED_MELON_STEM, PLANT); + MATERIALS.put(Blocks.PUMPKIN_STEM, PLANT); + MATERIALS.put(Blocks.MELON_STEM, PLANT); + MATERIALS.put(Blocks.VINE, REPLACEABLE_PLANT); + MATERIALS.put(Blocks.GLOW_LICHEN, REPLACEABLE_PLANT); + MATERIALS.put(Blocks.OAK_FENCE_GATE, WOOD); + MATERIALS.put(Blocks.BRICK_STAIRS, STONE); + MATERIALS.put(Blocks.STONE_BRICK_STAIRS, STONE); + MATERIALS.put(Blocks.MUD_BRICK_STAIRS, STONE); + MATERIALS.put(Blocks.MYCELIUM, SOLID_ORGANIC); + MATERIALS.put(Blocks.LILY_PAD, PLANT); + MATERIALS.put(Blocks.NETHER_BRICKS, STONE); + MATERIALS.put(Blocks.NETHER_BRICK_FENCE, STONE); + MATERIALS.put(Blocks.NETHER_BRICK_STAIRS, STONE); + MATERIALS.put(Blocks.NETHER_WART, PLANT); + MATERIALS.put(Blocks.ENCHANTING_TABLE, STONE); + MATERIALS.put(Blocks.BREWING_STAND, METAL); + MATERIALS.put(Blocks.CAULDRON, METAL); + MATERIALS.put(Blocks.WATER_CAULDRON, METAL); + MATERIALS.put(Blocks.LAVA_CAULDRON, METAL); + MATERIALS.put(Blocks.POWDER_SNOW_CAULDRON, METAL); + MATERIALS.put(Blocks.END_PORTAL, PORTAL); + MATERIALS.put(Blocks.END_PORTAL_FRAME, STONE); + MATERIALS.put(Blocks.END_STONE, STONE); + MATERIALS.put(Blocks.DRAGON_EGG, EGG); + MATERIALS.put(Blocks.REDSTONE_LAMP, REDSTONE_LAMP); + MATERIALS.put(Blocks.COCOA, PLANT); + MATERIALS.put(Blocks.SANDSTONE_STAIRS, STONE); + MATERIALS.put(Blocks.EMERALD_ORE, STONE); + MATERIALS.put(Blocks.DEEPSLATE_EMERALD_ORE, STONE); + MATERIALS.put(Blocks.ENDER_CHEST, STONE); + MATERIALS.put(Blocks.TRIPWIRE_HOOK, DECORATION); + MATERIALS.put(Blocks.TRIPWIRE, DECORATION); + MATERIALS.put(Blocks.EMERALD_BLOCK, METAL); + MATERIALS.put(Blocks.SPRUCE_STAIRS, WOOD); + MATERIALS.put(Blocks.BIRCH_STAIRS, WOOD); + MATERIALS.put(Blocks.JUNGLE_STAIRS, WOOD); + MATERIALS.put(Blocks.COMMAND_BLOCK, METAL); + MATERIALS.put(Blocks.BEACON, GLASS); + MATERIALS.put(Blocks.COBBLESTONE_WALL, STONE); + MATERIALS.put(Blocks.MOSSY_COBBLESTONE_WALL, STONE); + MATERIALS.put(Blocks.FLOWER_POT, DECORATION); + MATERIALS.put(Blocks.POTTED_TORCHFLOWER, DECORATION); + MATERIALS.put(Blocks.POTTED_OAK_SAPLING, DECORATION); + MATERIALS.put(Blocks.POTTED_SPRUCE_SAPLING, DECORATION); + MATERIALS.put(Blocks.POTTED_BIRCH_SAPLING, DECORATION); + MATERIALS.put(Blocks.POTTED_JUNGLE_SAPLING, DECORATION); + MATERIALS.put(Blocks.POTTED_ACACIA_SAPLING, DECORATION); + MATERIALS.put(Blocks.POTTED_CHERRY_SAPLING, DECORATION); + MATERIALS.put(Blocks.POTTED_DARK_OAK_SAPLING, DECORATION); + MATERIALS.put(Blocks.POTTED_MANGROVE_PROPAGULE, DECORATION); + MATERIALS.put(Blocks.POTTED_FERN, DECORATION); + MATERIALS.put(Blocks.POTTED_DANDELION, DECORATION); + MATERIALS.put(Blocks.POTTED_POPPY, DECORATION); + MATERIALS.put(Blocks.POTTED_BLUE_ORCHID, DECORATION); + MATERIALS.put(Blocks.POTTED_ALLIUM, DECORATION); + MATERIALS.put(Blocks.POTTED_AZURE_BLUET, DECORATION); + MATERIALS.put(Blocks.POTTED_RED_TULIP, DECORATION); + MATERIALS.put(Blocks.POTTED_ORANGE_TULIP, DECORATION); + MATERIALS.put(Blocks.POTTED_WHITE_TULIP, DECORATION); + MATERIALS.put(Blocks.POTTED_PINK_TULIP, DECORATION); + MATERIALS.put(Blocks.POTTED_OXEYE_DAISY, DECORATION); + MATERIALS.put(Blocks.POTTED_CORNFLOWER, DECORATION); + MATERIALS.put(Blocks.POTTED_LILY_OF_THE_VALLEY, DECORATION); + MATERIALS.put(Blocks.POTTED_WITHER_ROSE, DECORATION); + MATERIALS.put(Blocks.POTTED_RED_MUSHROOM, DECORATION); + MATERIALS.put(Blocks.POTTED_BROWN_MUSHROOM, DECORATION); + MATERIALS.put(Blocks.POTTED_DEAD_BUSH, DECORATION); + MATERIALS.put(Blocks.POTTED_CACTUS, DECORATION); + MATERIALS.put(Blocks.CARROTS, PLANT); + MATERIALS.put(Blocks.POTATOES, PLANT); + MATERIALS.put(Blocks.OAK_BUTTON, DECORATION); + MATERIALS.put(Blocks.SPRUCE_BUTTON, DECORATION); + MATERIALS.put(Blocks.BIRCH_BUTTON, DECORATION); + MATERIALS.put(Blocks.JUNGLE_BUTTON, DECORATION); + MATERIALS.put(Blocks.ACACIA_BUTTON, DECORATION); + MATERIALS.put(Blocks.CHERRY_BUTTON, DECORATION); + MATERIALS.put(Blocks.DARK_OAK_BUTTON, DECORATION); + MATERIALS.put(Blocks.MANGROVE_BUTTON, DECORATION); + MATERIALS.put(Blocks.BAMBOO_BUTTON, DECORATION); + MATERIALS.put(Blocks.SKELETON_SKULL, DECORATION); + MATERIALS.put(Blocks.SKELETON_WALL_SKULL, DECORATION); + MATERIALS.put(Blocks.WITHER_SKELETON_SKULL, DECORATION); + MATERIALS.put(Blocks.WITHER_SKELETON_WALL_SKULL, DECORATION); + MATERIALS.put(Blocks.ZOMBIE_HEAD, DECORATION); + MATERIALS.put(Blocks.ZOMBIE_WALL_HEAD, DECORATION); + MATERIALS.put(Blocks.PLAYER_HEAD, DECORATION); + MATERIALS.put(Blocks.PLAYER_WALL_HEAD, DECORATION); + MATERIALS.put(Blocks.CREEPER_HEAD, DECORATION); + MATERIALS.put(Blocks.CREEPER_WALL_HEAD, DECORATION); + MATERIALS.put(Blocks.DRAGON_HEAD, DECORATION); + MATERIALS.put(Blocks.DRAGON_WALL_HEAD, DECORATION); + MATERIALS.put(Blocks.PIGLIN_HEAD, DECORATION); + MATERIALS.put(Blocks.PIGLIN_WALL_HEAD, DECORATION); + MATERIALS.put(Blocks.ANVIL, REPAIR_STATION); + MATERIALS.put(Blocks.CHIPPED_ANVIL, REPAIR_STATION); + MATERIALS.put(Blocks.DAMAGED_ANVIL, REPAIR_STATION); + MATERIALS.put(Blocks.TRAPPED_CHEST, WOOD); + MATERIALS.put(Blocks.LIGHT_WEIGHTED_PRESSURE_PLATE, METAL); + MATERIALS.put(Blocks.HEAVY_WEIGHTED_PRESSURE_PLATE, METAL); + MATERIALS.put(Blocks.COMPARATOR, DECORATION); + MATERIALS.put(Blocks.DAYLIGHT_DETECTOR, WOOD); + MATERIALS.put(Blocks.REDSTONE_BLOCK, METAL); + MATERIALS.put(Blocks.NETHER_QUARTZ_ORE, STONE); + MATERIALS.put(Blocks.HOPPER, METAL); + MATERIALS.put(Blocks.QUARTZ_BLOCK, STONE); + MATERIALS.put(Blocks.CHISELED_QUARTZ_BLOCK, STONE); + MATERIALS.put(Blocks.QUARTZ_PILLAR, STONE); + MATERIALS.put(Blocks.QUARTZ_STAIRS, STONE); + MATERIALS.put(Blocks.ACTIVATOR_RAIL, DECORATION); + MATERIALS.put(Blocks.DROPPER, STONE); + MATERIALS.put(Blocks.WHITE_TERRACOTTA, STONE); + MATERIALS.put(Blocks.ORANGE_TERRACOTTA, STONE); + MATERIALS.put(Blocks.MAGENTA_TERRACOTTA, STONE); + MATERIALS.put(Blocks.LIGHT_BLUE_TERRACOTTA, STONE); + MATERIALS.put(Blocks.YELLOW_TERRACOTTA, STONE); + MATERIALS.put(Blocks.LIME_TERRACOTTA, STONE); + MATERIALS.put(Blocks.PINK_TERRACOTTA, STONE); + MATERIALS.put(Blocks.GRAY_TERRACOTTA, STONE); + MATERIALS.put(Blocks.LIGHT_GRAY_TERRACOTTA, STONE); + MATERIALS.put(Blocks.CYAN_TERRACOTTA, STONE); + MATERIALS.put(Blocks.PURPLE_TERRACOTTA, STONE); + MATERIALS.put(Blocks.BLUE_TERRACOTTA, STONE); + MATERIALS.put(Blocks.BROWN_TERRACOTTA, STONE); + MATERIALS.put(Blocks.GREEN_TERRACOTTA, STONE); + MATERIALS.put(Blocks.RED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.BLACK_TERRACOTTA, STONE); + MATERIALS.put(Blocks.WHITE_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.ORANGE_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.MAGENTA_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.LIGHT_BLUE_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.YELLOW_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.LIME_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.PINK_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.GRAY_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.LIGHT_GRAY_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.CYAN_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.PURPLE_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.BLUE_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.BROWN_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.GREEN_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.RED_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.BLACK_STAINED_GLASS_PANE, GLASS); + MATERIALS.put(Blocks.ACACIA_STAIRS, WOOD); + MATERIALS.put(Blocks.CHERRY_STAIRS, WOOD); + MATERIALS.put(Blocks.DARK_OAK_STAIRS, WOOD); + MATERIALS.put(Blocks.MANGROVE_STAIRS, WOOD); + MATERIALS.put(Blocks.BAMBOO_STAIRS, WOOD); + MATERIALS.put(Blocks.BAMBOO_MOSAIC_STAIRS, WOOD); + MATERIALS.put(Blocks.SLIME_BLOCK, ORGANIC_PRODUCT); + MATERIALS.put(Blocks.BARRIER, BARRIER); + MATERIALS.put(Blocks.LIGHT, AIR); + MATERIALS.put(Blocks.IRON_TRAPDOOR, METAL); + MATERIALS.put(Blocks.PRISMARINE, STONE); + MATERIALS.put(Blocks.PRISMARINE_BRICKS, STONE); + MATERIALS.put(Blocks.DARK_PRISMARINE, STONE); + MATERIALS.put(Blocks.PRISMARINE_STAIRS, STONE); + MATERIALS.put(Blocks.PRISMARINE_BRICK_STAIRS, STONE); + MATERIALS.put(Blocks.DARK_PRISMARINE_STAIRS, STONE); + MATERIALS.put(Blocks.PRISMARINE_SLAB, STONE); + MATERIALS.put(Blocks.PRISMARINE_BRICK_SLAB, STONE); + MATERIALS.put(Blocks.DARK_PRISMARINE_SLAB, STONE); + MATERIALS.put(Blocks.SEA_LANTERN, GLASS); + MATERIALS.put(Blocks.HAY_BLOCK, SOLID_ORGANIC); + MATERIALS.put(Blocks.WHITE_CARPET, CARPET); + MATERIALS.put(Blocks.ORANGE_CARPET, CARPET); + MATERIALS.put(Blocks.MAGENTA_CARPET, CARPET); + MATERIALS.put(Blocks.LIGHT_BLUE_CARPET, CARPET); + MATERIALS.put(Blocks.YELLOW_CARPET, CARPET); + MATERIALS.put(Blocks.LIME_CARPET, CARPET); + MATERIALS.put(Blocks.PINK_CARPET, CARPET); + MATERIALS.put(Blocks.GRAY_CARPET, CARPET); + MATERIALS.put(Blocks.LIGHT_GRAY_CARPET, CARPET); + MATERIALS.put(Blocks.CYAN_CARPET, CARPET); + MATERIALS.put(Blocks.PURPLE_CARPET, CARPET); + MATERIALS.put(Blocks.BLUE_CARPET, CARPET); + MATERIALS.put(Blocks.BROWN_CARPET, CARPET); + MATERIALS.put(Blocks.GREEN_CARPET, CARPET); + MATERIALS.put(Blocks.RED_CARPET, CARPET); + MATERIALS.put(Blocks.BLACK_CARPET, CARPET); + MATERIALS.put(Blocks.TERRACOTTA, STONE); + MATERIALS.put(Blocks.COAL_BLOCK, STONE); + MATERIALS.put(Blocks.PACKED_ICE, DENSE_ICE); + MATERIALS.put(Blocks.SUNFLOWER, REPLACEABLE_PLANT); + MATERIALS.put(Blocks.LILAC, REPLACEABLE_PLANT); + MATERIALS.put(Blocks.ROSE_BUSH, REPLACEABLE_PLANT); + MATERIALS.put(Blocks.PEONY, REPLACEABLE_PLANT); + MATERIALS.put(Blocks.TALL_GRASS, REPLACEABLE_PLANT); + MATERIALS.put(Blocks.LARGE_FERN, REPLACEABLE_PLANT); + MATERIALS.put(Blocks.WHITE_BANNER, WOOD); + MATERIALS.put(Blocks.ORANGE_BANNER, WOOD); + MATERIALS.put(Blocks.MAGENTA_BANNER, WOOD); + MATERIALS.put(Blocks.LIGHT_BLUE_BANNER, WOOD); + MATERIALS.put(Blocks.YELLOW_BANNER, WOOD); + MATERIALS.put(Blocks.LIME_BANNER, WOOD); + MATERIALS.put(Blocks.PINK_BANNER, WOOD); + MATERIALS.put(Blocks.GRAY_BANNER, WOOD); + MATERIALS.put(Blocks.LIGHT_GRAY_BANNER, WOOD); + MATERIALS.put(Blocks.CYAN_BANNER, WOOD); + MATERIALS.put(Blocks.PURPLE_BANNER, WOOD); + MATERIALS.put(Blocks.BLUE_BANNER, WOOD); + MATERIALS.put(Blocks.BROWN_BANNER, WOOD); + MATERIALS.put(Blocks.GREEN_BANNER, WOOD); + MATERIALS.put(Blocks.RED_BANNER, WOOD); + MATERIALS.put(Blocks.BLACK_BANNER, WOOD); + MATERIALS.put(Blocks.WHITE_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.ORANGE_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.MAGENTA_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.LIGHT_BLUE_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.YELLOW_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.LIME_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.PINK_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.GRAY_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.LIGHT_GRAY_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.CYAN_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.PURPLE_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.BLUE_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.BROWN_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.GREEN_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.RED_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.BLACK_WALL_BANNER, WOOD); + MATERIALS.put(Blocks.RED_SANDSTONE, STONE); + MATERIALS.put(Blocks.CHISELED_RED_SANDSTONE, STONE); + MATERIALS.put(Blocks.CUT_RED_SANDSTONE, STONE); + MATERIALS.put(Blocks.RED_SANDSTONE_STAIRS, STONE); + MATERIALS.put(Blocks.OAK_SLAB, WOOD); + MATERIALS.put(Blocks.SPRUCE_SLAB, WOOD); + MATERIALS.put(Blocks.BIRCH_SLAB, WOOD); + MATERIALS.put(Blocks.JUNGLE_SLAB, WOOD); + MATERIALS.put(Blocks.ACACIA_SLAB, WOOD); + MATERIALS.put(Blocks.CHERRY_SLAB, WOOD); + MATERIALS.put(Blocks.DARK_OAK_SLAB, WOOD); + MATERIALS.put(Blocks.MANGROVE_SLAB, WOOD); + MATERIALS.put(Blocks.BAMBOO_SLAB, WOOD); + MATERIALS.put(Blocks.BAMBOO_MOSAIC_SLAB, WOOD); + MATERIALS.put(Blocks.STONE_SLAB, STONE); + MATERIALS.put(Blocks.SMOOTH_STONE_SLAB, STONE); + MATERIALS.put(Blocks.SANDSTONE_SLAB, STONE); + MATERIALS.put(Blocks.CUT_SANDSTONE_SLAB, STONE); + MATERIALS.put(Blocks.PETRIFIED_OAK_SLAB, STONE); + MATERIALS.put(Blocks.COBBLESTONE_SLAB, STONE); + MATERIALS.put(Blocks.BRICK_SLAB, STONE); + MATERIALS.put(Blocks.STONE_BRICK_SLAB, STONE); + MATERIALS.put(Blocks.MUD_BRICK_SLAB, STONE); + MATERIALS.put(Blocks.NETHER_BRICK_SLAB, STONE); + MATERIALS.put(Blocks.QUARTZ_SLAB, STONE); + MATERIALS.put(Blocks.RED_SANDSTONE_SLAB, STONE); + MATERIALS.put(Blocks.CUT_RED_SANDSTONE_SLAB, STONE); + MATERIALS.put(Blocks.PURPUR_SLAB, STONE); + MATERIALS.put(Blocks.SMOOTH_STONE, STONE); + MATERIALS.put(Blocks.SMOOTH_SANDSTONE, STONE); + MATERIALS.put(Blocks.SMOOTH_QUARTZ, STONE); + MATERIALS.put(Blocks.SMOOTH_RED_SANDSTONE, STONE); + MATERIALS.put(Blocks.SPRUCE_FENCE_GATE, WOOD); + MATERIALS.put(Blocks.BIRCH_FENCE_GATE, WOOD); + MATERIALS.put(Blocks.JUNGLE_FENCE_GATE, WOOD); + MATERIALS.put(Blocks.ACACIA_FENCE_GATE, WOOD); + MATERIALS.put(Blocks.CHERRY_FENCE_GATE, WOOD); + MATERIALS.put(Blocks.DARK_OAK_FENCE_GATE, WOOD); + MATERIALS.put(Blocks.MANGROVE_FENCE_GATE, WOOD); + MATERIALS.put(Blocks.BAMBOO_FENCE_GATE, WOOD); + MATERIALS.put(Blocks.SPRUCE_FENCE, WOOD); + MATERIALS.put(Blocks.BIRCH_FENCE, WOOD); + MATERIALS.put(Blocks.JUNGLE_FENCE, WOOD); + MATERIALS.put(Blocks.ACACIA_FENCE, WOOD); + MATERIALS.put(Blocks.CHERRY_FENCE, WOOD); + MATERIALS.put(Blocks.DARK_OAK_FENCE, WOOD); + MATERIALS.put(Blocks.MANGROVE_FENCE, WOOD); + MATERIALS.put(Blocks.BAMBOO_FENCE, WOOD); + MATERIALS.put(Blocks.SPRUCE_DOOR, WOOD); + MATERIALS.put(Blocks.BIRCH_DOOR, WOOD); + MATERIALS.put(Blocks.JUNGLE_DOOR, WOOD); + MATERIALS.put(Blocks.ACACIA_DOOR, WOOD); + MATERIALS.put(Blocks.CHERRY_DOOR, WOOD); + MATERIALS.put(Blocks.DARK_OAK_DOOR, WOOD); + MATERIALS.put(Blocks.MANGROVE_DOOR, WOOD); + MATERIALS.put(Blocks.BAMBOO_DOOR, WOOD); + MATERIALS.put(Blocks.END_ROD, DECORATION); + MATERIALS.put(Blocks.CHORUS_PLANT, PLANT); + MATERIALS.put(Blocks.CHORUS_FLOWER, PLANT); + MATERIALS.put(Blocks.PURPUR_BLOCK, STONE); + MATERIALS.put(Blocks.PURPUR_PILLAR, STONE); + MATERIALS.put(Blocks.PURPUR_STAIRS, STONE); + MATERIALS.put(Blocks.END_STONE_BRICKS, STONE); + MATERIALS.put(Blocks.TORCHFLOWER_CROP, PLANT); + MATERIALS.put(Blocks.BEETROOTS, PLANT); + MATERIALS.put(Blocks.DIRT_PATH, SOIL); + MATERIALS.put(Blocks.END_GATEWAY, PORTAL); + MATERIALS.put(Blocks.REPEATING_COMMAND_BLOCK, METAL); + MATERIALS.put(Blocks.CHAIN_COMMAND_BLOCK, METAL); + MATERIALS.put(Blocks.FROSTED_ICE, ICE); + MATERIALS.put(Blocks.MAGMA_BLOCK, STONE); + MATERIALS.put(Blocks.NETHER_WART_BLOCK, SOLID_ORGANIC); + MATERIALS.put(Blocks.RED_NETHER_BRICKS, STONE); + MATERIALS.put(Blocks.BONE_BLOCK, STONE); + MATERIALS.put(Blocks.STRUCTURE_VOID, STRUCTURE_VOID); + MATERIALS.put(Blocks.OBSERVER, STONE); + MATERIALS.put(Blocks.SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.WHITE_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.ORANGE_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.MAGENTA_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.LIGHT_BLUE_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.YELLOW_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.LIME_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.PINK_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.GRAY_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.LIGHT_GRAY_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.CYAN_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.PURPLE_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.BLUE_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.BROWN_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.GREEN_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.RED_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.BLACK_SHULKER_BOX, SHULKER_BOX); + MATERIALS.put(Blocks.WHITE_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.ORANGE_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.MAGENTA_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.LIGHT_BLUE_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.YELLOW_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.LIME_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.PINK_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.GRAY_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.LIGHT_GRAY_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.CYAN_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.PURPLE_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.BLUE_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.BROWN_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.GREEN_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.RED_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.BLACK_GLAZED_TERRACOTTA, STONE); + MATERIALS.put(Blocks.WHITE_CONCRETE, STONE); + MATERIALS.put(Blocks.ORANGE_CONCRETE, STONE); + MATERIALS.put(Blocks.MAGENTA_CONCRETE, STONE); + MATERIALS.put(Blocks.LIGHT_BLUE_CONCRETE, STONE); + MATERIALS.put(Blocks.YELLOW_CONCRETE, STONE); + MATERIALS.put(Blocks.LIME_CONCRETE, STONE); + MATERIALS.put(Blocks.PINK_CONCRETE, STONE); + MATERIALS.put(Blocks.GRAY_CONCRETE, STONE); + MATERIALS.put(Blocks.LIGHT_GRAY_CONCRETE, STONE); + MATERIALS.put(Blocks.CYAN_CONCRETE, STONE); + MATERIALS.put(Blocks.PURPLE_CONCRETE, STONE); + MATERIALS.put(Blocks.BLUE_CONCRETE, STONE); + MATERIALS.put(Blocks.BROWN_CONCRETE, STONE); + MATERIALS.put(Blocks.GREEN_CONCRETE, STONE); + MATERIALS.put(Blocks.RED_CONCRETE, STONE); + MATERIALS.put(Blocks.BLACK_CONCRETE, STONE); + MATERIALS.put(Blocks.WHITE_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.ORANGE_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.MAGENTA_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.LIGHT_BLUE_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.YELLOW_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.LIME_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.PINK_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.GRAY_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.LIGHT_GRAY_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.CYAN_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.PURPLE_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.BLUE_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.BROWN_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.GREEN_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.RED_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.BLACK_CONCRETE_POWDER, AGGREGATE); + MATERIALS.put(Blocks.KELP, UNDERWATER_PLANT); + MATERIALS.put(Blocks.KELP_PLANT, UNDERWATER_PLANT); + MATERIALS.put(Blocks.DRIED_KELP_BLOCK, SOLID_ORGANIC); + MATERIALS.put(Blocks.TURTLE_EGG, EGG); + MATERIALS.put(Blocks.DEAD_TUBE_CORAL_BLOCK, STONE); + MATERIALS.put(Blocks.DEAD_BRAIN_CORAL_BLOCK, STONE); + MATERIALS.put(Blocks.DEAD_BUBBLE_CORAL_BLOCK, STONE); + MATERIALS.put(Blocks.DEAD_FIRE_CORAL_BLOCK, STONE); + MATERIALS.put(Blocks.DEAD_HORN_CORAL_BLOCK, STONE); + MATERIALS.put(Blocks.TUBE_CORAL_BLOCK, STONE); + MATERIALS.put(Blocks.BRAIN_CORAL_BLOCK, STONE); + MATERIALS.put(Blocks.BUBBLE_CORAL_BLOCK, STONE); + MATERIALS.put(Blocks.FIRE_CORAL_BLOCK, STONE); + MATERIALS.put(Blocks.HORN_CORAL_BLOCK, STONE); + MATERIALS.put(Blocks.DEAD_TUBE_CORAL, STONE); + MATERIALS.put(Blocks.DEAD_BRAIN_CORAL, STONE); + MATERIALS.put(Blocks.DEAD_BUBBLE_CORAL, STONE); + MATERIALS.put(Blocks.DEAD_FIRE_CORAL, STONE); + MATERIALS.put(Blocks.DEAD_HORN_CORAL, STONE); + MATERIALS.put(Blocks.TUBE_CORAL, UNDERWATER_PLANT); + MATERIALS.put(Blocks.BRAIN_CORAL, UNDERWATER_PLANT); + MATERIALS.put(Blocks.BUBBLE_CORAL, UNDERWATER_PLANT); + MATERIALS.put(Blocks.FIRE_CORAL, UNDERWATER_PLANT); + MATERIALS.put(Blocks.HORN_CORAL, UNDERWATER_PLANT); + MATERIALS.put(Blocks.DEAD_TUBE_CORAL_FAN, STONE); + MATERIALS.put(Blocks.DEAD_BRAIN_CORAL_FAN, STONE); + MATERIALS.put(Blocks.DEAD_BUBBLE_CORAL_FAN, STONE); + MATERIALS.put(Blocks.DEAD_FIRE_CORAL_FAN, STONE); + MATERIALS.put(Blocks.DEAD_HORN_CORAL_FAN, STONE); + MATERIALS.put(Blocks.TUBE_CORAL_FAN, UNDERWATER_PLANT); + MATERIALS.put(Blocks.BRAIN_CORAL_FAN, UNDERWATER_PLANT); + MATERIALS.put(Blocks.BUBBLE_CORAL_FAN, UNDERWATER_PLANT); + MATERIALS.put(Blocks.FIRE_CORAL_FAN, UNDERWATER_PLANT); + MATERIALS.put(Blocks.HORN_CORAL_FAN, UNDERWATER_PLANT); + MATERIALS.put(Blocks.DEAD_TUBE_CORAL_WALL_FAN, STONE); + MATERIALS.put(Blocks.DEAD_BRAIN_CORAL_WALL_FAN, STONE); + MATERIALS.put(Blocks.DEAD_BUBBLE_CORAL_WALL_FAN, STONE); + MATERIALS.put(Blocks.DEAD_FIRE_CORAL_WALL_FAN, STONE); + MATERIALS.put(Blocks.DEAD_HORN_CORAL_WALL_FAN, STONE); + MATERIALS.put(Blocks.TUBE_CORAL_WALL_FAN, UNDERWATER_PLANT); + MATERIALS.put(Blocks.BRAIN_CORAL_WALL_FAN, UNDERWATER_PLANT); + MATERIALS.put(Blocks.BUBBLE_CORAL_WALL_FAN, UNDERWATER_PLANT); + MATERIALS.put(Blocks.FIRE_CORAL_WALL_FAN, UNDERWATER_PLANT); + MATERIALS.put(Blocks.HORN_CORAL_WALL_FAN, UNDERWATER_PLANT); + MATERIALS.put(Blocks.SEA_PICKLE, UNDERWATER_PLANT); + MATERIALS.put(Blocks.BLUE_ICE, DENSE_ICE); + MATERIALS.put(Blocks.CONDUIT, GLASS); + MATERIALS.put(Blocks.BAMBOO_SAPLING, BAMBOO_SAPLING); + MATERIALS.put(Blocks.BAMBOO, BAMBOO); + MATERIALS.put(Blocks.POTTED_BAMBOO, DECORATION); + MATERIALS.put(Blocks.VOID_AIR, AIR); + MATERIALS.put(Blocks.CAVE_AIR, AIR); + MATERIALS.put(Blocks.BUBBLE_COLUMN, BUBBLE_COLUMN); + MATERIALS.put(Blocks.POLISHED_GRANITE_STAIRS, STONE); + MATERIALS.put(Blocks.SMOOTH_RED_SANDSTONE_STAIRS, STONE); + MATERIALS.put(Blocks.MOSSY_STONE_BRICK_STAIRS, STONE); + MATERIALS.put(Blocks.POLISHED_DIORITE_STAIRS, STONE); + MATERIALS.put(Blocks.MOSSY_COBBLESTONE_STAIRS, STONE); + MATERIALS.put(Blocks.END_STONE_BRICK_STAIRS, STONE); + MATERIALS.put(Blocks.STONE_STAIRS, STONE); + MATERIALS.put(Blocks.SMOOTH_SANDSTONE_STAIRS, STONE); + MATERIALS.put(Blocks.SMOOTH_QUARTZ_STAIRS, STONE); + MATERIALS.put(Blocks.GRANITE_STAIRS, STONE); + MATERIALS.put(Blocks.ANDESITE_STAIRS, STONE); + MATERIALS.put(Blocks.RED_NETHER_BRICK_STAIRS, STONE); + MATERIALS.put(Blocks.POLISHED_ANDESITE_STAIRS, STONE); + MATERIALS.put(Blocks.DIORITE_STAIRS, STONE); + MATERIALS.put(Blocks.POLISHED_GRANITE_SLAB, STONE); + MATERIALS.put(Blocks.SMOOTH_RED_SANDSTONE_SLAB, STONE); + MATERIALS.put(Blocks.MOSSY_STONE_BRICK_SLAB, STONE); + MATERIALS.put(Blocks.POLISHED_DIORITE_SLAB, STONE); + MATERIALS.put(Blocks.MOSSY_COBBLESTONE_SLAB, STONE); + MATERIALS.put(Blocks.END_STONE_BRICK_SLAB, STONE); + MATERIALS.put(Blocks.SMOOTH_SANDSTONE_SLAB, STONE); + MATERIALS.put(Blocks.SMOOTH_QUARTZ_SLAB, STONE); + MATERIALS.put(Blocks.GRANITE_SLAB, STONE); + MATERIALS.put(Blocks.ANDESITE_SLAB, STONE); + MATERIALS.put(Blocks.RED_NETHER_BRICK_SLAB, STONE); + MATERIALS.put(Blocks.POLISHED_ANDESITE_SLAB, STONE); + MATERIALS.put(Blocks.DIORITE_SLAB, STONE); + MATERIALS.put(Blocks.BRICK_WALL, STONE); + MATERIALS.put(Blocks.PRISMARINE_WALL, STONE); + MATERIALS.put(Blocks.RED_SANDSTONE_WALL, STONE); + MATERIALS.put(Blocks.MOSSY_STONE_BRICK_WALL, STONE); + MATERIALS.put(Blocks.GRANITE_WALL, STONE); + MATERIALS.put(Blocks.STONE_BRICK_WALL, STONE); + MATERIALS.put(Blocks.MUD_BRICK_WALL, STONE); + MATERIALS.put(Blocks.NETHER_BRICK_WALL, STONE); + MATERIALS.put(Blocks.ANDESITE_WALL, STONE); + MATERIALS.put(Blocks.RED_NETHER_BRICK_WALL, STONE); + MATERIALS.put(Blocks.SANDSTONE_WALL, STONE); + MATERIALS.put(Blocks.END_STONE_BRICK_WALL, STONE); + MATERIALS.put(Blocks.DIORITE_WALL, STONE); + MATERIALS.put(Blocks.SCAFFOLDING, DECORATION); + MATERIALS.put(Blocks.LOOM, WOOD); + MATERIALS.put(Blocks.BARREL, WOOD); + MATERIALS.put(Blocks.SMOKER, STONE); + MATERIALS.put(Blocks.BLAST_FURNACE, STONE); + MATERIALS.put(Blocks.CARTOGRAPHY_TABLE, WOOD); + MATERIALS.put(Blocks.FLETCHING_TABLE, WOOD); + MATERIALS.put(Blocks.GRINDSTONE, REPAIR_STATION); + MATERIALS.put(Blocks.LECTERN, WOOD); + MATERIALS.put(Blocks.SMITHING_TABLE, WOOD); + MATERIALS.put(Blocks.STONECUTTER, STONE); + MATERIALS.put(Blocks.BELL, METAL); + MATERIALS.put(Blocks.LANTERN, METAL); + MATERIALS.put(Blocks.SOUL_LANTERN, METAL); + MATERIALS.put(Blocks.CAMPFIRE, WOOD); + MATERIALS.put(Blocks.SOUL_CAMPFIRE, WOOD); + MATERIALS.put(Blocks.SWEET_BERRY_BUSH, PLANT); + MATERIALS.put(Blocks.WARPED_STEM, NETHER_WOOD); + MATERIALS.put(Blocks.STRIPPED_WARPED_STEM, NETHER_WOOD); + MATERIALS.put(Blocks.WARPED_HYPHAE, NETHER_WOOD); + MATERIALS.put(Blocks.STRIPPED_WARPED_HYPHAE, NETHER_WOOD); + MATERIALS.put(Blocks.WARPED_NYLIUM, STONE); + MATERIALS.put(Blocks.WARPED_FUNGUS, PLANT); + MATERIALS.put(Blocks.WARPED_WART_BLOCK, SOLID_ORGANIC); + MATERIALS.put(Blocks.WARPED_ROOTS, NETHER_SHOOTS); + MATERIALS.put(Blocks.NETHER_SPROUTS, NETHER_SHOOTS); + MATERIALS.put(Blocks.CRIMSON_STEM, NETHER_WOOD); + MATERIALS.put(Blocks.STRIPPED_CRIMSON_STEM, NETHER_WOOD); + MATERIALS.put(Blocks.CRIMSON_HYPHAE, NETHER_WOOD); + MATERIALS.put(Blocks.STRIPPED_CRIMSON_HYPHAE, NETHER_WOOD); + MATERIALS.put(Blocks.CRIMSON_NYLIUM, STONE); + MATERIALS.put(Blocks.CRIMSON_FUNGUS, PLANT); + MATERIALS.put(Blocks.SHROOMLIGHT, SOLID_ORGANIC); + MATERIALS.put(Blocks.WEEPING_VINES, PLANT); + MATERIALS.put(Blocks.WEEPING_VINES_PLANT, PLANT); + MATERIALS.put(Blocks.TWISTING_VINES, PLANT); + MATERIALS.put(Blocks.TWISTING_VINES_PLANT, PLANT); + MATERIALS.put(Blocks.CRIMSON_ROOTS, NETHER_SHOOTS); + MATERIALS.put(Blocks.CRIMSON_PLANKS, NETHER_WOOD); + MATERIALS.put(Blocks.WARPED_PLANKS, NETHER_WOOD); + MATERIALS.put(Blocks.CRIMSON_SLAB, NETHER_WOOD); + MATERIALS.put(Blocks.WARPED_SLAB, NETHER_WOOD); + MATERIALS.put(Blocks.CRIMSON_PRESSURE_PLATE, NETHER_WOOD); + MATERIALS.put(Blocks.WARPED_PRESSURE_PLATE, NETHER_WOOD); + MATERIALS.put(Blocks.CRIMSON_FENCE, NETHER_WOOD); + MATERIALS.put(Blocks.WARPED_FENCE, NETHER_WOOD); + MATERIALS.put(Blocks.CRIMSON_TRAPDOOR, NETHER_WOOD); + MATERIALS.put(Blocks.WARPED_TRAPDOOR, NETHER_WOOD); + MATERIALS.put(Blocks.CRIMSON_FENCE_GATE, NETHER_WOOD); + MATERIALS.put(Blocks.WARPED_FENCE_GATE, NETHER_WOOD); + MATERIALS.put(Blocks.CRIMSON_STAIRS, NETHER_WOOD); + MATERIALS.put(Blocks.WARPED_STAIRS, NETHER_WOOD); + MATERIALS.put(Blocks.CRIMSON_BUTTON, DECORATION); + MATERIALS.put(Blocks.WARPED_BUTTON, DECORATION); + MATERIALS.put(Blocks.CRIMSON_DOOR, NETHER_WOOD); + MATERIALS.put(Blocks.WARPED_DOOR, NETHER_WOOD); + MATERIALS.put(Blocks.CRIMSON_SIGN, NETHER_WOOD); + MATERIALS.put(Blocks.WARPED_SIGN, NETHER_WOOD); + MATERIALS.put(Blocks.CRIMSON_WALL_SIGN, NETHER_WOOD); + MATERIALS.put(Blocks.WARPED_WALL_SIGN, NETHER_WOOD); + MATERIALS.put(Blocks.STRUCTURE_BLOCK, METAL); + MATERIALS.put(Blocks.JIGSAW, METAL); + MATERIALS.put(Blocks.COMPOSTER, WOOD); + MATERIALS.put(Blocks.TARGET, SOLID_ORGANIC); + MATERIALS.put(Blocks.BEE_NEST, WOOD); + MATERIALS.put(Blocks.BEEHIVE, WOOD); + MATERIALS.put(Blocks.HONEY_BLOCK, ORGANIC_PRODUCT); + MATERIALS.put(Blocks.HONEYCOMB_BLOCK, ORGANIC_PRODUCT); + MATERIALS.put(Blocks.NETHERITE_BLOCK, METAL); + MATERIALS.put(Blocks.ANCIENT_DEBRIS, METAL); + MATERIALS.put(Blocks.CRYING_OBSIDIAN, STONE); + MATERIALS.put(Blocks.RESPAWN_ANCHOR, STONE); + MATERIALS.put(Blocks.POTTED_CRIMSON_FUNGUS, DECORATION); + MATERIALS.put(Blocks.POTTED_WARPED_FUNGUS, DECORATION); + MATERIALS.put(Blocks.POTTED_CRIMSON_ROOTS, DECORATION); + MATERIALS.put(Blocks.POTTED_WARPED_ROOTS, DECORATION); + MATERIALS.put(Blocks.LODESTONE, REPAIR_STATION); + MATERIALS.put(Blocks.BLACKSTONE, STONE); + MATERIALS.put(Blocks.BLACKSTONE_STAIRS, STONE); + MATERIALS.put(Blocks.BLACKSTONE_WALL, STONE); + MATERIALS.put(Blocks.BLACKSTONE_SLAB, STONE); + MATERIALS.put(Blocks.POLISHED_BLACKSTONE, STONE); + MATERIALS.put(Blocks.POLISHED_BLACKSTONE_BRICKS, STONE); + MATERIALS.put(Blocks.CRACKED_POLISHED_BLACKSTONE_BRICKS, STONE); + MATERIALS.put(Blocks.CHISELED_POLISHED_BLACKSTONE, STONE); + MATERIALS.put(Blocks.POLISHED_BLACKSTONE_BRICK_SLAB, STONE); + MATERIALS.put(Blocks.POLISHED_BLACKSTONE_BRICK_STAIRS, STONE); + MATERIALS.put(Blocks.POLISHED_BLACKSTONE_BRICK_WALL, STONE); + MATERIALS.put(Blocks.GILDED_BLACKSTONE, STONE); + MATERIALS.put(Blocks.POLISHED_BLACKSTONE_STAIRS, STONE); + MATERIALS.put(Blocks.POLISHED_BLACKSTONE_SLAB, STONE); + MATERIALS.put(Blocks.POLISHED_BLACKSTONE_PRESSURE_PLATE, STONE); + MATERIALS.put(Blocks.POLISHED_BLACKSTONE_BUTTON, DECORATION); + MATERIALS.put(Blocks.POLISHED_BLACKSTONE_WALL, STONE); + MATERIALS.put(Blocks.CHISELED_NETHER_BRICKS, STONE); + MATERIALS.put(Blocks.CRACKED_NETHER_BRICKS, STONE); + MATERIALS.put(Blocks.QUARTZ_BRICKS, STONE); + MATERIALS.put(Blocks.CANDLE, DECORATION); + MATERIALS.put(Blocks.WHITE_CANDLE, DECORATION); + MATERIALS.put(Blocks.ORANGE_CANDLE, DECORATION); + MATERIALS.put(Blocks.MAGENTA_CANDLE, DECORATION); + MATERIALS.put(Blocks.LIGHT_BLUE_CANDLE, DECORATION); + MATERIALS.put(Blocks.YELLOW_CANDLE, DECORATION); + MATERIALS.put(Blocks.LIME_CANDLE, DECORATION); + MATERIALS.put(Blocks.PINK_CANDLE, DECORATION); + MATERIALS.put(Blocks.GRAY_CANDLE, DECORATION); + MATERIALS.put(Blocks.LIGHT_GRAY_CANDLE, DECORATION); + MATERIALS.put(Blocks.CYAN_CANDLE, DECORATION); + MATERIALS.put(Blocks.PURPLE_CANDLE, DECORATION); + MATERIALS.put(Blocks.BLUE_CANDLE, DECORATION); + MATERIALS.put(Blocks.BROWN_CANDLE, DECORATION); + MATERIALS.put(Blocks.GREEN_CANDLE, DECORATION); + MATERIALS.put(Blocks.RED_CANDLE, DECORATION); + MATERIALS.put(Blocks.BLACK_CANDLE, DECORATION); + MATERIALS.put(Blocks.CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.WHITE_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.ORANGE_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.MAGENTA_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.LIGHT_BLUE_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.YELLOW_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.LIME_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.PINK_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.GRAY_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.LIGHT_GRAY_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.CYAN_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.PURPLE_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.BLUE_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.BROWN_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.GREEN_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.RED_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.BLACK_CANDLE_CAKE, CAKE); + MATERIALS.put(Blocks.AMETHYST_BLOCK, AMETHYST); + MATERIALS.put(Blocks.BUDDING_AMETHYST, AMETHYST); + MATERIALS.put(Blocks.AMETHYST_CLUSTER, AMETHYST); + MATERIALS.put(Blocks.LARGE_AMETHYST_BUD, AMETHYST); + MATERIALS.put(Blocks.MEDIUM_AMETHYST_BUD, AMETHYST); + MATERIALS.put(Blocks.SMALL_AMETHYST_BUD, AMETHYST); + MATERIALS.put(Blocks.TUFF, STONE); + MATERIALS.put(Blocks.CALCITE, STONE); + MATERIALS.put(Blocks.TINTED_GLASS, GLASS); + MATERIALS.put(Blocks.POWDER_SNOW, POWDER_SNOW); + MATERIALS.put(Blocks.SCULK_SENSOR, SCULK); + MATERIALS.put(Blocks.SCULK, SCULK); + MATERIALS.put(Blocks.SCULK_VEIN, SCULK); + MATERIALS.put(Blocks.SCULK_CATALYST, SCULK); + MATERIALS.put(Blocks.SCULK_SHRIEKER, SCULK); + MATERIALS.put(Blocks.OXIDIZED_COPPER, METAL); + MATERIALS.put(Blocks.WEATHERED_COPPER, METAL); + MATERIALS.put(Blocks.EXPOSED_COPPER, METAL); + MATERIALS.put(Blocks.COPPER_BLOCK, METAL); + MATERIALS.put(Blocks.COPPER_ORE, STONE); + MATERIALS.put(Blocks.DEEPSLATE_COPPER_ORE, STONE); + MATERIALS.put(Blocks.OXIDIZED_CUT_COPPER, METAL); + MATERIALS.put(Blocks.WEATHERED_CUT_COPPER, METAL); + MATERIALS.put(Blocks.EXPOSED_CUT_COPPER, METAL); + MATERIALS.put(Blocks.CUT_COPPER, METAL); + MATERIALS.put(Blocks.OXIDIZED_CUT_COPPER_STAIRS, METAL); + MATERIALS.put(Blocks.WEATHERED_CUT_COPPER_STAIRS, METAL); + MATERIALS.put(Blocks.EXPOSED_CUT_COPPER_STAIRS, METAL); + MATERIALS.put(Blocks.CUT_COPPER_STAIRS, METAL); + MATERIALS.put(Blocks.OXIDIZED_CUT_COPPER_SLAB, METAL); + MATERIALS.put(Blocks.WEATHERED_CUT_COPPER_SLAB, METAL); + MATERIALS.put(Blocks.EXPOSED_CUT_COPPER_SLAB, METAL); + MATERIALS.put(Blocks.CUT_COPPER_SLAB, METAL); + MATERIALS.put(Blocks.WAXED_COPPER_BLOCK, METAL); + MATERIALS.put(Blocks.WAXED_WEATHERED_COPPER, METAL); + MATERIALS.put(Blocks.WAXED_EXPOSED_COPPER, METAL); + MATERIALS.put(Blocks.WAXED_OXIDIZED_COPPER, METAL); + MATERIALS.put(Blocks.WAXED_OXIDIZED_CUT_COPPER, METAL); + MATERIALS.put(Blocks.WAXED_WEATHERED_CUT_COPPER, METAL); + MATERIALS.put(Blocks.WAXED_EXPOSED_CUT_COPPER, METAL); + MATERIALS.put(Blocks.WAXED_CUT_COPPER, METAL); + MATERIALS.put(Blocks.WAXED_OXIDIZED_CUT_COPPER_STAIRS, METAL); + MATERIALS.put(Blocks.WAXED_WEATHERED_CUT_COPPER_STAIRS, METAL); + MATERIALS.put(Blocks.WAXED_EXPOSED_CUT_COPPER_STAIRS, METAL); + MATERIALS.put(Blocks.WAXED_CUT_COPPER_STAIRS, METAL); + MATERIALS.put(Blocks.WAXED_OXIDIZED_CUT_COPPER_SLAB, METAL); + MATERIALS.put(Blocks.WAXED_WEATHERED_CUT_COPPER_SLAB, METAL); + MATERIALS.put(Blocks.WAXED_EXPOSED_CUT_COPPER_SLAB, METAL); + MATERIALS.put(Blocks.WAXED_CUT_COPPER_SLAB, METAL); + MATERIALS.put(Blocks.LIGHTNING_ROD, METAL); + MATERIALS.put(Blocks.POINTED_DRIPSTONE, STONE); + MATERIALS.put(Blocks.DRIPSTONE_BLOCK, STONE); + MATERIALS.put(Blocks.CAVE_VINES, PLANT); + MATERIALS.put(Blocks.CAVE_VINES_PLANT, PLANT); + MATERIALS.put(Blocks.SPORE_BLOSSOM, PLANT); + MATERIALS.put(Blocks.AZALEA, PLANT); + MATERIALS.put(Blocks.FLOWERING_AZALEA, PLANT); + MATERIALS.put(Blocks.MOSS_CARPET, PLANT); + MATERIALS.put(Blocks.PINK_PETALS, PLANT); + MATERIALS.put(Blocks.MOSS_BLOCK, MOSS_BLOCK); + MATERIALS.put(Blocks.BIG_DRIPLEAF, PLANT); + MATERIALS.put(Blocks.BIG_DRIPLEAF_STEM, PLANT); + MATERIALS.put(Blocks.SMALL_DRIPLEAF, PLANT); + MATERIALS.put(Blocks.HANGING_ROOTS, REPLACEABLE_PLANT); + MATERIALS.put(Blocks.ROOTED_DIRT, SOIL); + MATERIALS.put(Blocks.MUD, SOIL); + MATERIALS.put(Blocks.DEEPSLATE, STONE); + MATERIALS.put(Blocks.COBBLED_DEEPSLATE, STONE); + MATERIALS.put(Blocks.COBBLED_DEEPSLATE_STAIRS, STONE); + MATERIALS.put(Blocks.COBBLED_DEEPSLATE_SLAB, STONE); + MATERIALS.put(Blocks.COBBLED_DEEPSLATE_WALL, STONE); + MATERIALS.put(Blocks.POLISHED_DEEPSLATE, STONE); + MATERIALS.put(Blocks.POLISHED_DEEPSLATE_STAIRS, STONE); + MATERIALS.put(Blocks.POLISHED_DEEPSLATE_SLAB, STONE); + MATERIALS.put(Blocks.POLISHED_DEEPSLATE_WALL, STONE); + MATERIALS.put(Blocks.DEEPSLATE_TILES, STONE); + MATERIALS.put(Blocks.DEEPSLATE_TILE_STAIRS, STONE); + MATERIALS.put(Blocks.DEEPSLATE_TILE_SLAB, STONE); + MATERIALS.put(Blocks.DEEPSLATE_TILE_WALL, STONE); + MATERIALS.put(Blocks.DEEPSLATE_BRICKS, STONE); + MATERIALS.put(Blocks.DEEPSLATE_BRICK_STAIRS, STONE); + MATERIALS.put(Blocks.DEEPSLATE_BRICK_SLAB, STONE); + MATERIALS.put(Blocks.DEEPSLATE_BRICK_WALL, STONE); + MATERIALS.put(Blocks.CHISELED_DEEPSLATE, STONE); + MATERIALS.put(Blocks.CRACKED_DEEPSLATE_BRICKS, STONE); + MATERIALS.put(Blocks.CRACKED_DEEPSLATE_TILES, STONE); + MATERIALS.put(Blocks.INFESTED_DEEPSLATE, ORGANIC_PRODUCT); + MATERIALS.put(Blocks.SMOOTH_BASALT, STONE); + MATERIALS.put(Blocks.RAW_IRON_BLOCK, STONE); + MATERIALS.put(Blocks.RAW_COPPER_BLOCK, STONE); + MATERIALS.put(Blocks.RAW_GOLD_BLOCK, STONE); + MATERIALS.put(Blocks.POTTED_AZALEA_BUSH, DECORATION); + MATERIALS.put(Blocks.POTTED_FLOWERING_AZALEA_BUSH, DECORATION); + MATERIALS.put(Blocks.OCHRE_FROGLIGHT, FROGLIGHT); + MATERIALS.put(Blocks.VERDANT_FROGLIGHT, FROGLIGHT); + MATERIALS.put(Blocks.PEARLESCENT_FROGLIGHT, FROGLIGHT); + MATERIALS.put(Blocks.FROGSPAWN, FROGSPAWN); + MATERIALS.put(Blocks.REINFORCED_DEEPSLATE, STONE); + MATERIALS.put(Blocks.DECORATED_POT, DECORATED_POT); + } + + public static Material1_19_4 getMaterial(final Block block) { + if (block instanceof ShulkerBoxBlock && ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_14)) { + return STONE; + } + + return MATERIALS.get(block); + } + + public static Material1_19_4 getMaterial(final BlockState blockState) { + return getMaterial(blockState.getBlock()); + } + +} diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/tracker/WolfHealthTracker.java b/src/main/java/de/florianmichael/viafabricplus/fixes/tracker/WolfHealthTracker.java index cf2f4ac4..13bf7d80 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/tracker/WolfHealthTracker.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/tracker/WolfHealthTracker.java @@ -22,29 +22,33 @@ package de.florianmichael.viafabricplus.fixes.tracker; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; - -import java.util.HashMap; -import java.util.Map; +import it.unimi.dsi.fastutil.ints.Int2FloatMap; +import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap; public class WolfHealthTracker extends StoredObject { - private final Map healthDataMap = new HashMap<>(); + private final Int2FloatMap healthDataMap = new Int2FloatOpenHashMap(); public WolfHealthTracker(UserConnection user) { super(user); } - public Map getHealthDataMap() { - return healthDataMap; + public float getWolfHealth(final int entityId, final float fallback) { + return this.healthDataMap.getOrDefault(entityId, fallback); + } + + public void setWolfHealth(final int entityId, final float wolfHealth) { + this.healthDataMap.put(entityId, wolfHealth); } public static WolfHealthTracker get() { final var connection = ProtocolHack.getPlayNetworkUserConnection(); - if (connection == null) return null; + WolfHealthTracker tracker = connection.get(WolfHealthTracker.class); - if (!connection.has(WolfHealthTracker.class)) { - connection.put(new WolfHealthTracker(connection)); + if (tracker == null) { + connection.put(tracker = new WolfHealthTracker(connection)); } - return connection.get(WolfHealthTracker.class); + return tracker; } + } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBrushItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/access/IEntity.java similarity index 50% rename from src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBrushItem.java rename to src/main/java/de/florianmichael/viafabricplus/injection/access/IEntity.java index b84a2145..ad03e224 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBrushItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/access/IEntity.java @@ -17,25 +17,12 @@ * along with this program. If not, see . */ -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; +package de.florianmichael.viafabricplus.injection.access; -import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import net.minecraft.item.BrushItem; -import net.minecraft.item.ItemStack; -import net.raphimc.vialoader.util.VersionEnum; -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; +public interface IEntity { -@Mixin(BrushItem.class) -public abstract class MixinBrushItem { + boolean viaFabricPlus$isInLoadedChunkAndShouldTick(); - @Inject(method = "getMaxUseTime", at = @At("HEAD"), cancellable = true) - private void changeMaxUseTime(ItemStack stack, CallbackInfoReturnable cir) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) { - cir.setReturnValue(225); - } - } + void viaFabricPlus$setInLoadedChunkAndShouldTick(final boolean inLoadedChunkAndShouldTick); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/access/IItemStack.java b/src/main/java/de/florianmichael/viafabricplus/injection/access/IItemStack.java new file mode 100644 index 00000000..d1d4a5e2 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/access/IItemStack.java @@ -0,0 +1,30 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus + * Copyright (C) 2021-2023 FlorianMichael/EnZaXD + * Copyright (C) 2023 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.injection.access; + +public interface IItemStack { + + boolean viaFabricPlus$has1_10ProtocolHackTag(); + + int viaFabricPlus$get1_10Count(); + + void viaFabricPlus$set1_10Count(final int count); + +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/connect/MixinClientConnection.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/connect/MixinClientConnection.java index f8280954..afe23685 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/connect/MixinClientConnection.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/connect/MixinClientConnection.java @@ -144,7 +144,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler< return instance.channel(channelTypeClass); } - @Redirect(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;connect(Ljava/net/InetAddress;I)Lio/netty/channel/ChannelFuture;")) + @Redirect(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;connect(Ljava/net/InetAddress;I)Lio/netty/channel/ChannelFuture;", remap = false)) private static ChannelFuture useRakNetPingHandlers(Bootstrap instance, InetAddress inetHost, int inetPort, @Local(argsOnly = true) ClientConnection clientConnection, @Local(argsOnly = true) boolean isConnecting) { if (VersionEnum.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getTargetVersion()) && !isConnecting) { return instance.register().syncUninterruptibly().channel().bind(new InetSocketAddress(0)). diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinDownloadingTerrainScreenAndConnectScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinDownloadingTerrainScreen.java similarity index 87% rename from src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinDownloadingTerrainScreenAndConnectScreen.java rename to src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinDownloadingTerrainScreen.java index eb4dd4d2..18713177 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinDownloadingTerrainScreenAndConnectScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinDownloadingTerrainScreen.java @@ -20,10 +20,11 @@ package de.florianmichael.viafabricplus.injection.mixin.base.integration; import com.viaversion.viaversion.api.connection.UserConnection; -import de.florianmichael.viafabricplus.settings.impl.GeneralSettings; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import de.florianmichael.viafabricplus.settings.impl.GeneralSettings; import de.florianmichael.viafabricplus.util.ChatUtil; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.DownloadingTerrainScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storage.ClassicProgressStorage; @@ -32,11 +33,10 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@SuppressWarnings("DataFlowIssue") -@Mixin(targets = { "net.minecraft.client.gui.screen.DownloadingTerrainScreen", "net.minecraft.client.gui.screen.ConnectScreen" }) -public abstract class MixinDownloadingTerrainScreenAndConnectScreen extends Screen { +@Mixin(DownloadingTerrainScreen.class) +public abstract class MixinDownloadingTerrainScreen extends Screen { - public MixinDownloadingTerrainScreenAndConnectScreen(Text title) { + public MixinDownloadingTerrainScreen(Text title) { super(title); } @@ -45,9 +45,6 @@ public abstract class MixinDownloadingTerrainScreenAndConnectScreen extends Scre if (GeneralSettings.INSTANCE.showClassicLoadingProgressInConnectScreen.getValue()) { // Check if ViaVersion is translating final UserConnection connection = ProtocolHack.getPlayNetworkUserConnection(); - if (connection == null) { - return; - } // Check if the client is connecting to a classic server final ClassicProgressStorage classicProgressStorage = connection.get(ClassicProgressStorage.class); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinVexEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractClientPlayerEntity.java similarity index 66% rename from src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinVexEntity.java rename to src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractClientPlayerEntity.java index 1eb55d29..fb2467ad 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinVexEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractClientPlayerEntity.java @@ -19,28 +19,29 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; -import net.raphimc.vialoader.util.VersionEnum; +import com.mojang.authlib.GameProfile; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.mob.HostileEntity; -import net.minecraft.entity.mob.VexEntity; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; 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; -@Mixin(VexEntity.class) -public abstract class MixinVexEntity extends HostileEntity { +@Mixin(AbstractClientPlayerEntity.class) +public abstract class MixinAbstractClientPlayerEntity extends PlayerEntity { - public MixinVexEntity(EntityType entityType, World world) { - super(entityType, world); + public MixinAbstractClientPlayerEntity(World world, BlockPos pos, float yaw, GameProfile gameProfile) { + super(world, pos, yaw, gameProfile); } - @Inject(method = "getUnscaledRidingOffset", at = @At("HEAD"), cancellable = true) - private void changeHeightOffset(CallbackInfoReturnable cir) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) { - cir.setReturnValue(0.0); + @Inject(method = "isCreative", at = @At("HEAD"), cancellable = true) + private void fixCreativeCheck(CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { + cir.setReturnValue(this.getAbilities().creativeMode); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractDonkeyEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractDonkeyEntity.java deleted file mode 100644 index 04a170f6..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractDonkeyEntity.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2023 FlorianMichael/EnZaXD - * Copyright (C) 2023 RK_01/RaphiMC and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; - -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import net.minecraft.block.Blocks; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.passive.AbstractDonkeyEntity; -import net.minecraft.entity.passive.AbstractHorseEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.world.World; -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.CallbackInfoReturnable; - -@Mixin(AbstractDonkeyEntity.class) -public abstract class MixinAbstractDonkeyEntity extends AbstractHorseEntity { - - @Shadow public abstract boolean hasChest(); - - @Shadow public abstract void setHasChest(boolean hasChest); - - @Shadow protected abstract void playAddChestSound(); - - public MixinAbstractDonkeyEntity(EntityType entityType, World world) { - super(entityType, world); - } - - @Inject(method = "interactMob", at = @At("HEAD"), cancellable = true) - public void fixInteraction(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) { - ItemStack lv = player.getStackInHand(hand); - if (!this.isBaby()) { - if (this.isTame() && player.shouldCancelInteraction()) { - this.openInventory(player); - cir.setReturnValue(ActionResult.success(this.getWorld().isClient)); - } - if (this.hasPassengers()) { - cir.setReturnValue(super.interactMob(player, hand)); - } - } - if (!lv.isEmpty()) { - if (this.isBreedingItem(lv)) { - cir.setReturnValue(this.interactHorse(player, lv)); - } - if (!this.isTame()) { - this.playAngrySound(); - cir.setReturnValue(ActionResult.success(this.getWorld().isClient)); - } - if (!this.hasChest() && lv.isOf(Blocks.CHEST.asItem())) { - this.setHasChest(true); - this.playAddChestSound(); - if (!player.getAbilities().creativeMode) { - lv.decrement(1); - } - this.onChestedStatusChanged(); - cir.setReturnValue(ActionResult.success(this.getWorld().isClient)); - } - if (!this.isBaby() && !this.isSaddled() && lv.isOf(Items.SADDLE)) { - this.openInventory(player); - cir.setReturnValue(ActionResult.success(this.getWorld().isClient)); - } - } - if (this.isBaby()) { - cir.setReturnValue(super.interactMob(player, hand)); - } - this.putPlayerOnBack(player); - cir.setReturnValue(ActionResult.success(this.getWorld().isClient)); - } - } -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAnimalEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAnimalEntity.java index ece3c705..9865f951 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAnimalEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAnimalEntity.java @@ -19,11 +19,10 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -32,7 +31,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; public abstract class MixinAnimalEntity { @Redirect(method = "interactMob", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;isClient:Z")) - private boolean redirectInteractMob(World instance) { + private boolean fixIsClientCheck(World instance) { return instance.isClient && ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_15); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinBoatEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinBoatEntity.java new file mode 100644 index 00000000..b3fd94f7 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinBoatEntity.java @@ -0,0 +1,316 @@ +package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; + +import de.florianmichael.viafabricplus.fixes.EntityHeightOffsetsPre1_20_2; +import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.MovementType; +import net.minecraft.entity.vehicle.BoatEntity; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.registry.tag.FluidTags; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Box; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +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.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(BoatEntity.class) +public abstract class MixinBoatEntity extends Entity { + + @Shadow + private double x; + + @Shadow + private double y; + + @Shadow + private double z; + + @Shadow + private double boatYaw; + + @Shadow + private double boatPitch; + + @Shadow + public abstract int getDamageWobbleTicks(); + + @Shadow + public abstract void setDamageWobbleTicks(int wobbleTicks); + + @Shadow + public abstract float getDamageWobbleStrength(); + + @Shadow + public abstract void setDamageWobbleStrength(float wobbleStrength); + + @Shadow + private BoatEntity.Location location; + + @Shadow + public abstract LivingEntity getControllingPassenger(); + + @Unique + private double speedMultiplier = 0.07D; + + @Unique + private int boatInterpolationSteps; + + @Unique + private Vec3d boatVelocity = Vec3d.ZERO; + + public MixinBoatEntity(EntityType type, World world) { + super(type, world); + } + + @Inject(method = "pushAwayFrom", at = @At("HEAD"), cancellable = true) + private void pushAwayFrom1_8(Entity entity, CallbackInfo ci) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { + ci.cancel(); + super.pushAwayFrom(entity); + } + } + + @Inject(method = "updateTrackedPositionAndAngles", at = @At("HEAD"), cancellable = true) + private void updateTrackedPositionAndAngles1_8(double x, double y, double z, float yaw, float pitch, int interpolationSteps, CallbackInfo ci) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { + ci.cancel(); + if (/*interpolate &&*/ this.hasPassengers() && ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_7_6tor1_7_10)) { + this.prevX = x; + this.prevY = y; + this.prevZ = z; + this.boatInterpolationSteps = 0; + this.setPosition(x, y, z); + this.setRotation(yaw, pitch); + this.setVelocity(Vec3d.ZERO); + this.boatVelocity = Vec3d.ZERO; + } else { + if (!this.hasPassengers()) { + this.boatInterpolationSteps = interpolationSteps + 5; + } else { + if (this.squaredDistanceTo(x, y, z) <= 1) { + return; + } + this.boatInterpolationSteps = 3; + } + + this.x = x; + this.y = y; + this.z = z; + this.boatYaw = yaw; + this.boatPitch = pitch; + this.setVelocity(this.boatVelocity); + } + } + } + + @Override + public void setVelocityClient(double x, double y, double z) { + super.setVelocityClient(x, y, z); + + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { + this.boatVelocity = new Vec3d(x, y, z); + } + } + + @Inject(method = "tick", at = @At("HEAD"), cancellable = true) + private void tick1_8(CallbackInfo ci) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { + ci.cancel(); + super.tick(); + + if (this.getDamageWobbleTicks() > 0) { + this.setDamageWobbleTicks(this.getDamageWobbleTicks() - 1); + } + if (this.getDamageWobbleStrength() > 0) { + this.setDamageWobbleStrength(this.getDamageWobbleStrength() - 1); + } + this.prevX = this.getX(); + this.prevY = this.getY(); + this.prevZ = this.getZ(); + + final int yPartitions = 5; + double percentSubmerged = 0; + for (int partitionIndex = 0; partitionIndex < yPartitions; partitionIndex++) { + final double minY = this.getBoundingBox().minY + this.getBoundingBox().getLengthY() * partitionIndex / yPartitions - 0.125; + final double maxY = this.getBoundingBox().minY + this.getBoundingBox().getLengthY() * (partitionIndex + 1) / yPartitions - 0.125; + final Box box = new Box(this.getBoundingBox().minX, minY, this.getBoundingBox().minZ, this.getBoundingBox().maxX, maxY, this.getBoundingBox().maxZ); + if (BlockPos.stream(box).anyMatch(pos -> this.getWorld().getFluidState(pos).isIn(FluidTags.WATER))) { + percentSubmerged += 1.0 / yPartitions; + } + } + + final double oldHorizontalSpeed = this.getVelocity().horizontalLength(); + if (oldHorizontalSpeed > (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10) ? 0.2625D : 0.2975D)) { + final double rx = Math.cos(this.getYaw() * Math.PI / 180); + final double rz = Math.sin(this.getYaw() * Math.PI / 180); + for (int i = 0; i < 1 + oldHorizontalSpeed * 60; i++) { + final double dForward = this.random.nextFloat() * 2 - 1; + final double dSideways = (this.random.nextInt(2) * 2 - 1) * 0.7D; + if (this.random.nextBoolean()) { + final double x = this.getX() - rx * dForward * 0.8 + rz * dSideways; + final double z = this.getZ() - rz * dForward * 0.8 - rx * dSideways; + this.getWorld().addParticle(ParticleTypes.SPLASH, x, this.getY() - 0.125D, z, this.getVelocity().x, this.getVelocity().y, this.getVelocity().z); + } else { + final double x = this.getX() + rx + rz * dForward * 0.7; + final double z = this.getZ() + rz - rx * dForward * 0.7; + this.getWorld().addParticle(ParticleTypes.SPLASH, x, this.getY() - 0.125D, z, this.getVelocity().x, this.getVelocity().y, this.getVelocity().z); + } + } + } + + if (this.getWorld().isClient && !this.hasPassengers()) { + if (this.boatInterpolationSteps > 0) { + final double newX = this.getX() + (this.x - this.getX()) / this.boatInterpolationSteps; + final double newY = this.getY() + (this.y - this.getY()) / this.boatInterpolationSteps; + final double newZ = this.getZ() + (this.z - this.getZ()) / this.boatInterpolationSteps; + final double newYaw = this.getYaw() + MathHelper.wrapDegrees(this.boatYaw - this.getYaw()) / this.boatInterpolationSteps; + final double newPitch = this.getPitch() + (this.boatPitch - this.getPitch()) / this.boatInterpolationSteps; + this.boatInterpolationSteps--; + this.setPosition(newX, newY, newZ); + this.setRotation((float) newYaw, (float) newPitch); + } else { + this.setPosition(this.getX() + this.getVelocity().x, this.getY() + this.getVelocity().y, this.getZ() + this.getVelocity().z); + if (this.isOnGround()) { + this.setVelocity(this.getVelocity().multiply(0.5D)); + } + this.setVelocity(this.getVelocity().multiply(0.99D, 0.95D, 0.99D)); + } + } else { + if (percentSubmerged < 1) { + final double normalizedDistanceFromMiddle = percentSubmerged * 2 - 1; + this.setVelocity(this.getVelocity().add(0, 0.04D * normalizedDistanceFromMiddle, 0)); + } else { + if (this.getVelocity().y < 0) { + this.setVelocity(this.getVelocity().multiply(1, 0.5D, 1)); + } + this.setVelocity(this.getVelocity().add(0, 0.007D, 0)); + } + + if (this.getControllingPassenger() != null) { + final LivingEntity passenger = this.getControllingPassenger(); + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_5_2)) { + final double xAcceleration = passenger.getVelocity().x * this.speedMultiplier; + final double zAcceleration = passenger.getVelocity().z * this.speedMultiplier; + this.setVelocity(this.getVelocity().add(xAcceleration, 0, zAcceleration)); + } else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) { + if (passenger.forwardSpeed > 0) { + final double xAcceleration = -Math.sin(passenger.getYaw() * Math.PI / 180) * this.speedMultiplier * 0.05D; + final double zAcceleration = Math.cos(passenger.getYaw() * Math.PI / 180) * this.speedMultiplier * 0.05D; + this.setVelocity(this.getVelocity().add(xAcceleration, 0, zAcceleration)); + } + } else { + final float boatAngle = passenger.getYaw() - passenger.sidewaysSpeed * 90F; + final double xAcceleration = -Math.sin(boatAngle * Math.PI / 180) * this.speedMultiplier * passenger.forwardSpeed * 0.05D; + final double zAcceleration = Math.cos(boatAngle * Math.PI / 180) * this.speedMultiplier * passenger.forwardSpeed * 0.05D; + this.setVelocity(this.getVelocity().add(xAcceleration, 0, zAcceleration)); + } + } + + double newHorizontalSpeed = this.getVelocity().horizontalLength(); + if (newHorizontalSpeed > 0.35D) { + final double multiplier = 0.35D / newHorizontalSpeed; + this.setVelocity(this.getVelocity().multiply(multiplier, 1, multiplier)); + newHorizontalSpeed = 0.35D; + } + + if (newHorizontalSpeed > oldHorizontalSpeed && this.speedMultiplier < 0.35D) { + this.speedMultiplier += (0.35D - this.speedMultiplier) / 35; + if (this.speedMultiplier > 0.35D) { + this.speedMultiplier = 0.35D; + } + } else { + this.speedMultiplier -= (this.speedMultiplier - 0.07D) / 35; + if (this.speedMultiplier < 0.07D) { + this.speedMultiplier = 0.07D; + } + } + + if (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_6_4)) { + for (int i = 0; i < 4; i++) { + final int dx = MathHelper.floor(this.getX() + ((i % 2) - 0.5D) * 0.8D); + //noinspection IntegerDivisionInFloatingPointContext + final int dz = MathHelper.floor(this.getZ() + ((i / 2) - 0.5D) * 0.8D); + for (int ddy = 0; ddy < 2; ddy++) { + final int dy = MathHelper.floor(this.getY()) + ddy; + final BlockPos pos = new BlockPos(dx, dy, dz); + final Block block = this.getWorld().getBlockState(pos).getBlock(); + if (block == Blocks.SNOW) { + this.getWorld().setBlockState(pos, Blocks.AIR.getDefaultState()); + this.horizontalCollision = false; + } else if (block == Blocks.LILY_PAD) { + this.getWorld().breakBlock(pos, true); + this.horizontalCollision = false; + } + } + } + } + + if (this.isOnGround()) { + this.setVelocity(this.getVelocity().multiply(0.5D)); + } + + this.move(MovementType.SELF, this.getVelocity()); + + if (!this.horizontalCollision || oldHorizontalSpeed <= 0.2975D) { + this.setVelocity(this.getVelocity().multiply(0.99D, 0.95D, 0.99D)); + } + + this.setPitch(0); + final double deltaX = this.prevX - this.getX(); + final double deltaZ = this.prevZ - this.getZ(); + if (deltaX * deltaX + deltaZ * deltaZ > 0.001D) { + final double yawDelta = MathHelper.clamp(MathHelper.wrapDegrees((MathHelper.atan2(deltaZ, deltaX) * 180 / Math.PI) - this.getYaw()), -20, 20); + this.setYaw((float) (this.getYaw() + yawDelta)); + } + } + } + } + + @Inject(method = "updatePassengerPosition", at = @At(value = "HEAD"), cancellable = true) + private void updatePassengerPosition1_8(Entity passenger, PositionUpdater positionUpdater, CallbackInfo ci) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { + final Vec3d newPosition = new Vec3d(EntityHeightOffsetsPre1_20_2.getMountedHeightOffset(this, passenger)).add(this.getPos()); + positionUpdater.accept(passenger, newPosition.x, newPosition.y + EntityHeightOffsetsPre1_20_2.getHeightOffset(passenger), newPosition.z); + ci.cancel(); + } + } + + @Inject(method = "onPassengerLookAround", at = @At("HEAD"), cancellable = true) + private void onPassengerLookAround1_8(Entity passenger, CallbackInfo ci) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { + ci.cancel(); + super.onPassengerLookAround(passenger); + } + } + + @Inject(method = "fall", at = @At("HEAD"), cancellable = true) + private void fall1_8(double heightDifference, boolean onGround, BlockState state, BlockPos landedPosition, CallbackInfo ci) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) { + ci.cancel(); + super.fall(heightDifference, onGround, state, landedPosition); + } else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { + this.location = BoatEntity.Location.ON_LAND; + } + } + + @Inject(method = "canAddPassenger", at = @At("HEAD"), cancellable = true) + private void canAddPassenger1_8(Entity passenger, CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { + cir.setReturnValue(super.canAddPassenger(passenger)); + } + } + +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCamelEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCamelEntity.java index 7d6a4b4d..f3ce8602 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCamelEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCamelEntity.java @@ -29,8 +29,6 @@ import net.minecraft.world.World; import net.raphimc.vialoader.util.VersionEnum; 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.Redirect; @Mixin(CamelEntity.class) public abstract class MixinCamelEntity extends AbstractHorseEntity { @@ -39,14 +37,6 @@ public abstract class MixinCamelEntity extends AbstractHorseEntity { super(entityType, world); } - @Redirect(method = "interactMob", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/CamelEntity;isBaby()Z", ordinal = 0)) - private boolean removeBabyCondition(CamelEntity instance) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) { - return false; - } - return instance.isBaby(); - } - @Unique private void viaFabricPlus$clamPassengerYaw(final Entity passenger) { passenger.setBodyYaw(this.getYaw()); @@ -64,7 +54,7 @@ public abstract class MixinCamelEntity extends AbstractHorseEntity { @Override public void onPassengerLookAround(Entity passenger) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1) && this.getControllingPassenger() != passenger) { - viaFabricPlus$clamPassengerYaw(passenger); + this.viaFabricPlus$clamPassengerYaw(passenger); } } @@ -73,7 +63,7 @@ public abstract class MixinCamelEntity extends AbstractHorseEntity { super.updatePassengerPosition(passenger, positionUpdater); if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) { - viaFabricPlus$clamPassengerYaw(passenger); + this.viaFabricPlus$clamPassengerYaw(passenger); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java index 362510e8..ec070f16 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java @@ -20,25 +20,30 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; import com.mojang.authlib.GameProfile; -import de.florianmichael.viafabricplus.fixes.ClientsideFixes; +import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; +import com.viaversion.viaversion.api.type.Type; +import de.florianmichael.viafabricplus.injection.access.IClientConnection; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import de.florianmichael.viafabricplus.settings.impl.DebugSettings; -import de.florianmichael.viafabricplus.settings.impl.VisualSettings; import net.minecraft.client.MinecraftClient; import net.minecraft.client.input.Input; import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.Hand; +import net.minecraft.entity.Entity; +import net.minecraft.entity.vehicle.BoatEntity; +import net.minecraft.network.packet.Packet; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.GameMode; +import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.Protocol1_6_1to1_5_2; +import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ServerboundPackets1_5_2; import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @SuppressWarnings("ConstantValue") @Mixin(value = ClientPlayerEntity.class, priority = 2000) @@ -57,18 +62,20 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity @Shadow private int ticksSinceLastPositionPacketSent; - @Unique - private boolean viaFabricPlus$areSwingCanceledThisTick = false; - public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) { super(world, profile); } - @Shadow protected abstract void sendSprintingPacket(); + @Shadow + protected abstract void sendSprintingPacket(); + + @Shadow + @Final + public ClientPlayNetworkHandler networkHandler; @Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;square(D)D")) private double changeMagnitude(double n) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18_2)) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) { n = 9.0E-4D; } @@ -88,7 +95,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity @Inject(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z")) private void incrementLastPositionPacketSentCounter(CallbackInfo ci) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { - ++this.ticksSinceLastPositionPacketSent; + this.ticksSinceLastPositionPacketSent++; } } @@ -100,15 +107,6 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity return lastOnGround; } - @Inject(method = "swingHand", at = @At("HEAD"), cancellable = true) - private void injectSwingHand(Hand hand, CallbackInfo ci) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && viaFabricPlus$areSwingCanceledThisTick) { - ci.cancel(); - } - - viaFabricPlus$areSwingCanceledThisTick = false; - } - @Inject(method = "tickMovement()V", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isCamera()Z")), at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/Input;sneaking:Z", ordinal = 0)) @@ -124,20 +122,19 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity @Redirect(method = "tickMovement", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z")), at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSwimming()Z", ordinal = 0)) - private boolean redirectIsSneakingWhileSwimming(ClientPlayerEntity _this) { + private boolean redirectIsSneakingWhileSwimming(ClientPlayerEntity instance) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) { return false; } else { - return _this.isSwimming(); + return instance.isSwimming(); } } - @Redirect(method = "isWalking", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSubmergedInWater()Z")) - private boolean easierUnderwaterSprinting(ClientPlayerEntity instance) { + @Inject(method = "isWalking", at = @At("HEAD"), cancellable = true) + private void easierUnderwaterSprinting(CallbackInfoReturnable cir) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) { - return false; + cir.setReturnValue(((ClientPlayerEntity) (Object) this).input.movementForward >= 0.8); } - return instance.isSubmergedInWater(); } @Redirect(method = "tickMovement()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;hasForwardMovement()Z", ordinal = 0)) @@ -168,8 +165,8 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity @Redirect(method = "autoJump", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;inverseSqrt(F)F")) private float useFastInverse(float x) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) { + // fast inverse sqrt x = Float.intBitsToFloat(1597463007 - (Float.floatToIntBits(x) >> 1)); - return x * (1.5F - (0.5F * x) * x * x); } return MathHelper.inverseSqrt(x); @@ -185,7 +182,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity } @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isClimbing()Z")) - private boolean removeLadderCheck(ClientPlayerEntity instance) { + private boolean allowElytraWhenClimbing(ClientPlayerEntity instance) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_1)) { return false; } @@ -193,7 +190,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity } @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z", ordinal = 3)) - private boolean removeVehicleCheck(ClientPlayerEntity instance) { + private boolean allowElytraInVehicle(ClientPlayerEntity instance) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) { return false; } @@ -208,8 +205,16 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity return value; } + @Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z")) + private boolean removeVehicleCheck(ClientPlayerEntity instance) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) { + return false; + } + return instance.hasVehicle(); + } + @Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isFallFlying()Z")) - private boolean removeElytraMovementCheck(ClientPlayerEntity instance) { + private boolean removeFallFlyingCheck(ClientPlayerEntity instance) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) { return false; } @@ -217,30 +222,37 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity } @Redirect(method = "canSprint", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z")) - private boolean removeVehicleCondition(ClientPlayerEntity instance) { + private boolean dontAllowSprintingAsPassenger(ClientPlayerEntity instance) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) { return false; } return instance.hasVehicle(); } - @Override - public boolean isCreative() { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) { - if (client.interactionManager == null) { - return super.isCreative(); // Fixes https://github.com/ViaVersion/ViaFabricPlus/issues/216 - } - return client.interactionManager.getCurrentGameMode() == GameMode.CREATIVE; + @Inject(method = "startRiding", at = @At("RETURN")) + private void setRotationsWhenInBoat(Entity entity, boolean force, CallbackInfoReturnable cir) { + if (cir.getReturnValueZ() && entity instanceof BoatEntity && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) { + this.prevYaw = entity.getYaw(); + this.setYaw(entity.getYaw()); + this.setHeadYaw(entity.getYaw()); } - return super.isCreative(); } - @Override - public int getArmor() { - if (VisualSettings.INSTANCE.emulateArmorHud.isEnabled()) { - return client.player.getInventory().armor.stream().mapToInt(ClientsideFixes::getLegacyArmorPoints).sum(); + @Redirect(method = "tick", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z")), at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 0)) + private void modifyPositionPacket(ClientPlayNetworkHandler instance, Packet packet) throws Exception { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_5_2)) { + final PacketWrapper playerPosition = PacketWrapper.create(ServerboundPackets1_5_2.PLAYER_POSITION_AND_ROTATION, ((IClientConnection) this.networkHandler.getConnection()).viaFabricPlus$getUserConnection()); + playerPosition.write(Type.DOUBLE, this.getVelocity().x); // x + playerPosition.write(Type.DOUBLE, -999.0D); // y + playerPosition.write(Type.DOUBLE, -999.0D); // stance + playerPosition.write(Type.DOUBLE, this.getVelocity().z); // z + playerPosition.write(Type.FLOAT, this.getYaw()); // yaw + playerPosition.write(Type.FLOAT, this.getPitch()); // pitch + playerPosition.write(Type.BOOLEAN, this.isOnGround()); // onGround + playerPosition.scheduleSendToServer(Protocol1_6_1to1_5_2.class); + return; } - return super.getArmor(); + instance.sendPacket(packet); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCowEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCowEntity.java index 6ab852e7..9fbf7b9f 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCowEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCowEntity.java @@ -19,8 +19,6 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.AnimalEntity; @@ -29,6 +27,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -42,7 +41,7 @@ public abstract class MixinCowEntity extends AnimalEntity { } @Inject(method = "interactMob", at = @At("HEAD"), cancellable = true) - private void injectInteractMob(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { + private void disableMilkingInCreative(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2) && player.getAbilities().creativeMode) { cir.setReturnValue(super.interactMob(player, hand)); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCreeperEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCreeperEntity.java index 20403692..d9bbe66c 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCreeperEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCreeperEntity.java @@ -19,12 +19,11 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import net.minecraft.entity.mob.CreeperEntity; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -33,7 +32,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; public abstract class MixinCreeperEntity { @Redirect(method = "interactMob", at = @At(value = "FIELD", target = "Lnet/minecraft/sound/SoundEvents;ITEM_FIRECHARGE_USE:Lnet/minecraft/sound/SoundEvent;")) - private SoundEvent fixSound() { + private SoundEvent changeSound() { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) { return SoundEvents.ITEM_FLINTANDSTEEL_USE; } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java index cea2a7f8..74773f3e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java @@ -20,14 +20,14 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; import de.florianmichael.viafabricplus.fixes.EntityHeightOffsetsPre1_20_2; -import net.minecraft.entity.EntityDimensions; -import net.raphimc.vialoader.util.VersionEnum; +import de.florianmichael.viafabricplus.injection.access.IEntity; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import it.unimi.dsi.fastutil.objects.Object2DoubleMap; import net.minecraft.block.BlockState; import net.minecraft.block.FenceGateBlock; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityDimensions; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.registry.tag.BlockTags; @@ -37,21 +37,25 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; import org.joml.Vector3f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @SuppressWarnings("ConstantValue") @Mixin(Entity.class) -public abstract class MixinEntity { +public abstract class MixinEntity implements IEntity { @Shadow - public World world; + private World world; + @Shadow protected Object2DoubleMap> fluidHeight; + @Shadow private Vec3d pos; @@ -64,10 +68,14 @@ public abstract class MixinEntity { @Shadow public abstract void setVelocity(Vec3d velocity); - @Shadow protected abstract Vector3f getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor); + @Shadow + protected abstract Vector3f getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor); + + @Unique + private boolean viaFabricPlus$isInLoadedChunkAndShouldTick; @ModifyConstant(method = "movementInputToVelocity", constant = @Constant(doubleValue = 1E-7)) - private static double injectMovementInputToVelocity(double epsilon) { + private static double fixVelocityEpsilon(double epsilon) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { return 1E-4; } @@ -75,7 +83,7 @@ public abstract class MixinEntity { } @Inject(method = "getVelocityAffectingPos", at = @At("HEAD"), cancellable = true) - private void replaceAffectingVelocityMagnitude(CallbackInfoReturnable cir) { + private void modifyVelocityAffectingPos(CallbackInfoReturnable cir) { final VersionEnum target = ProtocolHack.getTargetVersion(); if (target.isOlderThanOrEqualTo(VersionEnum.r1_19_4)) { @@ -91,20 +99,19 @@ public abstract class MixinEntity { } @Inject(method = "setSwimming", at = @At("HEAD"), cancellable = true) - private void onSetSwimming(boolean swimming, CallbackInfo ci) { + private void cancelSwimming(boolean swimming, CallbackInfo ci) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) && swimming) { ci.cancel(); } } - @SuppressWarnings("deprecation") @Inject(method = "updateMovementInFluid", at = @At("HEAD"), cancellable = true) - private void modifyFluidMovementBoundingBox(TagKey fluidTag, double d, CallbackInfoReturnable ci) { + private void modifyFluidMovementBoundingBox(TagKey fluidTag, double d, CallbackInfoReturnable cir) { if (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_12_2)) { return; } - Box box = getBoundingBox().expand(0, -0.4, 0).contract(0.001); + Box box = this.getBoundingBox().expand(0, -0.4, 0).contract(0.001); int minX = MathHelper.floor(box.minX); int maxX = MathHelper.ceil(box.maxX); int minY = MathHelper.floor(box.minY); @@ -112,8 +119,9 @@ public abstract class MixinEntity { int minZ = MathHelper.floor(box.minZ); int maxZ = MathHelper.ceil(box.maxZ); - if (!world.isRegionLoaded(minX, minY, minZ, maxX, maxY, maxZ)) { - ci.setReturnValue(false); + if (!this.world.isRegionLoaded(minX, minY, minZ, maxX, maxY, maxZ)) { + cir.setReturnValue(false); + return; } double waterHeight = 0; @@ -126,14 +134,14 @@ public abstract class MixinEntity { for (int y = minY - 1; y < maxY; y++) { for (int z = minZ; z < maxZ; z++) { mutable.set(x, y, z); - FluidState state = world.getFluidState(mutable); + FluidState state = this.world.getFluidState(mutable); if (state.isIn(fluidTag)) { - double height = y + state.getHeight(world, mutable); + double height = y + state.getHeight(this.world, mutable); if (height >= box.minY - 0.4) waterHeight = Math.max(height - box.minY + 0.4, waterHeight); if (y >= minY && maxY >= height) { foundFluid = true; - pushVec = pushVec.add(state.getVelocity(world, mutable)); + pushVec = pushVec.add(state.getVelocity(this.world, mutable)); } } } @@ -142,11 +150,11 @@ public abstract class MixinEntity { if (pushVec.length() > 0) { pushVec = pushVec.normalize().multiply(0.014); - setVelocity(getVelocity().add(pushVec)); + this.setVelocity(this.getVelocity().add(pushVec)); } this.fluidHeight.put(fluidTag, waterHeight); - ci.setReturnValue(foundFluid); + cir.setReturnValue(foundFluid); } @Inject(method = "getTargetingMargin", at = @At("HEAD"), cancellable = true) @@ -157,28 +165,21 @@ public abstract class MixinEntity { } @Redirect(method = {"setYaw", "setPitch"}, at = @At(value = "INVOKE", target = "Ljava/lang/Float;isFinite(F)Z")) - private boolean modifyIsFinite(float f) { - return Float.isFinite(f) || ((Object) this instanceof ClientPlayerEntity && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)); + private boolean allowInfiniteValues(float f) { + return Float.isFinite(f) || ((Object) this instanceof ClientPlayerEntity && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)); } @ModifyConstant(method = "checkBlockCollision", constant = @Constant(doubleValue = 1.0E-7)) - private double changeBlockCollisionConstant(double constant) { + private double fixBlockCollisionMargin(double constant) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) { - return 0.001; + return 1E-3; } return constant; } - @Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;onLanding()V")) - private void revertOnLanding(Entity instance) { - if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19)) { - instance.onLanding(); - } - } - @Inject(method = "getPosWithYOffset", at = @At("HEAD"), cancellable = true) - private void changeLogic(float offset, CallbackInfoReturnable cir) { + private void modifyPosWithYOffset(float offset, CallbackInfoReturnable cir) { final VersionEnum target = ProtocolHack.getTargetVersion(); if (target.isOlderThanOrEqualTo(VersionEnum.r1_19_4)) { int i = MathHelper.floor(this.pos.x); @@ -186,10 +187,11 @@ public abstract class MixinEntity { int k = MathHelper.floor(this.pos.z); BlockPos blockPos = new BlockPos(i, j, k); if (this.world.getBlockState(blockPos).isAir()) { - BlockPos blockPos2 = blockPos.down(); - BlockState blockState = this.world.getBlockState(blockPos2); + BlockPos downPos = blockPos.down(); + BlockState blockState = this.world.getBlockState(downPos); if (blockState.isIn(BlockTags.FENCES) || blockState.isIn(BlockTags.WALLS) || blockState.getBlock() instanceof FenceGateBlock) { - cir.setReturnValue(blockPos2); + cir.setReturnValue(downPos); + return; } } @@ -198,14 +200,14 @@ public abstract class MixinEntity { } @Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true) - private void replaceRidingOffset(Entity vehicle, CallbackInfoReturnable cir) { + private void getRidingOffset1_20_1(Entity vehicle, CallbackInfoReturnable cir) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) { cir.setReturnValue((float) EntityHeightOffsetsPre1_20_2.getHeightOffset((Entity) (Object) this)); } } @Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lorg/joml/Vector3f;")) - private Vector3f revertStaticRidingOffsetCalculation(Entity instance, Entity passenger, EntityDimensions dimensions, float scaleFactor) { + private Vector3f getPassengerRidingPos1_20_1(Entity instance, Entity passenger, EntityDimensions dimensions, float scaleFactor) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) { return EntityHeightOffsetsPre1_20_2.getMountedHeightOffset(instance, passenger); } @@ -213,4 +215,14 @@ public abstract class MixinEntity { return getPassengerAttachmentPos(passenger, dimensions, scaleFactor); } + @Override + public boolean viaFabricPlus$isInLoadedChunkAndShouldTick() { + return this.viaFabricPlus$isInLoadedChunkAndShouldTick || !ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_9, VersionEnum.r1_16_4tor1_16_5) /* || TODO: Add setting to force this*/; + } + + @Override + public void viaFabricPlus$setInLoadedChunkAndShouldTick(final boolean inLoadedChunkAndShouldTick) { + this.viaFabricPlus$isInLoadedChunkAndShouldTick = inLoadedChunkAndShouldTick; + } + } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityPredicates.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityPredicates.java deleted file mode 100644 index ba9a1afa..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityPredicates.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2023 FlorianMichael/EnZaXD - * Copyright (C) 2023 RK_01/RaphiMC and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; - -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.predicate.entity.EntityPredicates; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(EntityPredicates.class) -public abstract class MixinEntityPredicates { - - @SuppressWarnings("target") - @Redirect(method = "method_5915(Lnet/minecraft/entity/Entity;Lnet/minecraft/scoreboard/AbstractTeam;Lnet/minecraft/scoreboard/AbstractTeam$CollisionRule;Lnet/minecraft/entity/Entity;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isMainPlayer()Z")) - private static boolean makeMainPlayerUnpushable(PlayerEntity player) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { - return false; - } - return player.isMainPlayer(); - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityRenderDispatcher.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityRenderDispatcher.java index dc89a96f..987349e8 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityRenderDispatcher.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityRenderDispatcher.java @@ -19,9 +19,8 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; -import de.florianmichael.viafabricplus.fixes.BoatRenderer_1_8; +import de.florianmichael.viafabricplus.fixes.BoatRenderer1_8; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import de.florianmichael.viafabricplus.settings.impl.ExperimentalSettings; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.render.entity.EntityRendererFactory; @@ -41,19 +40,19 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; public abstract class MixinEntityRenderDispatcher { @Unique - private BoatRenderer_1_8 viaFabricPlus$boatRenderer; + private BoatRenderer1_8 viaFabricPlus$boatRenderer; @SuppressWarnings("unchecked") @Inject(method = "getRenderer", at = @At("HEAD"), cancellable = true) private void onGetRenderer(T entity, CallbackInfoReturnable> ci) { - if (ExperimentalSettings.INSTANCE.emulateBoatMovement.getValue() && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && entity instanceof BoatEntity) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && entity instanceof BoatEntity) { ci.setReturnValue((EntityRenderer) viaFabricPlus$boatRenderer); } } @Inject(method = "reload", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD) private void onReload(ResourceManager manager, CallbackInfo ci, EntityRendererFactory.Context context) { - viaFabricPlus$boatRenderer = new BoatRenderer_1_8(context); + viaFabricPlus$boatRenderer = new BoatRenderer1_8(context); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java index f029b7f9..b1e47df2 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java @@ -19,14 +19,15 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; -import com.llamalad7.mixinextras.injector.WrapWithCondition; -import de.florianmichael.viafabricplus.settings.impl.ExperimentalSettings; import de.florianmichael.viafabricplus.fixes.EntityHeightOffsetsPre1_20_2; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import de.florianmichael.viafabricplus.settings.impl.ExperimentalSettings; import net.minecraft.block.BlockState; import net.minecraft.block.TrapdoorBlock; import net.minecraft.entity.*; -import net.minecraft.entity.mob.SkeletonHorseEntity; +import net.minecraft.entity.effect.StatusEffect; +import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluid; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -42,28 +43,17 @@ import org.joml.Vector3f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.Optional; -@SuppressWarnings("ConstantValue") @Mixin(LivingEntity.class) public abstract class MixinLivingEntity extends Entity { @Shadow protected boolean jumping; - public MixinLivingEntity(EntityType type, World world) { - super(type, world); - } - - @Inject(method = "getPreferredEquipmentSlot", at = @At("HEAD"), cancellable = true) - private static void removeShieldSlotPreference(ItemStack stack, CallbackInfoReturnable cir) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4) && stack.isOf(Items.SHIELD)) { - cir.setReturnValue(EquipmentSlot.MAINHAND); - } - } - @Shadow protected abstract float getBaseMovementSpeedMultiplier(); @@ -73,6 +63,30 @@ public abstract class MixinLivingEntity extends Entity { @Shadow protected abstract boolean canEnterTrapdoor(BlockPos pos, BlockState state); + @Shadow + public abstract boolean hasStatusEffect(StatusEffect effect); + + @Shadow + private int jumpingCooldown; + + public MixinLivingEntity(EntityType type, World world) { + super(type, world); + } + + @Inject(method = "", at = @At("RETURN")) + private void modify1_7StepHeight(EntityType type, World world, CallbackInfo ci) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) { + this.setStepHeight(0.5F); + } + } + + @Inject(method = "getPreferredEquipmentSlot", at = @At("HEAD"), cancellable = true) + private static void removeShieldSlotPreference(ItemStack stack, CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4) && stack.isOf(Items.SHIELD)) { + cir.setReturnValue(EquipmentSlot.MAINHAND); + } + } + @Redirect(method = "applyMovementInput", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;jumping:Z")) private boolean disableJumpOnLadder(LivingEntity self) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { @@ -85,12 +99,21 @@ public abstract class MixinLivingEntity extends Entity { @Redirect(method = "travel", slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/effect/StatusEffects;DOLPHINS_GRACE:Lnet/minecraft/entity/effect/StatusEffect;")), at = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;horizontalCollision:Z", ordinal = 0)) - private boolean disableClimbing(LivingEntity self) { + private boolean disableClimbing(LivingEntity instance) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { return false; } - return horizontalCollision; + return instance.horizontalCollision; + } + + @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isLogicalSideForUpdatingMovement()Z")) + private boolean allowPlayerToBeMovedByEntityPackets(LivingEntity instance) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3) || ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) { + return instance.getControllingPassenger() instanceof PlayerEntity player ? player.isMainPlayer() : !instance.getWorld().isClient; + } + + return instance.isLogicalSideForUpdatingMovement(); } @ModifyVariable(method = "applyFluidMovingSpeed", ordinal = 0, at = @At("HEAD"), argsOnly = true) @@ -102,19 +125,21 @@ public abstract class MixinLivingEntity extends Entity { return movingDown; } - @WrapWithCondition(method = "tickMovement", - slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/effect/StatusEffects;LEVITATION:Lnet/minecraft/entity/effect/StatusEffect;", ordinal = 0)), - at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;onLanding()V", ordinal = 0)) - private boolean dontResetLevitationFallDistance(LivingEntity instance) { - return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_12_2); + @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;onLanding()V")) + private void dontResetLevitationFallDistance(LivingEntity instance) { + if (!this.hasStatusEffect(StatusEffects.SLOW_FALLING) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) { + return; + } + + instance.onLanding(); } @Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isSprinting()Z", ordinal = 0)) - private boolean modifySwimSprintSpeed(LivingEntity self) { + private boolean modifySwimSprintSpeed(LivingEntity instance) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) { return false; } - return self.isSprinting(); + return instance.isSprinting(); } @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getFluidHeight(Lnet/minecraft/registry/tag/TagKey;)D")) @@ -129,7 +154,7 @@ public abstract class MixinLivingEntity extends Entity { @Inject(method = "applyFluidMovingSpeed", at = @At("HEAD"), cancellable = true) private void modifySwimSprintFallSpeed(double gravity, boolean movingDown, Vec3d velocity, CallbackInfoReturnable ci) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) && !hasNoGravity()) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) && !this.hasNoGravity()) { ci.setReturnValue(new Vec3d(velocity.x, velocity.y - 0.02, velocity.z)); } } @@ -143,27 +168,30 @@ public abstract class MixinLivingEntity extends Entity { } @Inject(method = "canEnterTrapdoor", at = @At("HEAD"), cancellable = true) - private void onCanEnterTrapdoor(CallbackInfoReturnable ci) { + private void disableCrawling(CallbackInfoReturnable ci) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { ci.setReturnValue(false); } } @ModifyConstant(method = "travel", constant = @Constant(floatValue = 0.9F)) - private float changeEntitySpeed(float constant) { + private float modifySwimFriction(float constant) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) { - //noinspection ConstantConditions - if ((Entity) this instanceof SkeletonHorseEntity) { - return this.getBaseMovementSpeedMultiplier(); // 0.96F - } - return 0.8F; + return this.getBaseMovementSpeedMultiplier(); } return constant; } - @Redirect(method = "travel", at = @At(value = "INVOKE", target = "Ljava/lang/Math;cos(D)D")) + @Inject(method = "tickMovement", at = @At("HEAD")) + private void removeJumpDelay1_0(CallbackInfo ci) { + if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_0_0tor1_0_1)) { + this.jumpingCooldown = 0; + } + } + + @Redirect(method = "travel", at = @At(value = "INVOKE", target = "Ljava/lang/Math;cos(D)D", remap = false)) private double fixCosTable(double a) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18_2)) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) { return MathHelper.cos((float) a); } return Math.cos(a); @@ -171,20 +199,20 @@ public abstract class MixinLivingEntity extends Entity { @Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getFluidHeight(Lnet/minecraft/registry/tag/TagKey;)D")) private double fixLavaMovement(LivingEntity instance, TagKey tagKey) { - double height = instance.getFluidHeight(tagKey); - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) { - height += getSwimHeight() + 4; + return Double.MAX_VALUE; } - return height; + + return instance.getFluidHeight(tagKey); } - @ModifyConstant(method = "isBlocking", constant = @Constant(intValue = 5)) - private int shieldBlockCounter(int constant) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { - return 0; + @Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isChunkLoaded(Lnet/minecraft/util/math/BlockPos;)Z")) + private boolean modify1_13LoadedCheck(World instance, BlockPos blockPos) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { + return this.getWorld().isChunkLoaded(blockPos) && instance.getChunkManager().isChunkLoaded(blockPos.getX() >> 4, blockPos.getZ() >> 4); + } else { + return this.getWorld().isChunkLoaded(blockPos); } - return constant; } @Redirect(method = "tickCramming", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isClient()Z")) @@ -211,14 +239,14 @@ public abstract class MixinLivingEntity extends Entity { } @Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true) - private void replaceRidingOffset(Entity vehicle, CallbackInfoReturnable cir) { + private void getRidingOffset1_20_1(Entity vehicle, CallbackInfoReturnable cir) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) { cir.setReturnValue((float) EntityHeightOffsetsPre1_20_2.getHeightOffset(this)); } } @Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lorg/joml/Vector3f;")) - private Vector3f revertStaticRidingOffsetCalculation(LivingEntity instance, Entity entity, EntityDimensions entityDimensions, float v) { + private Vector3f getPassengerRidingPos1_20_1(LivingEntity instance, Entity entity, EntityDimensions entityDimensions, float v) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) { return EntityHeightOffsetsPre1_20_2.getMountedHeightOffset(instance, entity); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinOtherClientPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinOtherClientPlayerEntity.java index 0297c3cc..8503bd14 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinOtherClientPlayerEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinOtherClientPlayerEntity.java @@ -20,12 +20,11 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; import com.mojang.authlib.GameProfile; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.OtherClientPlayerEntity; import net.minecraft.client.world.ClientWorld; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -39,7 +38,7 @@ public abstract class MixinOtherClientPlayerEntity extends AbstractClientPlayerE } @Inject(method = "updatePose", at = @At("HEAD")) - private void dontUpdatePose(CallbackInfo ci) { + private void onUpdatePose(CallbackInfo ci) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { super.updatePose(); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPiglinEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPiglinEntity.java deleted file mode 100644 index 2dfab301..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPiglinEntity.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2023 FlorianMichael/EnZaXD - * Copyright (C) 2023 RK_01/RaphiMC and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; - -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import net.minecraft.entity.EntityDimensions; -import net.minecraft.entity.EntityPose; -import net.minecraft.entity.mob.PiglinEntity; -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.CallbackInfoReturnable; - -@Mixin(PiglinEntity.class) -public abstract class MixinPiglinEntity { - - @Shadow public abstract boolean isBaby(); - - @Inject(method = "getActiveEyeHeight", at = @At("HEAD"), cancellable = true) - private void changeEyeHeight(EntityPose pose, EntityDimensions dimensions, CallbackInfoReturnable cir) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) { - cir.setReturnValue(this.isBaby() ? 0.93F : 1.74F); - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java index c03c4794..0621100a 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java @@ -21,23 +21,26 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import de.florianmichael.viafabricplus.settings.impl.VisualSettings; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.EntityDimensions; -import net.minecraft.entity.EntityPose; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; +import net.minecraft.block.BlockState; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.*; import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.effect.StatusEffect; +import net.minecraft.entity.effect.StatusEffectUtil; +import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerAbilities; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ElytraItem; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Hand; import net.minecraft.util.Identifier; import net.minecraft.world.World; import net.raphimc.vialoader.util.VersionEnum; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -46,15 +49,24 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) public abstract class MixinPlayerEntity extends LivingEntity { + @Shadow + @Final + private PlayerAbilities abilities; + + @Shadow + public abstract boolean canHarvest(BlockState state); + + @Shadow + @Final + private PlayerInventory inventory; @Unique private static final EntityDimensions viaFabricPlus$sneaking_dimensions_v1_13_2 = EntityDimensions.changing(0.6f, 1.65f); @Unique private static final SoundEvent viaFabricPlus$random_hurt = SoundEvent.of(new Identifier("viafabricplus", "random.hurt")); - @Shadow - @Final - private PlayerAbilities abilities; + @Unique + public boolean viaFabricPlus$isSprinting; protected MixinPlayerEntity(EntityType entityType, World world) { super(entityType, world); @@ -63,39 +75,38 @@ public abstract class MixinPlayerEntity extends LivingEntity { @Inject(method = "updatePose", at = @At("HEAD"), cancellable = true) private void onUpdatePose(CallbackInfo ci) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { - EntityPose pose; - - if (isFallFlying()) + final EntityPose pose; + if (this.isFallFlying()) { pose = EntityPose.FALL_FLYING; - else if (isSleeping()) + } else if (this.isSleeping()) { pose = EntityPose.SLEEPING; - else if (isSwimming()) + } else if (this.isSwimming()) { pose = EntityPose.SWIMMING; - else if (isUsingRiptide()) + } else if (this.isUsingRiptide()) { pose = EntityPose.SPIN_ATTACK; - else if (isSneaking() && !abilities.flying) + } else if (this.isSneaking() && !this.abilities.flying) { pose = EntityPose.CROUCHING; - else + } else { pose = EntityPose.STANDING; - + } this.setPose(pose); ci.cancel(); } } @Inject(method = "getDimensions", at = @At("HEAD"), cancellable = true) - private void onGetDimensions(EntityPose pose, CallbackInfoReturnable ci) { + private void modifyDimensions(EntityPose pose, CallbackInfoReturnable cir) { if (pose == EntityPose.CROUCHING) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { - ci.setReturnValue(PlayerEntity.STANDING_DIMENSIONS); - } else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2) || ProtocolHack.getTargetVersion() == VersionEnum.bedrockLatest) { - ci.setReturnValue(viaFabricPlus$sneaking_dimensions_v1_13_2); + cir.setReturnValue(PlayerEntity.STANDING_DIMENSIONS); + } else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { + cir.setReturnValue(viaFabricPlus$sneaking_dimensions_v1_13_2); } } } @Inject(method = "getAttackCooldownProgress", at = @At("HEAD"), cancellable = true) - private void injectGetAttackCooldownProgress(CallbackInfoReturnable ci) { + private void removeAttackCooldown(CallbackInfoReturnable ci) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { ci.setReturnValue(1f); } @@ -124,28 +135,102 @@ public abstract class MixinPlayerEntity extends LivingEntity { instance.swingHand(hand); } - @Unique - public boolean viaFabricPlus$isSprinting; - @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setMovementSpeed(F)V")) - private void trackOldField(CallbackInfo ci) { + private void storeSprintingState(CallbackInfo ci) { viaFabricPlus$isSprinting = this.isSprinting(); } @Redirect(method = "getOffGroundSpeed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isSprinting()Z")) - private boolean useOldField(PlayerEntity instance) { + private boolean useLastSprintingState(PlayerEntity instance) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) { return viaFabricPlus$isSprinting; } return instance.isSprinting(); } + @Redirect(method = "checkFallFlying", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z")) + private boolean allowElytraWhenLevitating(PlayerEntity instance, StatusEffect statusEffect) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) { + return false; + } + return instance.hasStatusEffect(statusEffect); + } + @Inject(method = "checkFallFlying", at = @At("HEAD"), cancellable = true) - private void makeElytraMovementServerside(CallbackInfoReturnable cir) { - // Elytra movement was serverside in <= 1.14.4 and got moved to the client in 1.15 - if ((Object) this instanceof ClientPlayerEntity && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) { - cir.setReturnValue(!this.isOnGround() && this.getVelocity().y < 0.0 && !isFallFlying()); + private void replaceFallFlyingCondition(CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) { + if (!this.isOnGround() && this.getVelocity().y < 0D && !this.isFallFlying()) { + final ItemStack itemStack = this.getEquippedStack(EquipmentSlot.CHEST); + if (itemStack.isOf(Items.ELYTRA) && ElytraItem.isUsable(itemStack)) { + cir.setReturnValue(true); + return; + } + } + cir.setReturnValue(false); } } + @Redirect(method = "adjustMovementForSneaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getStepHeight()F")) + private float modifyStepHeight1_10(PlayerEntity instance) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10)) { + return 1.0F; + } + return instance.getStepHeight(); + } + + /** + * @author RK_01 + * @reason ProtocolHack block break speed changes + */ + @Overwrite + public float getBlockBreakingSpeed(BlockState block) { + float f = this.inventory.getBlockBreakingSpeed(block); + final ItemStack itemStack = this.getMainHandStack(); + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_4tor1_4_5)) { + int i = EnchantmentHelper.getEfficiency(this); + if (i > 0 && this.canHarvest(block)) f += (float) (i * i + 1); + } else { + if (f > 1F || ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) { + int i = EnchantmentHelper.getEfficiency(this); + if (i > 0 && !itemStack.isEmpty()) { + final float f1 = (i * i + 1); + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) { + if (f <= 1.0 && !this.canHarvest(block)) f += f1 * 0.08F; + else f += f1; + } else { + f += f1; + } + } + } + } + + if (StatusEffectUtil.hasHaste(this)) { + f *= 1.0F + (float) (StatusEffectUtil.getHasteAmplifier(this) + 1) * 0.2F; + } + + if (this.hasStatusEffect(StatusEffects.MINING_FATIGUE)) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) { + f *= 1.0F - (float) (this.getStatusEffect(StatusEffects.MINING_FATIGUE).getAmplifier() + 1) * 0.2F; + if (f < 0) f = 0; + } else { + f *= switch (this.getStatusEffect(StatusEffects.MINING_FATIGUE).getAmplifier()) { + case 0 -> 0.3F; + case 1 -> 0.09F; + case 2 -> 0.0027F; + default -> 8.1E-4F; + }; + } + } + + if (this.isSubmergedIn(FluidTags.WATER) && !EnchantmentHelper.hasAquaAffinity(this)) { + f /= 5.0F; + } + + if (!this.isOnGround()) { + f /= 5F; + } + + return f; + } + } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinPlayerEntityRenderer.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntityRenderer.java similarity index 60% rename from src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinPlayerEntityRenderer.java rename to src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntityRenderer.java index bef8fad6..92cee0af 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinPlayerEntityRenderer.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntityRenderer.java @@ -17,15 +17,15 @@ * along with this program. If not, see . */ -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft; +package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.render.entity.PlayerEntityRenderer; +import net.minecraft.entity.EntityPose; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -35,18 +35,27 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntityRenderer.class) public abstract class MixinPlayerEntityRenderer { - @Inject(method = "getPositionOffset*", at = @At("RETURN"), cancellable = true) - private void injectGetPositionOffset(AbstractClientPlayerEntity player, float delta, CallbackInfoReturnable ci) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { - if (player.getSleepingDirection() != null) { - ci.setReturnValue(ci.getReturnValue().subtract(player.getSleepingDirection().getOffsetX() * 0.4, 0, player.getSleepingDirection().getOffsetZ() * 0.4)); + @Inject(method = "getPositionOffset(Lnet/minecraft/client/network/AbstractClientPlayerEntity;F)Lnet/minecraft/util/math/Vec3d;", at = @At("RETURN"), cancellable = true) + private void modifySleepingOffset(AbstractClientPlayerEntity player, float delta, CallbackInfoReturnable cir) { + if (player.getPose() == EntityPose.SLEEPING) { + final Direction sleepingDir = player.getSleepingDirection(); + if (sleepingDir != null) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { + cir.setReturnValue(cir.getReturnValue().subtract(sleepingDir.getOffsetX() * 0.4, 0, sleepingDir.getOffsetZ() * 0.4)); + } + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_5tob1_5_2)) { + cir.setReturnValue(cir.getReturnValue().subtract(sleepingDir.getOffsetX() * 0.1, 0, sleepingDir.getOffsetZ() * 0.1)); + } + if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.b1_6tob1_6_6, VersionEnum.r1_7_6tor1_7_10)) { + cir.setReturnValue(cir.getReturnValue().subtract(0, 0.3F, 0)); + } } } } @Redirect(method = "getPositionOffset(Lnet/minecraft/client/network/AbstractClientPlayerEntity;F)Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;isInSneakingPose()Z")) - private boolean redirectGetPositionOffset(AbstractClientPlayerEntity player) { + private boolean disableSneakPositionOffset(AbstractClientPlayerEntity player) { return (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_11_1to1_11_2)) && player.isInSneakingPose(); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinSkeletonHorseEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinSkeletonHorseEntity.java new file mode 100644 index 00000000..28472bbb --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinSkeletonHorseEntity.java @@ -0,0 +1,28 @@ +package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; + +import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.mob.SkeletonHorseEntity; +import net.minecraft.entity.passive.AbstractHorseEntity; +import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; +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; + +@Mixin(SkeletonHorseEntity.class) +public abstract class MixinSkeletonHorseEntity extends AbstractHorseEntity { + + protected MixinSkeletonHorseEntity(EntityType entityType, World world) { + super(entityType, world); + } + + @Inject(method = "getBaseMovementSpeedMultiplier", at = @At("HEAD"), cancellable = true) + private void modifyBaseMovementSpeedMultiplier(CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) { + cir.setReturnValue(super.getBaseMovementSpeedMultiplier()); + } + } + +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinSquidEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinSquidEntity.java index 5379d648..82098543 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinSquidEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinSquidEntity.java @@ -19,11 +19,10 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import net.minecraft.entity.passive.SquidEntity; import net.minecraft.entity.player.PlayerEntity; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -33,7 +32,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public abstract class MixinSquidEntity { @Inject(method = "canBeLeashedBy", at = @At("HEAD"), cancellable = true) - private void injectCanBeLeashedBy(PlayerEntity player, CallbackInfoReturnable cir) { + private void cancelLeashing(PlayerEntity player, CallbackInfoReturnable cir) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) { cir.setReturnValue(false); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinWolfEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinWolfEntity.java index 49ecc45f..5c7430bf 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinWolfEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinWolfEntity.java @@ -19,26 +19,87 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; -import net.raphimc.vialoader.util.VersionEnum; import de.florianmichael.viafabricplus.fixes.tracker.WolfHealthTracker; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.mob.Angerable; +import net.minecraft.entity.passive.TameableEntity; import net.minecraft.entity.passive.WolfEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.DyeItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.util.ActionResult; +import net.minecraft.util.DyeColor; +import net.minecraft.util.Hand; +import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +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.CallbackInfoReturnable; -@SuppressWarnings("DataFlowIssue") @Mixin(WolfEntity.class) -public abstract class MixinWolfEntity { +public abstract class MixinWolfEntity extends TameableEntity implements Angerable { + + @Shadow + public abstract DyeColor getCollarColor(); + + @Shadow + public abstract void setCollarColor(DyeColor color); + + protected MixinWolfEntity(EntityType entityType, World world) { + super(entityType, world); + } + + @Inject(method = "interactMob", at = @At("HEAD"), cancellable = true) + private void fixWolfInteract(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) { + final ItemStack itemStack = player.getStackInHand(hand); + final Item item = itemStack.getItem(); + if (this.isTamed()) { + if (item.isFood()) { + if (item.getFoodComponent().isMeat() && this.getWolfHealth() < 20.0F) { + if (!player.getAbilities().creativeMode) itemStack.decrement(1); + this.heal((float) item.getFoodComponent().getHunger()); + cir.setReturnValue(ActionResult.SUCCESS); + return; + } + } else if (item instanceof DyeItem dyeItem) { + final DyeColor dyeColor = dyeItem.getColor(); + if (dyeColor != this.getCollarColor()) { + this.setCollarColor(dyeColor); + if (!player.getAbilities().creativeMode) itemStack.decrement(1); + cir.setReturnValue(ActionResult.SUCCESS); + return; + } + } + } else if (item == Items.BONE && !this.hasAngerTime()) { + if (!player.getAbilities().creativeMode) itemStack.decrement(1); + cir.setReturnValue(ActionResult.SUCCESS); + return; + } + + cir.setReturnValue(super.interactMob(player, hand)); + } + } @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/WolfEntity;getHealth()F")) - private float rewriteHealth(WolfEntity instance) { - float health = instance.getHealth(); + private float fixWolfHealth(WolfEntity instance) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) { - return WolfHealthTracker.get().getHealthDataMap().getOrDefault(instance.getId(), health); + return this.getWolfHealth(); } - return health; + return instance.getHealth(); + } + + @Unique + private float getWolfHealth() { + return WolfHealthTracker.get().getWolfHealth(this.getId(), this.getHealth()); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/input/MixinKeyboardInput.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/input/MixinKeyboardInput.java index 4e8b204a..8d5877bf 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/input/MixinKeyboardInput.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/input/MixinKeyboardInput.java @@ -19,12 +19,11 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.input; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import net.minecraft.client.MinecraftClient; import net.minecraft.client.input.Input; import net.minecraft.client.input.KeyboardInput; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; @@ -33,7 +32,7 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; public abstract class MixinKeyboardInput extends Input { @ModifyVariable(method = "tick", at = @At(value = "LOAD", ordinal = 0), argsOnly = true) - private boolean injectTick(boolean slowDown) { + private boolean changeSneakSlowdownCondition(boolean slowDown) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { return this.sneaking; } else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java new file mode 100644 index 00000000..cdb17661 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java @@ -0,0 +1,27 @@ +package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; + +import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ArmorItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; +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; + +@Mixin(ArmorItem.class) +public abstract class MixinArmorItem { + + @Inject(method = "use", at = @At("HEAD"), cancellable = true) + private void disableRightClick(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) { + cir.setReturnValue(new TypedActionResult<>(ActionResult.FAIL, user.getStackInHand(hand))); + } + } + +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java index bc3d2bc4..c3b4e25e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java @@ -19,25 +19,65 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import com.google.common.collect.ImmutableSet; +import de.florianmichael.viafabricplus.fixes.Material1_19_4; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import net.minecraft.item.AxeItem; -import net.minecraft.item.ItemUsageContext; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.item.*; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.ActionResult; +import net.raphimc.vialoader.util.VersionEnum; 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.callback.CallbackInfoReturnable; +import java.util.Set; + @Mixin(AxeItem.class) -public abstract class MixinAxeItem { +public abstract class MixinAxeItem extends MiningToolItem { + + @Unique + private static final Set _b1_8_1_EFFECTIVE_BLOCKS = ImmutableSet.of(Blocks.OAK_PLANKS, Blocks.BOOKSHELF, Blocks.OAK_LOG, Blocks.CHEST); + + @Unique + private static final Set _r1_16_5_EFFECTIVE_BLOCKS = ImmutableSet.of(Blocks.LADDER, Blocks.SCAFFOLDING, Blocks.OAK_BUTTON, Blocks.SPRUCE_BUTTON, Blocks.BIRCH_BUTTON, Blocks.JUNGLE_BUTTON, Blocks.DARK_OAK_BUTTON, Blocks.ACACIA_BUTTON, Blocks.CRIMSON_BUTTON, Blocks.WARPED_BUTTON); + + @Unique + private static final Set _r1_16_5_EFFECTIVE_MATERIALS = ImmutableSet.of(Material1_19_4.WOOD, Material1_19_4.NETHER_WOOD, Material1_19_4.PLANT, Material1_19_4.REPLACEABLE_PLANT, Material1_19_4.BAMBOO, Material1_19_4.GOURD); + + public MixinAxeItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey effectiveBlocks, Settings settings) { + super(attackDamage, attackSpeed, material, effectiveBlocks, settings); + } @Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true) - private void alwaysPassInteraction(ItemUsageContext context, CallbackInfoReturnable cir) { + private void disableUse(ItemUsageContext context, CallbackInfoReturnable cir) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) { cir.setReturnValue(ActionResult.PASS); } } + @Override + public boolean isSuitableFor(BlockState state) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) { + return false; + } + + return super.isSuitableFor(state); + } + + @Override + public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) { + return _b1_8_1_EFFECTIVE_BLOCKS.contains(state.getBlock()) ? this.miningSpeed : 1.0F; + } else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) { + return _r1_16_5_EFFECTIVE_MATERIALS.contains(Material1_19_4.getMaterial(state)) ? this.miningSpeed : _r1_16_5_EFFECTIVE_BLOCKS.contains(state.getBlock()) ? this.miningSpeed : 1.0F; + } + + return super.getMiningSpeedMultiplier(stack, state); + } + } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBlockItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBlockItem.java index 9ffa54d7..f1c7f005 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBlockItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBlockItem.java @@ -19,8 +19,6 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -32,6 +30,7 @@ import net.minecraft.item.ItemPlacementContext; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -41,7 +40,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public abstract class MixinBlockItem { @Inject(method = "canPlace", at = @At("HEAD"), cancellable = true) - private void injectCanPlace(ItemPlacementContext context, BlockState state, CallbackInfoReturnable ci) { + private void checkChestPlacement(ItemPlacementContext context, BlockState state, CallbackInfoReturnable cir) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) { Block block = state.getBlock(); if (block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST) { @@ -52,12 +51,12 @@ public abstract class MixinBlockItem { BlockState otherState = world.getBlockState(pos.offset(dir)); if (otherState.getBlock() == block) { if (foundAdjChest) { - ci.setReturnValue(false); + cir.setReturnValue(false); return; } foundAdjChest = true; if (otherState.get(ChestBlock.CHEST_TYPE) != ChestType.SINGLE) { - ci.setReturnValue(false); + cir.setReturnValue(false); return; } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBowItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBowItem.java new file mode 100644 index 00000000..418bb5c0 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBowItem.java @@ -0,0 +1,48 @@ +package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; + +import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BowItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import net.minecraft.util.UseAction; +import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; +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; + +@Mixin(BowItem.class) +public abstract class MixinBowItem { + + @Inject(method = "getMaxUseTime", at = @At("HEAD"), cancellable = true) + private void makeInstantUsable(CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_7tob1_7_3)) { + cir.setReturnValue(0); + } + } + + @Inject(method = "getUseAction", at = @At("HEAD"), cancellable = true) + private void makeInstantUsable2(CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_7tob1_7_3)) { + cir.setReturnValue(UseAction.NONE); + } + } + + @Inject(method = "use", at = @At("HEAD"), cancellable = true) + private void makeInstantUsable(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_7tob1_7_3)) { + final ItemStack stack = user.getStackInHand(hand); + final ItemStack arrowStack = user.getProjectileType(stack); + if (arrowStack.isEmpty()) { + cir.setReturnValue(TypedActionResult.fail(stack)); + } else { + arrowStack.decrement(1); + cir.setReturnValue(TypedActionResult.pass(stack)); + } + } + } + +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinDrawContext.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinDrawContext.java similarity index 60% rename from src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinDrawContext.java rename to src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinDrawContext.java index e4f19fa1..5cb18e22 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinDrawContext.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinDrawContext.java @@ -17,12 +17,11 @@ * along with this program. If not, see . */ -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft; +package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; -import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import net.minecraft.client.font.TextRenderer; +import de.florianmichael.viafabricplus.injection.access.IItemStack; import net.minecraft.client.gui.DrawContext; -import net.raphimc.vialoader.util.VersionEnum; +import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -30,14 +29,20 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(DrawContext.class) public abstract class MixinDrawContext { - @Redirect(method = "drawItemInSlot(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawText(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;IIIZ)I")) - private int recolor(DrawContext instance, TextRenderer textRenderer, String text, int x, int y, int color, boolean shadow) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10) && text.startsWith("-")) { - color = -43213; // red + @Redirect(method = "drawItemInSlot(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getCount()I")) + private int handleNegativeItemCount(ItemStack instance) { + if (((IItemStack) (Object) instance).viaFabricPlus$has1_10ProtocolHackTag()) { + return ((IItemStack) (Object) instance).viaFabricPlus$get1_10Count(); } + return instance.getCount(); + } - return instance.drawText(textRenderer, text, x, y, color, shadow); + @Redirect(method = "drawItemInSlot(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Ljava/lang/String;valueOf(I)Ljava/lang/String;", remap = false)) + private String makeTextRed(int count) { + if (count <= 0) { + return "§c" + count; + } + return String.valueOf(count); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinEnderPearlItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinEnderPearlItem.java index 9054d3f9..09dc65a4 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinEnderPearlItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinEnderPearlItem.java @@ -19,8 +19,6 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnderPearlItem; @@ -28,6 +26,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -37,7 +36,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public abstract class MixinEnderPearlItem { @Inject(method = "use", at = @At("HEAD"), cancellable = true) - private void injectUse(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> ci) { + private void removeCreativeModeEnderPearl(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> ci) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && user.getAbilities().creativeMode) { ci.setReturnValue(TypedActionResult.pass(user.getStackInHand(hand))); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinEquipment.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinEquipment.java index a57e3308..c064a7ed 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinEquipment.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinEquipment.java @@ -20,35 +20,25 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Equipment; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import net.minecraft.world.World; import net.raphimc.vialoader.util.VersionEnum; 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.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Equipment.class) public interface MixinEquipment { - @Redirect(method = "equipAndSwap", at = @At(value = "INVOKE", target = "Lnet/minecraft/enchantment/EnchantmentHelper;hasBindingCurse(Lnet/minecraft/item/ItemStack;)Z")) - default boolean removeBindingCurseCondition(ItemStack stack) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) { - return false; - } - return EnchantmentHelper.hasBindingCurse(stack); - } - - @Redirect(method = "equipAndSwap", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;areEqual(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z")) - default boolean simplifyCondition(ItemStack left, ItemStack right) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) { - return !right.isEmpty(); - } - - return ItemStack.areEqual(left, right); - } - @Redirect(method = "equipAndSwap", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isCreative()Z")) default boolean removeCreativeCondition(PlayerEntity instance) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) { @@ -56,4 +46,18 @@ public interface MixinEquipment { } return instance.isCreative(); } + + @Inject(method = "equipAndSwap", at = @At("HEAD"), cancellable = true) + private void cancelArmorSwap(Item item, World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) { + final ItemStack heldItem = user.getStackInHand(hand); + final EquipmentSlot targetSlot = MobEntity.getPreferredEquipmentSlot(heldItem); + final ItemStack targetItem = user.getEquippedStack(targetSlot); + + if (!targetItem.isEmpty()) { + cir.setReturnValue(TypedActionResult.fail(heldItem)); + } + } + } + } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHeldItemRenderer.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHeldItemRenderer.java index 4809f9de..44593c7d 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHeldItemRenderer.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHeldItemRenderer.java @@ -19,17 +19,17 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; -import de.florianmichael.viafabricplus.settings.impl.VisualSettings; -import net.minecraft.util.Arm; -import net.raphimc.vialoader.util.VersionEnum; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import de.florianmichael.viafabricplus.settings.impl.VisualSettings; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.HeldItemRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; +import net.minecraft.util.Arm; import net.minecraft.util.Hand; import net.minecraft.util.math.RotationAxis; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHoeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHoeItem.java index 34769045..beb337a2 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHoeItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHoeItem.java @@ -73,11 +73,11 @@ public abstract class MixinHoeItem extends MiningToolItem { public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) { return 1.0F; - } - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) { + } else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) { return viaFabricPlus$EFFECTIVE_BLOCKS_1165.contains(state.getBlock()) ? this.miningSpeed : 1.0F; + } else { + return super.getMiningSpeedMultiplier(stack, state); } - return super.getMiningSpeedMultiplier(stack, state); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItem.java index 6ea27980..8db9d982 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItem.java @@ -27,14 +27,21 @@ import org.spongepowered.asm.mixin.Final; 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.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Item.class) public abstract class MixinItem { - @Shadow @Final private int maxDamage; + @Shadow + @Final + private int maxDamage; - @Redirect(method = { "getMaxDamage", "isDamageable", "getItemBarStep", "getItemBarColor" }, at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I")) + @Shadow + public abstract boolean isFood(); + + @Redirect(method = {"getMaxDamage", "isDamageable", "getItemBarStep", "getItemBarColor"}, at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I")) private int changeCrossbowDamage(Item instance) { if (instance instanceof CrossbowItem && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17_1)) { return 326; @@ -42,4 +49,19 @@ public abstract class MixinItem { return maxDamage; } + @Inject(method = "getMaxCount", at = @At("HEAD"), cancellable = true) + private void dontStackFood(CallbackInfoReturnable cir) { + if (this.isFood() && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_7tob1_7_3)) { + cir.setReturnValue(1); + } + } + + @Redirect(method = {"use", "finishUsing", "getUseAction", "getMaxUseTime"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;isFood()Z")) + private boolean makeFoodInstantConsumable(Item instance) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_7tob1_7_3)) { + return false; + } + return instance.isFood(); + } + } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemGroups.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemGroups.java index 01b73743..09588a3b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemGroups.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemGroups.java @@ -37,11 +37,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ItemGroups.class) public abstract class MixinItemGroups { - @Shadow @Nullable private static ItemGroup.@Nullable DisplayContext displayContext; + @Shadow + @Nullable + private static ItemGroup.@Nullable DisplayContext displayContext; @Shadow private static void updateEntries(ItemGroup.DisplayContext displayContext) { } + @Unique private static VersionEnum viaFabricPlus$version; diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemPlacementContext.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemPlacementContext.java index 5b7dd819..40e7f55e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemPlacementContext.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemPlacementContext.java @@ -19,27 +19,36 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.fixes.Material1_19_4; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemPlacementContext; +import net.minecraft.item.ItemUsageContext; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.raphimc.vialoader.util.VersionEnum; 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; @Mixin(ItemPlacementContext.class) -public abstract class MixinItemPlacementContext { +public abstract class MixinItemPlacementContext extends ItemUsageContext { + + public MixinItemPlacementContext(PlayerEntity player, Hand hand, BlockHitResult hit) { + super(player, hand, hit); + } @Inject(method = "getPlayerLookDirection", at = @At("HEAD"), cancellable = true) - private void injectGetPlayerLookDirection(CallbackInfoReturnable ci) { + private void get112LookDirection(CallbackInfoReturnable cir) { final ItemPlacementContext self = (ItemPlacementContext) (Object) this; final PlayerEntity player = self.getPlayer(); - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) && player != null) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) { final BlockPos placementPos = self.getBlockPos(); final double blockPosCenterFactor = ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_10) ? 0.5 : 0; @@ -47,17 +56,24 @@ public abstract class MixinItemPlacementContext { final double eyeY = player.getY() + player.getEyeHeight(player.getPose()); if (eyeY - placementPos.getY() > 2) { - ci.setReturnValue(Direction.DOWN); + cir.setReturnValue(Direction.DOWN); return; } if (placementPos.getY() - eyeY > 0) { - ci.setReturnValue(Direction.UP); + cir.setReturnValue(Direction.UP); return; } } - ci.setReturnValue(player.getHorizontalFacing()); + cir.setReturnValue(player.getHorizontalFacing()); + } + } + + @Inject(method = "canPlace", at = @At("RETURN"), cancellable = true) + private void anvilOverride(CallbackInfoReturnable cir) { + if (!cir.getReturnValueZ() && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) { + cir.setReturnValue(Material1_19_4.getMaterial(this.getWorld().getBlockState(this.getBlockPos())).equals(Material1_19_4.DECORATION) && Block.getBlockFromItem(this.getStack().getItem()).equals(Blocks.ANVIL)); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemRenderer.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemRenderer.java index 11f23674..64042395 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemRenderer.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemRenderer.java @@ -37,7 +37,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ItemRenderer.class) public abstract class MixinItemRenderer { - @Shadow @Final private ItemModels models; + @Shadow + @Final + private ItemModels models; @Inject(method = "getModel", at = @At("HEAD"), cancellable = true) private void removeModel(ItemStack stack, World world, LivingEntity entity, int seed, CallbackInfoReturnable cir) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java index d0f69432..82bc45b7 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java @@ -21,18 +21,15 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; +import de.florianmichael.viafabricplus.injection.access.IItemStack; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import de.florianmichael.viafabricplus.settings.impl.DebugSettings; -import net.minecraft.block.BlockState; -import net.minecraft.client.MinecraftClient; import net.minecraft.entity.attribute.EntityAttribute; import net.minecraft.entity.attribute.EntityAttributeModifier; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; import net.raphimc.vialoader.util.VersionEnum; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -42,39 +39,21 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.OptionalDouble; @Mixin(value = ItemStack.class, priority = 1) -public abstract class MixinItemStack { +public abstract class MixinItemStack implements IItemStack { @Shadow public abstract Item getItem(); - @Shadow @Final public static ItemStack EMPTY; + @Unique + private boolean viaFabricPlus$has1_10ProtocolHackTag; - @Shadow private int count; - - @Shadow @Final @Deprecated private @Nullable Item item; - - @Inject(method = "isEmpty", at = @At("HEAD"), cancellable = true) - private void dontRecalculateState(CallbackInfoReturnable cir) { - if (MinecraftClient.getInstance() != null && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10)) { - final ItemStack self = (ItemStack) (Object) this; - - cir.setReturnValue(self == EMPTY || this.item == null || this.item == Items.AIR || count == 0); - } - } - - @Inject(method = "getMiningSpeedMultiplier", at = @At("RETURN"), cancellable = true) - private void modifyMiningSpeedMultiplier(BlockState state, CallbackInfoReturnable ci) { - final Item toolItem = ((ItemStack) (Object) this).getItem(); - - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2) && toolItem instanceof HoeItem) { - ci.setReturnValue(1F); - } - } + @Unique + private int viaFabricPlus$1_10_count; @Redirect(method = "getTooltip", slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/attribute/EntityAttributes;GENERIC_ATTACK_DAMAGE:Lnet/minecraft/entity/attribute/EntityAttribute;", ordinal = 0)), at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getAttributeBaseValue(Lnet/minecraft/entity/attribute/EntityAttribute;)D", ordinal = 0)) - private double redirectGetTooltip(PlayerEntity player, EntityAttribute attribute) { + private double fixDamageCalculation(PlayerEntity player, EntityAttribute attribute) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { return 0; } else { @@ -91,7 +70,7 @@ public abstract class MixinItemStack { modifiers.removeAll(EntityAttributes.GENERIC_ATTACK_DAMAGE); OptionalDouble defaultAttackDamage = viaFabricPlus$getDefaultAttackDamage(getItem()); if (defaultAttackDamage.isPresent()) { - modifiers.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(Item.ATTACK_DAMAGE_MODIFIER_ID, "Weapon Modifier", defaultAttackDamage.getAsDouble(), EntityAttributeModifier.Operation.ADDITION)); + modifiers.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(Item.ATTACK_DAMAGE_MODIFIER_ID, "Tool modifier", defaultAttackDamage.getAsDouble(), EntityAttributeModifier.Operation.ADDITION)); } modifiers.removeAll(EntityAttributes.GENERIC_ATTACK_SPEED); modifiers.removeAll(EntityAttributes.GENERIC_ARMOR); @@ -99,20 +78,18 @@ public abstract class MixinItemStack { return modifiers; } + @Inject(method = "copy", at = @At("RETURN")) + private void copyProtocolHackData(CallbackInfoReturnable cir) { + final IItemStack mixinItemStack = (IItemStack) (Object) cir.getReturnValue(); + if (this.viaFabricPlus$has1_10ProtocolHackTag) { + mixinItemStack.viaFabricPlus$set1_10Count(this.viaFabricPlus$1_10_count); + } + } + @Unique private OptionalDouble viaFabricPlus$getDefaultAttackDamage(Item item) { - if (item instanceof ToolItem) { - ToolMaterial material = ((ToolItem) item).getMaterial(); - int materialBonus; - if (material == ToolMaterials.STONE) { - materialBonus = 1; - } else if (material == ToolMaterials.IRON) { - materialBonus = 2; - } else if (material == ToolMaterials.DIAMOND) { - materialBonus = 3; - } else { - materialBonus = 0; - } + if (item instanceof ToolItem toolItem) { + final float materialBonus = toolItem.getMaterial().getAttackDamage(); if (item instanceof SwordItem) { return OptionalDouble.of(4 + materialBonus); } else if (item instanceof PickaxeItem) { @@ -127,4 +104,20 @@ public abstract class MixinItemStack { return OptionalDouble.empty(); } + @Override + public boolean viaFabricPlus$has1_10ProtocolHackTag() { + return this.viaFabricPlus$has1_10ProtocolHackTag; + } + + @Override + public int viaFabricPlus$get1_10Count() { + return this.viaFabricPlus$1_10_count; + } + + @Override + public void viaFabricPlus$set1_10Count(final int count) { + this.viaFabricPlus$has1_10ProtocolHackTag = true; + this.viaFabricPlus$1_10_count = count; + } + } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinMiningToolItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinMiningToolItem.java deleted file mode 100644 index c165f1ed..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinMiningToolItem.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2023 FlorianMichael/EnZaXD - * Copyright (C) 2023 RK_01/RaphiMC and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; - -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import net.minecraft.block.BlockState; -import net.minecraft.item.HoeItem; -import net.minecraft.item.ItemStack; -import net.minecraft.item.MiningToolItem; -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; - -@Mixin(MiningToolItem.class) -public abstract class MixinMiningToolItem { - - @Inject(method = "getMiningSpeedMultiplier", at = @At("RETURN"), cancellable = true) - private void changeHoeEffectiveBlocks(ItemStack stack, BlockState state, CallbackInfoReturnable cir) { - //noinspection ConstantValue - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2) && (Object) this instanceof HoeItem) { - cir.setReturnValue(1.0F); - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinPickaxeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinPickaxeItem.java index 922660cf..2a2bd05d 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinPickaxeItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinPickaxeItem.java @@ -20,7 +20,9 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; import com.google.common.collect.ImmutableSet; +import de.florianmichael.viafabricplus.fixes.Material1_19_4; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import net.fabricmc.yarn.constants.MiningLevels; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -39,13 +41,16 @@ import java.util.Set; public abstract class MixinPickaxeItem extends MiningToolItem { @Unique - private static final Set viaFabricPlus$EFFECTIVE_BLOCKS_1165 = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.NETHER_GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX, Blocks.PISTON, Blocks.STICKY_PISTON, Blocks.PISTON_HEAD); + private static final Set _b1_8_1_EFFECTIVE_BLOCKS = ImmutableSet.of(Blocks.COBBLESTONE, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.STONE, Blocks.SANDSTONE, Blocks.MOSSY_COBBLESTONE, Blocks.IRON_ORE, Blocks.IRON_BLOCK, Blocks.COAL_ORE, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.DIAMOND_ORE, Blocks.DIAMOND_BLOCK, Blocks.ICE, Blocks.NETHERRACK, Blocks.LAPIS_ORE, Blocks.LAPIS_BLOCK); @Unique - private static final Set viaFabricPlus$EFFECTIVE_MATERIALS = ImmutableSet.of(Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.COBBLESTONE, Blocks.BEDROCK, Blocks.GOLD_ORE, Blocks.DEEPSLATE_GOLD_ORE, Blocks.IRON_ORE, Blocks.DEEPSLATE_IRON_ORE, Blocks.COAL_ORE, Blocks.DEEPSLATE_COAL_ORE, Blocks.NETHER_GOLD_ORE, Blocks.LAPIS_ORE, Blocks.DEEPSLATE_LAPIS_ORE, Blocks.LAPIS_BLOCK, Blocks.DISPENSER, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.GOLD_BLOCK, Blocks.IRON_BLOCK, Blocks.BRICKS, Blocks.MOSSY_COBBLESTONE, Blocks.OBSIDIAN, Blocks.SPAWNER, Blocks.DIAMOND_ORE, Blocks.DEEPSLATE_DIAMOND_ORE, Blocks.DIAMOND_BLOCK, Blocks.FURNACE, Blocks.COBBLESTONE_STAIRS, Blocks.STONE_PRESSURE_PLATE, Blocks.IRON_DOOR, Blocks.REDSTONE_ORE, Blocks.DEEPSLATE_REDSTONE_ORE, Blocks.NETHERRACK, Blocks.BASALT, Blocks.POLISHED_BASALT, Blocks.STONE_BRICKS, Blocks.MOSSY_STONE_BRICKS, Blocks.CRACKED_STONE_BRICKS, Blocks.CHISELED_STONE_BRICKS, Blocks.MUD_BRICKS, Blocks.IRON_BARS, Blocks.CHAIN, Blocks.BRICK_STAIRS, Blocks.STONE_BRICK_STAIRS, Blocks.MUD_BRICK_STAIRS, Blocks.NETHER_BRICKS, Blocks.NETHER_BRICK_FENCE, Blocks.NETHER_BRICK_STAIRS, Blocks.ENCHANTING_TABLE, Blocks.BREWING_STAND, Blocks.CAULDRON, Blocks.WATER_CAULDRON, Blocks.LAVA_CAULDRON, Blocks.POWDER_SNOW_CAULDRON, Blocks.END_PORTAL_FRAME, Blocks.END_STONE, Blocks.SANDSTONE_STAIRS, Blocks.EMERALD_ORE, Blocks.DEEPSLATE_EMERALD_ORE, Blocks.ENDER_CHEST, Blocks.EMERALD_BLOCK, Blocks.COMMAND_BLOCK, Blocks.COBBLESTONE_WALL, Blocks.MOSSY_COBBLESTONE_WALL, Blocks.ANVIL, Blocks.CHIPPED_ANVIL, Blocks.DAMAGED_ANVIL, Blocks.LIGHT_WEIGHTED_PRESSURE_PLATE, Blocks.HEAVY_WEIGHTED_PRESSURE_PLATE, Blocks.REDSTONE_BLOCK, Blocks.NETHER_QUARTZ_ORE, Blocks.HOPPER, Blocks.QUARTZ_BLOCK, Blocks.CHISELED_QUARTZ_BLOCK, Blocks.QUARTZ_PILLAR, Blocks.QUARTZ_STAIRS, Blocks.DROPPER, Blocks.WHITE_TERRACOTTA, Blocks.ORANGE_TERRACOTTA, Blocks.MAGENTA_TERRACOTTA, Blocks.LIGHT_BLUE_TERRACOTTA, Blocks.YELLOW_TERRACOTTA, Blocks.LIME_TERRACOTTA, Blocks.PINK_TERRACOTTA, Blocks.GRAY_TERRACOTTA, Blocks.LIGHT_GRAY_TERRACOTTA, Blocks.CYAN_TERRACOTTA, Blocks.PURPLE_TERRACOTTA, Blocks.BLUE_TERRACOTTA, Blocks.BROWN_TERRACOTTA, Blocks.GREEN_TERRACOTTA, Blocks.RED_TERRACOTTA, Blocks.BLACK_TERRACOTTA, Blocks.IRON_TRAPDOOR, Blocks.PRISMARINE, Blocks.PRISMARINE_BRICKS, Blocks.DARK_PRISMARINE, Blocks.PRISMARINE_STAIRS, Blocks.PRISMARINE_BRICK_STAIRS, Blocks.DARK_PRISMARINE_STAIRS, Blocks.PRISMARINE_SLAB, Blocks.PRISMARINE_BRICK_SLAB, Blocks.DARK_PRISMARINE_SLAB, Blocks.TERRACOTTA, Blocks.COAL_BLOCK, Blocks.RED_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE_STAIRS, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.CUT_SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.MUD_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.CUT_RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_STONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.PURPUR_BLOCK, Blocks.PURPUR_PILLAR, Blocks.PURPUR_STAIRS, Blocks.END_STONE_BRICKS, Blocks.REPEATING_COMMAND_BLOCK, Blocks.CHAIN_COMMAND_BLOCK, Blocks.MAGMA_BLOCK, Blocks.RED_NETHER_BRICKS, Blocks.BONE_BLOCK, Blocks.OBSERVER, Blocks.WHITE_GLAZED_TERRACOTTA, Blocks.ORANGE_GLAZED_TERRACOTTA, Blocks.MAGENTA_GLAZED_TERRACOTTA, Blocks.LIGHT_BLUE_GLAZED_TERRACOTTA, Blocks.YELLOW_GLAZED_TERRACOTTA, Blocks.LIME_GLAZED_TERRACOTTA, Blocks.PINK_GLAZED_TERRACOTTA, Blocks.GRAY_GLAZED_TERRACOTTA, Blocks.LIGHT_GRAY_GLAZED_TERRACOTTA, Blocks.CYAN_GLAZED_TERRACOTTA, Blocks.PURPLE_GLAZED_TERRACOTTA, Blocks.BLUE_GLAZED_TERRACOTTA, Blocks.BROWN_GLAZED_TERRACOTTA, Blocks.GREEN_GLAZED_TERRACOTTA, Blocks.RED_GLAZED_TERRACOTTA, Blocks.BLACK_GLAZED_TERRACOTTA, Blocks.WHITE_CONCRETE, Blocks.ORANGE_CONCRETE, Blocks.MAGENTA_CONCRETE, Blocks.LIGHT_BLUE_CONCRETE, Blocks.YELLOW_CONCRETE, Blocks.LIME_CONCRETE, Blocks.PINK_CONCRETE, Blocks.GRAY_CONCRETE, Blocks.LIGHT_GRAY_CONCRETE, Blocks.CYAN_CONCRETE, Blocks.PURPLE_CONCRETE, Blocks.BLUE_CONCRETE, Blocks.BROWN_CONCRETE, Blocks.GREEN_CONCRETE, Blocks.RED_CONCRETE, Blocks.BLACK_CONCRETE, Blocks.DEAD_TUBE_CORAL_BLOCK, Blocks.DEAD_BRAIN_CORAL_BLOCK, Blocks.DEAD_BUBBLE_CORAL_BLOCK, Blocks.DEAD_FIRE_CORAL_BLOCK, Blocks.DEAD_HORN_CORAL_BLOCK, Blocks.TUBE_CORAL_BLOCK, Blocks.BRAIN_CORAL_BLOCK, Blocks.BUBBLE_CORAL_BLOCK, Blocks.FIRE_CORAL_BLOCK, Blocks.HORN_CORAL_BLOCK, Blocks.DEAD_TUBE_CORAL, Blocks.DEAD_BRAIN_CORAL, Blocks.DEAD_BUBBLE_CORAL, Blocks.DEAD_FIRE_CORAL, Blocks.DEAD_HORN_CORAL, Blocks.DEAD_TUBE_CORAL_FAN, Blocks.DEAD_BRAIN_CORAL_FAN, Blocks.DEAD_BUBBLE_CORAL_FAN, Blocks.DEAD_FIRE_CORAL_FAN, Blocks.DEAD_HORN_CORAL_FAN, Blocks.DEAD_TUBE_CORAL_WALL_FAN, Blocks.DEAD_BRAIN_CORAL_WALL_FAN, Blocks.DEAD_BUBBLE_CORAL_WALL_FAN, Blocks.DEAD_FIRE_CORAL_WALL_FAN, Blocks.DEAD_HORN_CORAL_WALL_FAN, Blocks.POLISHED_GRANITE_STAIRS, Blocks.SMOOTH_RED_SANDSTONE_STAIRS, Blocks.MOSSY_STONE_BRICK_STAIRS, Blocks.POLISHED_DIORITE_STAIRS, Blocks.MOSSY_COBBLESTONE_STAIRS, Blocks.END_STONE_BRICK_STAIRS, Blocks.STONE_STAIRS, Blocks.SMOOTH_SANDSTONE_STAIRS, Blocks.SMOOTH_QUARTZ_STAIRS, Blocks.GRANITE_STAIRS, Blocks.ANDESITE_STAIRS, Blocks.RED_NETHER_BRICK_STAIRS, Blocks.POLISHED_ANDESITE_STAIRS, Blocks.DIORITE_STAIRS, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.BRICK_WALL, Blocks.PRISMARINE_WALL, Blocks.RED_SANDSTONE_WALL, Blocks.MOSSY_STONE_BRICK_WALL, Blocks.GRANITE_WALL, Blocks.STONE_BRICK_WALL, Blocks.MUD_BRICK_WALL, Blocks.NETHER_BRICK_WALL, Blocks.ANDESITE_WALL, Blocks.RED_NETHER_BRICK_WALL, Blocks.SANDSTONE_WALL, Blocks.END_STONE_BRICK_WALL, Blocks.DIORITE_WALL, Blocks.SMOKER, Blocks.BLAST_FURNACE, Blocks.GRINDSTONE, Blocks.STONECUTTER, Blocks.BELL, Blocks.LANTERN, Blocks.SOUL_LANTERN, Blocks.WARPED_NYLIUM, Blocks.CRIMSON_NYLIUM, Blocks.STRUCTURE_BLOCK, Blocks.JIGSAW, Blocks.NETHERITE_BLOCK, Blocks.ANCIENT_DEBRIS, Blocks.CRYING_OBSIDIAN, Blocks.RESPAWN_ANCHOR, Blocks.LODESTONE, Blocks.BLACKSTONE, Blocks.BLACKSTONE_STAIRS, Blocks.BLACKSTONE_WALL, Blocks.BLACKSTONE_SLAB, Blocks.POLISHED_BLACKSTONE, Blocks.POLISHED_BLACKSTONE_BRICKS, Blocks.CRACKED_POLISHED_BLACKSTONE_BRICKS, Blocks.CHISELED_POLISHED_BLACKSTONE, Blocks.POLISHED_BLACKSTONE_BRICK_SLAB, Blocks.POLISHED_BLACKSTONE_BRICK_STAIRS, Blocks.POLISHED_BLACKSTONE_BRICK_WALL, Blocks.GILDED_BLACKSTONE, Blocks.POLISHED_BLACKSTONE_STAIRS, Blocks.POLISHED_BLACKSTONE_SLAB, Blocks.POLISHED_BLACKSTONE_PRESSURE_PLATE, Blocks.POLISHED_BLACKSTONE_WALL, Blocks.CHISELED_NETHER_BRICKS, Blocks.CRACKED_NETHER_BRICKS, Blocks.QUARTZ_BRICKS, Blocks.TUFF, Blocks.CALCITE, Blocks.OXIDIZED_COPPER, Blocks.WEATHERED_COPPER, Blocks.EXPOSED_COPPER, Blocks.COPPER_BLOCK, Blocks.COPPER_ORE, Blocks.DEEPSLATE_COPPER_ORE, Blocks.OXIDIZED_CUT_COPPER, Blocks.WEATHERED_CUT_COPPER, Blocks.EXPOSED_CUT_COPPER, Blocks.CUT_COPPER, Blocks.OXIDIZED_CUT_COPPER_STAIRS, Blocks.WEATHERED_CUT_COPPER_STAIRS, Blocks.EXPOSED_CUT_COPPER_STAIRS, Blocks.CUT_COPPER_STAIRS, Blocks.OXIDIZED_CUT_COPPER_SLAB, Blocks.WEATHERED_CUT_COPPER_SLAB, Blocks.EXPOSED_CUT_COPPER_SLAB, Blocks.CUT_COPPER_SLAB, Blocks.WAXED_COPPER_BLOCK, Blocks.WAXED_WEATHERED_COPPER, Blocks.WAXED_EXPOSED_COPPER, Blocks.WAXED_OXIDIZED_COPPER, Blocks.WAXED_OXIDIZED_CUT_COPPER, Blocks.WAXED_WEATHERED_CUT_COPPER, Blocks.WAXED_EXPOSED_CUT_COPPER, Blocks.WAXED_CUT_COPPER, Blocks.WAXED_OXIDIZED_CUT_COPPER_STAIRS, Blocks.WAXED_WEATHERED_CUT_COPPER_STAIRS, Blocks.WAXED_EXPOSED_CUT_COPPER_STAIRS, Blocks.WAXED_CUT_COPPER_STAIRS, Blocks.WAXED_OXIDIZED_CUT_COPPER_SLAB, Blocks.WAXED_WEATHERED_CUT_COPPER_SLAB, Blocks.WAXED_EXPOSED_CUT_COPPER_SLAB, Blocks.WAXED_CUT_COPPER_SLAB, Blocks.LIGHTNING_ROD, Blocks.POINTED_DRIPSTONE, Blocks.DRIPSTONE_BLOCK, Blocks.DEEPSLATE, Blocks.COBBLED_DEEPSLATE, Blocks.COBBLED_DEEPSLATE_STAIRS, Blocks.COBBLED_DEEPSLATE_SLAB, Blocks.COBBLED_DEEPSLATE_WALL, Blocks.POLISHED_DEEPSLATE, Blocks.POLISHED_DEEPSLATE_STAIRS, Blocks.POLISHED_DEEPSLATE_SLAB, Blocks.POLISHED_DEEPSLATE_WALL, Blocks.DEEPSLATE_TILES, Blocks.DEEPSLATE_TILE_STAIRS, Blocks.DEEPSLATE_TILE_SLAB, Blocks.DEEPSLATE_TILE_WALL, Blocks.DEEPSLATE_BRICKS, Blocks.DEEPSLATE_BRICK_STAIRS, Blocks.DEEPSLATE_BRICK_SLAB, Blocks.DEEPSLATE_BRICK_WALL, Blocks.CHISELED_DEEPSLATE, Blocks.CRACKED_DEEPSLATE_BRICKS, Blocks.CRACKED_DEEPSLATE_TILES, Blocks.SMOOTH_BASALT, Blocks.RAW_IRON_BLOCK, Blocks.RAW_COPPER_BLOCK, Blocks.RAW_GOLD_BLOCK, Blocks.REINFORCED_DEEPSLATE); + private static final Set _r1_15_2_EFFECTIVE_BLOCKS = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX); @Unique - private static final Set viaFabricPlus$EFFECTIVE_BLOCKS_1152 = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX); + private static final Set _r1_16_5_EFFECTIVE_BLOCKS = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.NETHER_GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX, Blocks.PISTON, Blocks.STICKY_PISTON, Blocks.PISTON_HEAD); + + @Unique + private static final Set _r1_16_5_EFFECTIVE_MATERIALS = ImmutableSet.of(Material1_19_4.METAL, Material1_19_4.REPAIR_STATION, Material1_19_4.STONE); protected MixinPickaxeItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey effectiveBlocks, Settings settings) { super(attackDamage, attackSpeed, material, effectiveBlocks, settings); @@ -54,28 +59,31 @@ public abstract class MixinPickaxeItem extends MiningToolItem { @Override public boolean isSuitableFor(BlockState state) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) { - Block block = state.getBlock(); - int i = this.getMaterial().getMiningLevel(); - if (block == Blocks.OBSIDIAN) { - return i == 3; - } else if (block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE && block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK && block != Blocks.GOLD_BLOCK && block != Blocks.GOLD_ORE && block != Blocks.REDSTONE_ORE) { - if (block != Blocks.IRON_BLOCK && block != Blocks.IRON_ORE && block != Blocks.LAPIS_BLOCK && block != Blocks.LAPIS_ORE) { - return viaFabricPlus$EFFECTIVE_MATERIALS.contains(state.getBlock()); - } else - return i >= 1; - } else - return i >= 2; + final int miningLevel = this.getMaterial().getMiningLevel(); + if (state.isOf(Blocks.OBSIDIAN) || state.isOf(Blocks.CRYING_OBSIDIAN) || state.isOf(Blocks.NETHERITE_BLOCK) || state.isOf(Blocks.RESPAWN_ANCHOR) || state.isOf(Blocks.ANCIENT_DEBRIS)) { + return miningLevel >= MiningLevels.DIAMOND; + } else if (state.isOf(Blocks.DIAMOND_BLOCK) || state.isOf(Blocks.DIAMOND_ORE) || state.isOf(Blocks.EMERALD_ORE) || state.isOf(Blocks.EMERALD_BLOCK) || state.isOf(Blocks.GOLD_BLOCK) || state.isOf(Blocks.GOLD_ORE) || state.isOf(Blocks.REDSTONE_ORE)) { + return miningLevel >= MiningLevels.IRON; + } else if (state.isOf(Blocks.IRON_BLOCK) || state.isOf(Blocks.IRON_ORE) || state.isOf(Blocks.LAPIS_BLOCK) || state.isOf(Blocks.LAPIS_ORE)) { + return miningLevel >= MiningLevels.STONE; + } else { + return _r1_16_5_EFFECTIVE_MATERIALS.contains(Material1_19_4.getMaterial(state)) || state.isOf(Blocks.NETHER_GOLD_ORE); + } } + return super.isSuitableFor(state); } @Override public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) { - return viaFabricPlus$EFFECTIVE_MATERIALS.contains(state.getBlock()) || viaFabricPlus$EFFECTIVE_BLOCKS_1152.contains(state.getBlock()) ? this.miningSpeed : 1.0F; + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) { + return _b1_8_1_EFFECTIVE_BLOCKS.contains(state.getBlock()) ? this.miningSpeed : 1.0F; + } else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) { + return _r1_16_5_EFFECTIVE_MATERIALS.contains(Material1_19_4.getMaterial(state)) ? this.miningSpeed : _r1_15_2_EFFECTIVE_BLOCKS.contains(state.getBlock()) ? this.miningSpeed : 1.0F; } else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) { - return viaFabricPlus$EFFECTIVE_MATERIALS.contains(state.getBlock()) || viaFabricPlus$EFFECTIVE_BLOCKS_1165.contains(state.getBlock()) ? this.miningSpeed : 1.0F; + return _r1_16_5_EFFECTIVE_MATERIALS.contains(Material1_19_4.getMaterial(state)) ? this.miningSpeed : _r1_16_5_EFFECTIVE_BLOCKS.contains(state.getBlock()) ? this.miningSpeed : 1.0F; } + return super.getMiningSpeedMultiplier(stack, state); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShearsItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShearsItem.java new file mode 100644 index 00000000..ccd3dba3 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShearsItem.java @@ -0,0 +1,41 @@ +package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; + +import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ShearsItem; +import net.minecraft.registry.tag.BlockTags; +import net.raphimc.vialoader.util.VersionEnum; +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; + +@Mixin(ShearsItem.class) +public abstract class MixinShearsItem extends Item { + + public MixinShearsItem(Settings settings) { + super(settings); + } + + @Inject(method = "isSuitableFor", at = @At("HEAD"), cancellable = true) + private void changeEffectiveBlocks(BlockState state, CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) { + cir.setReturnValue(state.isOf(Blocks.COBWEB)); + } + } + + @Inject(method = "getMiningSpeedMultiplier", at = @At("HEAD"), cancellable = true) + private void changeMiningSpeed(ItemStack stack, BlockState state, CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) { + if (!state.isOf(Blocks.COBWEB) && !state.isIn(BlockTags.LEAVES)) { + cir.setReturnValue(state.isIn(BlockTags.WOOL) ? 5.0F : super.getMiningSpeedMultiplier(stack, state)); + } else { + cir.setReturnValue(15.0F); + } + } + } + +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShovelItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShovelItem.java index 3f1f5420..eb473b88 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShovelItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShovelItem.java @@ -19,29 +19,59 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import com.google.common.collect.ImmutableSet; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import net.minecraft.item.ShovelItem; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.item.*; +import net.minecraft.registry.tag.TagKey; +import net.raphimc.vialoader.util.VersionEnum; 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.Redirect; import org.spongepowered.asm.mixin.injection.Slice; import java.util.Map; +import java.util.Set; @Mixin(ShovelItem.class) -public abstract class MixinShovelItem { +public abstract class MixinShovelItem extends MiningToolItem { - @Redirect(method = "useOnBlock", - at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 0), - slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/item/ShovelItem;PATH_STATES:Ljava/util/Map;"))) - private Object redirectUseOnBlock(Map map, Object grassBlock) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { - return null; - } else { - return map.get(grassBlock); + @Unique + private static final Set _b1_8_1_EFFECTIVE_BLOCKS = ImmutableSet.of(Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.SAND, Blocks.GRAVEL, Blocks.SNOW, Blocks.SNOW_BLOCK, Blocks.CLAY, Blocks.FARMLAND); + + @Unique + private static final Set _r1_16_5_EFFECTIVE_BLOCKS = ImmutableSet.of(Blocks.CLAY, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL, Blocks.FARMLAND, Blocks.GRASS_BLOCK, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.RED_SAND, Blocks.SNOW_BLOCK, Blocks.SNOW, Blocks.SOUL_SAND, Blocks.DIRT_PATH, Blocks.WHITE_CONCRETE_POWDER, Blocks.ORANGE_CONCRETE_POWDER, Blocks.MAGENTA_CONCRETE_POWDER, Blocks.LIGHT_BLUE_CONCRETE_POWDER, Blocks.YELLOW_CONCRETE_POWDER, Blocks.LIME_CONCRETE_POWDER, Blocks.PINK_CONCRETE_POWDER, Blocks.GRAY_CONCRETE_POWDER, Blocks.LIGHT_GRAY_CONCRETE_POWDER, Blocks.CYAN_CONCRETE_POWDER, Blocks.PURPLE_CONCRETE_POWDER, Blocks.BLUE_CONCRETE_POWDER, Blocks.BROWN_CONCRETE_POWDER, Blocks.GREEN_CONCRETE_POWDER, Blocks.RED_CONCRETE_POWDER, Blocks.BLACK_CONCRETE_POWDER, Blocks.SOUL_SOIL); + + protected MixinShovelItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey effectiveBlocks, Item.Settings settings) { + super(attackDamage, attackSpeed, material, effectiveBlocks, settings); + } + + @Redirect(method = "useOnBlock", slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/item/ShovelItem;PATH_STATES:Ljava/util/Map;")), at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 0, remap = false)) + private Object disablePathAction(Map instance, Object grassBlock) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) return null; + return instance.get(grassBlock); + } + + @Override + public boolean isSuitableFor(BlockState state) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) { + return state.isOf(Blocks.SNOW) || state.isOf(Blocks.SNOW_BLOCK); } + return super.isSuitableFor(state); + } + + @Override + public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) { + return _b1_8_1_EFFECTIVE_BLOCKS.contains(state.getBlock()) ? this.miningSpeed : 1.0F; + } else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) { + return _r1_16_5_EFFECTIVE_BLOCKS.contains(state.getBlock()) ? this.miningSpeed : 1.0F; + } + + return super.getMiningSpeedMultiplier(stack, state); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java index fa5b943d..f1caec0f 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java @@ -19,9 +19,9 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; -import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; @@ -31,7 +31,11 @@ import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.util.UseAction; import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; 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; @Mixin(SwordItem.class) public abstract class MixinSwordItem extends ToolItem { @@ -42,7 +46,7 @@ public abstract class MixinSwordItem extends ToolItem { @Override public TypedActionResult use(World world, PlayerEntity user, Hand hand) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { + if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.b1_8tob1_8_1, VersionEnum.r1_8)) { ItemStack itemStack = user.getStackInHand(hand); user.setCurrentHand(hand); return TypedActionResult.consume(itemStack); @@ -60,10 +64,17 @@ public abstract class MixinSwordItem extends ToolItem { @Override public int getMaxUseTime(ItemStack stack) { - if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) { + if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.b1_8tob1_8_1, VersionEnum.r1_8)) { return 72000; } return super.getMaxUseTime(stack); } + @Inject(method = "getMiningSpeedMultiplier", at = @At("HEAD"), cancellable = true) + private void changeMiningSpeed(ItemStack stack, BlockState state, CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) { + cir.setReturnValue(state.isOf(Blocks.COBWEB) ? 15.0F : 1.5F); + } + } + } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinScreen.java index e47df05c..098ece8f 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinScreen.java @@ -37,7 +37,7 @@ public abstract class MixinScreen { @Shadow @Nullable protected MinecraftClient client; - @Inject(method = "handleTextClick", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", shift = At.Shift.BEFORE, ordinal = 1), cancellable = true) + @Inject(method = "handleTextClick", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", shift = At.Shift.BEFORE, ordinal = 1, remap = false), cancellable = true) private void allowRunCommandAction(Style style, CallbackInfoReturnable cir) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19)) { this.client.player.networkHandler.sendChatMessage(SharedConstants.stripInvalidChars(style.getClickEvent().getValue())); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinMetadataRewriter1_15To1_14_4.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinMetadataRewriter1_15To1_14_4.java index 77ac998f..31c1c54e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinMetadataRewriter1_15To1_14_4.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinMetadataRewriter1_15To1_14_4.java @@ -34,7 +34,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.List; -@SuppressWarnings("DataFlowIssue") @Mixin(MetadataRewriter1_15To1_14_4.class) public abstract class MixinMetadataRewriter1_15To1_14_4 extends EntityRewriter { @@ -44,7 +43,7 @@ public abstract class MixinMetadataRewriter1_15To1_14_4 extends EntityRewriter metadatas, UserConnection connection, CallbackInfo ci) { - WolfHealthTracker.get().getHealthDataMap().put(entityId, (Float) metadata.getValue()); + WolfHealthTracker.get().setWolfHealth(entityId, metadata.value()); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java b/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java index 34e7b455..ec3972c1 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java @@ -178,7 +178,7 @@ public class ProtocolHack { return ((IClientConnection) handler.getConnection()).viaFabricPlus$getUserConnection(); } - return null; + throw new IllegalStateException("The player is not connected to a server"); } /** diff --git a/src/main/java/de/florianmichael/viafabricplus/settings/impl/ExperimentalSettings.java b/src/main/java/de/florianmichael/viafabricplus/settings/impl/ExperimentalSettings.java index 506a2e08..e35c0c6b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/impl/ExperimentalSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/impl/ExperimentalSettings.java @@ -28,7 +28,6 @@ public class ExperimentalSettings extends SettingGroup { public final BooleanSetting fixChunkBorders = new BooleanSetting(this, Text.translatable("experimental.viafabricplus.chunkborderfix"), true); public final BooleanSetting waterMovementEdgeDetection = new BooleanSetting(this, Text.translatable("experimental.viafabricplus.watermovement"), true); - public final BooleanSetting emulateBoatMovement = new BooleanSetting(this, Text.translatable("experimental.viafabricplus.boatmovement"), false); public ExperimentalSettings() { super(Text.translatable("settings.viafabricplus.experimental")); diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index 0292531c..d7d3c5d5 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -11,13 +11,14 @@ "base.connect.MixinClientLoginNetworkHandler", "base.integration.MixinAddServerScreen", "base.integration.MixinDebugHud", - "base.integration.MixinDownloadingTerrainScreenAndConnectScreen", + "base.integration.MixinDownloadingTerrainScreen", "base.integration.MixinMinecraftClient", "base.integration.MixinMultiplayerScreen", "base.integration.MixinMultiplayerServerListPinger_1", "base.integration.MixinMultiplayerServerListWidget_ServerEntry", "base.per_server_version.MixinConnectScreen_1", "base.per_server_version.MixinMultiplayerServerListPinger", + "base.per_server_version.MixinPerformanceLog", "base.per_server_version.MixinServerInfo", "compat.classic4j.MixinCCAuthenticationResponse", "compat.classic4j.MixinTextFieldWidget", @@ -27,11 +28,9 @@ "fixes.authlib.MixinKeyPairResponse", "fixes.authlib.MixinYggdrasilUserApiService", "fixes.minecraft.MixinClientPlayerInteractionManager", - "fixes.minecraft.MixinDrawContext", "fixes.minecraft.MixinFontStorage", "fixes.minecraft.MixinMinecraftClient", "fixes.minecraft.MixinPendingUpdateManager", - "fixes.minecraft.MixinPlayerEntityRenderer", "fixes.minecraft.MixinPlayerListEntry", "fixes.minecraft.MixinPlayerPublicKey_PublicKeyData", "fixes.minecraft.MixinProfileKeysImpl", @@ -45,24 +44,31 @@ "fixes.minecraft.block.MixinBambooBlock", "fixes.minecraft.block.MixinBedBlock", "fixes.minecraft.block.MixinBrewingStandBlock", + "fixes.minecraft.block.MixinCarpetBlock", "fixes.minecraft.block.MixinCauldronBlock", "fixes.minecraft.block.MixinChestBlock", "fixes.minecraft.block.MixinCropBlock", + "fixes.minecraft.block.MixinEnderChestBlock", "fixes.minecraft.block.MixinEndPortalBlock", "fixes.minecraft.block.MixinEndPortalFrameBlock", "fixes.minecraft.block.MixinFarmlandBlock", "fixes.minecraft.block.MixinFenceBlock", + "fixes.minecraft.block.MixinFenceGateBlock", "fixes.minecraft.block.MixinFireBlock", "fixes.minecraft.block.MixinFlowerbedBlock", "fixes.minecraft.block.MixinFlowerPotBlock", "fixes.minecraft.block.MixinHopperBlock", "fixes.minecraft.block.MixinLadderBlock", + "fixes.minecraft.block.MixinLeavesBlock", "fixes.minecraft.block.MixinLilyPadBlock", + "fixes.minecraft.block.MixinNoteBlock", "fixes.minecraft.block.MixinPaneBlock", + "fixes.minecraft.block.MixinPistonBlock", "fixes.minecraft.block.MixinPistonHeadBlock", "fixes.minecraft.block.MixinSnowBlock", "fixes.minecraft.block.MixinSoulSandBlock", "fixes.minecraft.block.MixinWallBlock", + "fixes.minecraft.entity.MixinAbstractClientPlayerEntity", "fixes.minecraft.entity.MixinAbstractDonkeyEntity", "fixes.minecraft.entity.MixinAnimalEntity", "fixes.minecraft.entity.MixinBipedEntityModel", @@ -81,6 +87,7 @@ "fixes.minecraft.entity.MixinOtherClientPlayerEntity", "fixes.minecraft.entity.MixinPiglinEntity", "fixes.minecraft.entity.MixinPlayerEntity", + "fixes.minecraft.entity.MixinPlayerEntityRenderer", "fixes.minecraft.entity.MixinSquidEntity", "fixes.minecraft.entity.MixinVexEntity", "fixes.minecraft.entity.MixinWolfEntity", @@ -89,6 +96,7 @@ "fixes.minecraft.item.MixinAxeItem", "fixes.minecraft.item.MixinBlockItem", "fixes.minecraft.item.MixinBrushItem", + "fixes.minecraft.item.MixinDrawContext", "fixes.minecraft.item.MixinEnderPearlItem", "fixes.minecraft.item.MixinEquipment", "fixes.minecraft.item.MixinFireworkRocketItem", @@ -167,12 +175,10 @@ "defaultRequire": 1 }, "mixins": [ - "base.per_server_version.MixinPerformanceLog", - "fixes.minecraft.block.MixinCarpetBlock", - "fixes.minecraft.block.MixinEnderChestBlock", - "fixes.minecraft.block.MixinFenceGateBlock", - "fixes.minecraft.block.MixinLeavesBlock", - "fixes.minecraft.block.MixinNoteBlock", - "fixes.minecraft.block.MixinPistonBlock" + "fixes.minecraft.entity.MixinBoatEntity", + "fixes.minecraft.entity.MixinSkeletonHorseEntity", + "fixes.minecraft.item.MixinArmorItem", + "fixes.minecraft.item.MixinBowItem", + "fixes.minecraft.item.MixinShearsItem" ] }