Structural refactor of fixes package

This commit introduces the fixes/versioned package, where random class files for specific game versions are stored since I don't want them to be in the root package and splitting more common data dumps and more version-specific class files into separate packages looks like a good solution for me.
This commit is contained in:
FlorianMichael 2024-01-12 09:14:03 +01:00
parent e1a98531df
commit 35d795ea3d
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
36 changed files with 52 additions and 51 deletions

View File

@ -21,11 +21,12 @@ package de.florianmichael.viafabricplus.fixes;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.event.PostGameLoadCallback;
import de.florianmichael.viafabricplus.fixes.classic.CPEAdditions;
import de.florianmichael.viafabricplus.fixes.classic.GridItemSelectionScreen;
import de.florianmichael.viafabricplus.fixes.versioned.classic.CPEAdditions;
import de.florianmichael.viafabricplus.fixes.versioned.classic.GridItemSelectionScreen;
import de.florianmichael.viafabricplus.fixes.data.ResourcePackHeaderDiff;
import de.florianmichael.viafabricplus.fixes.entity.EntityDimensionReplacements;
import de.florianmichael.viafabricplus.fixes.particle.FootStepParticle;
import de.florianmichael.viafabricplus.fixes.data.EntityDimensionDiff;
import de.florianmichael.viafabricplus.fixes.versioned.visual.ArmorHudEmulation1_8;
import de.florianmichael.viafabricplus.fixes.versioned.visual.FootStepParticle1_12_2;
import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin;
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
@ -73,7 +74,7 @@ public class ClientsideFixes {
PostGameLoadCallback.EVENT.register(() -> {
// Handles and updates entity dimension changes in <= 1.17
EntityDimensionReplacements.init();
EntityDimensionDiff.init();
// Ticks the armor hud manually in <= 1.8.x
ArmorHudEmulation1_8.init();
@ -113,7 +114,7 @@ public class ClientsideFixes {
}));
// Register the footstep particle
FootStepParticle.init();
FootStepParticle1_12_2.init();
}
/**

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.entity;
package de.florianmichael.viafabricplus.fixes.data;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import net.minecraft.client.MinecraftClient;
@ -33,7 +33,7 @@ import static de.florianmichael.viafabricplus.util.MapUtil.linkedHashMap;
/**
* Data dump for entity dimension changes between versions.
*/
public class EntityDimensionReplacements {
public class EntityDimensionDiff {
/**
* A map of entity types to a map of versions to dimensions.

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes;
package de.florianmichael.viafabricplus.fixes.versioned;
import net.minecraft.util.ActionResult;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes;
package de.florianmichael.viafabricplus.fixes.versioned;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.replacement;
package de.florianmichael.viafabricplus.fixes.versioned;
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.replacement;
package de.florianmichael.viafabricplus.fixes.versioned;
import net.minecraft.block.BlockState;
import net.minecraft.client.network.ClientPlayerEntity;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.classic;
package de.florianmichael.viafabricplus.fixes.versioned.classic;
import com.viaversion.viaversion.api.connection.UserConnection;
import io.netty.buffer.ByteBuf;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.classic;
package de.florianmichael.viafabricplus.fixes.versioned.classic;
import de.florianmichael.viafabricplus.fixes.data.ItemRegistryDiff;
import de.florianmichael.viafabricplus.screen.VFPScreen;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.classic;
package de.florianmichael.viafabricplus.fixes.versioned.classic;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.classic.command;
package de.florianmichael.viafabricplus.fixes.versioned.classic.command;
import com.viaversion.viaversion.api.command.ViaCommandSender;
import com.viaversion.viaversion.api.connection.UserConnection;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.classic.command;
package de.florianmichael.viafabricplus.fixes.versioned.classic.command;
import com.viaversion.viaversion.api.command.ViaCommandSender;
import com.viaversion.viaversion.api.connection.UserConnection;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes;
package de.florianmichael.viafabricplus.fixes.versioned.visual;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.entity;
package de.florianmichael.viafabricplus.fixes.versioned.visual;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.model.*;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.entity;
package de.florianmichael.viafabricplus.fixes.versioned.visual;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.VertexConsumer;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.replacement;
package de.florianmichael.viafabricplus.fixes.versioned.visual;
import net.minecraft.client.font.Glyph;
import net.minecraft.client.font.GlyphRenderer;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.entity;
package de.florianmichael.viafabricplus.fixes.versioned.visual;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.Entity;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.fixes.particle;
package de.florianmichael.viafabricplus.fixes.versioned.visual;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
@ -34,11 +34,11 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.raphimc.vialoader.util.VersionEnum;
public class FootStepParticle extends SpriteBillboardParticle {
public class FootStepParticle1_12_2 extends SpriteBillboardParticle {
public static int ID;
protected FootStepParticle(ClientWorld clientWorld, double x, double y, double z) {
protected FootStepParticle1_12_2(ClientWorld clientWorld, double x, double y, double z) {
super(clientWorld, x, y, z);
this.scale = 0.125F;
@ -81,7 +81,7 @@ public class FootStepParticle extends SpriteBillboardParticle {
final DefaultParticleType footStepType = FabricParticleTypes.simple(true);
Registry.register(Registries.PARTICLE_TYPE, new Identifier("viafabricplus", "footstep"), footStepType);
ParticleFactoryRegistry.getInstance().register(footStepType, FootStepParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(footStepType, FootStepParticle1_12_2.Factory::new);
ID = Registries.PARTICLE_TYPE.getRawId(footStepType);
}
@ -100,7 +100,7 @@ public class FootStepParticle extends SpriteBillboardParticle {
throw new UnsupportedOperationException("FootStepParticle is not supported on versions newer than 1.12.2");
}
final FootStepParticle particle = new FootStepParticle(world, x, y, z);
final FootStepParticle1_12_2 particle = new FootStepParticle1_12_2(world, x, y, z);
particle.setSprite(this.spriteProvider);
return particle;
}

View File

@ -19,7 +19,7 @@
package de.florianmichael.viafabricplus.injection.access;
import de.florianmichael.viafabricplus.fixes.ClientPlayerInteractionManager1_18_2;
import de.florianmichael.viafabricplus.fixes.versioned.ClientPlayerInteractionManager1_18_2;
public interface IClientPlayerInteractionManager {

View File

@ -23,7 +23,7 @@ import com.mojang.authlib.minecraft.client.MinecraftClient;
import com.mojang.authlib.yggdrasil.YggdrasilUserApiService;
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.fixes.replacement.KeyPairResponse1_19_0;
import de.florianmichael.viafabricplus.fixes.versioned.KeyPairResponse1_19_0;
import de.florianmichael.viafabricplus.injection.access.ILegacyKeySignatureStorage;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -19,7 +19,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import de.florianmichael.viafabricplus.fixes.replacement.PendingUpdateManager1_18_2;
import de.florianmichael.viafabricplus.fixes.versioned.PendingUpdateManager1_18_2;
import de.florianmichael.viafabricplus.injection.access.IEntity;
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
import net.minecraft.client.network.ClientPlayNetworkHandler;

View File

@ -21,7 +21,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.llamalad7.mixinextras.sugar.Local;
import de.florianmichael.viafabricplus.fixes.data.RenderableGlyphDiff;
import de.florianmichael.viafabricplus.fixes.replacement.BuiltinEmptyGlyph1_12_2;
import de.florianmichael.viafabricplus.fixes.versioned.visual.BuiltinEmptyGlyph1_12_2;
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.*;

View File

@ -19,7 +19,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import de.florianmichael.viafabricplus.fixes.entity.EntityRidingOffsetsPre1_20_2;
import de.florianmichael.viafabricplus.fixes.versioned.visual.EntityRidingOffsetsPre1_20_2;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;

View File

@ -19,7 +19,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import de.florianmichael.viafabricplus.fixes.entity.EntityRidingOffsetsPre1_20_2;
import de.florianmichael.viafabricplus.fixes.versioned.visual.EntityRidingOffsetsPre1_20_2;
import de.florianmichael.viafabricplus.injection.access.IEntity;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;

View File

@ -20,7 +20,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.google.common.collect.ImmutableMap;
import de.florianmichael.viafabricplus.fixes.entity.BoatModel1_8;
import de.florianmichael.viafabricplus.fixes.versioned.visual.BoatModel1_8;
import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.client.render.entity.model.EntityModels;

View File

@ -19,7 +19,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import de.florianmichael.viafabricplus.fixes.entity.BoatRenderer1_8;
import de.florianmichael.viafabricplus.fixes.versioned.visual.BoatRenderer1_8;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;

View File

@ -19,7 +19,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import de.florianmichael.viafabricplus.fixes.entity.EntityRidingOffsetsPre1_20_2;
import de.florianmichael.viafabricplus.fixes.versioned.visual.EntityRidingOffsetsPre1_20_2;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
import net.minecraft.block.BlockState;

View File

@ -25,8 +25,8 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
import de.florianmichael.viafabricplus.fixes.ActionResultException1_12_2;
import de.florianmichael.viafabricplus.fixes.ClientPlayerInteractionManager1_18_2;
import de.florianmichael.viafabricplus.fixes.versioned.ActionResultException1_12_2;
import de.florianmichael.viafabricplus.fixes.versioned.ClientPlayerInteractionManager1_18_2;
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
import de.florianmichael.viafabricplus.injection.access.IClientPlayerInteractionManager;
import de.florianmichael.viafabricplus.injection.access.IScreenHandler;

View File

@ -19,7 +19,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import de.florianmichael.viafabricplus.fixes.classic.GridItemSelectionScreen;
import de.florianmichael.viafabricplus.fixes.versioned.classic.GridItemSelectionScreen;
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;

View File

@ -19,7 +19,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.vialegacy;
import de.florianmichael.viafabricplus.fixes.classic.CPEAdditions;
import de.florianmichael.viafabricplus.fixes.versioned.classic.CPEAdditions;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

View File

@ -19,7 +19,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.vialegacy;
import de.florianmichael.viafabricplus.fixes.classic.CPEAdditions;
import de.florianmichael.viafabricplus.fixes.versioned.classic.CPEAdditions;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.ClientboundPacketsc0_30cpe;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

View File

@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.Protocol1_19_4To1_19_3;
import de.florianmichael.viafabricplus.fixes.classic.CPEAdditions;
import de.florianmichael.viafabricplus.fixes.versioned.classic.CPEAdditions;
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.ClientboundPacketsc0_28;
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.ServerboundPacketsc0_28;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.ClientboundPacketsc0_30cpe;

View File

@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets.EntityPackets;
import de.florianmichael.viafabricplus.fixes.classic.WorldHeightSupport;
import de.florianmichael.viafabricplus.fixes.versioned.classic.WorldHeightSupport;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

View File

@ -20,7 +20,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;
import com.viaversion.viaversion.api.data.MappingDataBase;
import de.florianmichael.viafabricplus.fixes.particle.FootStepParticle;
import de.florianmichael.viafabricplus.fixes.versioned.visual.FootStepParticle1_12_2;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -31,7 +31,7 @@ public abstract class MixinMappingDataBase {
@Inject(method = "getNewParticleId", at = @At("HEAD"), cancellable = true)
private void passthroughFootStepParticle(int id, CallbackInfoReturnable<Integer> cir) {
if (id == FootStepParticle.ID) {
if (id == FootStepParticle1_12_2.ID) {
cir.setReturnValue(id);
}
}

View File

@ -20,7 +20,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.ParticleRewriter;
import de.florianmichael.viafabricplus.fixes.particle.FootStepParticle;
import de.florianmichael.viafabricplus.fixes.versioned.visual.FootStepParticle1_12_2;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -40,7 +40,7 @@ public abstract class MixinParticleRewriter {
@Inject(method = "<clinit>", at = @At("RETURN"))
private static void checkFootStepIdOverlap(CallbackInfo ci) {
if (FootStepParticle.ID < particles.size()) {
if (FootStepParticle1_12_2.ID < particles.size()) {
throw new IllegalStateException("ViaFabricPlus FootStepParticle ID overlaps with a vanilla 1.12.2 particle ID");
}
}
@ -50,7 +50,7 @@ public abstract class MixinParticleRewriter {
if (particles.size() == 8) { // minecraft:depthsuspend -> minecraft:mycelium
return 32;
} else if (particles.size() == 28) { // minecraft:footstep -> viafabricplus:footstep
return FootStepParticle.ID;
return FootStepParticle1_12_2.ID;
} else {
return id;
}

View File

@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets.WorldPackets;
import de.florianmichael.viafabricplus.fixes.classic.WorldHeightSupport;
import de.florianmichael.viafabricplus.fixes.versioned.classic.WorldHeightSupport;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

View File

@ -23,8 +23,8 @@ import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import de.florianmichael.viafabricplus.fixes.classic.command.ListExtensionsCommand;
import de.florianmichael.viafabricplus.fixes.classic.command.SetTimeCommand;
import de.florianmichael.viafabricplus.fixes.versioned.classic.command.ListExtensionsCommand;
import de.florianmichael.viafabricplus.fixes.versioned.classic.command.SetTimeCommand;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.raphimc.vialoader.impl.viaversion.VLCommandHandler;