Skip to content

Commit

Permalink
Backport Things to 1.20.1 (#271)
Browse files Browse the repository at this point in the history
* Update gradle.properties

* Update gradle.properties

* Backport Things to 1.20.1

* Update Chinese Translations

* Fix Unused Mixins

* Config should toggle old Boat model

* Delete unused mixin block

* Remove unused Codes

* Remove unused import

* Update Example gradle include

* Change 1.20.3 to 23w41a

---------

Co-authored-by: EnZaXD <[email protected]>
  • Loading branch information
HowardZHY and FlorianMichael authored Oct 18, 2023
1 parent c1558c4 commit c64287a
Show file tree
Hide file tree
Showing 50 changed files with 849 additions and 171 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ViaFabricPlus is intended to replace [multiconnect](https://github.com/Earthcomp
- Alpha (a1.0.15 - a1.2.6)
- Classic (c0.0.15 - c0.30 including [CPE](https://wiki.vg/Classic_Protocol_Extension))
- Snapshots (3D Shareware, 20w14infinite, Combat Test 8C)
- Bedrock (1.20.0)
- Bedrock (1.20.30)

### If you want to talk with me, feel free to join my [Discord](https://discord.gg/BwWhCHUKDf)

Expand Down Expand Up @@ -110,8 +110,7 @@ repositories {
}
dependencies {
implementation ("de.florianmichael:viafabricplus:2.8.5") { // Get latest version from releases
exclude group: "com.terraformersmc"
implementation ("de.florianmichael:viafabricplus:2.8.7") { // Get the latest version from releases
transitive = false
}
}
Expand All @@ -129,7 +128,7 @@ dependencies {
<dependency>
<groupId>de.florianmichael</groupId>
<artifactId>viafabricplus</artifactId>
<version>2.8.2</version> <!-- Get latest version from releases -->
<version>2.8.7</version> <!-- Get the latest version from releases -->
</dependency>
</dependencies>
```
Expand Down
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ group = project.maven_group

configurations {
api.extendsFrom library

include.extendsFrom jij
implementation.extendsFrom jij
}

allprojects {
Expand Down Expand Up @@ -54,9 +57,6 @@ dependencies {
modApi "com.terraformersmc:modmenu:${project.mod_menu_version}"

library "de.florianmichael:Classic4J:${project.classic4j_version}"
library ("net.raphimc:ViaLoader:${project.vialoader_version}") {
exclude group: "org.slf4j", module: "slf4j-api"
}

library "com.viaversion:viaversion:${project.viaversion_version}"
library ("com.viaversion:viabackwards-common:${project.viabackwards_version}") {
Expand All @@ -65,6 +65,9 @@ dependencies {
exclude group: "com.google.guava", module: "guava"
}

library ("net.raphimc:ViaLoader:${project.vialoader_version}") {
exclude group: "org.slf4j", module: "slf4j-api"
}
library ("net.raphimc:ViaLegacy:${project.vialegacy_version}") {
exclude group: "com.google.code.gson", module: "gson"
}
Expand All @@ -73,6 +76,7 @@ dependencies {
exclude group: "net.lenni0451.mcstructs", module: "text"
exclude group: "io.jsonwebtoken", module: "jjwt-impl"
exclude group: "io.jsonwebtoken", module: "jjwt-gson"
exclude group: "com.mojang", module: "brigadier"
}
library ("net.raphimc:MinecraftAuth:${project.minecraftauth_version}") {
exclude group: "com.google.code.gson", module: "gson"
Expand All @@ -86,7 +90,7 @@ dependencies {
exclude group: "io.netty", module: "netty-transport"
}

library "net.lenni0451:Reflect:${project.reflect_version}"
jij "net.lenni0451:Reflect:${project.reflect_version}"

include implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_version}"))
}
Expand Down
20 changes: 10 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ loader_version=0.14.22
fabric_api_version=0.86.1+1.20.1

# viafabricplus
mod_version=2.9.0-SNAPSHOT
mod_version=2.8.8
maven_group=de.florianmichael
archives_base_name=viafabricplus

# base lib
raknet_transport_version=1.0.0.CR1-SNAPSHOT
classic4j_version=1.2.0
classic4j_version=2.0.1

# viaversion (and required) libs
viaversion_version=4.8.0
viabackwards_version=4.8.0
viaversion_version=4.9.0-23w41a-SNAPSHOT
viabackwards_version=4.9.0-23w41a-SNAPSHOT

vialoader_version=2.2.9
vialoader_version=2.2.11-SNAPSHOT

vialegacy_version=2.2.19
viaaprilfools_version=2.0.9
vialegacy_version=2.2.21-SNAPSHOT
viaaprilfools_version=2.0.10-SNAPSHOT
viabedrock_version=0.0.3-SNAPSHOT

# raphimc libs
minecraftauth_version=2.1.6-SNAPSHOT
minecraftauth_version=2.1.7-SNAPSHOT

# lenni0451 libs
reflect_version=1.2.2
reflect_version=1.2.4

# other libs
mod_menu_version=7.2.1
netty_codec_http_version=4.1.96.Final
mixin_extras_version=0.2.0-beta.9
mixin_extras_version=0.2.0
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void init() {
// Load overriding jars first so other code can access the new classes
ViaJarReplacer.loadOverridingJars();

// PreLoad Callback (for example to register new protocols)
PreLoadCallback.EVENT.invoker().onLoad();

// Classic Stuff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class ExperimentalSettings extends SettingGroup {

public final BooleanSetting fixChunkBorders = new BooleanSetting(this, Text.translatable("experimental.viafabricplus.chunkborderfix"), true);
public final BooleanSetting waterMovementEdgeDetection = new BooleanSetting(this, Text.translatable("experimental.viafabricplus.watermovement"), true);
public final BooleanSetting emulateBoatMovement = new BooleanSetting(this, Text.translatable("experimental.viafabricplus.boatmovement"), false);

public ExperimentalSettings() {
super(Text.translatable("settings.viafabricplus.experimental"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class VisualSettings extends SettingGroup {
public final ProtocolSyncBooleanSetting emulateArmorHud = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.armor"), VersionRange.andOlder(VersionEnum.r1_8));
public final ProtocolSyncBooleanSetting removeNewerFeaturesFromCommandBlockScreen = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.command"), VersionRange.andOlder(VersionEnum.r1_8));

// 1.8.x -> r1_7_6tor1_7_10
public final ProtocolSyncBooleanSetting blockHitAnimation = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.blockhitanimation"), VersionRange.andOlder(VersionEnum.r1_7_6tor1_7_10));

// r1_0_0tor1_0_1 -> b1_8tob1_8_1
public final ProtocolSyncBooleanSetting replaceHurtSoundWithOOFSound = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.oof"), VersionRange.andOlder(VersionEnum.b1_8tob1_8_1));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.definition.account;

import com.google.gson.JsonObject;
import de.florianmichael.classic4j.model.classicube.highlevel.CCAccount;
import de.florianmichael.classic4j.model.classicube.account.CCAccount;
import de.florianmichael.viafabricplus.base.event.DisconnectConnectionCallback;
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
import de.florianmichael.viafabricplus.util.FileSaver;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and 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.definition.boat;

import com.google.common.collect.ImmutableList;
import net.minecraft.client.model.*;
import net.minecraft.client.render.entity.model.CompositeEntityModel;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.util.Identifier;

public class BoatModel_1_8 extends CompositeEntityModel<BoatEntity> {
public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(new Identifier("viafabricplus", "boat_1_8"), "main");
private final ImmutableList<ModelPart> parts;

public BoatModel_1_8(ModelPart root) {
this.parts = ImmutableList.of(root.getChild("bottom"), root.getChild("back"), root.getChild("front"), root.getChild("right"), root.getChild("left"));
}

public static TexturedModelData getTexturedModelData() {
ModelData modelData = new ModelData();
ModelPartData root = modelData.getRoot();
final float width = 24;
final float wallHeight = 6;
final float baseWidth = 20;
final float pivotY = 4;
root.addChild("bottom", ModelPartBuilder.create().uv(0, 8).cuboid(-width / 2, -baseWidth / 2 + 2, -3, width, baseWidth - 4, 4), ModelTransform.of(0, pivotY, 0, (float) Math.PI / 2, 0, 0));
root.addChild("back", ModelPartBuilder.create().uv(0, 0).cuboid(-width / 2 + 2, -wallHeight - 1, -1, width - 4, wallHeight, 2), ModelTransform.of(-width / 2 + 1, pivotY, 0, 0, (float) Math.PI * 1.5f, 0));
root.addChild("front", ModelPartBuilder.create().uv(0, 0).cuboid(-width / 2 + 2, -wallHeight - 1, -1, width - 4, wallHeight, 2), ModelTransform.of(width / 2 - 1, pivotY, 0, 0, (float) Math.PI / 2, 0));
root.addChild("right", ModelPartBuilder.create().uv(0, 0).cuboid(-width / 2 + 2, -wallHeight - 1, -1, width - 4, wallHeight, 2), ModelTransform.of(0, pivotY, -baseWidth / 2 + 1, 0, (float) Math.PI, 0));
root.addChild("left", ModelPartBuilder.create().uv(0, 0).cuboid(-width / 2 + 2, -wallHeight - 1, -1, width - 4, wallHeight, 2), ModelTransform.pivot(0, pivotY, baseWidth / 2 - 1));
return TexturedModelData.of(modelData, 64, 32);
}

@Override
public Iterable<ModelPart> getParts() {
return parts;
}

@Override
public void setAngles(BoatEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and 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.definition.boat;

import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;

public class BoatRenderer_1_8 extends EntityRenderer<BoatEntity> {
private static final Identifier TEXTURE = new Identifier("viafabricplus", "textures/boat_1_8.png");
private final BoatModel_1_8 model;

public BoatRenderer_1_8(EntityRendererFactory.Context ctx) {
super(ctx);
shadowRadius = 0.5f;
model = new BoatModel_1_8(ctx.getPart(BoatModel_1_8.MODEL_LAYER));
}

@Override
public Identifier getTexture(BoatEntity entity) {
return TEXTURE;
}

@Override
public void render(BoatEntity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
matrices.push();
matrices.translate(0, 0.25, 0);
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180 - yaw));
float damageWobbleTicks = entity.getDamageWobbleTicks() - tickDelta;
float damageWobbleStrength = entity.getDamageWobbleStrength() - tickDelta;
if (damageWobbleStrength < 0) {
damageWobbleStrength = 0;
}

if (damageWobbleTicks > 0) {
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(MathHelper.sin(damageWobbleTicks) * damageWobbleTicks * damageWobbleStrength / 10 * entity.getDamageWobbleSide()));
}

matrices.scale(-1, -1, 1);
model.setAngles(entity, tickDelta, 0, -0.1f, 0, 0);
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(model.getLayer(TEXTURE));
model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);

matrices.pop();
super.render(entity, yaw, tickDelta, matrices, vertexConsumers, light);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.BitSet;
import java.util.List;

@SuppressWarnings("all")
public class ClassicWorldHeightInjection {

public static PacketHandler handleJoinGame(final PacketHandler parentHandler) {
Expand All @@ -47,10 +48,10 @@ public static PacketHandler handleJoinGame(final PacketHandler parentHandler) {
if (wrapper.isCancelled()) return;

if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
for (Tag dimension : wrapper.get(Type.NBT, 0).<CompoundTag>get("minecraft:dimension_type").<ListTag>get("value")) {
for (Tag dimension : wrapper.get(Type.NAMED_COMPOUND_TAG, 0).<CompoundTag>get("minecraft:dimension_type").<ListTag>get("value")) {
changeDimensionTagHeight(wrapper.user(), ((CompoundTag) dimension).get("element"));
}
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NBT, 1));
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 1));
}
};
}
Expand All @@ -61,7 +62,7 @@ public static PacketHandler handleRespawn(final PacketHandler parentHandler) {
if (wrapper.isCancelled()) return;

if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NBT, 0));
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 0));
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and 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.access;

public interface IBoatEntity_1_8 {

void viafabricplus_setBoatEmpty(boolean boatEmpty);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@SuppressWarnings("DataFlowIssue")
@SuppressWarnings("all")
@Mixin(targets = { "net.minecraft.client.gui.screen.DownloadingTerrainScreen", "net.minecraft.client.gui.screen.ConnectScreen" })
public class MixinDownloadingTerrainScreenAndConnectScreen extends Screen {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.classic4j;

import de.florianmichael.classic4j.model.classicube.highlevel.CCError;
import de.florianmichael.classic4j.request.classicube.auth.base.CCAuthenticationResponse;
import de.florianmichael.classic4j.model.classicube.CCAuthenticationResponse;
import de.florianmichael.classic4j.model.classicube.CCError;
import de.florianmichael.viafabricplus.integration.Classic4JImpl;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -27,7 +27,7 @@
@Mixin(value = CCAuthenticationResponse.class, remap = false)
public class MixinCCAuthenticationResponse {

@Redirect(method = "getErrorDisplay", at = @At(value = "FIELD", target = "Lde/florianmichael/classic4j/model/classicube/highlevel/CCError;description:Ljava/lang/String;"))
@Redirect(method = "getErrorDisplay", at = @At(value = "FIELD", target = "Lde/florianmichael/classic4j/model/classicube/CCError;description:Ljava/lang/String;"))
public String mapTranslations(CCError instance) {
return Classic4JImpl.fromError(instance).getString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
*
* Fixes https://github.com/ViaVersion/ViaFabricPlus/issues/209
*/
@SuppressWarnings("all")
@Pseudo
@Mixin(targets = "org.anti_ad.mc.ipnext.event.AutoRefillHandler$ItemSlotMonitor")
@Mixin(targets = "org.anti_ad.mc.ipnext.event.AutoRefillHandler$ItemSlotMonitor", remap = false)
public class MixinAutoRefillHandler_ItemSlotMonitor {

@Shadow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.nio.ByteBuffer;

@Mixin(KeyPairResponse.class)
@Mixin(value = KeyPairResponse.class, remap = false)
public class MixinKeyPairResponse implements IKeyPairResponse {

@Unique
Expand All @@ -19,4 +19,4 @@ public class MixinKeyPairResponse implements IKeyPairResponse {
public ByteBuffer viafabricplus_getLegacyPublicKeySignature() {
return this.viafabricplus_legacyKeySignature;
}
}
}
Loading

0 comments on commit c64287a

Please sign in to comment.