mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-16 10:55:39 +01:00
Merge branch 'feat/particles'
This commit is contained in:
commit
b56c399e3e
@ -60,6 +60,8 @@ dependencies {
|
||||
modJij(fabricApi.module("fabric-networking-api-v1", project.fabric_api_version))
|
||||
modJij(fabricApi.module("fabric-command-api-v2", project.fabric_api_version))
|
||||
modJij(fabricApi.module("fabric-lifecycle-events-v1", project.fabric_api_version))
|
||||
modJij(fabricApi.module("fabric-particles-v1", project.fabric_api_version))
|
||||
modJij(fabricApi.module("fabric-registry-sync-v0", project.fabric_api_version))
|
||||
|
||||
// ViaVersion Libraries
|
||||
jij "com.viaversion:viaversion-common:${project.viaversion_version}"
|
||||
|
@ -26,6 +26,7 @@ import de.florianmichael.viafabricplus.fixes.classic.CPEAdditions;
|
||||
import de.florianmichael.viafabricplus.fixes.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.injection.ViaFabricPlusMixinPlugin;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
@ -130,6 +131,9 @@ public class ClientsideFixes {
|
||||
currentChatLength = Short.MAX_VALUE * 2;
|
||||
}
|
||||
});
|
||||
|
||||
// Register the footstep particle
|
||||
FootStepParticle.init();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.particle;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
|
||||
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class FootStepParticle extends SpriteBillboardParticle {
|
||||
|
||||
public static int ID;
|
||||
|
||||
protected FootStepParticle(ClientWorld clientWorld, double x, double y, double z) {
|
||||
super(clientWorld, x, y, z);
|
||||
|
||||
this.scale = 0.125F;
|
||||
this.setMaxAge(200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleTextureSheet getType() {
|
||||
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
|
||||
final float strength = ((float) this.age + tickDelta) / (float) this.maxAge;
|
||||
this.alpha = 2.0F - (strength * strength) * 2.0F;
|
||||
if (this.alpha > 1.0F) {
|
||||
this.alpha = 0.2F;
|
||||
} else {
|
||||
this.alpha *= 0.2F;
|
||||
}
|
||||
|
||||
final Vec3d cameraPos = camera.getPos();
|
||||
final float x = (float) (MathHelper.lerp(tickDelta, this.prevPosX, this.x) - cameraPos.getX());
|
||||
final float y = (float) (MathHelper.lerp(tickDelta, this.prevPosY, this.y) - cameraPos.getY());
|
||||
final float z = (float) (MathHelper.lerp(tickDelta, this.prevPosZ, this.z) - cameraPos.getZ());
|
||||
|
||||
final float minU = this.getMinU();
|
||||
final float maxU = this.getMaxU();
|
||||
final float minV = this.getMinV();
|
||||
final float maxV = this.getMaxV();
|
||||
|
||||
final int light = this.getBrightness(tickDelta); // This is missing in the original code, that's why the particles are broken
|
||||
vertexConsumer.vertex(x - scale, y, z + scale).texture(maxU, maxV).color(this.red, this.green, this.blue, this.alpha).light(light).next();
|
||||
vertexConsumer.vertex(x + scale, y, z + scale).texture(maxU, minV).color(this.red, this.green, this.blue, this.alpha).light(light).next();
|
||||
vertexConsumer.vertex(x + scale, y, z - scale).texture(minU, minV).color(this.red, this.green, this.blue, this.alpha).light(light).next();
|
||||
vertexConsumer.vertex(x - scale, y, z - scale).texture(minU, maxV).color(this.red, this.green, this.blue, this.alpha).light(light).next();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
final DefaultParticleType footStepType = FabricParticleTypes.simple(true);
|
||||
|
||||
Registry.register(Registries.PARTICLE_TYPE, new Identifier("viafabricplus", "footstep"), footStepType);
|
||||
ParticleFactoryRegistry.getInstance().register(footStepType, FootStepParticle.Factory::new); // Add some dummy factory
|
||||
|
||||
ID = Registries.PARTICLE_TYPE.getRawId(footStepType);
|
||||
}
|
||||
|
||||
public static class Factory implements ParticleFactory<DefaultParticleType> {
|
||||
|
||||
private final SpriteProvider spriteProvider;
|
||||
|
||||
public Factory(SpriteProvider spriteProvider) {
|
||||
this.spriteProvider = spriteProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle createParticle(DefaultParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
|
||||
if (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_12_2)) {
|
||||
throw new UnsupportedOperationException("FootStepParticle is not supported on versions newer than 1.12.2");
|
||||
}
|
||||
|
||||
final FootStepParticle particle = new FootStepParticle(world, x, y, z);
|
||||
particle.setSprite(this.spriteProvider);
|
||||
return particle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -30,7 +30,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(Main.class)
|
||||
public abstract class MixinMain {
|
||||
|
||||
@Inject(method = "main", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/crash/CrashReport;initCrashReport()V"))
|
||||
@Inject(method = "main", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Util;startTimerHack()V"))
|
||||
private static void bootstrap(CallbackInfo ci) {
|
||||
LoadCallback.EVENT.invoker().onLoad(LoadCallback.State.PRE);
|
||||
ViaFabricPlus.global().bootstrap();
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||
import de.florianmichael.viafabricplus.fixes.particle.FootStepParticle;
|
||||
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 = MappingDataBase.class, remap = false)
|
||||
public abstract class MixinMappingDataBase {
|
||||
|
||||
@Inject(method = "getNewParticleId", at = @At("HEAD"), cancellable = true)
|
||||
private void passthroughFootStepParticle(int id, CallbackInfoReturnable<Integer> cir) {
|
||||
if (id == FootStepParticle.ID) {
|
||||
cir.setReturnValue(id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(value = ParticleRewriter.class, remap = false)
|
||||
public abstract class MixinParticleRewriter {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private static List<?> particles;
|
||||
|
||||
@Inject(method = "<clinit>", at = @At("RETURN"))
|
||||
private static void checkFootStepIdOverlap(CallbackInfo ci) {
|
||||
if (FootStepParticle.ID < particles.size()) {
|
||||
throw new IllegalStateException("ViaFabricPlus FootStepParticle ID overlaps with a vanilla 1.12.2 particle ID");
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyArg(method = "add(I)V", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/ParticleRewriter$NewParticle;<init>(ILcom/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/ParticleRewriter$ParticleDataHandler;)V"))
|
||||
private static int replaceIds(int id) {
|
||||
if (particles.size() == 8) { // minecraft:depthsuspend -> minecraft:mycelium
|
||||
return 32;
|
||||
} else if (particles.size() == 28) { // minecraft:footstep -> viafabricplus:footstep
|
||||
return FootStepParticle.ID;
|
||||
} else {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"textures": [
|
||||
"viafabricplus:footprint"
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 922 B |
@ -2,7 +2,6 @@
|
||||
"schemaVersion": 1,
|
||||
"id": "viafabricplus",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "ViaFabricPlus",
|
||||
"description": "Fabric mod to connect to EVERY Minecraft server version (Release, Beta, Alpha, Classic, Snapshots, Bedrock) with QoL fixes to the gameplay",
|
||||
"authors": [
|
||||
@ -34,7 +33,6 @@
|
||||
"sources": "https://github.com/ViaVersion/ViaFabricPlus",
|
||||
"issues": "https://github.com/ViaVersion/ViaFabricPlus/issues"
|
||||
},
|
||||
|
||||
"license": "GPL-v3",
|
||||
"icon": "assets/viafabricplus/icon.png",
|
||||
"environment": "client",
|
||||
@ -53,6 +51,8 @@
|
||||
"fabric-networking-api-v1": ">=3.1.1",
|
||||
"fabric-command-api-v2": ">=2.2.18",
|
||||
"fabric-lifecycle-events-v1": ">=2.2.28",
|
||||
"fabric-particles-v1": ">=1.1.6",
|
||||
"fabric-registry-sync-v0": ">=4.0.13",
|
||||
"minecraft": ">=1.20.3",
|
||||
"java": ">=17"
|
||||
},
|
||||
|
@ -179,9 +179,11 @@
|
||||
"fixes.viaversion.MixinInventoryPackets1_13",
|
||||
"fixes.viaversion.MixinInventoryPackets1_17",
|
||||
"fixes.viaversion.MixinInventoryTracker1_16",
|
||||
"fixes.viaversion.MixinMappingDataBase",
|
||||
"fixes.viaversion.MixinMetadataRewriter1_15To1_14_4",
|
||||
"fixes.viaversion.MixinMetadataRewriter1_9To1_8",
|
||||
"fixes.viaversion.MixinNamedCompoundTagType",
|
||||
"fixes.viaversion.MixinParticleRewriter",
|
||||
"fixes.viaversion.MixinProtocol1_11To1_10",
|
||||
"fixes.viaversion.MixinProtocol1_12To1_11_1",
|
||||
"fixes.viaversion.MixinProtocol1_20_2To1_20",
|
||||
|
Loading…
Reference in New Issue
Block a user