mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-09-27 04:22:36 +02:00
Fixup classic weather extension
This commit is contained in:
parent
0056a53185
commit
6eccfc8849
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class SnowTrackerc0_30cpe implements StorableObject {
|
||||
|
||||
public static final SnowTrackerc0_30cpe INSTANCE = new SnowTrackerc0_30cpe();
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.viaversion.SnowTrackerc0_30cpe;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
public abstract class MixinWorldRenderer {
|
||||
|
||||
@Redirect(method = "renderWeather", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getPrecipitation(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/world/biome/Biome$Precipitation;"))
|
||||
private Biome.Precipitation forceSnow(Biome instance, BlockPos pos) {
|
||||
if (ProtocolTranslator.getTargetVersion().equals(LegacyProtocolVersion.c0_30cpe)) {
|
||||
if (ProtocolTranslator.getPlayNetworkUserConnection().has(SnowTrackerc0_30cpe.class)) {
|
||||
return Biome.Precipitation.SNOW;
|
||||
}
|
||||
}
|
||||
return instance.getPrecipitation(pos);
|
||||
}
|
||||
|
||||
}
|
@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.Protocol1_19_3To1_19_4;
|
||||
import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ClientboundPackets1_19_4;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.classic.CPEAdditions;
|
||||
import de.florianmichael.viafabricplus.fixes.viaversion.SnowTrackerc0_30cpe;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_28_30toa1_0_15.packet.ClientboundPacketsc0_28;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_28_30toa1_0_15.packet.ServerboundPacketsc0_28;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.Protocolc0_30cpeToc0_28_30;
|
||||
@ -49,16 +50,21 @@ public abstract class MixinProtocolc0_30cpeToc0_28_30 extends AbstractProtocol<C
|
||||
final byte weatherType = wrapper.read(Types.BYTE);
|
||||
|
||||
final PacketWrapper changeRainState = PacketWrapper.create(ClientboundPackets1_19_4.GAME_EVENT, wrapper.user());
|
||||
changeRainState.write(Types.UNSIGNED_BYTE, weatherType == 0 /* sunny */ ? (short) 2 : (short) 1); // start raining
|
||||
changeRainState.write(Types.UNSIGNED_BYTE, weatherType == 0 /* sunny */ ? (short) 1 : (short) 2); // start raining
|
||||
changeRainState.write(Types.FLOAT, 0F); // unused
|
||||
changeRainState.send(Protocol1_19_3To1_19_4.class);
|
||||
|
||||
if (weatherType == 1 /* raining */ || weatherType == 2 /* snowing */) {
|
||||
final PacketWrapper changeRainType = PacketWrapper.create(ClientboundPackets1_19_4.GAME_EVENT, wrapper.user());
|
||||
changeRainType.write(Types.UNSIGNED_BYTE, (short) 7);
|
||||
changeRainType.write(Types.FLOAT, weatherType == 1 /* raining */ ? 0F : 1F);
|
||||
changeRainType.write(Types.UNSIGNED_BYTE, (short) 7); // set rain gradient
|
||||
changeRainType.write(Types.FLOAT, 1F);
|
||||
changeRainType.send(Protocol1_19_3To1_19_4.class);
|
||||
}
|
||||
if (weatherType == 2) {
|
||||
wrapper.user().put(SnowTrackerc0_30cpe.INSTANCE);
|
||||
} else {
|
||||
wrapper.user().remove(SnowTrackerc0_30cpe.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -59,6 +59,7 @@
|
||||
"fixes.minecraft.MixinServerResourcePackLoader_4",
|
||||
"fixes.minecraft.MixinStringHelper",
|
||||
"fixes.minecraft.MixinTextRenderer",
|
||||
"fixes.minecraft.MixinWorldRenderer",
|
||||
"fixes.minecraft.block.MixinAbstractBlock",
|
||||
"fixes.minecraft.block.MixinAbstractBlock_AbstractBlockState",
|
||||
"fixes.minecraft.block.MixinAbstractSignBlock",
|
||||
@ -186,6 +187,7 @@
|
||||
"fixes.viaversion.MixinMappingDataBase",
|
||||
"fixes.viaversion.MixinNamedCompoundTagType",
|
||||
"fixes.viaversion.MixinParticleIdMappings1_13",
|
||||
"fixes.viaversion.MixinParticleMappings",
|
||||
"fixes.viaversion.MixinProtocol1_10To1_11",
|
||||
"fixes.viaversion.MixinProtocol1_11_1To1_12",
|
||||
"fixes.viaversion.MixinProtocol1_20_3To1_20_5",
|
||||
@ -197,8 +199,7 @@
|
||||
"fixes.viaversion.MixinWorldPacketRewriter1_19",
|
||||
"viabedrock.MixinJoinPackets",
|
||||
"vialegacy.MixinExtensionProtocolMetadataStorage",
|
||||
"vialegacy.MixinViaLegacyConfig",
|
||||
"fixes.viaversion.MixinParticleMappings"
|
||||
"vialegacy.MixinViaLegacyConfig"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
Loading…
Reference in New Issue
Block a user