From 16c92741e0207b03c01da4668342d782933cdfdd Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Mon, 20 Feb 2023 01:04:09 +0100 Subject: [PATCH] started with adding codebase from Clamp/tarasande --- LICENSE | 18 + README.md | 3 + build.gradle | 6 + gradle.properties | 5 +- .../mixin/base/MixinClientConnection.java | 52 - .../injection/mixin/base/MixinMain.java | 17 - .../platform/PreNettyConstants.java | 7 - .../platform/ViaAprilFoolsPlatformImpl.java | 27 - .../platform/ViaLegacyPlatformImpl.java | 27 - .../EveryProtocolHandItemProvider.java | 20 - ...ryProtocolMovementTransmitterProvider.java | 20 - .../ViaFabricPlus.java} | 64 +- .../ItemReleaseVersionDefinition.java | 1288 +++++++++++++++++ .../definition/PackFormatsDefinition.java | 118 ++ .../c0_30/ClassicWorldHeightInjection.java | 178 +++ .../definition/v1_19_0/JsonHelper.java | 81 ++ .../v1_19_0/MessageMetadataModel.java | 4 + .../definition/v1_19_0/MessageSigner.java | 30 + .../model/SignatureUpdatableModel.java | 6 + .../v1_19_0/model/SignatureUpdaterModel.java | 6 + .../provider/CommandArgumentsProvider.java | 13 + .../v1_19_0/storage/AbstractChatSession.java | 35 + .../v1_19_0/storage/ChatSession1_19_0.java | 43 + .../definition/v1_19_2/MessageBodyModel.java | 55 + .../v1_19_2/MessageHeaderModel.java | 44 + .../v1_19_2/storage/ChatSession1_19_2.java | 32 + .../injection/access/IClientConnection.java | 6 + .../injection/access/IMinecraftClient.java | 7 + .../injection/access/IPacketWrapperImpl.java | 2 +- .../injection/access/IPublicKeyData.java | 10 + .../injection/access/IScreenHandler.java | 6 + .../mixin/base/MixinClientConnection.java | 74 + .../mixin/base/MixinClientConnection_1.java | 23 +- .../injection/mixin/base/MixinMain.java | 38 + .../mixin/fixes/MixinMinecraftClient.java | 149 ++ .../MixinPlayerPublicKey_PublicKeyData.java | 46 + .../mixin/fixes/MixinProfileKeysImpl.java | 40 + .../mixin/fixes/MixinServerAddress.java | 46 + .../MixinServerResourcePackProvider.java | 99 ++ ...MixinAbstractBlock_AbstractBlockState.java | 72 + .../mixin/fixes/block/MixinAnvilBlock.java | 60 + .../mixin/fixes/block/MixinBambooBlock.java | 44 + .../mixin/fixes/block/MixinBedBlock.java | 62 + .../mixin/fixes/block/MixinBlock.java | 59 + .../mixin/fixes/block/MixinBlockView.java | 44 + .../fixes/block/MixinBrewingStandBlock.java | 55 + .../mixin/fixes/block/MixinCauldronBlock.java | 60 + .../fixes/block/MixinEndPortalBlock.java | 71 + .../fixes/block/MixinEndPortalFrameBlock.java | 56 + .../mixin/fixes/block/MixinFarmlandBlock.java | 66 + .../mixin/fixes/block/MixinFenceBlock.java | 42 + .../mixin/fixes/block/MixinFireBlock.java | 47 + .../fixes/block/MixinFlowerPotBlock.java | 50 + .../mixin/fixes/block/MixinHopperBlock.java | 66 + .../mixin/fixes/block/MixinLadderBlock.java | 65 + .../mixin/fixes/block/MixinLightBlock.java | 43 + .../mixin/fixes/block/MixinLilyPadBlock.java | 51 + .../mixin/fixes/block/MixinPaneBlock.java | 102 ++ .../fixes/block/MixinPistonHeadBlock.java | 122 ++ .../mixin/fixes/block/MixinSnowBlock.java | 67 + .../mixin/fixes/block/MixinSoulSandBlock.java | 60 + .../fixes/block/MixinSugarCaneBlock.java | 45 + .../mixin/fixes/block/MixinWallBlock.java | 175 +++ .../mixin/fixes/input/MixinKeyboard.java | 59 + .../mixin/fixes/input/MixinKeyboardInput.java | 45 + .../mixin/fixes/input/MixinMouse.java | 48 + .../mixin/fixes/item/MixinAxeItem.java | 43 + .../mixin/fixes/item/MixinBlockItem.java | 69 + .../mixin/fixes/item/MixinEnderPearlItem.java | 46 + .../fixes/item/MixinFireworkRocketItem.java | 43 + .../fixes/item/MixinHeldItemRenderer.java | 60 + .../mixin/fixes/item/MixinHoeItem.java | 84 ++ .../fixes/item/MixinItemCooldownManager.java | 41 + .../item/MixinItemGroup_EntriesImpl.java | 43 + .../mixin/fixes/item/MixinItemGroups.java | 50 + .../fixes/item/MixinItemPlacementContext.java | 64 + .../mixin/fixes/item/MixinItemStack.java | 126 ++ .../mixin/fixes/item/MixinMiningToolItem.java | 58 + .../mixin/fixes/item/MixinPickaxeItem.java | 97 ++ .../mixin/fixes/item/MixinShovelItem.java | 60 + .../mixin/fixes/item/MixinSwordItem.java | 82 ++ .../fixes/packet/MixinPacketByteBuf.java | 42 + .../MixinUpdatePlayerAbilitiesC2SPacket.java | 62 + .../fixes/screen/MixinCommandBlockScreen.java | 72 + .../fixes/screen/MixinConnectScreen_1.java | 112 ++ .../screen/MixinDownloadingTerrainScreen.java | 94 ++ .../screen/MixinGameModeSelectionScreen.java | 44 + ...ModeSelectionScreen_GameModeSelection.java | 56 + .../fixes/screen/MixinJigsawBlockScreen.java | 87 ++ .../screen/MixinStructureBlockScreen_1.java | 59 + .../fixes/screen/hud/MixinBossBarHud_1.java | 40 + .../screen/merchant/MixinMerchantScreen.java | 68 + .../merchant/MixinMerchantScreenHandler.java | 54 + ...xinBrewingStandScreenHandler_FuelSlot.java | 50 + .../MixinPlayerScreenHandler.java | 75 + .../screenhandler/MixinScreenHandler.java | 66 + .../vialoadingbase/MixinCustomViaConfig.java | 2 +- .../viaversion/MixinPacketWrapperImpl.java | 4 +- .../platform/PreNettyConstants.java | 28 + .../viafabricplus/platform/ProtocolRange.java | 45 + .../platform/ViaAprilFoolsPlatformImpl.java | 48 + .../platform/ViaLegacyPlatformImpl.java | 48 + .../EveryProtocolHandItemProvider.java | 41 + ...ryProtocolMovementTransmitterProvider.java | 41 + .../translator/ItemTranslator.java | 25 +- .../viafabricplus/value/AbstractValue.java | 31 + .../viafabricplus/value/ValueHolder.java | 28 + .../value/impl/BooleanValue.java | 10 + .../value/impl/ProtocolSyncBooleanValue.java | 31 + .../{everyprotocol => viafabricplus}/icon.png | Bin src/main/resources/everyprotocol.mixins.json | 18 - src/main/resources/fabric.mod.json | 12 +- .../resources/viafabricplus.accesswidener | 8 + src/main/resources/viafabricplus.mixins.json | 80 + 114 files changed, 6716 insertions(+), 212 deletions(-) create mode 100644 LICENSE delete mode 100644 src/main/java/de/florianmichael/everyprotocol/injection/mixin/base/MixinClientConnection.java delete mode 100644 src/main/java/de/florianmichael/everyprotocol/injection/mixin/base/MixinMain.java delete mode 100644 src/main/java/de/florianmichael/everyprotocol/platform/PreNettyConstants.java delete mode 100644 src/main/java/de/florianmichael/everyprotocol/platform/ViaAprilFoolsPlatformImpl.java delete mode 100644 src/main/java/de/florianmichael/everyprotocol/platform/ViaLegacyPlatformImpl.java delete mode 100644 src/main/java/de/florianmichael/everyprotocol/provider/EveryProtocolHandItemProvider.java delete mode 100644 src/main/java/de/florianmichael/everyprotocol/provider/EveryProtocolMovementTransmitterProvider.java rename src/main/java/de/florianmichael/{everyprotocol/EveryProtocol.java => viafabricplus/ViaFabricPlus.java} (60%) create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/ItemReleaseVersionDefinition.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/PackFormatsDefinition.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/c0_30/ClassicWorldHeightInjection.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/JsonHelper.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/MessageMetadataModel.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/MessageSigner.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/model/SignatureUpdatableModel.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/model/SignatureUpdaterModel.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/provider/CommandArgumentsProvider.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/storage/AbstractChatSession.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/storage/ChatSession1_19_0.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/v1_19_2/MessageBodyModel.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/v1_19_2/MessageHeaderModel.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/definition/v1_19_2/storage/ChatSession1_19_2.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/access/IClientConnection.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/access/IMinecraftClient.java rename src/main/java/de/florianmichael/{everyprotocol => viafabricplus}/injection/access/IPacketWrapperImpl.java (78%) create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/access/IPublicKeyData.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/access/IScreenHandler.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinClientConnection.java rename src/main/java/de/florianmichael/{everyprotocol => viafabricplus}/injection/mixin/base/MixinClientConnection_1.java (58%) create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinMain.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinMinecraftClient.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinPlayerPublicKey_PublicKeyData.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinProfileKeysImpl.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinServerAddress.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinServerResourcePackProvider.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinAbstractBlock_AbstractBlockState.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinAnvilBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBambooBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBedBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBlockView.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBrewingStandBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinCauldronBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinEndPortalBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinEndPortalFrameBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFarmlandBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFenceBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFireBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFlowerPotBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinHopperBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinLadderBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinLightBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinLilyPadBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinPaneBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinPistonHeadBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinSnowBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinSoulSandBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinSugarCaneBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinWallBlock.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/input/MixinKeyboard.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/input/MixinKeyboardInput.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/input/MixinMouse.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinAxeItem.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinBlockItem.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinEnderPearlItem.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinFireworkRocketItem.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinHeldItemRenderer.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinHoeItem.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemCooldownManager.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemGroup_EntriesImpl.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemGroups.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemPlacementContext.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemStack.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinMiningToolItem.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinPickaxeItem.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinShovelItem.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinSwordItem.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/packet/MixinPacketByteBuf.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/packet/MixinUpdatePlayerAbilitiesC2SPacket.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinCommandBlockScreen.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinConnectScreen_1.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinDownloadingTerrainScreen.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinGameModeSelectionScreen.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinGameModeSelectionScreen_GameModeSelection.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinJigsawBlockScreen.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinStructureBlockScreen_1.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/hud/MixinBossBarHud_1.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/merchant/MixinMerchantScreen.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/merchant/MixinMerchantScreenHandler.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/screenhandler/MixinBrewingStandScreenHandler_FuelSlot.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/screenhandler/MixinPlayerScreenHandler.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/screenhandler/MixinScreenHandler.java rename src/main/java/de/florianmichael/{everyprotocol => viafabricplus}/injection/mixin/vialoadingbase/MixinCustomViaConfig.java (90%) rename src/main/java/de/florianmichael/{everyprotocol => viafabricplus}/injection/mixin/viaversion/MixinPacketWrapperImpl.java (83%) create mode 100644 src/main/java/de/florianmichael/viafabricplus/platform/PreNettyConstants.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/platform/ProtocolRange.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/platform/ViaAprilFoolsPlatformImpl.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/platform/ViaLegacyPlatformImpl.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/provider/EveryProtocolHandItemProvider.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/provider/EveryProtocolMovementTransmitterProvider.java rename src/main/java/de/florianmichael/{everyprotocol => viafabricplus}/translator/ItemTranslator.java (63%) create mode 100644 src/main/java/de/florianmichael/viafabricplus/value/AbstractValue.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/value/ValueHolder.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/value/impl/BooleanValue.java create mode 100644 src/main/java/de/florianmichael/viafabricplus/value/impl/ProtocolSyncBooleanValue.java rename src/main/resources/assets/{everyprotocol => viafabricplus}/icon.png (100%) delete mode 100644 src/main/resources/everyprotocol.mixins.json create mode 100644 src/main/resources/viafabricplus.accesswidener create mode 100644 src/main/resources/viafabricplus.mixins.json diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..29d8c027 --- /dev/null +++ b/LICENSE @@ -0,0 +1,18 @@ + +--FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + +This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), +any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this +file / project is prohibited. It requires in that use a written permission with official signature of the owner +"Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not +cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. +The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements +that have arisen, are arising or will arise from this project / file. + +Changelog: + v1.0: + Added License + v1.1: + Ownership withdrawn + v1.2: + Version-independent validity and automatic renewal diff --git a/README.md b/README.md index fdc67415..6ffe1596 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # ViaFabricPlus Clientside ViaVersion, ViaLegacy and ViaAprilFools implementation with clientside fixes for Fabric + +TODO: +[ ] ViaFabricPlus-Visual diff --git a/build.gradle b/build.gradle index fd8ac5c5..87e7e2b8 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,10 @@ repositories { } } +loom { + accessWidenerPath = file("src/main/resources/viafabricplus.accesswidener") +} + dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" @@ -34,6 +38,8 @@ dependencies { implementation "com.github.RaphiMC:ViaLegacy:${project.vialegacy_version}" implementation "com.github.RaphiMC:ViaAprilFools:${project.viaaprilfools_version}" + + implementation "net.lenni0451.mcstructs:text:${project.mcstructs_text_version}" } processResources { diff --git a/gradle.properties b/gradle.properties index 075bff57..03ded6af 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,8 @@ maven_group=de.florianmichael archives_base_name=every-protocol vialoadingbase_version=ad5fd83ad1 -viaversion_version=4.6.0-23w06a-SNAPSHOT -viabackwards_version=4.6.0-23w06a-SNAPSHOT +viaversion_version=4.6.0-23w07a-SNAPSHOT +viabackwards_version=4.6.0-23w07a-SNAPSHOT vialegacy_version=f451a8ffb2 viaaprilfools_version=e98bfb8aa5 +mcstructs_text_version=2.2.0 diff --git a/src/main/java/de/florianmichael/everyprotocol/injection/mixin/base/MixinClientConnection.java b/src/main/java/de/florianmichael/everyprotocol/injection/mixin/base/MixinClientConnection.java deleted file mode 100644 index aed0bedd..00000000 --- a/src/main/java/de/florianmichael/everyprotocol/injection/mixin/base/MixinClientConnection.java +++ /dev/null @@ -1,52 +0,0 @@ -package de.florianmichael.everyprotocol.injection.mixin.base; - -import de.florianmichael.everyprotocol.platform.PreNettyConstants; -import de.florianmichael.vialoadingbase.ViaLoadingBase; -import de.florianmichael.vialoadingbase.event.PipelineReorderEvent; -import io.netty.channel.Channel; -import net.minecraft.network.ClientConnection; -import net.minecraft.network.encryption.PacketDecryptor; -import net.minecraft.network.encryption.PacketEncryptor; -import net.raphimc.vialegacy.api.LegacyProtocolVersions; -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 javax.crypto.Cipher; - -@Mixin(ClientConnection.class) -public class MixinClientConnection { - - @Shadow private Channel channel; - - @Shadow private boolean encrypted; - @Unique - private Cipher vialegacy_decryptionCipher; - - @Unique - private Cipher vialegacy_encryptionCipher; - - @Inject(method = "setCompressionThreshold", at = @At("RETURN")) - private void reorderCompression(int compressionThreshold, boolean rejectBad, CallbackInfo ci) { - channel.pipeline().fireUserEventTriggered(new PipelineReorderEvent()); - } - - @Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true) - private void storeEncryptionCiphers(Cipher decryptionCipher, Cipher encryptionCipher, CallbackInfo ci) { - if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.r1_6_4)) { - ci.cancel(); - this.vialegacy_decryptionCipher = decryptionCipher; - this.vialegacy_encryptionCipher = encryptionCipher; - } - } - - @Unique - public void vialegacy_setupPreNettyEncryption() { - this.encrypted = true; - this.channel.pipeline().addBefore(PreNettyConstants.DECODER, "decrypt", new PacketDecryptor(this.vialegacy_decryptionCipher)); - this.channel.pipeline().addBefore(PreNettyConstants.ENCODER, "encrypt", new PacketEncryptor(this.vialegacy_encryptionCipher)); - } -} diff --git a/src/main/java/de/florianmichael/everyprotocol/injection/mixin/base/MixinMain.java b/src/main/java/de/florianmichael/everyprotocol/injection/mixin/base/MixinMain.java deleted file mode 100644 index b31c6d82..00000000 --- a/src/main/java/de/florianmichael/everyprotocol/injection/mixin/base/MixinMain.java +++ /dev/null @@ -1,17 +0,0 @@ -package de.florianmichael.everyprotocol.injection.mixin.base; - -import de.florianmichael.everyprotocol.EveryProtocol; -import net.minecraft.client.main.Main; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(Main.class) -public class MixinMain { - - @Inject(method = "main([Ljava/lang/String;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/crash/CrashReport;initCrashReport()V")) - private static void loadViaLoadingBase(CallbackInfo ci) { - EveryProtocol.getClassWrapper().create(); - } -} diff --git a/src/main/java/de/florianmichael/everyprotocol/platform/PreNettyConstants.java b/src/main/java/de/florianmichael/everyprotocol/platform/PreNettyConstants.java deleted file mode 100644 index dac554e4..00000000 --- a/src/main/java/de/florianmichael/everyprotocol/platform/PreNettyConstants.java +++ /dev/null @@ -1,7 +0,0 @@ -package de.florianmichael.everyprotocol.platform; - -public class PreNettyConstants { - - public static final String DECODER = "via-legacy-decoder"; - public static final String ENCODER = "via-legacy-encoder"; -} diff --git a/src/main/java/de/florianmichael/everyprotocol/platform/ViaAprilFoolsPlatformImpl.java b/src/main/java/de/florianmichael/everyprotocol/platform/ViaAprilFoolsPlatformImpl.java deleted file mode 100644 index bc93f603..00000000 --- a/src/main/java/de/florianmichael/everyprotocol/platform/ViaAprilFoolsPlatformImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package de.florianmichael.everyprotocol.platform; - -import com.viaversion.viaversion.api.Via; -import de.florianmichael.vialoadingbase.util.JLoggerToLog4j; -import net.raphimc.vialegacy.platform.ViaLegacyPlatform; -import org.apache.logging.log4j.LogManager; - -import java.io.File; -import java.util.logging.Logger; - -public class ViaAprilFoolsPlatformImpl implements ViaLegacyPlatform { - private static final Logger LOGGER = new JLoggerToLog4j(LogManager.getLogger("ViaAprilFools")); - - public ViaAprilFoolsPlatformImpl() { - this.init(this.getDataFolder()); - } - - @Override - public Logger getLogger() { - return LOGGER; - } - - @Override - public File getDataFolder() { - return Via.getPlatform().getDataFolder(); - } -} diff --git a/src/main/java/de/florianmichael/everyprotocol/platform/ViaLegacyPlatformImpl.java b/src/main/java/de/florianmichael/everyprotocol/platform/ViaLegacyPlatformImpl.java deleted file mode 100644 index 45c628cc..00000000 --- a/src/main/java/de/florianmichael/everyprotocol/platform/ViaLegacyPlatformImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package de.florianmichael.everyprotocol.platform; - -import com.viaversion.viaversion.api.Via; -import de.florianmichael.vialoadingbase.util.JLoggerToLog4j; -import net.raphimc.vialegacy.platform.ViaLegacyPlatform; -import org.apache.logging.log4j.LogManager; - -import java.io.File; -import java.util.logging.Logger; - -public class ViaLegacyPlatformImpl implements ViaLegacyPlatform { - private static final Logger LOGGER = new JLoggerToLog4j(LogManager.getLogger("ViaLegacy")); - - public ViaLegacyPlatformImpl() { - this.init(this.getDataFolder()); - } - - @Override - public Logger getLogger() { - return LOGGER; - } - - @Override - public File getDataFolder() { - return Via.getPlatform().getDataFolder(); - } -} diff --git a/src/main/java/de/florianmichael/everyprotocol/provider/EveryProtocolHandItemProvider.java b/src/main/java/de/florianmichael/everyprotocol/provider/EveryProtocolHandItemProvider.java deleted file mode 100644 index 82ad74e7..00000000 --- a/src/main/java/de/florianmichael/everyprotocol/provider/EveryProtocolHandItemProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.florianmichael.everyprotocol.provider; - -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.item.Item; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider; -import de.florianmichael.everyprotocol.translator.ItemTranslator; -import net.minecraft.item.ItemStack; - -public class EveryProtocolHandItemProvider extends HandItemProvider { - public static ItemStack lastUsedItem = null; - - @Override - public Item getHandItem(UserConnection info) { - if (lastUsedItem == null) { - return null; - } - return ItemTranslator.minecraftToViaVersion(info, lastUsedItem, ProtocolVersion.v1_8.getVersion()); - } -} diff --git a/src/main/java/de/florianmichael/everyprotocol/provider/EveryProtocolMovementTransmitterProvider.java b/src/main/java/de/florianmichael/everyprotocol/provider/EveryProtocolMovementTransmitterProvider.java deleted file mode 100644 index 74677759..00000000 --- a/src/main/java/de/florianmichael/everyprotocol/provider/EveryProtocolMovementTransmitterProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.florianmichael.everyprotocol.provider; - -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; - -public class EveryProtocolMovementTransmitterProvider extends MovementTransmitterProvider { - - @Override - public Object getFlyingPacket() { - return null; - } - - @Override - public Object getGroundPacket() { - return null; - } - - @Override - public void sendPlayer(UserConnection userConnection) {} -} diff --git a/src/main/java/de/florianmichael/everyprotocol/EveryProtocol.java b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java similarity index 60% rename from src/main/java/de/florianmichael/everyprotocol/EveryProtocol.java rename to src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java index c100b897..e96ef46d 100644 --- a/src/main/java/de/florianmichael/everyprotocol/EveryProtocol.java +++ b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java @@ -1,33 +1,66 @@ -package de.florianmichael.everyprotocol; +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ +package de.florianmichael.viafabricplus; + +import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.libs.gson.JsonArray; import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider; import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; -import de.florianmichael.everyprotocol.platform.ViaAprilFoolsPlatformImpl; -import de.florianmichael.everyprotocol.platform.ViaLegacyPlatformImpl; -import de.florianmichael.everyprotocol.provider.EveryProtocolHandItemProvider; -import de.florianmichael.everyprotocol.provider.EveryProtocolMovementTransmitterProvider; +import de.florianmichael.viafabricplus.definition.ItemReleaseVersionDefinition; +import de.florianmichael.viafabricplus.definition.PackFormatsDefinition; +import de.florianmichael.viafabricplus.platform.ViaAprilFoolsPlatformImpl; +import de.florianmichael.viafabricplus.platform.ViaLegacyPlatformImpl; +import de.florianmichael.viafabricplus.provider.EveryProtocolHandItemProvider; +import de.florianmichael.viafabricplus.provider.EveryProtocolMovementTransmitterProvider; +import de.florianmichael.viafabricplus.value.ValueHolder; import de.florianmichael.vialoadingbase.ViaLoadingBase; import de.florianmichael.vialoadingbase.api.SubPlatform; import io.netty.channel.DefaultEventLoop; +import io.netty.util.AttributeKey; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; import net.fabricmc.loader.api.metadata.Person; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; +import net.minecraft.item.Item; +import net.minecraft.registry.Registries; import net.raphimc.viaaprilfools.api.AprilFoolsProtocolVersion; import net.raphimc.vialegacy.api.LegacyProtocolVersions; +import java.util.ArrayList; import java.util.List; -public class EveryProtocol { - private final static EveryProtocol self = new EveryProtocol(); +public class ViaFabricPlus { + public static final AttributeKey LOCAL_USER_CONNECTION = AttributeKey.newInstance("via-version-user-connection"); + + private final static ViaFabricPlus self = new ViaFabricPlus(); private final SubPlatform SUB_PLATFORM_VIA_LEGACY = new SubPlatform("ViaLegacy", () -> true, ViaLegacyPlatformImpl::new, protocolVersions -> protocolVersions.addAll(LegacyProtocolVersions.PROTOCOLS)); private final SubPlatform SUB_PLATFORM_VIA_APRIL_FOOLS = new SubPlatform("ViaAprilFools", () -> true, ViaAprilFoolsPlatformImpl::new, this::invokeAprilFoolsProtocols); + private final List availableItemsInTargetVersion = new ArrayList<>(); + protected void invokeAprilFoolsProtocols(List origin) { final int v1_14Index = origin.indexOf(ProtocolVersion.v1_14); final int v1_16Index = origin.indexOf(ProtocolVersion.v1_16); @@ -81,11 +114,24 @@ public class EveryProtocol { providers.use(MovementTransmitterProvider.class, new EveryProtocolMovementTransmitterProvider()); providers.use(HandItemProvider.class, new EveryProtocolHandItemProvider()); }); + builder = builder.protocolReloader(protocolVersion -> { + availableItemsInTargetVersion.clear(); + availableItemsInTargetVersion.addAll(Registries.ITEM.stream().filter(item -> ItemReleaseVersionDefinition.contains(item, protocolVersion)).toList()); + }); + + ValueHolder.setup(); + + PackFormatsDefinition.load(); + ItemReleaseVersionDefinition.load(); builder.build(); } - public static EveryProtocol getClassWrapper() { - return EveryProtocol.self; + public List getAvailableItemsInTargetVersion() { + return availableItemsInTargetVersion; + } + + public static ViaFabricPlus getClassWrapper() { + return ViaFabricPlus.self; } } diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/ItemReleaseVersionDefinition.java b/src/main/java/de/florianmichael/viafabricplus/definition/ItemReleaseVersionDefinition.java new file mode 100644 index 00000000..c1677faf --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/ItemReleaseVersionDefinition.java @@ -0,0 +1,1288 @@ +package de.florianmichael.viafabricplus.definition; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.platform.ProtocolRange; +import de.florianmichael.vialoadingbase.api.version.ComparableProtocolVersion; +import net.minecraft.item.Item; +import net.minecraft.item.Items; +import net.raphimc.vialegacy.api.LegacyProtocolVersions; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Assigns to each Minecraft version the version in which the respective block or item was added + * + * @copyright FlorianMichael as Jesse - 2020-2023 + */ +public class ItemReleaseVersionDefinition { + private final static Map itemMap = new HashMap<>(); + + public static boolean contains(final Item item, final ComparableProtocolVersion version) { + if (!itemMap.containsKey(item)) return false; + + return Arrays.stream(itemMap.get(item)).anyMatch(protocolRange -> protocolRange.contains(version)); + } + + public static void load() { + register(Items.IRON_GOLEM_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_19_3)); + register(Items.SNOW_GOLEM_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_19_3)); + + register(Items.ACACIA_CHEST_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.ALLAY_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.BIRCH_CHEST_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.TADPOLE_BUCKET, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.DARK_OAK_CHEST_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.DISC_FRAGMENT_5, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.ECHO_SHARD, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.FROG_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.FROGSPAWN, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.GOAT_HORN, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.JUNGLE_CHEST_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_CHEST_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_BUTTON, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_DOOR, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_FENCE, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_FENCE_GATE, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_LEAVES, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_LOG, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_PLANKS, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_PRESSURE_PLATE, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_PROPAGULE, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_ROOTS, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_SIGN, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_TRAPDOOR, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MANGROVE_WOOD, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MUD, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MUD_BRICK_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MUD_BRICK_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MUD_BRICK_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MUD_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MUDDY_MANGROVE_ROOTS, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.MUSIC_DISC_5, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.OAK_CHEST_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.OCHRE_FROGLIGHT, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.PACKED_MUD, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.PEARLESCENT_FROGLIGHT, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.RECOVERY_COMPASS, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.REINFORCED_DEEPSLATE, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.SCULK, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.SCULK_CATALYST, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.SCULK_SHRIEKER, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.SCULK_VEIN, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.SPRUCE_CHEST_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.STRIPPED_MANGROVE_LOG, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.STRIPPED_MANGROVE_WOOD, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.TADPOLE_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.VERDANT_FROGLIGHT, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + register(Items.WARDEN_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_19)); + + register(Items.MUSIC_DISC_OTHERSIDE, ProtocolRange.andNewer(ProtocolVersion.v1_18)); + + register(Items.AMETHYST_SHARD, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.SMALL_AMETHYST_BUD, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.MEDIUM_AMETHYST_BUD, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.LARGE_AMETHYST_BUD, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.AMETHYST_CLUSTER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.AXOLOTL_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.AZALEA, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.AZALEA_LEAVES, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.BIG_DRIPLEAF, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.AMETHYST_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.COPPER_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.RAW_COPPER_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.RAW_GOLD_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.RAW_IRON_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.AXOLOTL_BUCKET, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.BUDDING_AMETHYST, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.BUNDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.CALCITE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.BLACK_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.BLUE_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.BROWN_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.CYAN_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.GRAY_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.GREEN_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.LIGHT_BLUE_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.LIGHT_GRAY_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.LIME_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.MAGENTA_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.ORANGE_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.PINK_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.PURPLE_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.RED_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WHITE_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.YELLOW_CANDLE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.CHISELED_DEEPSLATE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.COBBLED_DEEPSLATE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.COBBLED_DEEPSLATE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.COBBLED_DEEPSLATE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.COBBLED_DEEPSLATE_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.COPPER_INGOT, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.COPPER_ORE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.CRACKED_DEEPSLATE_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.CRACKED_DEEPSLATE_TILES, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.CUT_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.CUT_COPPER_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.CUT_COPPER_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_BRICK_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_BRICK_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_BRICK_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_COAL_ORE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_COPPER_ORE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_DIAMOND_ORE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_EMERALD_ORE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_GOLD_ORE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_IRON_ORE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_LAPIS_ORE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_REDSTONE_ORE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_TILE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_TILE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_TILE_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DEEPSLATE_TILES, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.DRIPSTONE_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.EXPOSED_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.EXPOSED_CUT_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.EXPOSED_CUT_COPPER_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.EXPOSED_CUT_COPPER_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.FLOWERING_AZALEA, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.FLOWERING_AZALEA_LEAVES, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.GLOW_BERRIES, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.GLOW_INK_SAC, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.GLOW_ITEM_FRAME, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.GLOW_LICHEN, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.GLOW_SQUID_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.GOAT_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.HANGING_ROOTS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.INFESTED_DEEPSLATE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.LIGHT, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.LIGHTNING_ROD, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.MOSS_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.MOSS_CARPET, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.OXIDIZED_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.OXIDIZED_CUT_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.OXIDIZED_CUT_COPPER_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.OXIDIZED_CUT_COPPER_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.POINTED_DRIPSTONE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.POLISHED_DEEPSLATE, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.POLISHED_DEEPSLATE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.POLISHED_DEEPSLATE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.POLISHED_DEEPSLATE_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.POWDER_SNOW_BUCKET, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.RAW_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.RAW_GOLD, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.RAW_IRON, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.ROOTED_DIRT, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.SCULK_SENSOR, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.SMALL_DRIPLEAF, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.SMOOTH_BASALT, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.SPORE_BLOSSOM, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.SPYGLASS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.TINTED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.TUFF, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_COPPER_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_CUT_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_CUT_COPPER_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_CUT_COPPER_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_EXPOSED_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_EXPOSED_CUT_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_EXPOSED_CUT_COPPER_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_EXPOSED_CUT_COPPER_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_OXIDIZED_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_OXIDIZED_CUT_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_OXIDIZED_CUT_COPPER_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_OXIDIZED_CUT_COPPER_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_WEATHERED_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_WEATHERED_CUT_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_WEATHERED_CUT_COPPER_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WAXED_WEATHERED_CUT_COPPER_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WEATHERED_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WEATHERED_CUT_COPPER, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WEATHERED_CUT_COPPER_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + register(Items.WEATHERED_CUT_COPPER_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_17)); + + register(Items.ANCIENT_DEBRIS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.PIGLIN_BANNER_PATTERN, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.BASALT, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.BLACKSTONE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.BLACKSTONE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.BLACKSTONE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.BLACKSTONE_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHERITE_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CHAIN, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CHISELED_NETHER_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CHISELED_POLISHED_BLACKSTONE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRACKED_NETHER_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRACKED_POLISHED_BLACKSTONE_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_BUTTON, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_DOOR, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_FENCE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_FENCE_GATE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_FUNGUS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_HYPHAE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_NYLIUM, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_PLANKS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_PRESSURE_PLATE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_ROOTS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_SIGN, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_STEM, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRIMSON_TRAPDOOR, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.CRYING_OBSIDIAN, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.GILDED_BLACKSTONE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.HOGLIN_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.LODESTONE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.MUSIC_DISC_PIGSTEP, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHER_GOLD_ORE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHER_SPROUTS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHERITE_AXE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHERITE_BOOTS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHERITE_CHESTPLATE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHERITE_HELMET, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHERITE_HOE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHERITE_INGOT, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHERITE_LEGGINGS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHERITE_PICKAXE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHERITE_SCRAP, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHERITE_SHOVEL, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.NETHERITE_SWORD, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.PIGLIN_BRUTE_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.PIGLIN_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.POLISHED_BASALT, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.POLISHED_BLACKSTONE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.POLISHED_BLACKSTONE_BRICK_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.POLISHED_BLACKSTONE_BRICK_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.POLISHED_BLACKSTONE_BRICK_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.POLISHED_BLACKSTONE_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.POLISHED_BLACKSTONE_BUTTON, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.POLISHED_BLACKSTONE_PRESSURE_PLATE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.POLISHED_BLACKSTONE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.POLISHED_BLACKSTONE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.POLISHED_BLACKSTONE_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.QUARTZ_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.RESPAWN_ANCHOR, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.SHROOMLIGHT, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.SOUL_CAMPFIRE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.SOUL_LANTERN, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.SOUL_SOIL, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.SOUL_TORCH, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.STRIDER_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.STRIPPED_CRIMSON_HYPHAE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.STRIPPED_CRIMSON_STEM, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.STRIPPED_WARPED_HYPHAE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.STRIPPED_WARPED_STEM, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.TARGET, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.TWISTING_VINES, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_BUTTON, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_DOOR, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_FENCE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_FENCE_GATE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_FUNGUS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_FUNGUS_ON_A_STICK, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_HYPHAE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_NYLIUM, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_PLANKS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_PRESSURE_PLATE, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_ROOTS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_SIGN, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_STEM, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_TRAPDOOR, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WARPED_WART_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.WEEPING_VINES, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.ZOGLIN_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + register(Items.ZOMBIFIED_PIGLIN_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_16)); + + register(Items.BEE_NEST, ProtocolRange.andNewer(ProtocolVersion.v1_15)); + register(Items.BEE_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_15)); + register(Items.BEEHIVE, ProtocolRange.andNewer(ProtocolVersion.v1_15)); + register(Items.HONEY_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_15)); + register(Items.HONEY_BOTTLE, ProtocolRange.andNewer(ProtocolVersion.v1_15)); + register(Items.HONEYCOMB, ProtocolRange.andNewer(ProtocolVersion.v1_15)); + register(Items.HONEYCOMB_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_15)); + + register(Items.ACACIA_SIGN, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.ANDESITE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.ANDESITE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.ANDESITE_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.BAMBOO, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.FLOWER_BANNER_PATTERN, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.CREEPER_BANNER_PATTERN, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SKULL_BANNER_PATTERN, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.GLOBE_BANNER_PATTERN, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.MOJANG_BANNER_PATTERN, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.BARREL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.BELL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.BIRCH_SIGN, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.BLACK_DYE, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.BLAST_FURNACE, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.BLUE_DYE, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.BRICK_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.BROWN_DYE, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.CAMPFIRE, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.CARTOGRAPHY_TABLE, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.CAT_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.COMPOSTER, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.CORNFLOWER, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.CROSSBOW, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.CUT_RED_SANDSTONE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.CUT_SANDSTONE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.DARK_OAK_SIGN, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.DIORITE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.DIORITE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.DIORITE_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.END_STONE_BRICK_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.END_STONE_BRICK_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.END_STONE_BRICK_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.FLETCHING_TABLE, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.FOX_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.GRANITE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.GRANITE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.GRANITE_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.GRINDSTONE, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.JIGSAW, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.JUNGLE_SIGN, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.LANTERN, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.LEATHER_HORSE_ARMOR, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.LECTERN, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.LILY_OF_THE_VALLEY, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.LOOM, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.MOSSY_COBBLESTONE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.MOSSY_COBBLESTONE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.MOSSY_STONE_BRICK_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.MOSSY_STONE_BRICK_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.MOSSY_STONE_BRICK_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.NETHER_BRICK_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.PANDA_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.PILLAGER_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.POLISHED_ANDESITE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.POLISHED_ANDESITE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.POLISHED_DIORITE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.POLISHED_DIORITE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.POLISHED_GRANITE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.POLISHED_GRANITE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.PRISMARINE_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.RAVAGER_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.RED_NETHER_BRICK_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.RED_NETHER_BRICK_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.RED_NETHER_BRICK_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.RED_SANDSTONE_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SANDSTONE_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SCAFFOLDING, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SMITHING_TABLE, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SMOKER, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SMOOTH_QUARTZ_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SMOOTH_QUARTZ_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SMOOTH_RED_SANDSTONE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SMOOTH_RED_SANDSTONE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SMOOTH_SANDSTONE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SMOOTH_SANDSTONE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SPRUCE_SIGN, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.STONE_BRICK_WALL, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.STONE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.STONE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.STONECUTTER, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SUSPICIOUS_STEW, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.SWEET_BERRIES, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.TRADER_LLAMA_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.WANDERING_TRADER_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.WHITE_DYE, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + register(Items.WITHER_ROSE, ProtocolRange.andNewer(ProtocolVersion.v1_14)); + + register(Items.ACACIA_PRESSURE_PLATE, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.ACACIA_TRAPDOOR, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.ACACIA_WOOD, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.BIRCH_PRESSURE_PLATE, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.BIRCH_TRAPDOOR, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.BLACK_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.BLUE_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.BLUE_ICE, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.BRAIN_CORAL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.BRAIN_CORAL_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.BRAIN_CORAL_FAN, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.BROWN_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.BUBBLE_CORAL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.BUBBLE_CORAL_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.BUBBLE_CORAL_FAN, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.COD_BUCKET, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.PUFFERFISH_BUCKET, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.SALMON_BUCKET, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.TROPICAL_FISH_BUCKET, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.CARVED_PUMPKIN, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.CHIPPED_ANVIL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.COD_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.CONDUIT, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.CYAN_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DAMAGED_ANVIL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DARK_OAK_PRESSURE_PLATE, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DARK_OAK_TRAPDOOR, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DARK_OAK_WOOD, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DARK_PRISMARINE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DARK_PRISMARINE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_BRAIN_CORAL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_BRAIN_CORAL_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_BRAIN_CORAL_FAN, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_BUBBLE_CORAL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_BUBBLE_CORAL_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_BUBBLE_CORAL_FAN, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_FIRE_CORAL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_FIRE_CORAL_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_FIRE_CORAL_FAN, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_HORN_CORAL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_HORN_CORAL_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_HORN_CORAL_FAN, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_TUBE_CORAL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_TUBE_CORAL_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEAD_TUBE_CORAL_FAN, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DEBUG_STICK, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DOLPHIN_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DRIED_KELP, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DRIED_KELP_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.DROWNED_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.FIRE_CORAL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.FIRE_CORAL_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.FIRE_CORAL_FAN, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.GRAY_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.GREEN_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.HEART_OF_THE_SEA, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.HORN_CORAL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.HORN_CORAL_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.HORN_CORAL_FAN, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.JUNGLE_PRESSURE_PLATE, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.JUNGLE_TRAPDOOR, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.KELP, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.LIGHT_BLUE_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.LIGHT_GRAY_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.LIME_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.MAGENTA_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.MUSHROOM_STEM, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.NAUTILUS_SHELL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.ORANGE_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + //register(Items.PETRIFIED_OAK_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_13)); it's right, but the item exists in another form before, so it's actually wrong + register(Items.PHANTOM_MEMBRANE, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.PHANTOM_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.PINK_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.PRISMARINE_BRICK_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.PRISMARINE_BRICK_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.PRISMARINE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.PRISMARINE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.PUFFERFISH_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.PURPLE_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.SALMON_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.SCUTE, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.SEA_PICKLE, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.SEAGRASS, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.SMOOTH_QUARTZ, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.SMOOTH_RED_SANDSTONE, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.SMOOTH_SANDSTONE, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.SMOOTH_STONE, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.SPRUCE_PRESSURE_PLATE, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.SPRUCE_TRAPDOOR, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.STRIPPED_ACACIA_LOG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.STRIPPED_ACACIA_WOOD, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.STRIPPED_BIRCH_LOG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.STRIPPED_BIRCH_WOOD, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.STRIPPED_DARK_OAK_LOG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.STRIPPED_DARK_OAK_WOOD, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.STRIPPED_JUNGLE_LOG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.STRIPPED_JUNGLE_WOOD, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.STRIPPED_OAK_LOG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.STRIPPED_OAK_WOOD, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.STRIPPED_SPRUCE_LOG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.STRIPPED_SPRUCE_WOOD, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.TRIDENT, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.TROPICAL_FISH_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.TUBE_CORAL, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.TUBE_CORAL_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.TUBE_CORAL_FAN, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.TURTLE_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.TURTLE_HELMET, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.TURTLE_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.WHITE_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + register(Items.YELLOW_BED, ProtocolRange.andNewer(ProtocolVersion.v1_13)); + + register(Items.BLACK_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.BLACK_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.BLACK_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.BLUE_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.BLUE_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.BLUE_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.BROWN_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.BROWN_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.BROWN_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.CYAN_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.CYAN_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.CYAN_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.GRAY_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.GRAY_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.GRAY_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.GREEN_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.GREEN_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.GREEN_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.KNOWLEDGE_BOOK, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.LIGHT_BLUE_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.LIGHT_BLUE_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.LIGHT_BLUE_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.LIGHT_GRAY_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.LIGHT_GRAY_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.LIGHT_GRAY_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.LIME_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.LIME_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.LIME_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.MAGENTA_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.MAGENTA_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.MAGENTA_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.ORANGE_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.ORANGE_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.ORANGE_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.PARROT_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.PINK_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.PINK_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.PINK_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.PURPLE_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.PURPLE_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.PURPLE_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.RED_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.RED_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.RED_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.WHITE_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.WHITE_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.WHITE_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.YELLOW_CONCRETE, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.YELLOW_CONCRETE_POWDER, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + register(Items.YELLOW_GLAZED_TERRACOTTA, ProtocolRange.andNewer(ProtocolVersion.v1_12)); + + register(Items.BLACK_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.BLUE_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.BROWN_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.CYAN_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.DONKEY_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.EVOKER_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.GRAY_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.GREEN_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.HUSK_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.IRON_NUGGET, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.LIGHT_BLUE_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.LIGHT_GRAY_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.LIME_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.LLAMA_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.MAGENTA_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.FILLED_MAP, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.MULE_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.OBSERVER, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.ORANGE_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.PINK_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.PURPLE_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.RED_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.SHULKER_SHELL, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.SKELETON_HORSE_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.STRAY_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.TOTEM_OF_UNDYING, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.VEX_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.VINDICATOR_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.WHITE_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.WITHER_SKELETON_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.YELLOW_SHULKER_BOX, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.ZOMBIE_HORSE_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + register(Items.ZOMBIE_VILLAGER_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_11)); + + register(Items.BONE_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_10)); + register(Items.MAGMA_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_10), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + register(Items.NETHER_WART_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_10)); + register(Items.POLAR_BEAR_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_10)); + register(Items.RED_NETHER_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_10)); + register(Items.STRUCTURE_VOID, ProtocolRange.andNewer(ProtocolVersion.v1_10)); + + register(Items.ACACIA_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.BEETROOT, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.BEETROOT_SEEDS, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.BEETROOT_SOUP, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.BIRCH_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.CHAIN_COMMAND_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.CHORUS_FLOWER, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.CHORUS_FRUIT, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.CHORUS_PLANT, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.DARK_OAK_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.DIRT_PATH, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.DRAGON_HEAD, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.DRAGON_BREATH, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.ELYTRA, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.END_CRYSTAL, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.END_ROD, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.END_STONE_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.JUNGLE_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.LINGERING_POTION, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.POPPED_CHORUS_FRUIT, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.PURPUR_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.PURPUR_PILLAR, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.PURPUR_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.PURPUR_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.REPEATING_COMMAND_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.SHIELD, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.SHULKER_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.SPECTRAL_ARROW, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.SPRUCE_BOAT, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.STRUCTURE_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + register(Items.TIPPED_ARROW, ProtocolRange.andNewer(ProtocolVersion.v1_9)); + + register(Items.ACACIA_DOOR, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.ACACIA_FENCE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.ACACIA_FENCE_GATE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.ANDESITE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.ARMOR_STAND, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.BLACK_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.BLUE_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.BROWN_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.CYAN_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.GRAY_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.GREEN_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.LIGHT_BLUE_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.LIGHT_GRAY_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.LIME_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.MAGENTA_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.ORANGE_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.PINK_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.PURPLE_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.RED_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.WHITE_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.YELLOW_BANNER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.BARRIER, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.BIRCH_DOOR, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.BIRCH_FENCE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.BIRCH_FENCE_GATE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.CHISELED_RED_SANDSTONE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.COARSE_DIRT, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.COOKED_MUTTON, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.COOKED_RABBIT, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.CREEPER_HEAD, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.CUT_RED_SANDSTONE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.DARK_OAK_DOOR, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.DARK_OAK_FENCE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.DARK_OAK_FENCE_GATE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.DARK_PRISMARINE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.DIORITE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.ELDER_GUARDIAN_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.ENDERMITE_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.GRANITE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.GUARDIAN_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.IRON_TRAPDOOR, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.JUNGLE_DOOR, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.JUNGLE_FENCE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.JUNGLE_FENCE_GATE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.PLAYER_HEAD, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.POLISHED_ANDESITE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.POLISHED_DIORITE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.POLISHED_GRANITE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.PRISMARINE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.PRISMARINE_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.PRISMARINE_CRYSTALS, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.PRISMARINE_SHARD, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.RABBIT_HIDE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.RABBIT_SPAWN_EGG, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.RABBIT_STEW, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.RABBIT_FOOT, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.MUTTON, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.RABBIT, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.RED_SANDSTONE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.RED_SANDSTONE_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.RED_SANDSTONE_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.SEA_LANTERN, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.SKELETON_SKULL, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.SLIME_BLOCK, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.SPONGE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.SPRUCE_DOOR, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.SPRUCE_FENCE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.SPRUCE_FENCE_GATE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.WET_SPONGE, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.WITHER_SKELETON_SKULL, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + register(Items.ZOMBIE_HEAD, ProtocolRange.andNewer(ProtocolVersion.v1_8)); + + register(Items.ACACIA_BUTTON, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.ACACIA_LEAVES, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.ACACIA_LOG, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.ACACIA_PLANKS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.ACACIA_SAPLING, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.ACACIA_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.ACACIA_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.ALLIUM, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.AZURE_BLUET, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.BIRCH_BUTTON, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.BLACK_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.BLACK_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.BLUE_ORCHID, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.BLUE_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.BLUE_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.BROWN_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.BROWN_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.CYAN_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.CYAN_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.DARK_OAK_BUTTON, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.DARK_OAK_LEAVES, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.DARK_OAK_LOG, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.DARK_OAK_PLANKS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.DARK_OAK_SAPLING, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.DARK_OAK_SLAB, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.DARK_OAK_STAIRS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.GRAY_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.GRAY_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.GREEN_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.GREEN_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.INFESTED_CHISELED_STONE_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.INFESTED_CRACKED_STONE_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.INFESTED_MOSSY_STONE_BRICKS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.JUNGLE_BUTTON, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.LARGE_FERN, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.LIGHT_BLUE_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.LIGHT_BLUE_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.LIGHT_GRAY_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.LIGHT_GRAY_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.LILAC, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.LIME_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.LIME_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.MAGENTA_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.MAGENTA_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.COMMAND_BLOCK_MINECART, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.ORANGE_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.ORANGE_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.ORANGE_TULIP, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.OXEYE_DAISY, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.PACKED_ICE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.PEONY, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.PINK_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.PINK_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.PINK_TULIP, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.PODZOL, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.PUFFERFISH, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.PURPLE_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.PURPLE_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.SALMON, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.RED_SAND, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.RED_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.RED_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.RED_TULIP, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.ROSE_BUSH, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.SPRUCE_BUTTON, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.SUNFLOWER, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.TALL_GRASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.TROPICAL_FISH, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.WHITE_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.WHITE_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.WHITE_TULIP, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.YELLOW_STAINED_GLASS, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.YELLOW_STAINED_GLASS_PANE, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + register(Items.COOKED_SALMON, ProtocolRange.andNewer(ProtocolVersion.v1_7_1)); + + register(Items.BLACK_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.BLACK_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.COAL_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.BLUE_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.BLUE_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.BROWN_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.BROWN_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.CYAN_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.CYAN_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.DIAMOND_HORSE_ARMOR, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.GOLDEN_HORSE_ARMOR, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.GRAY_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.GRAY_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.GREEN_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.GREEN_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.HAY_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.HORSE_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.IRON_HORSE_ARMOR, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.LEAD, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.LIGHT_BLUE_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.LIGHT_BLUE_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.LIGHT_GRAY_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.LIGHT_GRAY_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.LIME_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.LIME_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.MAGENTA_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.MAGENTA_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.NAME_TAG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.ORANGE_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.ORANGE_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.PINK_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.PINK_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.PURPLE_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.PURPLE_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.RED_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.RED_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.WHITE_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.WHITE_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.YELLOW_CARPET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + register(Items.YELLOW_TERRACOTTA, ProtocolRange.andNewer(LegacyProtocolVersions.r1_6_1)); + + register(Items.ACTIVATOR_RAIL, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.QUARTZ_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.REDSTONE_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.CHISELED_QUARTZ_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.DAYLIGHT_DETECTOR, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.DROPPER, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.HEAVY_WEIGHTED_PRESSURE_PLATE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.HOPPER, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.LIGHT_WEIGHTED_PRESSURE_PLATE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.HOPPER_MINECART, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.TNT_MINECART, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.NETHER_BRICK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.QUARTZ, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.NETHER_QUARTZ_ORE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.QUARTZ_PILLAR, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + register(Items.QUARTZ_SLAB, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.QUARTZ_STAIRS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.COMPARATOR, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + register(Items.TRAPPED_CHEST, ProtocolRange.andNewer(LegacyProtocolVersions.r1_5tor1_5_1)); + + register(Items.ANVIL, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.BAKED_POTATO, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.BAT_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.BEACON, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.CARROT, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.CARROT_ON_A_STICK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.COBBLESTONE_WALL, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.COMMAND_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.MAP, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.ENCHANTED_BOOK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.FIREWORK_ROCKET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.FIREWORK_STAR, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.FLOWER_POT, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.GOLDEN_CARROT, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.ITEM_FRAME, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.MOSSY_COBBLESTONE_WALL, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.NETHER_BRICK_SLAB, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.NETHER_STAR, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.OAK_BUTTON, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.POISONOUS_POTATO, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.POTATO, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.PUMPKIN_PIE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + register(Items.WITCH_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + // "[The disc was] made available in survival" Is this the release in which it was added or made available? + register(Items.MUSIC_DISC_WAIT, ProtocolRange.andNewer(LegacyProtocolVersions.r1_4_2)); + + register(Items.BIRCH_PLANKS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.BIRCH_SLAB, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.BIRCH_STAIRS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.BIRCH_WOOD, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.EMERALD_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.WRITABLE_BOOK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.COCOA_BEANS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.EMERALD, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.EMERALD_ORE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.ENCHANTED_GOLDEN_APPLE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.ENDER_CHEST, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.JUNGLE_PLANKS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.JUNGLE_SLAB, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.JUNGLE_STAIRS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.JUNGLE_WOOD, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.OAK_WOOD, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.SANDSTONE_STAIRS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + register(Items.SPRUCE_PLANKS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.SPRUCE_SLAB, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.SPRUCE_STAIRS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.SPRUCE_WOOD, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.TRIPWIRE_HOOK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + register(Items.WRITTEN_BOOK, ProtocolRange.andNewer(LegacyProtocolVersions.r1_3_1tor1_3_2)); + + register(Items.CHISELED_STONE_BRICKS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_2_1tor1_2_3)); + register(Items.FIRE_CHARGE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_2_1tor1_2_3)); + register(Items.JUNGLE_LEAVES, ProtocolRange.andNewer(LegacyProtocolVersions.r1_2_1tor1_2_3)); + register(Items.JUNGLE_LOG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_2_1tor1_2_3)); + register(Items.JUNGLE_SAPLING, ProtocolRange.andNewer(LegacyProtocolVersions.r1_2_1tor1_2_3)); + register(Items.OCELOT_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_2_1tor1_2_3)); + register(Items.CHISELED_SANDSTONE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_2_1tor1_2_3)); + register(Items.CUT_SANDSTONE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_2_1tor1_2_3)); + register(Items.REDSTONE_LAMP, ProtocolRange.andNewer(LegacyProtocolVersions.r1_2_1tor1_2_3)); + register(Items.EXPERIENCE_BOTTLE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_2_1tor1_2_3)); + + register(Items.BLAZE_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.CAVE_SPIDER_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.CHICKEN_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.COW_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.CREEPER_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.ENDERMAN_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.GHAST_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.MAGMA_CUBE_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.MOOSHROOM_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.PIG_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.SHEEP_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.SILVERFISH_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.SKELETON_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.SLIME_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.SPIDER_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.SQUID_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.VILLAGER_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.WOLF_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.ZOMBIFIED_PIGLIN_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + register(Items.ZOMBIE_SPAWN_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_1)); + + register(Items.GHAST_TEAR, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.BLAZE_ROD, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.NETHER_WART, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.GOLD_NUGGET, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.GLASS_BOTTLE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.POTION, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.SPLASH_POTION, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.SPIDER_EYE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.FERMENTED_SPIDER_EYE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.BLAZE_POWDER, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.MAGMA_CREAM, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.GLISTERING_MELON_SLICE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.ENDER_EYE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.MUSIC_DISC_11, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.MUSIC_DISC_BLOCKS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.MUSIC_DISC_CHIRP, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.MUSIC_DISC_FAR, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.MUSIC_DISC_MALL, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.MUSIC_DISC_MELLOHI, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.MUSIC_DISC_STAL, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.MUSIC_DISC_STRAD, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.MUSIC_DISC_WARD, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.BREWING_STAND, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.ENCHANTING_TABLE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.NETHER_BRICKS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.NETHER_BRICK_FENCE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.NETHER_BRICK_STAIRS, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.END_PORTAL_FRAME, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.END_STONE, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.DRAGON_EGG, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.CAULDRON, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + + // b1.9-pre1 + register(Items.MYCELIUM, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + register(Items.LILY_PAD, ProtocolRange.andNewer(LegacyProtocolVersions.r1_0_0tor1_0_1)); + + register(Items.STONE_BRICKS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + register(Items.MOSSY_STONE_BRICKS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.CRACKED_STONE_BRICKS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.INFESTED_STONE_BRICKS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.INFESTED_MOSSY_STONE_BRICKS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.INFESTED_CRACKED_STONE_BRICKS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.INFESTED_STONE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.BRICK_SLAB, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.BROWN_MUSHROOM_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.RED_MUSHROOM_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.MUSHROOM_STEM, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.MELON, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.MELON_SEEDS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.PUMPKIN_SEEDS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.IRON_BARS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.GLASS_PANE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.OAK_FENCE_GATE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.BRICK_STAIRS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.STONE_BRICK_STAIRS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.CHICKEN, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.COOKED_CHICKEN, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.BEEF, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.COOKED_BEEF, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.ENDER_PEARL, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.MELON_SLICE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.ROTTEN_FLESH, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.VINE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.INFESTED_COBBLESTONE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + register(Items.STONE_BRICK_SLAB, ProtocolRange.andNewer(LegacyProtocolVersions.b1_8tob1_8_1)); + + register(Items.PISTON, ProtocolRange.andNewer(LegacyProtocolVersions.b1_7tob1_7_3)); + register(Items.STICKY_PISTON, ProtocolRange.andNewer(LegacyProtocolVersions.b1_7tob1_7_3)); + register(Items.SHEARS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_7tob1_7_3)); + + register(Items.DEAD_BUSH, ProtocolRange.andNewer(LegacyProtocolVersions.b1_6tob1_6_6)); + register(Items.GRASS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_6tob1_6_6)); + register(Items.FERN, ProtocolRange.andNewer(LegacyProtocolVersions.b1_6tob1_6_6)); + register(Items.OAK_TRAPDOOR, ProtocolRange.andNewer(LegacyProtocolVersions.b1_6tob1_6_6)); + register(Items.MAP, ProtocolRange.andNewer(LegacyProtocolVersions.b1_6tob1_6_6)); + + register(Items.BIRCH_SAPLING, ProtocolRange.andNewer(LegacyProtocolVersions.b1_5tob1_5_2)); + register(Items.COBWEB, ProtocolRange.andNewer(LegacyProtocolVersions.b1_5tob1_5_2)); + register(Items.DETECTOR_RAIL, ProtocolRange.andNewer(LegacyProtocolVersions.b1_5tob1_5_2)); + register(Items.POWERED_RAIL, ProtocolRange.andNewer(LegacyProtocolVersions.b1_5tob1_5_2)); + register(Items.SPRUCE_SAPLING, ProtocolRange.andNewer(LegacyProtocolVersions.b1_5tob1_5_2)); + + register(Items.TRAPPED_CHEST, ProtocolRange.andNewer(LegacyProtocolVersions.b1_4tob1_4_1)); + register(Items.COOKIE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_4tob1_4_1)); + + register(Items.RED_BED, ProtocolRange.andNewer(LegacyProtocolVersions.b1_3tob1_3_1)); + register(Items.REPEATER, ProtocolRange.andNewer(LegacyProtocolVersions.b1_3tob1_3_1)); + register(Items.COBBLESTONE_SLAB, ProtocolRange.andNewer(LegacyProtocolVersions.b1_3tob1_3_1), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + register(Items.OAK_SLAB, ProtocolRange.andNewer(LegacyProtocolVersions.b1_3tob1_3_1)); + register(Items.SANDSTONE_SLAB, ProtocolRange.andNewer(LegacyProtocolVersions.b1_3tob1_3_1)); + + register(Items.CAKE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.DISPENSER, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.LAPIS_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.LAPIS_ORE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.NOTE_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.SANDSTONE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.SPRUCE_LOG, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.BIRCH_LOG, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.SPRUCE_LEAVES, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.BIRCH_LEAVES, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.BONE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.BONE_MEAL, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.LAPIS_LAZULI, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.COCOA_BEANS, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.INK_SAC, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.CHARCOAL, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.SUGAR, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.WHITE_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.ORANGE_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.MAGENTA_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.LIGHT_BLUE_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.YELLOW_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.LIME_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.PINK_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.GRAY_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.LIGHT_GRAY_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.CYAN_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.PURPLE_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.BLUE_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.BROWN_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.GREEN_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.RED_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + register(Items.BLACK_DYE, ProtocolRange.andNewer(LegacyProtocolVersions.b1_2_0tob1_2_2)); + + register(Items.NETHERRACK, ProtocolRange.andNewer(LegacyProtocolVersions.a1_2_0toa1_2_1_1)); + register(Items.SOUL_SAND, ProtocolRange.andNewer(LegacyProtocolVersions.a1_2_0toa1_2_1_1)); + register(Items.GLOWSTONE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_2_0toa1_2_1_1)); + register(Items.CARVED_PUMPKIN, ProtocolRange.andNewer(LegacyProtocolVersions.a1_2_0toa1_2_1_1)); + register(Items.JACK_O_LANTERN, ProtocolRange.andNewer(LegacyProtocolVersions.a1_2_0toa1_2_1_1)); + register(Items.CLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.a1_2_0toa1_2_1_1)); + register(Items.GLOWSTONE_DUST, ProtocolRange.andNewer(LegacyProtocolVersions.a1_2_0toa1_2_1_1)); + register(Items.COOKED_COD, ProtocolRange.andNewer(LegacyProtocolVersions.a1_2_0toa1_2_1_1)); + register(Items.COD, ProtocolRange.andNewer(LegacyProtocolVersions.a1_2_0toa1_2_1_1)); + register(Items.PUMPKIN, ProtocolRange.andNewer(LegacyProtocolVersions.a1_2_0toa1_2_1_1)); + + register(Items.FISHING_ROD, ProtocolRange.andNewer(LegacyProtocolVersions.a1_1_0toa1_1_2_1)); + register(Items.COMPASS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_1_0toa1_1_2_1)); + + // Indev with former 20100223 (it's not known) + register(Items.PAINTING, ProtocolRange.andNewer(LegacyProtocolVersions.a1_1_0toa1_1_2_1)); + + register(Items.OAK_FENCE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_17toa1_0_17_4)); + + // a1.0.14 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.JUKEBOX, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.EGG, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.MUSIC_DISC_13, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.MUSIC_DISC_CAT, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.CHEST_MINECART, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.FURNACE_MINECART, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // a1.0.11 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.SUGAR_CANE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.CLAY, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.PAPER, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.BOOK, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.CLAY_BALL, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.SLIME_BALL, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.BRICK, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // a1.0.8 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.LEATHER, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.MILK_BUCKET, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // a1.0.6 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.CACTUS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.OAK_BOAT, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // a1.0.5 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.SNOW_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.SNOWBALL, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // a1.0.4 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.ICE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + register(Items.SNOW, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + + // a1.0.1 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.IRON_DOOR, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.LEVER, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.REDSTONE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.REDSTONE_ORE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.REDSTONE_TORCH, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.STONE_BUTTON, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.OAK_PRESSURE_PLATE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.STONE_PRESSURE_PLATE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Infdev 20100629 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.COBBLESTONE_STAIRS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.OAK_STAIRS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Infdev 20100625-2 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.SPAWNER, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.SADDLE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Infdev 20100624 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.RAIL, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.OAK_DOOR, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.MINECART, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Infdev 20100615 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.BUCKET, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.WATER_BUCKET, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.LAVA_BUCKET, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Infdev 20100607 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.OAK_SIGN, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.LADDER, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Infdev 20100227-1 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.GOLDEN_APPLE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Infdev 20100219 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.FURNACE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.FLINT, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.PORKCHOP, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.COOKED_PORKCHOP, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Infdev 20100212-1 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.CHAINMAIL_HELMET, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.CHAINMAIL_CHESTPLATE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.CHAINMAIL_LEGGINGS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.CHAINMAIL_BOOTS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_HELMET, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_CHESTPLATE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_LEGGINGS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_BOOTS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.GOLDEN_HELMET, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.GOLDEN_CHESTPLATE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.GOLDEN_LEGGINGS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.GOLDEN_BOOTS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.DIAMOND_HELMET, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.DIAMOND_CHESTPLATE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.DIAMOND_LEGGINGS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.DIAMOND_BOOTS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Infdev 20100206 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.FARMLAND, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.WHEAT_SEEDS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.BREAD, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.STONE_HOE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.WOODEN_HOE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_HOE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.GOLDEN_HOE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.DIAMOND_HOE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.WHEAT, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Infdev 0.31 20100130 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.CRAFTING_TABLE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.GOLDEN_SWORD, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.GOLDEN_AXE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.GOLDEN_PICKAXE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.GOLDEN_SHOVEL, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.BOWL, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.MUSHROOM_STEW, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.GUNPOWDER, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.STRING, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.FEATHER, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Infdev 0.31 20100129 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.STICK, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Indev 0.31 20100128 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.DIAMOND_ORE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.DIAMOND_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.COAL, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.DIAMOND, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.GOLD_INGOT, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_INGOT, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.WOODEN_SWORD, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.WOODEN_AXE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.WOODEN_PICKAXE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.WOODEN_SHOVEL, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.STONE_SWORD, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.STONE_AXE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.STONE_PICKAXE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.STONE_SHOVEL, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.DIAMOND_SWORD, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.DIAMOND_AXE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.DIAMOND_PICKAXE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.DIAMOND_SHOVEL, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Indev 0.31 20091231-2 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.IRON_SHOVEL, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_SWORD, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_AXE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_PICKAXE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_HELMET, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_CHESTPLATE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_LEGGINGS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.IRON_BOOTS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.LEATHER_HELMET, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.LEATHER_CHESTPLATE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.LEATHER_LEGGINGS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.LEATHER_BOOTS, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.APPLE, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Indev 0.31 20100124-1 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.CHEST, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Indev 0.31 20100122 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.BOW, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.ARROW, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Indev 0.31 20100110 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.FLINT_AND_STEEL, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Indev 0.31 20091223-2 (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.TORCH, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.STONE_SLAB, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + // Cave game tech test? I literally have no idea + register(Items.GRASS_BLOCK, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + register(Items.BEDROCK, ProtocolRange.andNewer(LegacyProtocolVersions.a1_0_15)); + + register(Items.TNT, ProtocolRange.andNewer(LegacyProtocolVersions.c0_28toc0_30)); + register(Items.OBSIDIAN, ProtocolRange.andNewer(LegacyProtocolVersions.c0_28toc0_30)); + + // 0.26 SURVIVAL TEST (doesn't have multiplayer, so we assign it to the next multiplayer version) + register(Items.IRON_ORE, ProtocolRange.andNewer(LegacyProtocolVersions.c0_28toc0_30)); + register(Items.GOLD_ORE, ProtocolRange.andNewer(LegacyProtocolVersions.c0_28toc0_30)); + register(Items.COAL_ORE, ProtocolRange.andNewer(LegacyProtocolVersions.c0_28toc0_30)); + register(Items.MOSSY_COBBLESTONE, ProtocolRange.andNewer(LegacyProtocolVersions.c0_28toc0_30)); + register(Items.BOOKSHELF, ProtocolRange.andNewer(LegacyProtocolVersions.c0_28toc0_30)); + register(Items.BRICKS, ProtocolRange.andNewer(LegacyProtocolVersions.c0_28toc0_30)); + + + register(Items.WHITE_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.ORANGE_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.MAGENTA_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.LIGHT_BLUE_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.YELLOW_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.LIME_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.PINK_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + register(Items.GRAY_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.LIGHT_GRAY_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.CYAN_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + register(Items.PURPLE_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.BLUE_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + register(Items.BROWN_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + register(Items.GREEN_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + register(Items.RED_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.BLACK_WOOL, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.SMOOTH_STONE_SLAB, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.POPPY, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.DANDELION, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.RED_MUSHROOM, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27)); + register(Items.BROWN_MUSHROOM, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_20ac0_27), ProtocolRange.singleton(LegacyProtocolVersions.c0_30cpe)); + + register(Items.SPONGE, ProtocolRange.andNewer(LegacyProtocolVersions.c0_0_19a_06)); + } + + private static void register(final Item item, final ProtocolRange range) { + itemMap.put(item, new ProtocolRange[]{range}); + } + + private static void register(final Item item, final ProtocolRange... ranges) { + itemMap.put(item, ranges); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/PackFormatsDefinition.java b/src/main/java/de/florianmichael/viafabricplus/definition/PackFormatsDefinition.java new file mode 100644 index 00000000..d1ded1b5 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/PackFormatsDefinition.java @@ -0,0 +1,118 @@ +package de.florianmichael.viafabricplus.definition; + +import com.mojang.bridge.game.PackType; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.GameVersion; +import net.minecraft.SaveVersion; +import net.minecraft.SharedConstants; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +public class PackFormatsDefinition { + private final static Map protocolMap = new HashMap<>(); + + public static void load() { + registerVersion(ProtocolVersion.v1_19_3, 12, "1.19.3"); + registerVersion(ProtocolVersion.v1_19_1, 9, "1.19.2"); + registerVersion(ProtocolVersion.v1_19, 9, "1.19"); + registerVersion(ProtocolVersion.v1_18_2, 8, "1.18.2"); + registerVersion(ProtocolVersion.v1_18, 8, "1.18"); + registerVersion(ProtocolVersion.v1_17_1, 7, "1.17.1"); + registerVersion(ProtocolVersion.v1_17, 7, "1.17"); + registerVersion(ProtocolVersion.v1_16_4, 6, "1.16.5"); + registerVersion(ProtocolVersion.v1_16_3, 6, "1.16.3"); + registerVersion(ProtocolVersion.v1_16_2, 6, "1.16.2"); + registerVersion(ProtocolVersion.v1_16_1, 5, "1.16.1"); + registerVersion(ProtocolVersion.v1_16, 5, "1.16"); + registerVersion(ProtocolVersion.v1_15_2, 5, "1.15.2"); + registerVersion(ProtocolVersion.v1_15_1, 5, "1.15.1"); + registerVersion(ProtocolVersion.v1_15, 5, "1.15"); + registerVersion(ProtocolVersion.v1_14_4, 4, "1.14.4"); + registerVersion(ProtocolVersion.v1_14_3, 4, "1.14.3"); + registerVersion(ProtocolVersion.v1_14_2, 4, "1.14.2", "1.14.2 / f647ba8dc371474797bee24b2b312ff4"); + registerVersion(ProtocolVersion.v1_14_1, 4, "1.14.1", "1.14.1 / a8f78b0d43c74598a199d6d80cda413f"); + registerVersion(ProtocolVersion.v1_14, 4, "1.14", "1.14 / 5dac5567e13e46bdb0c1d90aa8d8b3f7"); + registerVersion(ProtocolVersion.v1_13_2, 4, "1.13.2"); // ids weren't sent over the http headers back then, why care... + registerVersion(ProtocolVersion.v1_13_1, 4, "1.13.1"); + registerVersion(ProtocolVersion.v1_13, 4, "1.13"); + registerVersion(ProtocolVersion.v1_12_2, 3, "1.12.2"); + registerVersion(ProtocolVersion.v1_12_1, 3, "1.12.1"); + registerVersion(ProtocolVersion.v1_12, 3, "1.12"); + registerVersion(ProtocolVersion.v1_11_1, 3, "1.11.2"); + registerVersion(ProtocolVersion.v1_11, 3, "1.11"); + registerVersion(ProtocolVersion.v1_10, 2, "1.10.2"); + registerVersion(ProtocolVersion.v1_9_3, 2, "1.9.4"); + registerVersion(ProtocolVersion.v1_9_2, 2, "1.9.2"); + registerVersion(ProtocolVersion.v1_9_1, 2, "1.9.1"); + registerVersion(ProtocolVersion.v1_9, 2, "1.9"); + registerVersion(ProtocolVersion.v1_8, 1, "1.8.9"); + registerVersion(ProtocolVersion.v1_7_6, 1, "1.7.10"); + registerVersion(ProtocolVersion.v1_7_1, 1, "1.7.5"); + } + + public static void checkOutdated(final int nativeVersion) { + if (!protocolMap.containsKey(nativeVersion)) + throw new RuntimeException("The current version has no pack format registered"); + + final GameVersion gameVersion = protocolMap.get(nativeVersion); + if (!gameVersion.getName().equals(SharedConstants.getGameVersion().getName()) || + !gameVersion.getId().equals(SharedConstants.getGameVersion().getId()) || + gameVersion.getPackVersion(PackType.RESOURCE) != SharedConstants.getGameVersion().getPackVersion(PackType.RESOURCE)) + throw new RuntimeException("The current version has no pack format registered"); + } + + public static GameVersion current() { + final int targetVersion = ViaLoadingBase.getTargetVersion().getOriginalVersion(); + if (!protocolMap.containsKey(targetVersion)) return SharedConstants.getGameVersion(); + return protocolMap.get(targetVersion); + } + + private static void registerVersion(final ProtocolVersion version, final int packFormat, final String name) { + registerVersion(version, packFormat, name, name); + } + + private static void registerVersion(final ProtocolVersion version, final int packFormat, final String name, final String id) { + protocolMap.put(version.getVersion(), new GameVersion() { + @Override + public SaveVersion getSaveVersion() { + return null; + } + + @Override + public String getId() { + return id; + } + + @Override + public String getName() { + return name; + } + + @Override + public int getProtocolVersion() { + return version.getVersion(); + } + + @Override + public int getPackVersion(PackType packType) { + if (packType == PackType.RESOURCE) { + return packFormat; + } + throw new UnsupportedOperationException(); + } + + @Override + public Date getBuildTime() { + return null; + } + + @Override + public boolean isStable() { + return true; + } + }); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/c0_30/ClassicWorldHeightInjection.java b/src/main/java/de/florianmichael/viafabricplus/definition/c0_30/ClassicWorldHeightInjection.java new file mode 100644 index 00000000..1ef47101 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/c0_30/ClassicWorldHeightInjection.java @@ -0,0 +1,178 @@ +package de.florianmichael.viafabricplus.definition.c0_30; + +import com.viaversion.viaversion.api.Via; +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.chunks.Chunk; +import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; +import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; +import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.raphimc.vialegacy.api.LegacyProtocolVersions; +import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.model.ClassicLevel; +import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicWorldHeightProvider; +import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storage.ClassicLevelStorage; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.List; + +@SuppressWarnings("DataFlowIssue") +public class ClassicWorldHeightInjection { + + public static PacketHandler handleJoinGame(final PacketHandler parentRemapper) { + return new PacketHandlers() { + @Override + public void register() { + handler(wrapper -> { + parentRemapper.handle(wrapper); + if (wrapper.isCancelled()) return; + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.c0_28toc0_30)) { + for (Tag dimension : wrapper.get(Type.NBT, 0).get("minecraft:dimension_type").get("value")) { + changeDimensionTagHeight(wrapper.user(), ((CompoundTag) dimension).get("element")); + } + changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NBT, 1)); + } + }); + } + }; + } + + public static PacketHandler handleRespawn(final PacketHandler parentRemapper) { + return new PacketHandlers() { + @Override + public void register() { + handler(wrapper -> { + parentRemapper.handle(wrapper); + if (wrapper.isCancelled()) return; + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.c0_28toc0_30)) { + changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NBT, 0)); + } + }); + } + }; + } + + public static PacketHandler handleChunkData(final PacketHandler parentRemapper) { + return new PacketHandlers() { + @Override + public void register() { + handler(wrapper -> { + parentRemapper.handle(wrapper); + if (wrapper.isCancelled()) return; + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.c0_28toc0_30)) { + wrapper.resetReader(); + final Chunk chunk = wrapper.read(new Chunk1_17Type(16)); + wrapper.write(new Chunk1_17Type(chunk.getSections().length), chunk); + + final ClassicWorldHeightProvider heightProvider = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class); + if (chunk.getSections().length < heightProvider.getMaxChunkSectionCount(wrapper.user())) { // Increase available sections to match new world height + final ChunkSection[] newArray = new ChunkSection[heightProvider.getMaxChunkSectionCount(wrapper.user())]; + System.arraycopy(chunk.getSections(), 0, newArray, 0, chunk.getSections().length); + chunk.setSections(newArray); + } + + final BitSet chunkMask = new BitSet(); + for (int i = 0; i < chunk.getSections().length; i++) { + if (chunk.getSections()[i] != null) chunkMask.set(i); + } + chunk.setChunkMask(chunkMask); + + final int[] newBiomeData = new int[chunk.getSections().length * 4 * 4 * 4]; + System.arraycopy(chunk.getBiomeData(), 0, newBiomeData, 0, chunk.getBiomeData().length); + for (int i = 64; i < chunk.getSections().length * 4; i++) { // copy top layer of old biome data all the way to max world height + System.arraycopy(chunk.getBiomeData(), chunk.getBiomeData().length - 16, newBiomeData, i * 16, 16); + } + chunk.setBiomeData(newBiomeData); + + chunk.setHeightMap(new CompoundTag()); // rip heightmap :( + } + }); + } + }; + } + + public static PacketHandler handleUpdateLight(final PacketHandler parentRemapper) { + final PacketHandler classicLightHandler = new PacketHandlers() { + @Override + public void register() { + map(Type.VAR_INT); // x + map(Type.VAR_INT); // y + map(Type.BOOLEAN); // trust edges + handler(wrapper -> { + wrapper.read(Type.VAR_INT); // sky light mask + wrapper.read(Type.VAR_INT); // block light mask + final int emptySkyLightMask = wrapper.read(Type.VAR_INT); // empty sky light mask + final int emptyBlockLightMask = wrapper.read(Type.VAR_INT); // empty block light mask + + final ClassicLevel level = wrapper.user().get(ClassicLevelStorage.class).getClassicLevel(); + final ClassicWorldHeightProvider heightProvider = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class); + + int sectionYCount = level.getSizeY() >> 4; + if (level.getSizeY() % 16 != 0) sectionYCount++; + if (sectionYCount > heightProvider.getMaxChunkSectionCount(wrapper.user())) { + sectionYCount = heightProvider.getMaxChunkSectionCount(wrapper.user()); + } + + final List lightArrays = new ArrayList<>(); + while (wrapper.isReadable(Type.BYTE_ARRAY_PRIMITIVE, 0)) { + lightArrays.add(wrapper.read(Type.BYTE_ARRAY_PRIMITIVE)); + } + + int skyLightCount = 16; + int blockLightCount = sectionYCount; + if (lightArrays.size() == 18) { + blockLightCount = 0; + } else if (lightArrays.size() == sectionYCount + sectionYCount + 2) { + skyLightCount = sectionYCount; + } + skyLightCount += 2; // Chunk below 0 and above 255 + + final BitSet skyLightMask = new BitSet(); + final BitSet blockLightMask = new BitSet(); + skyLightMask.set(0, skyLightCount); + blockLightMask.set(0, blockLightCount); + + wrapper.write(Type.LONG_ARRAY_PRIMITIVE, skyLightMask.toLongArray()); + wrapper.write(Type.LONG_ARRAY_PRIMITIVE, blockLightMask.toLongArray()); + wrapper.write(Type.LONG_ARRAY_PRIMITIVE, new long[emptySkyLightMask]); + wrapper.write(Type.LONG_ARRAY_PRIMITIVE, new long[emptyBlockLightMask]); + + wrapper.write(Type.VAR_INT, skyLightCount); + for (int i = 0; i < skyLightCount; i++) { + wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, lightArrays.remove(0)); + } + wrapper.write(Type.VAR_INT, blockLightCount); + for (int i = 0; i < blockLightCount; i++) { + wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, lightArrays.remove(0)); + } + }); + } + }; + + return new PacketHandlers() { + @Override + public void register() { + handler(wrapper -> { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.c0_28toc0_30)) { + classicLightHandler.handle(wrapper); + } else { + parentRemapper.handle(wrapper); + } + }); + } + }; + } + + private static void changeDimensionTagHeight(final UserConnection user, final CompoundTag tag) { + tag.put("height", new IntTag(Via.getManager().getProviders().get(ClassicWorldHeightProvider.class).getMaxChunkSectionCount(user) << 4)); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/JsonHelper.java b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/JsonHelper.java new file mode 100644 index 00000000..7bc5718a --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/JsonHelper.java @@ -0,0 +1,81 @@ +package de.florianmichael.viafabricplus.definition.v1_19_0; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; +import com.google.gson.stream.JsonWriter; +import org.jetbrains.annotations.Nullable; + +import java.io.IOException; +import java.io.StringWriter; +import java.util.*; + +public class JsonHelper { + + public static String toSortedString(JsonElement json) { + StringWriter stringWriter = new StringWriter(); + JsonWriter jsonWriter = new JsonWriter(stringWriter); + + try { + writeSorted(jsonWriter, json, Comparator.naturalOrder()); + } catch (IOException var4) { + throw new AssertionError(var4); + } + + return stringWriter.toString(); + } + + public static void writeSorted(JsonWriter writer, @Nullable JsonElement json, @Nullable Comparator comparator) throws IOException { + if (json != null && !json.isJsonNull()) { + if (json.isJsonPrimitive()) { + JsonPrimitive jsonPrimitive = json.getAsJsonPrimitive(); + if (jsonPrimitive.isNumber()) { + writer.value(jsonPrimitive.getAsNumber()); + } else if (jsonPrimitive.isBoolean()) { + writer.value(jsonPrimitive.getAsBoolean()); + } else { + writer.value(jsonPrimitive.getAsString()); + } + } else { + Iterator var5; + if (json.isJsonArray()) { + writer.beginArray(); + var5 = json.getAsJsonArray().iterator(); + + while(var5.hasNext()) { + JsonElement jsonElement = (JsonElement)var5.next(); + writeSorted(writer, jsonElement, comparator); + } + + writer.endArray(); + } else { + if (!json.isJsonObject()) { + throw new IllegalArgumentException("Couldn't write " + json.getClass()); + } + + writer.beginObject(); + var5 = sort(json.getAsJsonObject().entrySet(), comparator).iterator(); + + while(var5.hasNext()) { + Map.Entry entry = (Map.Entry)var5.next(); + writer.name((String)entry.getKey()); + writeSorted(writer, (JsonElement)entry.getValue(), comparator); + } + + writer.endObject(); + } + } + } else { + writer.nullValue(); + } + } + + private static Collection> sort(Collection> entries, @Nullable Comparator comparator) { + if (comparator == null) { + return entries; + } else { + List> list = new ArrayList(entries); + list.sort(Map.Entry.comparingByKey(comparator)); + return list; + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/MessageMetadataModel.java b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/MessageMetadataModel.java new file mode 100644 index 00000000..b5265108 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/MessageMetadataModel.java @@ -0,0 +1,4 @@ +package de.florianmichael.viafabricplus.definition.v1_19_0; + +public record MessageMetadataModel(String plain, long timestamp, long salt) { +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/MessageSigner.java b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/MessageSigner.java new file mode 100644 index 00000000..3b6c9f3a --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/MessageSigner.java @@ -0,0 +1,30 @@ +package de.florianmichael.viafabricplus.definition.v1_19_0; + +import de.florianmichael.viafabricplus.definition.v1_19_0.model.SignatureUpdatableModel; + +import java.security.*; + +public interface MessageSigner { + + byte[] sign(final SignatureUpdatableModel signer); + + static MessageSigner create(final PrivateKey privateKey, final String algorithm) { + return signer -> { + try { + final Signature signature = Signature.getInstance(algorithm); + signature.initSign(privateKey); + + signer.update(data -> { + try { + signature.update(data); + } catch (SignatureException e) { + throw new RuntimeException(e); + } + }); + return signature.sign(); + } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) { + throw new IllegalStateException("Failed to sign message", e); + } + }; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/model/SignatureUpdatableModel.java b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/model/SignatureUpdatableModel.java new file mode 100644 index 00000000..bc143b1a --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/model/SignatureUpdatableModel.java @@ -0,0 +1,6 @@ +package de.florianmichael.viafabricplus.definition.v1_19_0.model; + +public interface SignatureUpdatableModel { + + void update(final SignatureUpdaterModel updater); +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/model/SignatureUpdaterModel.java b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/model/SignatureUpdaterModel.java new file mode 100644 index 00000000..5003d3fa --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/model/SignatureUpdaterModel.java @@ -0,0 +1,6 @@ +package de.florianmichael.viafabricplus.definition.v1_19_0.model; + +public interface SignatureUpdaterModel { + + void update(final byte[] data); +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/provider/CommandArgumentsProvider.java b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/provider/CommandArgumentsProvider.java new file mode 100644 index 00000000..52a6b466 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/provider/CommandArgumentsProvider.java @@ -0,0 +1,13 @@ +package de.florianmichael.viafabricplus.definition.v1_19_0.provider; + +import com.viaversion.viaversion.api.platform.providers.Provider; +import net.minecraft.util.Pair; + +import java.util.List; + +public class CommandArgumentsProvider implements Provider { + + public List> getSignedArguments(final String command) { + return null; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/storage/AbstractChatSession.java b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/storage/AbstractChatSession.java new file mode 100644 index 00000000..11e3cfd3 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/storage/AbstractChatSession.java @@ -0,0 +1,35 @@ +package de.florianmichael.viafabricplus.definition.v1_19_0.storage; + +import com.viaversion.viaversion.api.connection.StoredObject; +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ProfileKey; +import de.florianmichael.viafabricplus.definition.v1_19_0.MessageSigner; + +import java.security.PrivateKey; + +public abstract class AbstractChatSession extends StoredObject { + private final ProfileKey profileKey; + private final PrivateKey privateKey; + + private final MessageSigner signer; + + public AbstractChatSession(UserConnection user, final ProfileKey profileKey, final PrivateKey privateKey) { + super(user); + this.profileKey = profileKey; + this.privateKey = privateKey; + + this.signer = MessageSigner.create(privateKey, "SHA256withRSA"); + } + + public ProfileKey getProfileKey() { + return profileKey; + } + + public PrivateKey getPrivateKey() { + return privateKey; + } + + public MessageSigner getSigner() { + return signer; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/storage/ChatSession1_19_0.java b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/storage/ChatSession1_19_0.java new file mode 100644 index 00000000..deaa2c9a --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_0/storage/ChatSession1_19_0.java @@ -0,0 +1,43 @@ +package de.florianmichael.viafabricplus.definition.v1_19_0.storage; + +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ProfileKey; +import de.florianmichael.viafabricplus.definition.v1_19_0.JsonHelper; +import de.florianmichael.viafabricplus.definition.v1_19_0.MessageMetadataModel; +import net.lenni0451.mcstructs.text.components.StringComponent; +import net.lenni0451.mcstructs.text.serializer.TextComponentSerializer; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.charset.StandardCharsets; +import java.security.PrivateKey; +import java.time.Instant; +import java.util.UUID; + +public class ChatSession1_19_0 extends AbstractChatSession { + + private final byte[] legacyKey; + + public ChatSession1_19_0(UserConnection user, ProfileKey profileKey, PrivateKey privateKey, byte[] legacyKey) { + super(user, profileKey, privateKey); + this.legacyKey = legacyKey; + } + + public byte[] sign(final UUID sender, final MessageMetadataModel messageMetadata) { + return getSigner().sign(updater -> { + final byte[] data = new byte[32]; + final ByteBuffer buffer = ByteBuffer.wrap(data).order(ByteOrder.BIG_ENDIAN); + + buffer.putLong(messageMetadata.salt()); + buffer.putLong(sender.getMostSignificantBits()).putLong(sender.getLeastSignificantBits()); + buffer.putLong(Instant.ofEpochMilli(messageMetadata.timestamp()).getEpochSecond()); + + updater.update(data); + updater.update(JsonHelper.toSortedString(TextComponentSerializer.V1_18.serializeJson(new StringComponent(messageMetadata.plain()))).getBytes(StandardCharsets.UTF_8)); + }); + } + + public byte[] getLegacyKey() { + return legacyKey; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_2/MessageBodyModel.java b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_2/MessageBodyModel.java new file mode 100644 index 00000000..acce15c5 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_2/MessageBodyModel.java @@ -0,0 +1,55 @@ +package de.florianmichael.viafabricplus.definition.v1_19_2; + +import com.google.common.hash.Hashing; +import com.google.common.hash.HashingOutputStream; +import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; +import de.florianmichael.viafabricplus.definition.v1_19_0.MessageMetadataModel; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.time.Instant; + +@SuppressWarnings("UnstableApiUsage") +public class MessageBodyModel { + private final MessageMetadataModel messageMetadata; + private final PlayerMessageSignature[] lastSeenMessages; + + public MessageBodyModel(MessageMetadataModel messageMetadata, PlayerMessageSignature[] lastSeenMessages) { + this.messageMetadata = messageMetadata; + this.lastSeenMessages = lastSeenMessages; + } + + public void writeLastSeenMessage(final DataOutput dataOutput) { + for (PlayerMessageSignature seenMessage : lastSeenMessages) { + try { + dataOutput.writeByte(70); + dataOutput.writeLong(seenMessage.uuid().getMostSignificantBits()); + dataOutput.writeLong(seenMessage.uuid().getLeastSignificantBits()); + dataOutput.write(seenMessage.signatureBytes()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + public byte[] digestBytes() { + final HashingOutputStream hashingOutputStream = new HashingOutputStream(Hashing.sha256(), OutputStream.nullOutputStream()); + final DataOutputStream dataOutputStream = new DataOutputStream(hashingOutputStream); + + try { + dataOutputStream.writeLong(messageMetadata.salt()); + dataOutputStream.writeLong(Instant.ofEpochMilli(messageMetadata.timestamp()).getEpochSecond()); + + final OutputStreamWriter outputStreamWriter = new OutputStreamWriter(dataOutputStream, StandardCharsets.UTF_8); + outputStreamWriter.write(messageMetadata.plain()); + outputStreamWriter.flush(); + + dataOutputStream.write(70); + writeLastSeenMessage(dataOutputStream); + } catch (IOException e) { + throw new RuntimeException(e); + } + + return hashingOutputStream.hash().asBytes(); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_2/MessageHeaderModel.java b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_2/MessageHeaderModel.java new file mode 100644 index 00000000..c8ed1501 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_2/MessageHeaderModel.java @@ -0,0 +1,44 @@ +package de.florianmichael.viafabricplus.definition.v1_19_2; + +import de.florianmichael.viafabricplus.definition.v1_19_0.model.SignatureUpdaterModel; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.UUID; + +public class MessageHeaderModel { + private final UUID sender; + private final byte[] precedingSignature; + + public MessageHeaderModel(UUID sender, byte[] precedingSignature) { + this.sender = sender; + this.precedingSignature = precedingSignature; + } + + public byte[] toByteArray(final UUID uuid) { + final byte[] data = new byte[16]; + final ByteBuffer byteBuffer = ByteBuffer.wrap(data).order(ByteOrder.BIG_ENDIAN); + + byteBuffer.putLong(uuid.getMostSignificantBits()); + byteBuffer.putLong(uuid.getLeastSignificantBits()); + + return data; + } + + public void updater(final byte[] bodyDigest, final SignatureUpdaterModel updater) { + if (precedingSignature != null) { + updater.update(precedingSignature); + } + + updater.update(toByteArray(getSender())); + updater.update(bodyDigest); + } + + public UUID getSender() { + return sender; + } + + public byte[] getPrecedingSignature() { + return precedingSignature; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_2/storage/ChatSession1_19_2.java b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_2/storage/ChatSession1_19_2.java new file mode 100644 index 00000000..020c38f4 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/definition/v1_19_2/storage/ChatSession1_19_2.java @@ -0,0 +1,32 @@ +package de.florianmichael.viafabricplus.definition.v1_19_2.storage; + +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; +import com.viaversion.viaversion.api.minecraft.ProfileKey; +import de.florianmichael.viafabricplus.definition.v1_19_0.MessageMetadataModel; +import de.florianmichael.viafabricplus.definition.v1_19_0.storage.AbstractChatSession; +import de.florianmichael.viafabricplus.definition.v1_19_2.MessageBodyModel; +import de.florianmichael.viafabricplus.definition.v1_19_2.MessageHeaderModel; + +import java.security.PrivateKey; +import java.security.SecureRandom; +import java.util.UUID; + +public class ChatSession1_19_2 extends AbstractChatSession { + public final static SecureRandom SECURE_RANDOM = new SecureRandom(); + + private byte[] precedingSignature = null; + + public ChatSession1_19_2(UserConnection user, ProfileKey profileKey, PrivateKey privateKey) { + super(user, profileKey, privateKey); + } + + public byte[] sign(final UUID sender, final MessageMetadataModel messageMetadata, final PlayerMessageSignature[] lastSeenMessages) { + final MessageHeaderModel header = new MessageHeaderModel(sender, precedingSignature); + final MessageBodyModel body = new MessageBodyModel(messageMetadata, lastSeenMessages); + + precedingSignature = getSigner().sign(updater -> header.updater(body.digestBytes(), updater)); + + return precedingSignature; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/access/IClientConnection.java b/src/main/java/de/florianmichael/viafabricplus/injection/access/IClientConnection.java new file mode 100644 index 00000000..f5f30812 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/access/IClientConnection.java @@ -0,0 +1,6 @@ +package de.florianmichael.viafabricplus.injection.access; + +public interface IClientConnection { + + void viafabricplus_setupPreNettyEncryption(); +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/access/IMinecraftClient.java b/src/main/java/de/florianmichael/viafabricplus/injection/access/IMinecraftClient.java new file mode 100644 index 00000000..09c3a03c --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/access/IMinecraftClient.java @@ -0,0 +1,7 @@ +package de.florianmichael.viafabricplus.injection.access; + +public interface IMinecraftClient { + + void protocolhack_trackKeyboardInteraction(final Runnable interaction); + void protocolhack_trackMouseInteraction(final Runnable interaction); +} diff --git a/src/main/java/de/florianmichael/everyprotocol/injection/access/IPacketWrapperImpl.java b/src/main/java/de/florianmichael/viafabricplus/injection/access/IPacketWrapperImpl.java similarity index 78% rename from src/main/java/de/florianmichael/everyprotocol/injection/access/IPacketWrapperImpl.java rename to src/main/java/de/florianmichael/viafabricplus/injection/access/IPacketWrapperImpl.java index d7e0884f..f49a3f24 100644 --- a/src/main/java/de/florianmichael/everyprotocol/injection/access/IPacketWrapperImpl.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/access/IPacketWrapperImpl.java @@ -1,4 +1,4 @@ -package de.florianmichael.everyprotocol.injection.access; +package de.florianmichael.viafabricplus.injection.access; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.util.Pair; diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/access/IPublicKeyData.java b/src/main/java/de/florianmichael/viafabricplus/injection/access/IPublicKeyData.java new file mode 100644 index 00000000..fb84f056 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/access/IPublicKeyData.java @@ -0,0 +1,10 @@ +package de.florianmichael.viafabricplus.injection.access; + +import java.nio.ByteBuffer; + +public interface IPublicKeyData { + + ByteBuffer protocolhack_get1_19_0Key(); + + void protocolhack_set1_19_0Key(final ByteBuffer oldKey); +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/access/IScreenHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/access/IScreenHandler.java new file mode 100644 index 00000000..1c49ce53 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/access/IScreenHandler.java @@ -0,0 +1,6 @@ +package de.florianmichael.viafabricplus.injection.access; + +public interface IScreenHandler { + + short protocolhack_getAndIncrementLastActionId(); +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinClientConnection.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinClientConnection.java new file mode 100644 index 00000000..eebd0a2f --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinClientConnection.java @@ -0,0 +1,74 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.base; + +import de.florianmichael.viafabricplus.injection.access.IClientConnection; +import de.florianmichael.viafabricplus.platform.PreNettyConstants; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import de.florianmichael.vialoadingbase.event.PipelineReorderEvent; +import io.netty.channel.Channel; +import net.minecraft.network.ClientConnection; +import net.minecraft.network.encryption.PacketDecryptor; +import net.minecraft.network.encryption.PacketEncryptor; +import net.raphimc.vialegacy.api.LegacyProtocolVersions; +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 javax.crypto.Cipher; + +@Mixin(ClientConnection.class) +public class MixinClientConnection implements IClientConnection { + + @Shadow private Channel channel; + + @Shadow private boolean encrypted; + @Unique + private Cipher viafabricplus_decryptionCipher; + + @Unique + private Cipher viafabricplus_encryptionCipher; + + @Inject(method = "setCompressionThreshold", at = @At("RETURN")) + private void reorderCompression(int compressionThreshold, boolean rejectBad, CallbackInfo ci) { + channel.pipeline().fireUserEventTriggered(new PipelineReorderEvent()); + } + + @Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true) + private void storeEncryptionCiphers(Cipher decryptionCipher, Cipher encryptionCipher, CallbackInfo ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.r1_6_4)) { + ci.cancel(); + this.viafabricplus_decryptionCipher = decryptionCipher; + this.viafabricplus_encryptionCipher = encryptionCipher; + } + } + + @Override + public void viafabricplus_setupPreNettyEncryption() { + this.encrypted = true; + this.channel.pipeline().addBefore(PreNettyConstants.DECODER, "decrypt", new PacketDecryptor(this.viafabricplus_decryptionCipher)); + this.channel.pipeline().addBefore(PreNettyConstants.ENCODER, "encrypt", new PacketEncryptor(this.viafabricplus_encryptionCipher)); + } +} diff --git a/src/main/java/de/florianmichael/everyprotocol/injection/mixin/base/MixinClientConnection_1.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinClientConnection_1.java similarity index 58% rename from src/main/java/de/florianmichael/everyprotocol/injection/mixin/base/MixinClientConnection_1.java rename to src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinClientConnection_1.java index 96c032c1..e351f5ce 100644 --- a/src/main/java/de/florianmichael/everyprotocol/injection/mixin/base/MixinClientConnection_1.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinClientConnection_1.java @@ -1,4 +1,25 @@ -package de.florianmichael.everyprotocol.injection.mixin.base; +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.base; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.connection.UserConnectionImpl; diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinMain.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinMain.java new file mode 100644 index 00000000..a60b5265 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinMain.java @@ -0,0 +1,38 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.base; + +import de.florianmichael.viafabricplus.ViaFabricPlus; +import net.minecraft.client.main.Main; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Main.class) +public class MixinMain { + + @Inject(method = "main([Ljava/lang/String;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/crash/CrashReport;initCrashReport()V")) + private static void loadViaLoadingBase(CallbackInfo ci) { + ViaFabricPlus.getClassWrapper().create(); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinMinecraftClient.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinMinecraftClient.java new file mode 100644 index 00000000..601b917b --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinMinecraftClient.java @@ -0,0 +1,149 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes; + +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; +import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1; +import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; +import de.florianmichael.viafabricplus.ViaFabricPlus; +import de.florianmichael.viafabricplus.injection.access.IMinecraftClient; +import de.florianmichael.viafabricplus.value.ValueHolder; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Mouse; +import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.render.item.HeldItemRenderer; +import net.minecraft.item.SwordItem; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +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; +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.Slice; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.concurrent.ConcurrentLinkedDeque; + +@Mixin(MinecraftClient.class) +public abstract class MixinMinecraftClient implements IMinecraftClient { + + @Shadow + @Nullable + public ClientPlayerEntity player; + + @Shadow @Final public Mouse mouse; + + @Shadow protected int attackCooldown; + + @Shadow @Nullable public abstract ClientPlayNetworkHandler getNetworkHandler(); + + @Redirect(method = "doItemUse", + slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")), + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;resetEquipProgress(Lnet/minecraft/util/Hand;)V", ordinal = 0)) + private void redirectDoItemUse(HeldItemRenderer heldItemRenderer, Hand hand) { + if (ViaLoadingBase.getTargetVersion().isNewerThan(ProtocolVersion.v1_8) || !(player.getStackInHand(hand).getItem() instanceof SwordItem)) { + heldItemRenderer.resetEquipProgress(hand); + } + } + + @Redirect(method = "doItemUse", + slice = @Slice(to = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactEntity(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/entity/Entity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")), + at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult;isAccepted()Z", ordinal = 0)) + private boolean preventGenericInteract(ActionResult instance) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_7_6)) { + return true; + } + + return instance.isAccepted(); + } + + /** + * This code removes the cooldown if + */ + @Redirect(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;attackCooldown:I", ordinal = 1)) + public int unwrapOperation(MinecraftClient instance) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + return 0; + } + return attackCooldown; + } + + @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;handleInputEvents()V", shift = At.Shift.BEFORE)) + public void updateCooldown(CallbackInfo ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + if (this.attackCooldown > 0) { + --this.attackCooldown; + } + } + } + + @Unique + private final ConcurrentLinkedDeque protocolhack_keyboardInteractions = new ConcurrentLinkedDeque<>(); + + @Unique + private final ConcurrentLinkedDeque protocolhack_mouseInteractions = new ConcurrentLinkedDeque<>(); + + @SuppressWarnings("ConstantConditions") + @Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;", + ordinal = 4, shift = At.Shift.BEFORE)) + public void injectTick(CallbackInfo ci) { + if (!ValueHolder.executeInputsInSync.getValue()) return; + + while (!protocolhack_mouseInteractions.isEmpty()) { + protocolhack_mouseInteractions.poll().run(); + } + while (!protocolhack_keyboardInteractions.isEmpty()) { + protocolhack_keyboardInteractions.poll().run(); + } + } + + @Inject(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;hasRidingInventory()Z")) + private void onInventoryKeyPressed(CallbackInfo ci) throws Exception { + final UserConnection viaConnection = getNetworkHandler().getConnection().channel.attr(ViaFabricPlus.LOCAL_USER_CONNECTION).get(); + + if (viaConnection != null && ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11_1)) { + final PacketWrapper clientStatus = PacketWrapper.create(ServerboundPackets1_9_3.CLIENT_STATUS, viaConnection); + clientStatus.write(Type.VAR_INT, 2); // Open Inventory Achievement + + clientStatus.sendToServer(Protocol1_12To1_11_1.class); + } + } + + @Override + public void protocolhack_trackKeyboardInteraction(Runnable interaction) { + this.protocolhack_keyboardInteractions.add(interaction); + } + + @Override + public void protocolhack_trackMouseInteraction(Runnable interaction) { + this.protocolhack_mouseInteractions.add(interaction); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinPlayerPublicKey_PublicKeyData.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinPlayerPublicKey_PublicKeyData.java new file mode 100644 index 00000000..1db1134c --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinPlayerPublicKey_PublicKeyData.java @@ -0,0 +1,46 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes; + +import de.florianmichael.viafabricplus.injection.access.IPublicKeyData; +import net.minecraft.network.encryption.PlayerPublicKey; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; + +import java.nio.ByteBuffer; + +@Mixin(PlayerPublicKey.PublicKeyData.class) +public class MixinPlayerPublicKey_PublicKeyData implements IPublicKeyData { + + @Unique + private ByteBuffer protocolhack_1_19_0Key; + + @Override + public ByteBuffer protocolhack_get1_19_0Key() { + return protocolhack_1_19_0Key; + } + + @Override + public void protocolhack_set1_19_0Key(ByteBuffer byteBuffer) { + this.protocolhack_1_19_0Key = byteBuffer; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinProfileKeysImpl.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinProfileKeysImpl.java new file mode 100644 index 00000000..3b46a087 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinProfileKeysImpl.java @@ -0,0 +1,40 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes; + +import com.mojang.authlib.yggdrasil.response.KeyPairResponse; +import de.florianmichael.viafabricplus.injection.access.IPublicKeyData; +import net.minecraft.client.util.ProfileKeysImpl; +import net.minecraft.network.encryption.PlayerPublicKey; +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(ProfileKeysImpl.class) +public class MixinProfileKeysImpl { + + @Inject(method = "decodeKeyPairResponse", at = @At("RETURN")) + private static void trackLegacyKey(KeyPairResponse keyPairResponse, CallbackInfoReturnable cir) { + ((IPublicKeyData) (Object) cir.getReturnValue()).protocolhack_set1_19_0Key(keyPairResponse.getLegacyPublicKeySignature()); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinServerAddress.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinServerAddress.java new file mode 100644 index 00000000..3b971d28 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinServerAddress.java @@ -0,0 +1,46 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.client.network.AllowedAddressResolver; +import net.minecraft.client.network.ServerAddress; +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.callback.CallbackInfoReturnable; + +@Mixin(ServerAddress.class) +public class MixinServerAddress { + + @Shadow @Final private static ServerAddress INVALID; + + @Inject(method = "parse", at = @At("RETURN"), cancellable = true) + private static void fixAddress(String address, CallbackInfoReturnable cir) { + if (!cir.getReturnValue().equals(INVALID) && ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) { + cir.setReturnValue(AllowedAddressResolver.DEFAULT.redirectResolver.lookupRedirect(cir.getReturnValue()).orElse(cir.getReturnValue())); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinServerResourcePackProvider.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinServerResourcePackProvider.java new file mode 100644 index 00000000..209b0333 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/MixinServerResourcePackProvider.java @@ -0,0 +1,99 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes; + +import com.google.common.hash.HashCode; +import com.google.common.hash.Hashing; +import com.google.common.io.Files; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.definition.PackFormatsDefinition; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.GameVersion; +import net.minecraft.client.resource.ServerResourcePackProvider; +import org.apache.commons.codec.digest.DigestUtils; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Locale; +import java.util.Map; + +@Mixin(ServerResourcePackProvider.class) +public class MixinServerResourcePackProvider { + + @Unique + private File protocolhack_trackedFile; + + @Redirect(method = "getDownloadHeaders", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;getGameVersion()Lnet/minecraft/GameVersion;")) + private static GameVersion editHeaders() { + return PackFormatsDefinition.current(); + } + + @Inject(method = "getDownloadHeaders", at = @At("TAIL"), cancellable = true) + private static void removeHeaders(CallbackInfoReturnable> cir) { + final LinkedHashMap modifiableMap = new LinkedHashMap<>(cir.getReturnValue()); + if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_14)) { + modifiableMap.remove("X-Minecraft-Version-ID"); + } + if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_13)) { + modifiableMap.remove("X-Minecraft-Pack-Format"); + modifiableMap.remove("User-Agent"); + } + + cir.setReturnValue(modifiableMap); + } + + @Inject(method = "verifyFile", at = @At("HEAD")) + public void keepFile(String expectedSha1, File file, CallbackInfoReturnable cir) { + protocolhack_trackedFile = file; + } + + @Redirect(method = "verifyFile", at = @At(value = "INVOKE", target = "Lcom/google/common/hash/HashCode;toString()Ljava/lang/String;", remap = false)) + public String revertHashAlgorithm(HashCode instance) { + try { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + //noinspection deprecation + return Hashing.sha1().hashBytes(Files.toByteArray(protocolhack_trackedFile)).toString(); + } else if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_18)) { + return DigestUtils.sha1Hex(new FileInputStream(protocolhack_trackedFile)); + } + } catch (IOException ignored) { + } + return instance.toString(); + } + + @Redirect(method = "verifyFile", at = @At(value = "INVOKE", target = "Ljava/lang/String;toLowerCase(Ljava/util/Locale;)Ljava/lang/String;")) + public String disableIgnoreCase(String instance, Locale locale) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + return instance; + } + + return instance.toLowerCase(locale); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinAbstractBlock_AbstractBlockState.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinAbstractBlock_AbstractBlockState.java new file mode 100644 index 00000000..021248e1 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinAbstractBlock_AbstractBlockState.java @@ -0,0 +1,72 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.AbstractBlock; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.InfestedBlock; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.BlockView; +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(AbstractBlock.AbstractBlockState.class) +public abstract class MixinAbstractBlock_AbstractBlockState { + + @Shadow + protected abstract BlockState asBlockState(); + + @Inject(method = "getHardness", at = @At("RETURN"), cancellable = true) + public void injectGetHardness(BlockView world, BlockPos pos, CallbackInfoReturnable cir) { + final BlockState state = this.asBlockState(); + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + if (state.getBlock() instanceof InfestedBlock) { + cir.setReturnValue(0.75F); + } + } + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) { + if (state.getBlock() == Blocks.END_STONE_BRICKS || state.getBlock() == Blocks.END_STONE_BRICK_SLAB || state.getBlock() == Blocks.END_STONE_BRICK_STAIRS || state.getBlock() == Blocks.END_STONE_BRICK_WALL) { + cir.setReturnValue(0.8F); + } + } + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) { + if (state.getBlock() == Blocks.PISTON || state.getBlock() == Blocks.STICKY_PISTON || state.getBlock() == Blocks.PISTON_HEAD) { + cir.setReturnValue(0.5F); + } + } + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) { + if (state.getBlock() instanceof InfestedBlock) { + cir.setReturnValue(0F); + } + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinAnvilBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinAnvilBlock.java new file mode 100644 index 00000000..782fd0df --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinAnvilBlock.java @@ -0,0 +1,60 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.AnvilBlock; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.ShapeContext; +import net.minecraft.state.property.DirectionProperty; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; +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.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(AnvilBlock.class) +public class MixinAnvilBlock { + + @Unique + private static final VoxelShape protocolhack_X_AXIS_SHAPE_1_12_2 = Block.createCuboidShape(0, 0, 2, 16, 16, 14); + @Unique + private static final VoxelShape protocolhack_Z_AXIS_SHAPE_1_12_2 = Block.createCuboidShape(2, 0, 0, 14, 16, 16); + @Shadow + @Final + public static DirectionProperty FACING; + + @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) + public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + cir.setReturnValue(state.get(FACING).getAxis() == Direction.Axis.X ? protocolhack_X_AXIS_SHAPE_1_12_2 : protocolhack_Z_AXIS_SHAPE_1_12_2); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBambooBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBambooBlock.java new file mode 100644 index 00000000..9434d796 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBambooBlock.java @@ -0,0 +1,44 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.BambooBlock; +import net.minecraft.block.BlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.BlockView; +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(BambooBlock.class) +public class MixinBambooBlock { + + @Inject(method = "isShapeFullCube", at = @At("HEAD"), cancellable = true) + public void changeFullCube(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) { + cir.setReturnValue(true); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBedBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBedBlock.java new file mode 100644 index 00000000..c330de40 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBedBlock.java @@ -0,0 +1,62 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.BedBlock; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.ShapeContext; +import net.minecraft.entity.Entity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; +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.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(BedBlock.class) +public class MixinBedBlock { + + @Unique + private final static VoxelShape protocolhack_BED_SHAPE_1_13_2 = Block.createCuboidShape(0, 0, 0, 16, 9, 16); + + @Inject(method = "bounceEntity", at = @At("HEAD"), cancellable = true) + public void injectBounceEntity(Entity entity, CallbackInfo ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11_1)) { + ci.cancel(); + } + } + + @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) + public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getClassWrapper() != null) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) { + cir.setReturnValue(protocolhack_BED_SHAPE_1_13_2); + } + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBlock.java new file mode 100644 index 00000000..b3757ab5 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBlock.java @@ -0,0 +1,59 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.block.InfestedBlock; +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(Block.class) +public class MixinBlock { + + @Inject(method = "getBlastResistance", at = @At("RETURN"), cancellable = true) + private void modifyBlastResistance(CallbackInfoReturnable ci) { + final Block block = ((Block) (Object) this); + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) { + if (block == Blocks.END_STONE_BRICKS || block == Blocks.END_STONE_BRICK_SLAB || block == Blocks.END_STONE_BRICK_STAIRS || block == Blocks.END_STONE_BRICK_WALL) { + ci.setReturnValue(0.8F); + } + } + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) { + if (block == Blocks.PISTON || block == Blocks.STICKY_PISTON || block == Blocks.PISTON_HEAD) { + ci.setReturnValue(0.5F); + } + } + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) { + if (block instanceof InfestedBlock) { + ci.setReturnValue(0.75F); + } + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBlockView.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBlockView.java new file mode 100644 index 00000000..e4c094bc --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBlockView.java @@ -0,0 +1,44 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import net.minecraft.block.BlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(BlockView.class) +public interface MixinBlockView { + + @Redirect(method = "raycastBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getRaycastShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/shape/VoxelShape;")) + default VoxelShape hookedGetRaycastShape(BlockState instance, BlockView blockView, BlockPos blockPos) { + VoxelShape shape = instance.getRaycastShape(blockView, blockPos); + // It appears, that certain game states react unstable to the shape changes we are producing. + if (shape == null) + shape = VoxelShapes.empty(); + return shape; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBrewingStandBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBrewingStandBlock.java new file mode 100644 index 00000000..12d6a994 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinBrewingStandBlock.java @@ -0,0 +1,55 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.BrewingStandBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +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; + +@Mixin(BrewingStandBlock.class) +public class MixinBrewingStandBlock { + + @Unique + private static final VoxelShape protocolhack_BASE_SHAPE_1_12_2 = VoxelShapes.union( + Block.createCuboidShape(0, 0, 0, 16, 2, 16) /* Base */, + Block.createCuboidShape(7, 0, 7, 9, 14, 9) /* Stick */ + ); + + @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) + public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + cir.setReturnValue(protocolhack_BASE_SHAPE_1_12_2); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinCauldronBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinCauldronBlock.java new file mode 100644 index 00000000..b5244a66 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinCauldronBlock.java @@ -0,0 +1,60 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.*; +import net.minecraft.block.cauldron.CauldronBehavior; +import net.minecraft.item.Item; +import net.minecraft.util.function.BooleanBiFunction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; + +import java.util.Map; + +@Mixin(CauldronBlock.class) +public abstract class MixinCauldronBlock extends AbstractCauldronBlock { + + @Unique + private final static VoxelShape protocolhack_CAULDRON_SHAPE_1_12_2 = VoxelShapes.combineAndSimplify( + VoxelShapes.fullCube(), + Block.createCuboidShape(2.0D, 5.0D, 2.0D, 14.0D, 16.0D, 14.0D), + BooleanBiFunction.ONLY_FIRST + ); + + public MixinCauldronBlock(Settings settings, Map behaviorMap) { + super(settings, behaviorMap); + } + + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + return protocolhack_CAULDRON_SHAPE_1_12_2; + } + return super.getOutlineShape(state, world, pos, context); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinEndPortalBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinEndPortalBlock.java new file mode 100644 index 00000000..38bccaf1 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinEndPortalBlock.java @@ -0,0 +1,71 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.*; +import net.minecraft.client.MinecraftClient; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; +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.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(EndPortalBlock.class) +public abstract class MixinEndPortalBlock extends BlockWithEntity { + + @Shadow + @Final + protected static VoxelShape SHAPE; + @Unique + private final VoxelShape protocolhack_SHAPE_1_8 = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 1.0, 16.0); + + @Unique + private final VoxelShape protocolhack_SHAPE_1_16_5 = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 12.0, 16.0); + + protected MixinEndPortalBlock(Settings settings) { + super(settings); + } + + @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) + public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (MinecraftClient.getInstance() == null || MinecraftClient.getInstance().world == null) return; + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + cir.setReturnValue(protocolhack_SHAPE_1_8); + } + else if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) { + cir.setReturnValue(protocolhack_SHAPE_1_16_5); + } + } + + @Override + public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + return SHAPE; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinEndPortalFrameBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinEndPortalFrameBlock.java new file mode 100644 index 00000000..6cf63f02 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinEndPortalFrameBlock.java @@ -0,0 +1,56 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.EndPortalFrameBlock; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +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.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(EndPortalFrameBlock.class) +public class MixinEndPortalFrameBlock { + + @Shadow + @Final + protected static VoxelShape FRAME_SHAPE; + @Shadow + @Final + protected static VoxelShape FRAME_WITH_EYE_SHAPE; + @Unique + private final VoxelShape protocolhack_EYE_SHAPE_1_12_2 = Block.createCuboidShape(5.0, 13.0, 5.0, 11.0, 16.0, 11.0); + + @Redirect(method = "getOutlineShape", at = @At(value = "FIELD", target = "Lnet/minecraft/block/EndPortalFrameBlock;FRAME_WITH_EYE_SHAPE:Lnet/minecraft/util/shape/VoxelShape;")) + public VoxelShape redirectGetOutlineShape() { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + return VoxelShapes.union(FRAME_SHAPE, protocolhack_EYE_SHAPE_1_12_2); + } + return FRAME_WITH_EYE_SHAPE; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFarmlandBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFarmlandBlock.java new file mode 100644 index 00000000..51ad3c2d --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFarmlandBlock.java @@ -0,0 +1,66 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.FarmlandBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +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.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(FarmlandBlock.class) +public class MixinFarmlandBlock extends Block { + + @Unique + private static final VoxelShape protocolhack_SHAPE_1_9_4 = VoxelShapes.fullCube(); + @Shadow + @Final + protected static VoxelShape SHAPE; + + public MixinFarmlandBlock(Settings settings) { + super(settings); + } + + @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) + public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_9_3)) { + cir.setReturnValue(protocolhack_SHAPE_1_9_4); + } + } + + @Override + public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) { + return SHAPE; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFenceBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFenceBlock.java new file mode 100644 index 00000000..8d87a1fc --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFenceBlock.java @@ -0,0 +1,42 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.FenceBlock; +import net.minecraft.util.ActionResult; +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(FenceBlock.class) +public class MixinFenceBlock { + + @Inject(method = "onUse", at = @At("HEAD"), cancellable = true) + private void injectOnUse(CallbackInfoReturnable ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10)) { + ci.setReturnValue(ActionResult.SUCCESS); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFireBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFireBlock.java new file mode 100644 index 00000000..58c22c5e --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFireBlock.java @@ -0,0 +1,47 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.BlockState; +import net.minecraft.block.FireBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +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(FireBlock.class) +public class MixinFireBlock { + + @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) + public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) { + cir.setReturnValue(VoxelShapes.empty()); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFlowerPotBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFlowerPotBlock.java new file mode 100644 index 00000000..80d948cc --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinFlowerPotBlock.java @@ -0,0 +1,50 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.block.FlowerPotBlock; +import net.minecraft.util.ActionResult; +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.callback.CallbackInfoReturnable; + +@Mixin(FlowerPotBlock.class) +public class MixinFlowerPotBlock { + + @Shadow + @Final + private Block content; + + @Inject(method = "onUse", at = @At(value = "FIELD", target = "Lnet/minecraft/block/FlowerPotBlock;content:Lnet/minecraft/block/Block;", ordinal = 0), cancellable = true) + private void injectOnUse(CallbackInfoReturnable ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10) && content != Blocks.AIR) { + ci.setReturnValue(ActionResult.CONSUME); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinHopperBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinHopperBlock.java new file mode 100644 index 00000000..4ed7f2b8 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinHopperBlock.java @@ -0,0 +1,66 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.HopperBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.function.BooleanBiFunction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +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; + +@Mixin(HopperBlock.class) +public class MixinHopperBlock { + + @Unique + private final static VoxelShape protocolhack_INSIDE_SHAPE_1_12_2 = Block.createCuboidShape(2, 10, 2, 14, 16, 14); + + @Unique + private final static VoxelShape protocolhack_HOPPER_SHAPE_1_12_2 = VoxelShapes.combineAndSimplify( + VoxelShapes.fullCube(), + protocolhack_INSIDE_SHAPE_1_12_2, + BooleanBiFunction.ONLY_FIRST); + + @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) + public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + cir.setReturnValue(protocolhack_HOPPER_SHAPE_1_12_2); + } + } + + @Inject(method = "getRaycastShape", at = @At("HEAD"), cancellable = true) + public void injectGetRaycastShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + cir.setReturnValue(protocolhack_INSIDE_SHAPE_1_12_2); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinLadderBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinLadderBlock.java new file mode 100644 index 00000000..08ef370e --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinLadderBlock.java @@ -0,0 +1,65 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.LadderBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; +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; + +@Mixin(LadderBlock.class) +public class MixinLadderBlock { + + @Unique + private static final VoxelShape protocolhack_EAST_SHAPE_1_8 = Block.createCuboidShape(0, 0, 0, 2, 16, 16); + + @Unique + private static final VoxelShape protocolhack_WEST_SHAPE_1_8 = Block.createCuboidShape(14, 0, 0, 16, 16, 16); + + @Unique + private static final VoxelShape protocolhack_SOUTH_SHAPE_1_8 = Block.createCuboidShape(0, 0, 0, 16, 16, 2); + + @Unique + private static final VoxelShape protocolhack_NORTH_SHAPE_1_8 = Block.createCuboidShape(0, 0, 14, 16, 16, 16); + + @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) + private void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + switch (state.get(LadderBlock.FACING)) { + case NORTH -> ci.setReturnValue(protocolhack_NORTH_SHAPE_1_8); + case SOUTH -> ci.setReturnValue(protocolhack_SOUTH_SHAPE_1_8); + case WEST -> ci.setReturnValue(protocolhack_WEST_SHAPE_1_8); + default -> ci.setReturnValue(protocolhack_EAST_SHAPE_1_8); + } + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinLightBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinLightBlock.java new file mode 100644 index 00000000..465bdcd5 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinLightBlock.java @@ -0,0 +1,43 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.LightBlock; +import net.minecraft.entity.player.PlayerEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(LightBlock.class) +public class MixinLightBlock { + + // Not relevant for GamePlay + @Redirect(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isCreativeLevelTwoOp()Z")) + public boolean removeIf(PlayerEntity instance) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) { + return true; + } + return instance.isCreativeLevelTwoOp(); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinLilyPadBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinLilyPadBlock.java new file mode 100644 index 00000000..10aba98d --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinLilyPadBlock.java @@ -0,0 +1,51 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.LilyPadBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; +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; + +@Mixin(LilyPadBlock.class) +public class MixinLilyPadBlock { + + @Unique + private static final VoxelShape protocolhack_SHAPE_1_8 = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 0.015625D /* 1 / 64 */ * 16, 16.0D); + + @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) + public void changeBoundingBox(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + cir.setReturnValue(protocolhack_SHAPE_1_8); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinPaneBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinPaneBlock.java new file mode 100644 index 00000000..92c709f4 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinPaneBlock.java @@ -0,0 +1,102 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.*; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; + +@Mixin(PaneBlock.class) +public class MixinPaneBlock extends HorizontalConnectingBlock { + + public MixinPaneBlock(float radius1, float radius2, float boundingHeight1, float boundingHeight2, float collisionHeight, Settings settings) { + super(radius1, radius2, boundingHeight1, boundingHeight2, collisionHeight, settings); + } + + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + return protocolhack_get1_8Shape(state); + } + return super.getOutlineShape(state, world, pos, context); + } + + @Override + public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + return protocolhack_get1_8Shape(state); + } + return super.getCollisionShape(state, world, pos, context); + } + + @Unique + private final VoxelShape protocolhack_WEST_SHAPE_1_8 = Block.createCuboidShape(0, 0, 7, 8, 16, 9); + + @Unique + private final VoxelShape protocolhack_EAST_SHAPE_1_8 = Block.createCuboidShape(8, 0, 7, 16, 16, 9); + + @Unique + private final VoxelShape protocolhack_WEST_EAST_COMBINED_SHAPE_1_8 = Block.createCuboidShape(0, 0, 7, 16, 16, 9); + + @Unique + private final VoxelShape protocolhack_NORTH_SHAPE_1_8 = Block.createCuboidShape(7, 0, 0, 9, 16, 8); + + @Unique + private final VoxelShape protocolhack_SOUTH_SHAPE_1_8 = Block.createCuboidShape(7, 0, 8, 9, 16, 16); + + @Unique + private final VoxelShape protocolhack_NORTH_SOUTH_COMBINED_SHAPE_1_8 = Block.createCuboidShape(7, 0, 0, 9, 16, 16); + + @Unique + public VoxelShape protocolhack_get1_8Shape(BlockState state) { + VoxelShape finalShape = VoxelShapes.empty(); + + final boolean isNorthFacing = state.get(NORTH); + final boolean isSouthFacing = state.get(SOUTH); + final boolean isWestFacing = state.get(WEST); + final boolean isEastFacing = state.get(EAST); + + if ((!isWestFacing || !isEastFacing) && (isWestFacing || isEastFacing || isNorthFacing || isSouthFacing)) { + if (isWestFacing) + finalShape = VoxelShapes.union(finalShape, protocolhack_WEST_SHAPE_1_8); + else if (isEastFacing) + finalShape = VoxelShapes.union(finalShape, protocolhack_EAST_SHAPE_1_8); + } else + finalShape = VoxelShapes.union(finalShape, protocolhack_WEST_EAST_COMBINED_SHAPE_1_8); + + if ((!isNorthFacing || !isSouthFacing) && (isWestFacing || isEastFacing || isNorthFacing || isSouthFacing)) { + if (isNorthFacing) + finalShape = VoxelShapes.union(finalShape, protocolhack_NORTH_SHAPE_1_8); + else if (isSouthFacing) + finalShape = VoxelShapes.union(finalShape, protocolhack_SOUTH_SHAPE_1_8); + } else + finalShape = VoxelShapes.union(finalShape, protocolhack_NORTH_SOUTH_COMBINED_SHAPE_1_8); + + return finalShape; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinPistonHeadBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinPistonHeadBlock.java new file mode 100644 index 00000000..77c7127d --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinPistonHeadBlock.java @@ -0,0 +1,122 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.*; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +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; + +@Mixin(PistonHeadBlock.class) +public class MixinPistonHeadBlock extends FacingBlock { + + public MixinPistonHeadBlock(Settings settings) { + super(settings); + } + + @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) + public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) + cir.setReturnValue(getCoreShape_1_8(state)); + } + + @Override + public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) + return VoxelShapes.union(getHeadShape_1_8(state), getCoreShape_1_8(state)); + + return super.getCollisionShape(state, world, pos, context); + } + + @Unique + private final VoxelShape protocolhack_CORE_DOWN_SHAPE_1_8 = Block.createCuboidShape(6, 4, 6, 10, 16, 10); + + @Unique + private final VoxelShape protocolhack_CORE_UP_SHAPE_1_8 = Block.createCuboidShape(6, 0, 6, 10, 12, 10); + + @Unique + private final VoxelShape protocolhack_CORE_NORTH_SHAPE_1_8 = Block.createCuboidShape(4, 6, 4, 12, 10, 16); + + @Unique + private final VoxelShape protocolhack_CORE_SOUTH_SHAPE_1_8 = Block.createCuboidShape(4, 6, 0, 12, 10, 12); + + @Unique + private final VoxelShape protocolhack_CORE_WEST_SHAPE_1_8 = Block.createCuboidShape(6, 4, 4, 10, 12, 16); + + @Unique + private final VoxelShape protocolhack_CORE_EAST_SHAPE_1_8 = Block.createCuboidShape(0, 6, 4, 12, 10, 12); + + @Unique + private VoxelShape getCoreShape_1_8(BlockState state) { + final Direction direction = state.get(FACING); + + return switch (direction) { + case DOWN -> protocolhack_CORE_DOWN_SHAPE_1_8; + case UP -> protocolhack_CORE_UP_SHAPE_1_8; + case NORTH -> protocolhack_CORE_NORTH_SHAPE_1_8; + case SOUTH -> protocolhack_CORE_SOUTH_SHAPE_1_8; + case WEST -> protocolhack_CORE_WEST_SHAPE_1_8; + case EAST -> protocolhack_CORE_EAST_SHAPE_1_8; + }; + } + + @Unique + private final VoxelShape protocolhack_HEAD_DOWN_SHAPE_1_8 = Block.createCuboidShape(0, 0, 0, 16, 4, 16); + + @Unique + private final VoxelShape protocolhack_HEAD_UP_SHAPE_1_8 = Block.createCuboidShape(0, 12, 0, 16, 16, 16); + + @Unique + private final VoxelShape protocolhack_HEAD_NORTH_SHAPE_1_8 = Block.createCuboidShape(0, 0, 0, 16, 16, 4); + + @Unique + private final VoxelShape protocolhack_HEAD_SOUTH_SHAPE_1_8 = Block.createCuboidShape(0, 0, 12, 16, 16, 16); + + @Unique + private final VoxelShape protocolhack_HEAD_WEST_SHAPE_1_8 = Block.createCuboidShape(0, 0, 0, 4, 16, 16); + + @Unique + private final VoxelShape protocolhack_HEAD_EAST_SHAPE_1_8 = Block.createCuboidShape(12, 0, 0, 16, 16, 16); + + @Unique + private VoxelShape getHeadShape_1_8(BlockState state) { + final Direction direction = state.get(FACING); + + return switch (direction) { + case DOWN -> protocolhack_HEAD_DOWN_SHAPE_1_8; + case UP -> protocolhack_HEAD_UP_SHAPE_1_8; + case NORTH -> protocolhack_HEAD_NORTH_SHAPE_1_8; + case SOUTH -> protocolhack_HEAD_SOUTH_SHAPE_1_8; + case WEST -> protocolhack_HEAD_WEST_SHAPE_1_8; + case EAST -> protocolhack_HEAD_EAST_SHAPE_1_8; + }; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinSnowBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinSnowBlock.java new file mode 100644 index 00000000..7e7960c7 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinSnowBlock.java @@ -0,0 +1,67 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.ShapeContext; +import net.minecraft.block.SnowBlock; +import net.minecraft.state.property.IntProperty; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; +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.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(SnowBlock.class) +public class MixinSnowBlock { + + @Unique + private static final VoxelShape[] protocolhack_LAYERS_TO_SHAPE_1_12_2 = new VoxelShape[]{ + Block.createCuboidShape(0, -0.00001 /* Bypass for Minecraft-Fixes */, 0, 16, 0, 16), + Block.createCuboidShape(0, 0, 0, 16, 2, 16), + Block.createCuboidShape(0, 0, 0, 16, 4, 16), + Block.createCuboidShape(0, 0, 0, 16, 6, 16), + Block.createCuboidShape(0, 0, 0, 16, 8, 16), + Block.createCuboidShape(0, 0, 0, 16, 10, 16), + Block.createCuboidShape(0, 0, 0, 16, 12, 16), + Block.createCuboidShape(0, 0, 0, 16, 14, 16), + Block.createCuboidShape(0, 0, 0, 16, 16, 16) + }; + @Shadow + @Final + public static IntProperty LAYERS; + + @Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true) + public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + cir.setReturnValue(protocolhack_LAYERS_TO_SHAPE_1_12_2[state.get(LAYERS) - 1]); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinSoulSandBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinSoulSandBlock.java new file mode 100644 index 00000000..94f1cf6d --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinSoulSandBlock.java @@ -0,0 +1,60 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.SoulSandBlock; +import net.minecraft.entity.Entity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(SoulSandBlock.class) +public class MixinSoulSandBlock extends Block { + + public MixinSoulSandBlock(Settings settings) { + super(settings); + } + + @Override + public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { + super.onEntityCollision(state, world, pos, entity); + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) { + final Vec3d velocity = entity.getVelocity(); + + double multiplier = 0.4D; + entity.setVelocity(velocity.getX() * multiplier, velocity.getY(), velocity.getZ() * multiplier); + } + } + + @Override + public float getVelocityMultiplier() { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) + return 1.0F; + return super.getVelocityMultiplier(); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinSugarCaneBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinSugarCaneBlock.java new file mode 100644 index 00000000..31b701ef --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinSugarCaneBlock.java @@ -0,0 +1,45 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.SugarCaneBlock; +import net.minecraft.registry.tag.TagKey; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(SugarCaneBlock.class) +public class MixinSugarCaneBlock { + + @Redirect(method = "canPlaceAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isIn(Lnet/minecraft/registry/tag/TagKey;)Z")) + public boolean changePlaceTarget(BlockState instance, TagKey tagKey) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) { + return instance.isOf(Blocks.GRASS_BLOCK) || instance.isOf(Blocks.DIRT) || instance.isOf(Blocks.COARSE_DIRT) || instance.isOf(Blocks.PODZOL); + } + return instance.isIn(tagKey); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinWallBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinWallBlock.java new file mode 100644 index 00000000..6be8d5b9 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/block/MixinWallBlock.java @@ -0,0 +1,175 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.ShapeContext; +import net.minecraft.block.WallBlock; +import net.minecraft.block.enums.WallShape; +import net.minecraft.item.ItemPlacementContext; +import net.minecraft.state.property.EnumProperty; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; +import net.minecraft.world.WorldAccess; +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.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(WallBlock.class) +public class MixinWallBlock extends Block { + + @Unique + private static final VoxelShape[] protocolhack_SHAPE_BY_INDEX_1_12_2 = new VoxelShape[]{ + Block.createCuboidShape(4, 0, 4, 12, 16, 12), + Block.createCuboidShape(4, 0, 4, 12, 16, 16), + Block.createCuboidShape(0, 0, 4, 12, 16, 12), + Block.createCuboidShape(0, 0, 4, 12, 16, 16), + Block.createCuboidShape(4, 0, 0, 12, 16, 12), + + Block.createCuboidShape(5, 0, 0, 11, 14, 16), + + Block.createCuboidShape(0, 0, 0, 12, 16, 12), + Block.createCuboidShape(0, 0, 0, 12, 16, 16), + Block.createCuboidShape(4, 0, 4, 16, 16, 12), + Block.createCuboidShape(4, 0, 4, 16, 16, 16), + + Block.createCuboidShape(0, 0, 5, 16, 14, 11), + + Block.createCuboidShape(0, 0, 4, 16, 16, 16), + Block.createCuboidShape(4, 0, 0, 16, 16, 12), + Block.createCuboidShape(4, 0, 0, 16, 16, 16), + Block.createCuboidShape(0, 0, 0, 16, 16, 12), + Block.createCuboidShape(0, 0, 0, 16, 16, 16) + }; + @Unique + private static final VoxelShape[] protocolhack_CLIP_SHAPE_BY_INDEX_1_12_2 = new VoxelShape[]{ + Block.createCuboidShape(4, 0, 4, 12, 24, 12), + Block.createCuboidShape(4, 0, 4, 12, 24, 16), + Block.createCuboidShape(0, 0, 4, 12, 24, 12), + Block.createCuboidShape(0, 0, 4, 12, 24, 16), + Block.createCuboidShape(4, 0, 0, 12, 24, 12), + + Block.createCuboidShape(5, 0, 0, 11, 24, 16), + + Block.createCuboidShape(0, 0, 0, 12, 24, 12), + Block.createCuboidShape(0, 0, 0, 12, 24, 16), + Block.createCuboidShape(4, 0, 4, 16, 24, 12), + Block.createCuboidShape(4, 0, 4, 16, 24, 16), + + Block.createCuboidShape(0, 0, 5, 16, 24, 11), + + Block.createCuboidShape(0, 0, 4, 16, 24, 16), + Block.createCuboidShape(4, 0, 0, 16, 24, 12), + Block.createCuboidShape(4, 0, 0, 16, 24, 16), + Block.createCuboidShape(0, 0, 0, 16, 24, 12), + Block.createCuboidShape(0, 0, 0, 16, 24, 16) + }; + @Shadow + @Final + public static EnumProperty EAST_SHAPE; + @Shadow + @Final + public static EnumProperty NORTH_SHAPE; + @Shadow + @Final + public static EnumProperty WEST_SHAPE; + @Shadow + @Final + public static EnumProperty SOUTH_SHAPE; + public MixinWallBlock(Settings settings) { + super(settings); + } + + @Unique + private static BlockState protocolhack_oldWallPlacementLogic(BlockState state) { + boolean addUp = false; + if (state.get(WallBlock.NORTH_SHAPE) == WallShape.TALL) { + state = state.with(WallBlock.NORTH_SHAPE, WallShape.LOW); + addUp = true; + } + if (state.get(WallBlock.EAST_SHAPE) == WallShape.TALL) { + state = state.with(WallBlock.EAST_SHAPE, WallShape.LOW); + addUp = true; + } + if (state.get(WallBlock.SOUTH_SHAPE) == WallShape.TALL) { + state = state.with(WallBlock.SOUTH_SHAPE, WallShape.LOW); + addUp = true; + } + if (state.get(WallBlock.WEST_SHAPE) == WallShape.TALL) { + state = state.with(WallBlock.WEST_SHAPE, WallShape.LOW); + addUp = true; + } + if (addUp) { + state = state.with(WallBlock.UP, true); + } + return state; + } + + @Unique + private static int protocolhack_getShapeIndex_1122(BlockState state) { + int i = 0; + + if (state.get(NORTH_SHAPE) != WallShape.NONE) i |= 1 << Direction.NORTH.getHorizontal(); + if (state.get(EAST_SHAPE) != WallShape.NONE) i |= 1 << Direction.EAST.getHorizontal(); + if (state.get(SOUTH_SHAPE) != WallShape.NONE) i |= 1 << Direction.SOUTH.getHorizontal(); + if (state.get(WEST_SHAPE) != WallShape.NONE) i |= 1 << Direction.WEST.getHorizontal(); + + return i; + } + + @Inject(method = "getPlacementState", at = @At("RETURN"), cancellable = true) + public void injectGetPlacementState(ItemPlacementContext ctx, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) { + cir.setReturnValue(protocolhack_oldWallPlacementLogic(cir.getReturnValue())); + } + } + + @Inject(method = "getStateForNeighborUpdate", at = @At("RETURN"), cancellable = true) + public void injectGetStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) { + cir.setReturnValue(protocolhack_oldWallPlacementLogic(cir.getReturnValue())); + } + } + + @Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true) + public void injectGetCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + cir.setReturnValue(protocolhack_CLIP_SHAPE_BY_INDEX_1_12_2[protocolhack_getShapeIndex_1122(state)]); + } + } + + @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) + public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + cir.setReturnValue(protocolhack_SHAPE_BY_INDEX_1_12_2[protocolhack_getShapeIndex_1122(state)]); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/input/MixinKeyboard.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/input/MixinKeyboard.java new file mode 100644 index 00000000..db9eb6e7 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/input/MixinKeyboard.java @@ -0,0 +1,59 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.input; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.injection.access.IMinecraftClient; +import de.florianmichael.viafabricplus.value.ValueHolder; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.client.Keyboard; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayNetworkHandler; +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.Redirect; + +@Mixin(Keyboard.class) +public class MixinKeyboard { + + @Shadow @Final private MinecraftClient client; + + @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V")) + public void redirectSync(MinecraftClient instance, Runnable runnable) { + if (ValueHolder.executeInputsInSync.getValue()) { + ((IMinecraftClient) client).protocolhack_trackKeyboardInteraction(runnable); + return; + } + + instance.execute(runnable); + } + + @Redirect(method = "processF3", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendCommand(Ljava/lang/String;)Z", ordinal = 0)) + public boolean replaceSpectatorCommand(ClientPlayNetworkHandler instance, String command) { + if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) { + return false; + } + return instance.sendCommand(command); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/input/MixinKeyboardInput.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/input/MixinKeyboardInput.java new file mode 100644 index 00000000..87e3b874 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/input/MixinKeyboardInput.java @@ -0,0 +1,45 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.input; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.input.Input; +import net.minecraft.client.input.KeyboardInput; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Mixin(KeyboardInput.class) +public class MixinKeyboardInput extends Input { + + @ModifyVariable(method = "tick", at = @At(value = "LOAD", ordinal = 0), argsOnly = true) + private boolean injectTick(boolean slowDown) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) { + return this.sneaking; + } else if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) { + return !MinecraftClient.getInstance().player.isSpectator() && (this.sneaking || slowDown); + } + return slowDown; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/input/MixinMouse.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/input/MixinMouse.java new file mode 100644 index 00000000..bbacf1fe --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/input/MixinMouse.java @@ -0,0 +1,48 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.input; + +import de.florianmichael.viafabricplus.injection.access.IMinecraftClient; +import de.florianmichael.viafabricplus.value.ValueHolder; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Mouse; +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.Redirect; + +@Mixin(value = Mouse.class, priority = 1001) +public class MixinMouse { + + @Shadow @Final private MinecraftClient client; + + @Redirect(method = { "method_29615", "method_22685", "method_22684" }, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V")) + public void redirectSync(MinecraftClient instance, Runnable runnable) { + if (ValueHolder.executeInputsInSync.getValue()) { + ((IMinecraftClient) client).protocolhack_trackMouseInteraction(runnable); + return; + } + + instance.execute(runnable); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinAxeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinAxeItem.java new file mode 100644 index 00000000..08f29bcb --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinAxeItem.java @@ -0,0 +1,43 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.item.AxeItem; +import net.minecraft.item.ItemUsageContext; +import net.minecraft.util.ActionResult; +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(AxeItem.class) +public class MixinAxeItem { + + @Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true) + public void injectUseOnBlock(ItemUsageContext context, CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + cir.setReturnValue(ActionResult.PASS); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinBlockItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinBlockItem.java new file mode 100644 index 00000000..e532f55e --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinBlockItem.java @@ -0,0 +1,69 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.ChestBlock; +import net.minecraft.block.enums.ChestType; +import net.minecraft.item.BlockItem; +import net.minecraft.item.ItemPlacementContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.world.World; +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(BlockItem.class) +public class MixinBlockItem { + + @Inject(method = "canPlace", at = @At("HEAD"), cancellable = true) + private void injectCanPlace(ItemPlacementContext context, BlockState state, CallbackInfoReturnable ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + Block block = state.getBlock(); + if (block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST) { + World world = context.getWorld(); + BlockPos pos = context.getBlockPos(); + boolean foundAdjChest = false; + for (Direction dir : Direction.Type.HORIZONTAL) { + BlockState otherState = world.getBlockState(pos.offset(dir)); + if (otherState.getBlock() == block) { + if (foundAdjChest) { + ci.setReturnValue(false); + return; + } + foundAdjChest = true; + if (otherState.get(ChestBlock.CHEST_TYPE) != ChestType.SINGLE) { + ci.setReturnValue(false); + return; + } + } + } + } + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinEnderPearlItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinEnderPearlItem.java new file mode 100644 index 00000000..6c95a0b8 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinEnderPearlItem.java @@ -0,0 +1,46 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.EnderPearlItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import net.minecraft.world.World; +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(EnderPearlItem.class) +public class MixinEnderPearlItem { + + @Inject(method = "use", at = @At("HEAD"), cancellable = true) + private void injectUse(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && user.getAbilities().creativeMode) { + ci.setReturnValue(TypedActionResult.pass(user.getStackInHand(hand))); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinFireworkRocketItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinFireworkRocketItem.java new file mode 100644 index 00000000..97446ee7 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinFireworkRocketItem.java @@ -0,0 +1,43 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.FireworkRocketItem; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(FireworkRocketItem.class) +public class MixinFireworkRocketItem { + + @Redirect(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isFallFlying()Z", ordinal = 0)) + private boolean disableFireworkElytraBoost(PlayerEntity player) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11)) { + return false; + } + + return player.isFallFlying(); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinHeldItemRenderer.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinHeldItemRenderer.java new file mode 100644 index 00000000..fdc20bb7 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinHeldItemRenderer.java @@ -0,0 +1,60 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.client.MinecraftClient; +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.Hand; +import net.minecraft.util.math.RotationAxis; +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.Slice; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(HeldItemRenderer.class) +public class MixinHeldItemRenderer { + + @Shadow + @Final + private MinecraftClient client; + + @Inject(method = "renderFirstPersonItem", + slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getUseAction()Lnet/minecraft/util/UseAction;")), + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V")) + private void onRenderFirstPersonItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + //noinspection DataFlowIssue + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && client.player.isBlocking()) { + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-102.25f)); + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(13.365f)); + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(78.05f)); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinHoeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinHoeItem.java new file mode 100644 index 00000000..7f165c08 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinHoeItem.java @@ -0,0 +1,84 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import com.google.common.collect.ImmutableSet; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.item.HoeItem; +import net.minecraft.item.ItemStack; +import net.minecraft.item.MiningToolItem; +import net.minecraft.item.ToolMaterial; +import net.minecraft.registry.tag.TagKey; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; + +import java.util.Set; + +@Mixin(HoeItem.class) +public abstract class MixinHoeItem extends MiningToolItem { + + @Unique + private static final Set protocolhack_EFFECTIVE_BLOCKS_1165 = ImmutableSet.of( + Blocks.NETHER_WART_BLOCK, + Blocks.WARPED_WART_BLOCK, + Blocks.HAY_BLOCK, + Blocks.DRIED_KELP_BLOCK, + Blocks.TARGET, + Blocks.SHROOMLIGHT, + Blocks.SPONGE, + Blocks.WET_SPONGE, + Blocks.JUNGLE_LEAVES, + Blocks.OAK_LEAVES, + Blocks.SPRUCE_LEAVES, + Blocks.DARK_OAK_LEAVES, + Blocks.ACACIA_LEAVES, + Blocks.BIRCH_LEAVES + ); + + protected MixinHoeItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey effectiveBlocks, Settings settings) { + super(attackDamage, attackSpeed, material, effectiveBlocks, settings); + } + + @Override + public boolean isSuitableFor(BlockState state) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) { + return false; + } + + return super.isSuitableFor(state); + } + + @Override + public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) { + return 1.0F; + } + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) { + return protocolhack_EFFECTIVE_BLOCKS_1165.contains(state.getBlock()) ? this.miningSpeed : 1.0F; + } + return super.getMiningSpeedMultiplier(stack, state); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemCooldownManager.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemCooldownManager.java new file mode 100644 index 00000000..2ff1174c --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemCooldownManager.java @@ -0,0 +1,41 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import de.florianmichael.viafabricplus.value.ValueHolder; +import net.minecraft.entity.player.ItemCooldownManager; +import net.minecraft.item.Item; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(value = ItemCooldownManager.class) +public class MixinItemCooldownManager { + + @Inject(method = "set", at = @At("HEAD"), cancellable = true) + public void injectSet(Item item, int duration, CallbackInfo ci) { + if (ValueHolder.removeCooldowns.getValue()) { + ci.cancel(); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemGroup_EntriesImpl.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemGroup_EntriesImpl.java new file mode 100644 index 00000000..e8e088ed --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemGroup_EntriesImpl.java @@ -0,0 +1,43 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import de.florianmichael.viafabricplus.ViaFabricPlus; +import de.florianmichael.viafabricplus.value.ValueHolder; +import net.minecraft.client.MinecraftClient; +import net.minecraft.item.Item; +import net.minecraft.resource.featuretoggle.FeatureSet; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(targets = "net.minecraft.item.ItemGroup$EntriesImpl") +public class MixinItemGroup_EntriesImpl { + + @Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;isEnabled(Lnet/minecraft/resource/featuretoggle/FeatureSet;)Z")) + public boolean removeUnknownItems(Item instance, FeatureSet featureSet) { + if ((ViaFabricPlus.getClassWrapper().getAvailableItemsInTargetVersion().contains(instance) && ValueHolder.removeNotAvailableItemsFromCreativeTab.getValue()) || MinecraftClient.getInstance().isInSingleplayer()) { + return instance.isEnabled(featureSet); + } + return false; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemGroups.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemGroups.java new file mode 100644 index 00000000..0ed37688 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemGroups.java @@ -0,0 +1,50 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import de.florianmichael.vialoadingbase.api.version.ComparableProtocolVersion; +import net.minecraft.item.ItemGroups; +import net.minecraft.resource.featuretoggle.FeatureSet; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ItemGroups.class) +public class MixinItemGroups { + + @Unique + private static ComparableProtocolVersion protocolhack_version; + + @Redirect(method = "displayParametersMatch", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/featuretoggle/FeatureSet;equals(Ljava/lang/Object;)Z")) + private static boolean adjustLastVersionMatchCheck(FeatureSet instance, Object o) { + return instance.equals(o) && protocolhack_version == ViaLoadingBase.getTargetVersion(); + } + + @Inject(method = "updateDisplayParameters", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemGroups;updateEntries(Lnet/minecraft/resource/featuretoggle/FeatureSet;Z)V", shift = At.Shift.BEFORE)) + private static void trackLastVersion(FeatureSet enabledFeatures, boolean operatorEnabled, CallbackInfoReturnable cir) { + protocolhack_version = ViaLoadingBase.getTargetVersion(); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemPlacementContext.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemPlacementContext.java new file mode 100644 index 00000000..c34df8d3 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemPlacementContext.java @@ -0,0 +1,64 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemPlacementContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +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 class MixinItemPlacementContext { + + @Inject(method = "getPlayerLookDirection", at = @At("HEAD"), cancellable = true) + private void injectGetPlayerLookDirection(CallbackInfoReturnable ci) { + final ItemPlacementContext self = (ItemPlacementContext) (Object) this; + final PlayerEntity player = self.getPlayer(); + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && player != null) { + final BlockPos placementPos = self.getBlockPos(); + final double blockPosCenterFactor = ViaLoadingBase.getTargetVersion().isNewerThan(ProtocolVersion.v1_10) ? 0.5 : 0; + + if (Math.abs(player.getX() - (placementPos.getX() + blockPosCenterFactor)) < 2 && Math.abs(player.getZ() - (placementPos.getZ() + blockPosCenterFactor)) < 2) { + final double eyeY = player.getY() + player.getEyeHeight(player.getPose()); + + if (eyeY - placementPos.getY() > 2) { + ci.setReturnValue(Direction.DOWN); + return; + } + + if (placementPos.getY() - eyeY > 0) { + ci.setReturnValue(Direction.UP); + return; + } + } + + ci.setReturnValue(player.getHorizontalFacing()); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemStack.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemStack.java new file mode 100644 index 00000000..42c467d8 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemStack.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) FlorianMichael as EnZaXD 2022 + * Created on 6/24/22, 8:21 PM + * + * --FLORIAN MICHAEL PRIVATE LICENCE v1.0-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. + */ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.BlockState; +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 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.CallbackInfoReturnable; + +import java.util.OptionalDouble; + +@Mixin(ItemStack.class) +public abstract class MixinItemStack { + + @Shadow + public abstract Item getItem(); + + @Inject(method = "getMiningSpeedMultiplier", at = @At("RETURN"), cancellable = true) + private void modifyMiningSpeedMultiplier(BlockState state, CallbackInfoReturnable ci) { + final Item toolItem = ((ItemStack) (Object) this).getItem(); + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && toolItem instanceof HoeItem) { + ci.setReturnValue(1F); + } + } + + @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) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + return 0; + } else { + return player.getAttributeBaseValue(attribute); + } + } + + @SuppressWarnings({"InvalidInjectorMethodSignature", "MixinAnnotationTarget"}) + @ModifyVariable(method = "getAttributeModifiers", ordinal = 0, at = @At(value = "STORE", ordinal = 1)) + private Multimap modifyVariableGetAttributeModifiers(Multimap modifiers) { + if (modifiers.isEmpty()) { + return modifiers; + } + modifiers = HashMultimap.create(modifiers); + modifiers.removeAll(EntityAttributes.GENERIC_ATTACK_DAMAGE); + OptionalDouble defaultAttackDamage = protocolhack_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.removeAll(EntityAttributes.GENERIC_ATTACK_SPEED); + modifiers.removeAll(EntityAttributes.GENERIC_ARMOR); + modifiers.removeAll(EntityAttributes.GENERIC_ARMOR_TOUGHNESS); + return modifiers; + } + + @Unique + private OptionalDouble protocolhack_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 SwordItem) { + return OptionalDouble.of(4 + materialBonus); + } else if (item instanceof PickaxeItem) { + return OptionalDouble.of(2 + materialBonus); + } else if (item instanceof ShovelItem) { + return OptionalDouble.of(1 + materialBonus); + } else if (item instanceof AxeItem) { + return OptionalDouble.of(3 + materialBonus); + } + } + + return OptionalDouble.empty(); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinMiningToolItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinMiningToolItem.java new file mode 100644 index 00000000..a5ef2006 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinMiningToolItem.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) FlorianMichael as EnZaXD 2022 + * Created on 7/9/22, 10:40 AM + * + * --FLORIAN MICHAEL PRIVATE LICENCE v1.0-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. + */ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +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 class MixinMiningToolItem { + + @Inject(method = "getMiningSpeedMultiplier", at = @At("RETURN"), cancellable = true) + public void changeHoeEffectiveBlocks(ItemStack stack, BlockState state, CallbackInfoReturnable cir) { + //noinspection ConstantValue + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && (Object) this instanceof HoeItem) { + cir.setReturnValue(1.0F); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinPickaxeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinPickaxeItem.java new file mode 100644 index 00000000..d70279d1 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinPickaxeItem.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) FlorianMichael as EnZaXD 2022 + * Created on 6/24/22, 8:22 PM + * + * --FLORIAN MICHAEL PRIVATE LICENCE v1.0-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. + */ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import com.google.common.collect.ImmutableSet; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.Material; +import net.minecraft.item.ItemStack; +import net.minecraft.item.MiningToolItem; +import net.minecraft.item.PickaxeItem; +import net.minecraft.item.ToolMaterial; +import net.minecraft.registry.tag.TagKey; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; + +import java.util.Set; + +@Mixin(PickaxeItem.class) +public abstract class MixinPickaxeItem extends MiningToolItem { + + @Unique + private static final Set protocolhack_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); + + @Unique + private static final Set protocolhack_EFFECTIVE_MATERIALS = ImmutableSet.of(Material.METAL, Material.REPAIR_STATION, Material.STONE); + + @Unique + private static final Set protocolhack_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); + + protected MixinPickaxeItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey effectiveBlocks, Settings settings) { + super(attackDamage, attackSpeed, material, effectiveBlocks, settings); + } + + @Override + public boolean isSuitableFor(BlockState state) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) { + 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 protocolhack_EFFECTIVE_MATERIALS.contains(state.getMaterial()); + } else + return i >= 1; + } else + return i >= 2; + } + return super.isSuitableFor(state); + } + + @Override + public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) { + return protocolhack_EFFECTIVE_MATERIALS.contains(state.getMaterial()) || protocolhack_EFFECTIVE_BLOCKS_1152.contains(state.getBlock()) ? this.miningSpeed : 1.0F; + } else if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) { + return protocolhack_EFFECTIVE_MATERIALS.contains(state.getMaterial()) || protocolhack_EFFECTIVE_BLOCKS_1165.contains(state.getBlock()) ? this.miningSpeed : 1.0F; + } + return super.getMiningSpeedMultiplier(stack, state); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinShovelItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinShovelItem.java new file mode 100644 index 00000000..01a39180 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinShovelItem.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) FlorianMichael as EnZaXD 2022 + * Created on 6/24/22, 8:27 PM + * + * --FLORIAN MICHAEL PRIVATE LICENCE v1.0-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. + */ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.item.ShovelItem; +import org.spongepowered.asm.mixin.Mixin; +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; + +@Mixin(ShovelItem.class) +public class MixinShovelItem { + + @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 (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + return null; + } else { + return map.get(grassBlock); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinSwordItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinSwordItem.java new file mode 100644 index 00000000..41a78cfa --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinSwordItem.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) FlorianMichael as EnZaXD 2022 + * Created on 6/24/22, 8:28 PM + * + * --FLORIAN MICHAEL PRIVATE LICENCE v1.0-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. + */ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.item; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.SwordItem; +import net.minecraft.item.ToolItem; +import net.minecraft.item.ToolMaterial; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import net.minecraft.util.UseAction; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(SwordItem.class) +public class MixinSwordItem extends ToolItem { + + public MixinSwordItem(ToolMaterial material, Settings settings) { + super(material, settings); + } + + @Override + public TypedActionResult use(World world, PlayerEntity user, Hand hand) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + ItemStack itemStack = user.getStackInHand(hand); + user.setCurrentHand(hand); + return TypedActionResult.consume(itemStack); + } + return super.use(world, user, hand); + } + + @Override + public UseAction getUseAction(ItemStack stack) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + return UseAction.BLOCK; + } + return super.getUseAction(stack); + } + + @Override + public int getMaxUseTime(ItemStack stack) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + return 72000; + } + return super.getMaxUseTime(stack); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/packet/MixinPacketByteBuf.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/packet/MixinPacketByteBuf.java new file mode 100644 index 00000000..6af3b60d --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/packet/MixinPacketByteBuf.java @@ -0,0 +1,42 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.packet; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.text.Text; +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(value = PacketByteBuf.class) +public class MixinPacketByteBuf { + + @Inject(method = "readText", at = @At(value = "INVOKE", target = "Lio/netty/handler/codec/DecoderException;(Ljava/lang/String;)V", shift = At.Shift.BEFORE, remap = false), cancellable = true) + public void injectReadText(CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18)) { + cir.setReturnValue(null); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/packet/MixinUpdatePlayerAbilitiesC2SPacket.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/packet/MixinUpdatePlayerAbilitiesC2SPacket.java new file mode 100644 index 00000000..14b042b4 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/packet/MixinUpdatePlayerAbilitiesC2SPacket.java @@ -0,0 +1,62 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.packet; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.player.PlayerAbilities; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.packet.c2s.play.UpdatePlayerAbilitiesC2SPacket; +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.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +@Mixin(UpdatePlayerAbilitiesC2SPacket.class) +public class MixinUpdatePlayerAbilitiesC2SPacket { + + @Shadow + @Final + private boolean flying; + + @Inject(method = "write", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;writeByte(I)Lio/netty/buffer/ByteBuf;", shift = At.Shift.BEFORE), cancellable = true) + public void injectWrite(PacketByteBuf buf, CallbackInfo ci) { + final PlayerAbilities abilities = MinecraftClient.getInstance().player.getAbilities(); + + byte b = 0; + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) { + if (this.flying) b = (byte) (b | 2); // Minecraft + + if (abilities.invulnerable) b |= 1; + if (abilities.allowFlying) b |= 4; + if (abilities.creativeMode) b |= 8; // Protocol Hack Fixes + + buf.writeByte(b); + ci.cancel(); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinCommandBlockScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinCommandBlockScreen.java new file mode 100644 index 00000000..b6034996 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinCommandBlockScreen.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) FlorianMichael as EnZaXD 2022 + * Created on 6/24/22, 8:47 PM + * + * --FLORIAN MICHAEL PRIVATE LICENCE v1.0-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. + */ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.entity.CommandBlockBlockEntity; +import net.minecraft.client.gui.screen.ingame.CommandBlockScreen; +import net.minecraft.client.gui.widget.CyclingButtonWidget; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(CommandBlockScreen.class) +public abstract class MixinCommandBlockScreen { + + @Shadow + private CyclingButtonWidget modeButton; + + @Shadow + private CyclingButtonWidget conditionalModeButton; + @Shadow + private CyclingButtonWidget redstoneTriggerButton; + + @Shadow + public abstract void updateCommandBlock(); + + @Inject(method = "init", at = @At("TAIL")) + private void injectInit(CallbackInfo ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + modeButton.visible = false; + conditionalModeButton.visible = false; + redstoneTriggerButton.visible = false; + + updateCommandBlock(); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinConnectScreen_1.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinConnectScreen_1.java new file mode 100644 index 00000000..7780aab6 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinConnectScreen_1.java @@ -0,0 +1,112 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen; + +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ProfileKey; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.ViaFabricPlus; +import de.florianmichael.viafabricplus.injection.access.IPublicKeyData; +import de.florianmichael.viafabricplus.definition.v1_19_0.storage.ChatSession1_19_0; +import de.florianmichael.viafabricplus.definition.v1_19_2.storage.ChatSession1_19_2; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.ConnectScreen; +import net.minecraft.client.network.ServerAddress; +import net.minecraft.network.encryption.PlayerKeyPair; +import net.minecraft.network.encryption.PlayerPublicKey; +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.CallbackInfo; + +import java.net.InetSocketAddress; +import java.util.concurrent.ExecutionException; +import java.util.logging.Level; + +@Mixin(targets = "net.minecraft.client.gui.screen.ConnectScreen$1") +public class MixinConnectScreen_1 { + + @Final + @Shadow + ServerAddress field_33737; + + @Final + @Shadow + ConnectScreen field_2416; + + @Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetSocketAddress;getHostName()Ljava/lang/String;", ordinal = 1)) + public String replaceAddress(InetSocketAddress instance) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) return field_33737.getAddress(); + + return instance.getHostString(); + } + + @Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetSocketAddress;getPort()I")) + public int replacePort(InetSocketAddress instance) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) return field_33737.getPort(); + + return instance.getPort(); + } + + @Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/Packet;)V", ordinal = 1, shift = At.Shift.BEFORE)) + public void setupConnectionSessions(CallbackInfo ci) { + final UserConnection userConnection = field_2416.connection.channel.attr(ViaFabricPlus.LOCAL_USER_CONNECTION).get(); + + if (userConnection == null) { + ViaLoadingBase.LOGGER.log(Level.WARNING, "ViaVersion userConnection is null"); + return; + } + + if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_19)) { + return; // This disables the chat session emulation for all versions <= 1.18.2 + } + + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) { + try { + final PlayerKeyPair playerKeyPair = MinecraftClient.getInstance().getProfileKeys().fetchKeyPair().get().orElse(null); + if (playerKeyPair != null) { + final PlayerPublicKey.PublicKeyData publicKeyData = playerKeyPair.publicKey().data(); + final ProfileKey profileKey = new ProfileKey(publicKeyData.expiresAt().toEpochMilli(), publicKeyData.key().getEncoded(), publicKeyData.keySignature()); + + userConnection.put(new ChatSession1_19_2(userConnection, profileKey, playerKeyPair.privateKey())); + + if (ViaLoadingBase.getTargetVersion() == ProtocolVersion.v1_19) { + final byte[] legacyKey = ((IPublicKeyData) (Object) publicKeyData).protocolhack_get1_19_0Key().array(); + if (legacyKey != null) { + userConnection.put(new ChatSession1_19_0(userConnection, profileKey, playerKeyPair.privateKey(), legacyKey)); + } else { + ViaLoadingBase.LOGGER.log(Level.WARNING, "Mojang removed the legacy key"); + } + } + } else { + ViaLoadingBase.LOGGER.log(Level.WARNING, "Failed to fetch the key pair"); + } + } catch (InterruptedException | ExecutionException e) { + ViaLoadingBase.LOGGER.log(Level.WARNING, "Failed to fetch the key pair"); + } + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinDownloadingTerrainScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinDownloadingTerrainScreen.java new file mode 100644 index 00000000..4c090dc7 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinDownloadingTerrainScreen.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) FlorianMichael as EnZaXD 2022 + * Created on 6/24/22, 8:47 PM + * + * --FLORIAN MICHAEL PRIVATE LICENCE v1.0-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. + */ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.DownloadingTerrainScreen; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.network.packet.c2s.play.KeepAliveC2SPacket; +import net.minecraft.text.Text; +import net.minecraft.util.math.BlockPos; +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.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(DownloadingTerrainScreen.class) +public class MixinDownloadingTerrainScreen extends Screen { + + @Shadow @Final private long loadStartTime; + @Shadow private boolean closeOnNextTick; + @Shadow private boolean ready; + @Unique + private int protocolhack_tickCounter; + + public MixinDownloadingTerrainScreen(Text title) { + super(title); + } + + @Inject(method = "tick", at = @At("HEAD"), cancellable = true) + public void injectTick(CallbackInfo ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_1)) { + protocolhack_tickCounter++; + + if (protocolhack_tickCounter % 20 == 0) { + MinecraftClient.getInstance().getNetworkHandler().sendPacket(new KeepAliveC2SPacket(0)); + } + } + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) { + final boolean isTimeOver = this.closeOnNextTick || System.currentTimeMillis() > this.loadStartTime + 2000L; + + if (isTimeOver && this.client != null && this.client.player != null) { + final BlockPos blockPos = this.client.player.getBlockPos(); + final boolean isWorldLoaded = this.client.world != null && this.client.world.isOutOfHeightLimit(blockPos.getY()); + + if (isWorldLoaded || this.client.worldRenderer.isRenderingReady(blockPos)) { + this.close(); + } + + if (this.ready) { + this.closeOnNextTick = true; + } + + } + ci.cancel(); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinGameModeSelectionScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinGameModeSelectionScreen.java new file mode 100644 index 00000000..f908dbb2 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinGameModeSelectionScreen.java @@ -0,0 +1,44 @@ +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.client.gui.screen.GameModeSelectionScreen; +import net.raphimc.vialegacy.api.LegacyProtocolVersions; +import org.spongepowered.asm.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.CallbackInfo; + +import java.util.Arrays; +import java.util.List; + +@Mixin(GameModeSelectionScreen.class) +public class MixinGameModeSelectionScreen { + + @Mutable + @Shadow @Final private static int UI_WIDTH; + + @Unique + private GameModeSelectionScreen.GameModeSelection[] protocolhack_unwrappedGameModes; + + @Inject(method = "", at = @At("RETURN")) + public void fixUIWidth(CallbackInfo ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) { + final List gameModeSelections = Arrays.stream(GameModeSelectionScreen.GameModeSelection.values()).toList(); + if (ViaLoadingBase.getTargetVersion().isOlderThan(LegacyProtocolVersions.r1_3_1tor1_3_2)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE); + if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR); + + protocolhack_unwrappedGameModes = gameModeSelections.toArray(GameModeSelectionScreen.GameModeSelection[]::new); + UI_WIDTH = protocolhack_unwrappedGameModes.length * 31 - 5; + } + } + + @Redirect(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;VALUES:[Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;")) + public GameModeSelectionScreen.GameModeSelection[] removeNewerGameModes() { + if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) { + return protocolhack_unwrappedGameModes; + } + return GameModeSelectionScreen.GameModeSelection.values(); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinGameModeSelectionScreen_GameModeSelection.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinGameModeSelectionScreen_GameModeSelection.java new file mode 100644 index 00000000..1b9ddddb --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinGameModeSelectionScreen_GameModeSelection.java @@ -0,0 +1,56 @@ +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.GameModeSelectionScreen; +import net.raphimc.vialegacy.api.LegacyProtocolVersions; +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.callback.CallbackInfoReturnable; + +import java.util.Optional; + +@SuppressWarnings("DataFlowIssue") +@Mixin(GameModeSelectionScreen.GameModeSelection.class) +public class MixinGameModeSelectionScreen_GameModeSelection { + + @Shadow @Final public static GameModeSelectionScreen.GameModeSelection SURVIVAL; + + @Shadow @Final public static GameModeSelectionScreen.GameModeSelection CREATIVE; + + @Inject(method = "getCommand", at = @At("HEAD"), cancellable = true) + private void oldCommand(CallbackInfoReturnable cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.r1_2_4tor1_2_5)) { + cir.setReturnValue( + "gamemode " + MinecraftClient.getInstance().getSession().getUsername() + ' ' + switch (((Enum)(Object)this).ordinal()) { + case 0, 3 -> 1; + case 1, 2 -> 0; + default -> throw new AssertionError(); + } + ); + } + } + + @Inject(method = "next", at = @At("HEAD"), cancellable = true) + public void unwrapGameModes(CallbackInfoReturnable> cir) { + if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) { + switch ((GameModeSelectionScreen.GameModeSelection)(Object)this) { + case CREATIVE -> cir.setReturnValue(Optional.of(SURVIVAL)); + case SURVIVAL -> { + if (ViaLoadingBase.getTargetVersion().isOlderThan(LegacyProtocolVersions.r1_2_4tor1_2_5)) { + cir.setReturnValue(Optional.of(CREATIVE)); + } else { + cir.setReturnValue(Optional.of(GameModeSelectionScreen.GameModeSelection.ADVENTURE)); + } + } + case ADVENTURE -> { + cir.setReturnValue(Optional.of(CREATIVE)); + } + } + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinJigsawBlockScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinJigsawBlockScreen.java new file mode 100644 index 00000000..b9df8b1d --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinJigsawBlockScreen.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) FlorianMichael as EnZaXD 2022 + * Created on 6/24/22, 8:49 PM + * + * --FLORIAN MICHAEL PRIVATE LICENCE v1.0-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. + */ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.block.entity.JigsawBlockEntity; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.ingame.JigsawBlockScreen; +import net.minecraft.client.gui.widget.ClickableWidget; +import net.minecraft.client.gui.widget.CyclingButtonWidget; +import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(JigsawBlockScreen.class) +public class MixinJigsawBlockScreen extends Screen { + + @Shadow + private TextFieldWidget nameField; + + @Shadow + private CyclingButtonWidget jointRotationButton; + + @Shadow + private TextFieldWidget targetField; + + public MixinJigsawBlockScreen(Text title) { + super(title); + } + + @Inject(method = "init", at = @At("RETURN")) + public void injectInit(CallbackInfo ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) { + nameField.active = false; + jointRotationButton.active = false; + int index = children().indexOf(jointRotationButton); + ((ClickableWidget) children().get(index + 1)).active = false; // levels slider + ((ClickableWidget) children().get(index + 2)).active = false; // keep jigsaws toggle + ((ClickableWidget) children().get(index + 3)).active = false; // generate button + } + } + + @Inject(method = "render", at = @At("HEAD")) + public void injectRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) { + nameField.setText(targetField.getText()); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinStructureBlockScreen_1.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinStructureBlockScreen_1.java new file mode 100644 index 00000000..3a8a587a --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/MixinStructureBlockScreen_1.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) FlorianMichael as EnZaXD 2022 + * Created on 6/24/22, 8:50 PM + * + * --FLORIAN MICHAEL PRIVATE LICENCE v1.0-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. + */ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.text.Text; +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(targets = "net.minecraft.client.gui.screen.ingame.StructureBlockScreen$1") +public class MixinStructureBlockScreen_1 extends TextFieldWidget { + + public MixinStructureBlockScreen_1(TextRenderer textRenderer, int x, int y, int width, int height, TextFieldWidget copyFrom, Text text) { + super(textRenderer, x, y, width, height, copyFrom, text); + } + + @Inject(method = "charTyped(CI)Z", at = @At("HEAD"), cancellable = true) + private void onCharTyped(char chr, int keyCode, CallbackInfoReturnable ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) + ci.setReturnValue(super.charTyped(chr, keyCode)); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/hud/MixinBossBarHud_1.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/hud/MixinBossBarHud_1.java new file mode 100644 index 00000000..82cd99da --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/hud/MixinBossBarHud_1.java @@ -0,0 +1,40 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.hud; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.client.gui.hud.ClientBossBar; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(targets = "net.minecraft.client.gui.hud.BossBarHud$1") +public class MixinBossBarHud_1 { + + @Redirect(method = "updateProgress", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ClientBossBar;setPercent(F)V")) + public void nullSafety(ClientBossBar instance, float percent) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { + if (instance != null) instance.setPercent(percent); + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/merchant/MixinMerchantScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/merchant/MixinMerchantScreen.java new file mode 100644 index 00000000..429cd3fc --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/merchant/MixinMerchantScreen.java @@ -0,0 +1,68 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.merchant; + +import de.florianmichael.viafabricplus.value.ValueHolder; +import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.client.gui.screen.ingame.MerchantScreen; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.network.packet.c2s.play.SelectMerchantTradeC2SPacket; +import net.minecraft.screen.MerchantScreenHandler; +import net.minecraft.text.Text; +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; + +@Mixin(MerchantScreen.class) +public abstract class MixinMerchantScreen extends HandledScreen { + + @Shadow + private int selectedIndex; + + @Unique + private int protocolhack_previousRecipeIndex; + + public MixinMerchantScreen(MerchantScreenHandler handler, PlayerInventory inventory, Text title) { + super(handler, inventory, title); + } + + @Inject(method = "init", at = @At("HEAD")) + public void reset(CallbackInfo ci) { + protocolhack_previousRecipeIndex = 0; + } + + @Inject(method = "syncRecipeIndex", at = @At("HEAD")) + public void smoothOutRecipeIndex(CallbackInfo ci) { + if (ValueHolder.smoothOutMerchantScreens.getValue()) { + if (protocolhack_previousRecipeIndex != selectedIndex) { + int direction = protocolhack_previousRecipeIndex < selectedIndex ? 1 : -1; + for (int smooth = protocolhack_previousRecipeIndex + direction /* don't send the page we already are on */; smooth != selectedIndex; smooth += direction) { + client.getNetworkHandler().sendPacket(new SelectMerchantTradeC2SPacket(smooth)); + } + protocolhack_previousRecipeIndex = selectedIndex; + } + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/merchant/MixinMerchantScreenHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/merchant/MixinMerchantScreenHandler.java new file mode 100644 index 00000000..5630036d --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/merchant/MixinMerchantScreenHandler.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) FlorianMichael as EnZaXD 2022 + * Created on 7/9/22, 10:26 AM + * + * --FLORIAN MICHAEL PRIVATE LICENCE v1.0-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. + */ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.merchant; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.screen.MerchantScreenHandler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(MerchantScreenHandler.class) +public class MixinMerchantScreenHandler { + + @Inject(method = "switchTo", at = @At("HEAD"), cancellable = true) + private void injectSwitchTo(int recipeId, CallbackInfo ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) { + ci.cancel(); // no lmao? + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/screenhandler/MixinBrewingStandScreenHandler_FuelSlot.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/screenhandler/MixinBrewingStandScreenHandler_FuelSlot.java new file mode 100644 index 00000000..11b72251 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/screenhandler/MixinBrewingStandScreenHandler_FuelSlot.java @@ -0,0 +1,50 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.screenhandler; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.inventory.Inventory; +import net.minecraft.screen.slot.Slot; +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(targets = "net.minecraft.screen.BrewingStandScreenHandler$FuelSlot") +public class MixinBrewingStandScreenHandler_FuelSlot extends Slot { + + public MixinBrewingStandScreenHandler_FuelSlot(Inventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } + + @Inject(method = "matches(Lnet/minecraft/item/ItemStack;)Z", at = @At("HEAD"), cancellable = true) + private static void removeFuelSlot(CallbackInfoReturnable ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) + ci.setReturnValue(false); + } + + @Override + public boolean isEnabled() { + return ViaLoadingBase.getTargetVersion().isNewerThan(ProtocolVersion.v1_8); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/screenhandler/MixinPlayerScreenHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/screenhandler/MixinPlayerScreenHandler.java new file mode 100644 index 00000000..93b1e4d1 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/screenhandler/MixinPlayerScreenHandler.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) FlorianMichael as EnZaXD 2022 + * Created on 7/9/22, 10:28 AM + * + * --FLORIAN MICHAEL PRIVATE LICENCE v1.0-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. + */ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.screenhandler; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.inventory.CraftingInventory; +import net.minecraft.screen.AbstractRecipeScreenHandler; +import net.minecraft.screen.PlayerScreenHandler; +import net.minecraft.screen.ScreenHandlerType; +import net.minecraft.screen.slot.Slot; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.Slice; + +@Mixin(PlayerScreenHandler.class) +public abstract class MixinPlayerScreenHandler extends AbstractRecipeScreenHandler { + + public MixinPlayerScreenHandler(ScreenHandlerType screenHandlerType, int i) { + super(screenHandlerType, i); + } + + @Redirect(method = "", + slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/screen/PlayerScreenHandler$2;(Lnet/minecraft/screen/PlayerScreenHandler;Lnet/minecraft/inventory/Inventory;III)V")), + at = @At(value = "INVOKE", target = "Lnet/minecraft/screen/PlayerScreenHandler;addSlot(Lnet/minecraft/screen/slot/Slot;)Lnet/minecraft/screen/slot/Slot;", ordinal = 0)) + private Slot redirectAddOffhandSlot(PlayerScreenHandler screenHandler, Slot slot) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) + return null; + return addSlot(slot); + } + + @SuppressWarnings("InvalidInjectorMethodSignature") + @ModifyVariable(method = "quickMove", ordinal = 0, at = @At(value = "STORE", ordinal = 0)) + private EquipmentSlot injectTransferSlot(EquipmentSlot slot) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && slot == EquipmentSlot.OFFHAND) + return EquipmentSlot.MAINHAND; + else + return slot; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/screenhandler/MixinScreenHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/screenhandler/MixinScreenHandler.java new file mode 100644 index 00000000..5bd220ef --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/screen/screenhandler/MixinScreenHandler.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) FlorianMichael as EnZaXD 2022 + * Created on 7/9/22, 1:46 AM + * + * --FLORIAN MICHAEL PRIVATE LICENCE v1.0-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. + */ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.screenhandler; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.injection.access.IScreenHandler; +import de.florianmichael.vialoadingbase.ViaLoadingBase; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.slot.SlotActionType; +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.CallbackInfo; + +@Mixin(ScreenHandler.class) +public class MixinScreenHandler implements IScreenHandler { + + @Unique + private short protocolhack_lastActionId = 0; + + @Inject(method = "internalOnSlotClick", at = @At("HEAD"), cancellable = true) + private void injectInternalOnSlotClick(int slot, int clickData, SlotActionType actionType, PlayerEntity player, CallbackInfo ci) { + if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && actionType == SlotActionType.SWAP && clickData == 40) { + ci.cancel(); + } + } + + @Override + public short protocolhack_getAndIncrementLastActionId() { + return ++protocolhack_lastActionId; + } +} diff --git a/src/main/java/de/florianmichael/everyprotocol/injection/mixin/vialoadingbase/MixinCustomViaConfig.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/vialoadingbase/MixinCustomViaConfig.java similarity index 90% rename from src/main/java/de/florianmichael/everyprotocol/injection/mixin/vialoadingbase/MixinCustomViaConfig.java rename to src/main/java/de/florianmichael/viafabricplus/injection/mixin/vialoadingbase/MixinCustomViaConfig.java index dbce7b9a..93447e4f 100644 --- a/src/main/java/de/florianmichael/everyprotocol/injection/mixin/vialoadingbase/MixinCustomViaConfig.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/vialoadingbase/MixinCustomViaConfig.java @@ -1,4 +1,4 @@ -package de.florianmichael.everyprotocol.injection.mixin.vialoadingbase; +package de.florianmichael.viafabricplus.injection.mixin.vialoadingbase; import com.viaversion.viaversion.configuration.AbstractViaConfig; import de.florianmichael.vialoadingbase.internal.viaversion.CustomViaConfig; diff --git a/src/main/java/de/florianmichael/everyprotocol/injection/mixin/viaversion/MixinPacketWrapperImpl.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/viaversion/MixinPacketWrapperImpl.java similarity index 83% rename from src/main/java/de/florianmichael/everyprotocol/injection/mixin/viaversion/MixinPacketWrapperImpl.java rename to src/main/java/de/florianmichael/viafabricplus/injection/mixin/viaversion/MixinPacketWrapperImpl.java index 9c563aef..2249d189 100644 --- a/src/main/java/de/florianmichael/everyprotocol/injection/mixin/viaversion/MixinPacketWrapperImpl.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/viaversion/MixinPacketWrapperImpl.java @@ -1,9 +1,9 @@ -package de.florianmichael.everyprotocol.injection.mixin.viaversion; +package de.florianmichael.viafabricplus.injection.mixin.viaversion; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocol.packet.PacketWrapperImpl; import com.viaversion.viaversion.util.Pair; -import de.florianmichael.everyprotocol.injection.access.IPacketWrapperImpl; +import de.florianmichael.viafabricplus.injection.access.IPacketWrapperImpl; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; diff --git a/src/main/java/de/florianmichael/viafabricplus/platform/PreNettyConstants.java b/src/main/java/de/florianmichael/viafabricplus/platform/PreNettyConstants.java new file mode 100644 index 00000000..4edfb4e6 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/platform/PreNettyConstants.java @@ -0,0 +1,28 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.platform; + +public class PreNettyConstants { + + public static final String DECODER = "via-legacy-decoder"; + public static final String ENCODER = "via-legacy-encoder"; +} diff --git a/src/main/java/de/florianmichael/viafabricplus/platform/ProtocolRange.java b/src/main/java/de/florianmichael/viafabricplus/platform/ProtocolRange.java new file mode 100644 index 00000000..6a13f8a6 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/platform/ProtocolRange.java @@ -0,0 +1,45 @@ +package de.florianmichael.viafabricplus.platform; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.vialoadingbase.api.version.ComparableProtocolVersion; +import de.florianmichael.vialoadingbase.api.version.InternalProtocolList; + +public class ProtocolRange { + private final ComparableProtocolVersion lowerBound; + private final ComparableProtocolVersion upperBound; + + public ProtocolRange(ProtocolVersion lowerBound, ProtocolVersion upperBound) { + if (lowerBound == null && upperBound == null) { + throw new RuntimeException("Invalid protocol range"); + } + this.lowerBound = InternalProtocolList.fromProtocolVersion(lowerBound); + this.upperBound = InternalProtocolList.fromProtocolVersion(upperBound); + } + + public static ProtocolRange andNewer(final ProtocolVersion version) { + return new ProtocolRange(null, version); + } + + public static ProtocolRange singleton(final ProtocolVersion version) { + return new ProtocolRange(version, version); + } + + public static ProtocolRange andOlder(final ProtocolVersion version) { + return new ProtocolRange(version, null); + } + + public boolean contains(final ComparableProtocolVersion protocolVersion) { + if (this.lowerBound != null && this.lowerBound.getIndex() < protocolVersion.getIndex()) return false; + + return this.upperBound == null || this.upperBound.getIndex() <= protocolVersion.getIndex(); + } + + @Override + public String toString() { + if (lowerBound == null) return upperBound.getName() + "+"; + if (upperBound == null) return lowerBound.getName() + "-"; + if (lowerBound == upperBound) return lowerBound.getName(); + + return lowerBound.getName() + " - " + upperBound.getName(); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/platform/ViaAprilFoolsPlatformImpl.java b/src/main/java/de/florianmichael/viafabricplus/platform/ViaAprilFoolsPlatformImpl.java new file mode 100644 index 00000000..8347ac15 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/platform/ViaAprilFoolsPlatformImpl.java @@ -0,0 +1,48 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.platform; + +import com.viaversion.viaversion.api.Via; +import de.florianmichael.vialoadingbase.util.JLoggerToLog4j; +import net.raphimc.vialegacy.platform.ViaLegacyPlatform; +import org.apache.logging.log4j.LogManager; + +import java.io.File; +import java.util.logging.Logger; + +public class ViaAprilFoolsPlatformImpl implements ViaLegacyPlatform { + private static final Logger LOGGER = new JLoggerToLog4j(LogManager.getLogger("ViaAprilFools")); + + public ViaAprilFoolsPlatformImpl() { + this.init(this.getDataFolder()); + } + + @Override + public Logger getLogger() { + return LOGGER; + } + + @Override + public File getDataFolder() { + return Via.getPlatform().getDataFolder(); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/platform/ViaLegacyPlatformImpl.java b/src/main/java/de/florianmichael/viafabricplus/platform/ViaLegacyPlatformImpl.java new file mode 100644 index 00000000..1c16e03c --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/platform/ViaLegacyPlatformImpl.java @@ -0,0 +1,48 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.platform; + +import com.viaversion.viaversion.api.Via; +import de.florianmichael.vialoadingbase.util.JLoggerToLog4j; +import net.raphimc.vialegacy.platform.ViaLegacyPlatform; +import org.apache.logging.log4j.LogManager; + +import java.io.File; +import java.util.logging.Logger; + +public class ViaLegacyPlatformImpl implements ViaLegacyPlatform { + private static final Logger LOGGER = new JLoggerToLog4j(LogManager.getLogger("ViaLegacy")); + + public ViaLegacyPlatformImpl() { + this.init(this.getDataFolder()); + } + + @Override + public Logger getLogger() { + return LOGGER; + } + + @Override + public File getDataFolder() { + return Via.getPlatform().getDataFolder(); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/provider/EveryProtocolHandItemProvider.java b/src/main/java/de/florianmichael/viafabricplus/provider/EveryProtocolHandItemProvider.java new file mode 100644 index 00000000..d58e7943 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/provider/EveryProtocolHandItemProvider.java @@ -0,0 +1,41 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.provider; + +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.item.Item; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider; +import de.florianmichael.viafabricplus.translator.ItemTranslator; +import net.minecraft.item.ItemStack; + +public class EveryProtocolHandItemProvider extends HandItemProvider { + public static ItemStack lastUsedItem = null; + + @Override + public Item getHandItem(UserConnection info) { + if (lastUsedItem == null) { + return null; + } + return ItemTranslator.minecraftToViaVersion(info, lastUsedItem, ProtocolVersion.v1_8.getVersion()); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/provider/EveryProtocolMovementTransmitterProvider.java b/src/main/java/de/florianmichael/viafabricplus/provider/EveryProtocolMovementTransmitterProvider.java new file mode 100644 index 00000000..245edda2 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/provider/EveryProtocolMovementTransmitterProvider.java @@ -0,0 +1,41 @@ +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.provider; + +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; + +public class EveryProtocolMovementTransmitterProvider extends MovementTransmitterProvider { + + @Override + public Object getFlyingPacket() { + return null; + } + + @Override + public Object getGroundPacket() { + return null; + } + + @Override + public void sendPlayer(UserConnection userConnection) {} +} diff --git a/src/main/java/de/florianmichael/everyprotocol/translator/ItemTranslator.java b/src/main/java/de/florianmichael/viafabricplus/translator/ItemTranslator.java similarity index 63% rename from src/main/java/de/florianmichael/everyprotocol/translator/ItemTranslator.java rename to src/main/java/de/florianmichael/viafabricplus/translator/ItemTranslator.java index 214ac398..8d0f7ca2 100644 --- a/src/main/java/de/florianmichael/everyprotocol/translator/ItemTranslator.java +++ b/src/main/java/de/florianmichael/viafabricplus/translator/ItemTranslator.java @@ -1,4 +1,25 @@ -package de.florianmichael.everyprotocol.translator; +/** + * --FLORIAN MICHAEL PRIVATE LICENCE v1.2-- + * + * This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD), + * any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this + * file / project is prohibited. It requires in that use a written permission with official signature of the owner + * "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not + * cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected. + * The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements + * that have arisen, are arising or will arise from this project / file. If this licence is used anywhere, + * the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically. + * + * Changelog: + * v1.0: + * Added License + * v1.1: + * Ownership withdrawn + * v1.2: + * Version-independent validity and automatic renewal + */ + +package de.florianmichael.viafabricplus.translator; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; @@ -8,7 +29,7 @@ import com.viaversion.viaversion.api.protocol.packet.Direction; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.protocol.packet.PacketWrapperImpl; -import de.florianmichael.everyprotocol.injection.access.IPacketWrapperImpl; +import de.florianmichael.viafabricplus.injection.access.IPacketWrapperImpl; import de.florianmichael.vialoadingbase.ViaLoadingBase; import io.netty.buffer.Unpooled; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/florianmichael/viafabricplus/value/AbstractValue.java b/src/main/java/de/florianmichael/viafabricplus/value/AbstractValue.java new file mode 100644 index 00000000..7881c7e6 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/value/AbstractValue.java @@ -0,0 +1,31 @@ +package de.florianmichael.viafabricplus.value; + +public abstract class AbstractValue { + private final String name; + private final T defaultValue; + + private T value; + + public AbstractValue(String name, T defaultValue) { + this.name = name; + this.defaultValue = defaultValue; + + this.value = defaultValue; + } + + public String getName() { + return name; + } + + public T getDefaultValue() { + return defaultValue; + } + + public T getValue() { + return value; + } + + public void setValue(T value) { + this.value = value; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/value/ValueHolder.java b/src/main/java/de/florianmichael/viafabricplus/value/ValueHolder.java new file mode 100644 index 00000000..2467ef1e --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/value/ValueHolder.java @@ -0,0 +1,28 @@ +package de.florianmichael.viafabricplus.value; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.platform.ProtocolRange; +import de.florianmichael.viafabricplus.value.impl.BooleanValue; +import de.florianmichael.viafabricplus.value.impl.ProtocolSyncBooleanValue; + +import java.util.ArrayList; +import java.util.List; + +public class ValueHolder { + private final static List> values = new ArrayList<>(); + + // General settings + public static final BooleanValue removeNotAvailableItemsFromCreativeTab = new BooleanValue("Remove not available items from creative tab", true); + + // 1.14 -> 1.13.2 + public static final ProtocolSyncBooleanValue smoothOutMerchantScreens = new ProtocolSyncBooleanValue("Smooth out merchant screens", ProtocolRange.andOlder(ProtocolVersion.v1_13_2)); + + // 1.13 -> 1.12.2 + public static final ProtocolSyncBooleanValue executeInputsInSync = new ProtocolSyncBooleanValue("Execute inputs in sync", ProtocolRange.andOlder(ProtocolVersion.v1_12_2)); + + // 1.9 -> 1.8.x + public static final ProtocolSyncBooleanValue removeCooldowns = new ProtocolSyncBooleanValue("Remove cooldowns", ProtocolRange.andOlder(ProtocolVersion.v1_8)); + + public static void setup() { + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/value/impl/BooleanValue.java b/src/main/java/de/florianmichael/viafabricplus/value/impl/BooleanValue.java new file mode 100644 index 00000000..695c1d90 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/value/impl/BooleanValue.java @@ -0,0 +1,10 @@ +package de.florianmichael.viafabricplus.value.impl; + +import de.florianmichael.viafabricplus.value.AbstractValue; + +public class BooleanValue extends AbstractValue { + + public BooleanValue(String name, Boolean defaultValue) { + super(name, defaultValue); + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/value/impl/ProtocolSyncBooleanValue.java b/src/main/java/de/florianmichael/viafabricplus/value/impl/ProtocolSyncBooleanValue.java new file mode 100644 index 00000000..173e1a37 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/value/impl/ProtocolSyncBooleanValue.java @@ -0,0 +1,31 @@ +package de.florianmichael.viafabricplus.value.impl; + +import de.florianmichael.viafabricplus.platform.ProtocolRange; +import de.florianmichael.viafabricplus.value.AbstractValue; +import de.florianmichael.vialoadingbase.ViaLoadingBase; + +public class ProtocolSyncBooleanValue extends AbstractValue { + private final ProtocolRange protocolRange; + + private boolean syncWithProtocol; + + public ProtocolSyncBooleanValue(String name, ProtocolRange protocolRange) { + super(name, true); + + this.protocolRange = protocolRange; + } + + @Override + public Boolean getValue() { + if (this.syncWithProtocol) return protocolRange.contains(ViaLoadingBase.getTargetVersion()); + return super.getValue(); + } + + public boolean isSyncWithProtocol() { + return syncWithProtocol; + } + + public void setSyncWithProtocol(boolean syncWithProtocol) { + this.syncWithProtocol = syncWithProtocol; + } +} diff --git a/src/main/resources/assets/everyprotocol/icon.png b/src/main/resources/assets/viafabricplus/icon.png similarity index 100% rename from src/main/resources/assets/everyprotocol/icon.png rename to src/main/resources/assets/viafabricplus/icon.png diff --git a/src/main/resources/everyprotocol.mixins.json b/src/main/resources/everyprotocol.mixins.json deleted file mode 100644 index 62dce473..00000000 --- a/src/main/resources/everyprotocol.mixins.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "de.florianmichael.everyprotocol.injection.mixin", - "compatibilityLevel": "JAVA_17", - "mixins": [ - "base.MixinClientConnection", - "base.MixinClientConnection_1", - "vialoadingbase.MixinCustomViaConfig", - "viaversion.MixinPacketWrapperImpl" - ], - "injectors": { - "defaultRequire": 1 - }, - "client": [ - "base.MixinMain" - ] -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 7467da17..e5e9d6ad 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,9 +1,9 @@ { "schemaVersion": 1, - "id": "everyprotocol", + "id": "viafabricplus", "version": "${version}", - "name": "Every Protocol", + "name": "ViaFabricPlus", "description": " Clientside ViaVersion, ViaLegacy and ViaAprilFools implementation with clientside fixes for Fabric", "authors": [ "FlorianMichael", @@ -12,17 +12,17 @@ ], "contact": { "homepage": "https://github.com/FlorianMichael/", - "sources": "https://github.com/FlorianMichael/EveryProtocol" + "sources": "https://github.com/FlorianMichael/ViaFabricPlus" }, "license": "CC0-1.0", - "icon": "assets/everyprotocol/icon.png", + "icon": "assets/viafabricplus/icon.png", "environment": "*", "mixins": [ - "everyprotocol.mixins.json" + "viafabricplus.mixins.json" ], - + "accessWidener": "viafabricplus.accesswidener", "depends": { "fabricloader": ">=0.14.11", "minecraft": "~1.19.3", diff --git a/src/main/resources/viafabricplus.accesswidener b/src/main/resources/viafabricplus.accesswidener new file mode 100644 index 00000000..4ef21899 --- /dev/null +++ b/src/main/resources/viafabricplus.accesswidener @@ -0,0 +1,8 @@ +accessWidener v1 named + +accessible field net/minecraft/client/network/AllowedAddressResolver redirectResolver Lnet/minecraft/client/network/RedirectResolver; +accessible field net/minecraft/item/Item ATTACK_DAMAGE_MODIFIER_ID Ljava/util/UUID; +accessible field net/minecraft/client/gui/screen/ConnectScreen connection Lnet/minecraft/network/ClientConnection; +accessible field net/minecraft/network/ClientConnection channel Lio/netty/channel/Channel; + +accessible class net/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json new file mode 100644 index 00000000..b28abe9d --- /dev/null +++ b/src/main/resources/viafabricplus.mixins.json @@ -0,0 +1,80 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "de.florianmichael.viafabricplus.injection.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "base.MixinClientConnection", + "base.MixinClientConnection_1", + "fixes.MixinPlayerPublicKey_PublicKeyData", + "fixes.block.MixinAbstractBlock_AbstractBlockState", + "fixes.block.MixinAnvilBlock", + "fixes.block.MixinBambooBlock", + "fixes.block.MixinBedBlock", + "fixes.block.MixinBlock", + "fixes.block.MixinBlockView", + "fixes.block.MixinBrewingStandBlock", + "fixes.block.MixinCauldronBlock", + "fixes.block.MixinEndPortalBlock", + "fixes.block.MixinEndPortalFrameBlock", + "fixes.block.MixinFarmlandBlock", + "fixes.block.MixinFenceBlock", + "fixes.block.MixinFireBlock", + "fixes.block.MixinFlowerPotBlock", + "fixes.block.MixinHopperBlock", + "fixes.block.MixinLadderBlock", + "fixes.block.MixinLightBlock", + "fixes.block.MixinLilyPadBlock", + "fixes.block.MixinPaneBlock", + "fixes.block.MixinPistonHeadBlock", + "fixes.block.MixinSnowBlock", + "fixes.block.MixinSoulSandBlock", + "fixes.block.MixinSugarCaneBlock", + "fixes.block.MixinWallBlock", + "fixes.item.MixinAxeItem", + "fixes.item.MixinBlockItem", + "fixes.item.MixinEnderPearlItem", + "fixes.item.MixinFireworkRocketItem", + "fixes.item.MixinHoeItem", + "fixes.item.MixinItemCooldownManager", + "fixes.item.MixinItemGroup_EntriesImpl", + "fixes.item.MixinItemGroups", + "fixes.item.MixinItemPlacementContext", + "fixes.item.MixinItemStack", + "fixes.item.MixinMiningToolItem", + "fixes.item.MixinPickaxeItem", + "fixes.item.MixinShovelItem", + "fixes.item.MixinSwordItem", + "fixes.packet.MixinPacketByteBuf", + "fixes.packet.MixinUpdatePlayerAbilitiesC2SPacket", + "fixes.screen.MixinConnectScreen_1", + "fixes.screen.hud.MixinBossBarHud_1", + "fixes.screen.merchant.MixinMerchantScreenHandler", + "fixes.screen.screenhandler.MixinBrewingStandScreenHandler_FuelSlot", + "fixes.screen.screenhandler.MixinPlayerScreenHandler", + "fixes.screen.screenhandler.MixinScreenHandler", + "vialoadingbase.MixinCustomViaConfig", + "viaversion.MixinPacketWrapperImpl" + ], + "injectors": { + "defaultRequire": 1 + }, + "client": [ + "base.MixinMain", + "fixes.MixinMinecraftClient", + "fixes.MixinProfileKeysImpl", + "fixes.MixinServerAddress", + "fixes.MixinServerResourcePackProvider", + "fixes.input.MixinKeyboard", + "fixes.input.MixinKeyboardInput", + "fixes.input.MixinMouse", + "fixes.item.MixinHeldItemRenderer", + "fixes.screen.MixinCommandBlockScreen", + "fixes.screen.MixinDownloadingTerrainScreen", + "fixes.screen.MixinGameModeSelectionScreen", + "fixes.screen.MixinGameModeSelectionScreen_GameModeSelection", + "fixes.screen.MixinJigsawBlockScreen", + "fixes.screen.MixinStructureBlockScreen_1", + "fixes.screen.merchant.MixinMerchantScreen" + ] +}