Addon: ViaFabricPlusVisual

updated README.md
This commit is contained in:
FlorianMichael 2023-02-21 02:02:06 +01:00
parent 1b70846c38
commit 15914f33c2
18 changed files with 476 additions and 12 deletions

View File

@ -1,3 +1,15 @@
# ViaFabricPlus
Clientside ViaVersion, ViaLegacy and ViaAprilFools implementation with clientside fixes for Fabric
## Why?
Originally ViaFabricPlus was not a standalone project but a part of my Minecraft Utility Mod, <br>
since this is no longer existent I am now developing the Protocol Translation part as a standalone mod, <br>
and now: ViaFabricPlus is here
## Project structure
ViaFabricPlus splits into three major parts:
| Part | Description |
|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ViaFabricPlus | Core of the project, all fixes here are stable and have been tested many times |
| ViaFabricPlus-Visual | Addon for the core, it adds only visual changes between the versions like old textures, <br>optional and not necessary for the gameplay, but recommended. |
| ViaFabricPlus-Emulation | Addon for the Core, this addon is for all for the 1.8 and 1.12 protocol, here it adds complete emulations of the Raytrace or also Movement,<br> to consider is that this breaks much mod incompatibility and is also very experimental |

View File

@ -0,0 +1,26 @@
plugins {
id "fabric-loom" version "1.1-SNAPSHOT"
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name + "-visual"
version = project.mod_version
group = project.maven_group
repositories {
mavenCentral()
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
implementation "com.viaversion:viaversion:${project.viaversion_version}"
implementation "com.github.RaphiMC:ViaLegacy:${project.vialegacy_version}"
implementation project(":")
}

View File

@ -0,0 +1,49 @@
/**
* --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_visual;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.platform.ProtocolRange;
import de.florianmichael.viafabricplus.value.impl.ProtocolSyncBooleanValue;
import de.florianmichael.viafabricplus_visual.definition.ArmorPointsDefinition;
import net.fabricmc.api.ClientModInitializer;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
public class ViaFabricPlusVisual implements ClientModInitializer {
// 1.19.2 -> 1.19
public final static ProtocolSyncBooleanValue disableSecureChatWarning = new ProtocolSyncBooleanValue("Disable secure chat warning", ProtocolRange.andOlder(ProtocolVersion.v1_19));
// 1.19 -> 1.18.2
public final static ProtocolSyncBooleanValue hideSignatureIndicator = new ProtocolSyncBooleanValue("Hide signature indicator", ProtocolRange.andOlder(ProtocolVersion.v1_18_2));
// 1.13 -> 1.12.2
public final static ProtocolSyncBooleanValue replacePetrifiedOakSlab = new ProtocolSyncBooleanValue("Replace petrified oak slab", new ProtocolRange(ProtocolVersion.v1_12_2, LegacyProtocolVersion.r1_3_1tor1_3_2));
// 1.9 -> 1.8.x
public final static ProtocolSyncBooleanValue emulateArmorHud = new ProtocolSyncBooleanValue("Emulate Armor hud", ProtocolRange.andOlder(ProtocolVersion.v1_8));
@Override
public void onInitializeClient() {
ArmorPointsDefinition.load();
}
}

View File

@ -0,0 +1,75 @@
/**
* --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_visual.definition;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ArmorType;
import net.minecraft.client.MinecraftClient;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ArmorPointsDefinition {
public static final List<Item> ARMOR_ITEMS_IN_1_8 = Arrays.asList(
Items.LEATHER_HELMET,
Items.LEATHER_CHESTPLATE,
Items.LEATHER_BOOTS,
Items.CHAINMAIL_HELMET,
Items.CHAINMAIL_CHESTPLATE,
Items.CHAINMAIL_LEGGINGS,
Items.CHAINMAIL_BOOTS,
Items.IRON_HELMET,
Items.IRON_CHESTPLATE,
Items.IRON_LEGGINGS,
Items.IRON_BOOTS,
Items.DIAMOND_HELMET,
Items.DIAMOND_CHESTPLATE,
Items.DIAMOND_LEGGINGS,
Items.DIAMOND_BOOTS,
Items.GOLDEN_HELMET,
Items.GOLDEN_CHESTPLATE,
Items.GOLDEN_LEGGINGS,
Items.GOLDEN_BOOTS
);
private final static Map<Item, Integer> armorTracker = new HashMap<>();
public static void load() {
for (Item armorItem : ARMOR_ITEMS_IN_1_8) {
armorTracker.put(armorItem, ArmorType.findByType(Registries.ITEM.getId(armorItem).toString()).getArmorPoints());
}
}
private static int getArmorPoints(final ItemStack itemStack) {
if (!armorTracker.containsKey(itemStack.getItem())) return 0;
return armorTracker.get(itemStack.getItem());
}
public static int sum() {
return MinecraftClient.getInstance().player.getInventory().armor.stream().mapToInt(ArmorPointsDefinition::getArmorPoints).sum();
}
}

View File

@ -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_visual.injection.mixin;
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.gui.hud.ChatHudLine;
import net.minecraft.client.gui.hud.MessageIndicator;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ChatHud.class)
public class MixinChatHud {
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHudLine$Visible;indicator()Lnet/minecraft/client/gui/hud/MessageIndicator;"))
public MessageIndicator removeIndicators(ChatHudLine.Visible instance) {
if (ViaFabricPlusVisual.hideSignatureIndicator.getValue()) {
return null;
}
return instance.indicator();
}
}

View File

@ -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_visual.injection.mixin;
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.gui.hud.MessageIndicator;
import net.minecraft.client.gui.screen.ChatScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ChatScreen.class)
public class MixinChatScreen {
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;getIndicatorAt(DD)Lnet/minecraft/client/gui/hud/MessageIndicator;"))
public MessageIndicator removeIndicator(ChatHud instance, double mouseX, double mouseY) {
if (ViaFabricPlusVisual.hideSignatureIndicator.getValue()) {
return null;
}
return instance.getIndicatorAt(mouseX, mouseY);
}
}

View File

@ -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_visual.injection.mixin;
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.network.packet.s2c.play.ServerMetadataS2CPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ClientPlayNetworkHandler.class)
public class MixinClientPlayNetworkHandler {
@Redirect(method = "onServerMetadata", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/ServerMetadataS2CPacket;isSecureChatEnforced()Z"))
public boolean removeSecureChatWarning(ServerMetadataS2CPacket instance) {
return instance.isSecureChatEnforced() || ViaFabricPlusVisual.disableSecureChatWarning.getValue();
}
}

View File

@ -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_visual.injection.mixin;
import com.mojang.authlib.GameProfile;
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
import de.florianmichael.viafabricplus_visual.definition.ArmorPointsDefinition;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(ClientPlayerEntity.class)
public class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) {
super(world, profile);
}
@Override
public int getArmor() {
if (ViaFabricPlusVisual.emulateArmorHud.getValue()) {
return ArmorPointsDefinition.sum();
}
return super.getArmor();
}
}

View File

@ -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_visual.injection.mixin;
import de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual;
import net.minecraft.client.render.item.ItemModels;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.world.World;
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(ItemRenderer.class)
public class MixinItemRenderer {
@Shadow @Final private ItemModels models;
@Inject(method = "getModel", at = @At("HEAD"), cancellable = true)
public void removeModel(ItemStack stack, World world, LivingEntity entity, int seed, CallbackInfoReturnable<BakedModel> cir) {
if (ViaFabricPlusVisual.replacePetrifiedOakSlab.getValue() && world != null /* world is null in gui rendering */ && stack.isOf(Items.PETRIFIED_OAK_SLAB)) {
cir.setReturnValue(this.models.getModelManager().getMissingModel());
}
}
}

View File

@ -0,0 +1,35 @@
{
"schemaVersion": 1,
"id": "viafabricplus-visual",
"version": "${version}",
"name": "ViaFabricPlus Visual",
"description": " ViaFabricPlus addon which adds visual fixes",
"authors": [
"FlorianMichael",
"EnZaXD",
"JesseUwU"
],
"contact": {
"homepage": "https://github.com/FlorianMichael/",
"sources": "https://github.com/FlorianMichael/ViaFabricPlus"
},
"entrypoints": {
"client": [
"de.florianmichael.viafabricplus_visual.ViaFabricPlusVisual"
]
},
"license": "CC0-1.0",
"environment": "*",
"mixins": [
"viafabricplus-visual.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.11",
"minecraft": "~1.19.3",
"java": ">=17"
},
"suggests": {
"another-mod": "*"
}
}

View File

@ -0,0 +1,18 @@
{
"required": true,
"minVersion": "0.8",
"package": "de.florianmichael.viafabricplus_visual.injection.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"injectors": {
"defaultRequire": 1
},
"client": [
"MixinChatHud",
"MixinChatScreen",
"MixinClientPlayerEntity",
"MixinClientPlayNetworkHandler",
"MixinItemRenderer"
]
}

View File

@ -9,6 +9,7 @@ archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
allprojects {
repositories {
mavenCentral()
maven {
@ -20,6 +21,7 @@ repositories {
url "https://repo.viaversion.com"
}
}
}
loom {
accessWidenerPath = file("src/main/resources/viafabricplus.accesswidener")
@ -63,3 +65,27 @@ jar {
rename { "${it}_${project.archivesBaseName}" }
}
}
tasks.register("installAddons") {
group archivesBaseName
dependsOn "build"
doLast {
File base = file(".")
base.listFiles().each {
if (it.name.startsWith("ViaFabricPlus-") && it.isDirectory()) {
String addonName = it.name.toLowerCase() + "-" + project(it.name).version + ".jar"
File build = new File(it, "build" + File.separator + "libs" + File.separator + addonName)
File modDest = new File(base, "run" + File.separator + "mods" + File.separator + addonName)
if(build.exists()) {
if (modDest.delete())
println "Deleted old $addonName"
else
println "Failed to delete old $addonName version"
if (build.renameTo(modDest))
println "Copied $addonName"
}
}
}
}
}

View File

@ -7,7 +7,7 @@ loader_version=0.14.14
mod_version=1.0.0
maven_group=de.florianmichael
archives_base_name=every-protocol
archives_base_name=viafabricplus
vialoadingbase_version=15f55e6b3e
viaversion_version=4.6.0-23w07a-SNAPSHOT

View File

@ -8,3 +8,5 @@ pluginManagement {
gradlePluginPortal()
}
}
include 'ViaFabricPlus-Visual'

View File

@ -58,7 +58,7 @@ import java.util.List;
* - Add ViaFabricPlus-Emulation
*/
public class ViaFabricPlus {
public final static File RUN_DIRECTORY = new File(".viafabricplus");
public final static File RUN_DIRECTORY = new File("ViaFabricPlus");
public final static AttributeKey<UserConnection> LOCAL_USER_CONNECTION = AttributeKey.newInstance("viafabricplus-via-connection");
private final static ViaFabricPlus self = new ViaFabricPlus();

View File

@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Protocol1_8to1_7_6_10.class)
@Mixin(value = Protocol1_8to1_7_6_10.class, remap = false)
public class MixinProtocol1_8to1_7_6_10 extends AbstractProtocol<ClientboundPackets1_7_2, ClientboundPackets1_8, ServerboundPackets1_7_2, ServerboundPackets1_8> {
@Inject(method = "registerPackets", at = @At("RETURN"))

View File

@ -37,6 +37,8 @@ public class BooleanValue extends AbstractValue<Boolean> {
@Override
public void read(JsonObject object) {
if (!object.has(getName())) return;
setValue(object.get(getName()).getAsBoolean());
}
}

View File

@ -49,6 +49,7 @@ public class ProtocolSyncBooleanValue extends AbstractValue<Boolean> {
@Override
public void read(JsonObject object) {
if (!object.has(getName())) return;
final JsonObject valueNode = object.get(getName()).getAsJsonObject();
setValue(valueNode.get("value").getAsBoolean());