mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-22 11:56:21 +01:00
Fixed some initial porting mistakes and improved mixin code style
This commit is contained in:
parent
b7612bf808
commit
db5c96d038
@ -38,7 +38,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public abstract class MixinDecoratedPotBlock {
|
||||
|
||||
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
|
||||
public void alwaysPass(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
|
||||
private void alwaysPass(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20_2)) {
|
||||
cir.setReturnValue(ActionResult.PASS);
|
||||
}
|
||||
|
@ -32,14 +32,15 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@Mixin(AbstractHorseEntity.class)
|
||||
public abstract class MixinAbstractHorseEntity {
|
||||
|
||||
@Shadow protected abstract boolean receiveFood(PlayerEntity player, ItemStack item);
|
||||
@Shadow
|
||||
protected abstract boolean receiveFood(PlayerEntity player, ItemStack item);
|
||||
|
||||
@Redirect(method = "interactHorse", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/AbstractHorseEntity;receiveFood(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/ItemStack;)Z"))
|
||||
public boolean dontRemoveItemOnClientside(AbstractHorseEntity instance, PlayerEntity player, ItemStack item) {
|
||||
private boolean decrementFoodItemClientside(AbstractHorseEntity instance, PlayerEntity player, ItemStack item) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20_2)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return receiveFood(player, item);
|
||||
return this.receiveFood(player, item);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
}
|
||||
|
||||
@Redirect(method = "getMaxRelativeHeadRotation", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isBlocking()Z"))
|
||||
public boolean dontModifyHeadRotationWhenBlocking(PlayerEntity instance) {
|
||||
private boolean dontModifyHeadRotationWhenBlocking(PlayerEntity instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20_2)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import de.florianmichael.viafabricplus.injection.access.IDownloadingTerrainScree
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
|
||||
import net.minecraft.client.network.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@ -70,7 +69,8 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH
|
||||
@Shadow
|
||||
public abstract void onSynchronizeRecipes(SynchronizeRecipesS2CPacket packet);
|
||||
|
||||
@Shadow protected abstract boolean isSecureChatEnforced();
|
||||
@Shadow
|
||||
protected abstract boolean isSecureChatEnforced();
|
||||
|
||||
protected MixinClientPlayNetworkHandler(MinecraftClient client, ClientConnection connection, ClientConnectionState connectionState) {
|
||||
super(client, connection, connectionState);
|
||||
@ -120,8 +120,8 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerSpawnPosition", at = @At("RETURN"))
|
||||
public void moveDownloadingTerrainClosing(PlayerSpawnPositionS2CPacket packet, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_19, VersionEnum.r1_20_2) && this.client.currentScreen instanceof IDownloadingTerrainScreen mixinDownloadingTerrainScreen) {
|
||||
private void moveDownloadingTerrainClosing(PlayerSpawnPositionS2CPacket packet, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_18_2, VersionEnum.r1_20_2) && this.client.currentScreen instanceof IDownloadingTerrainScreen mixinDownloadingTerrainScreen) {
|
||||
mixinDownloadingTerrainScreen.viaFabricPlus$setReady();
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IDownloadingTerrainScreen;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.network.packet.c2s.common.KeepAliveC2SPacket;
|
||||
@ -60,26 +59,7 @@ public abstract class MixinDownloadingTerrainScreen extends Screen implements ID
|
||||
private void modifyCloseCondition(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20_2)) {
|
||||
ci.cancel();
|
||||
if (System.currentTimeMillis() > this.loadStartTime + 30000L) {
|
||||
this.close();
|
||||
} else {
|
||||
if (this.viaFabricPlus$closeOnNextTick) {
|
||||
if (this.client.player == null) return;
|
||||
|
||||
BlockPos blockPos = this.client.player.getBlockPos();
|
||||
boolean bl = this.client.world != null && this.client.world.isOutOfHeightLimit(blockPos.getY());
|
||||
if (bl || this.client.worldRenderer.isRenderingReady(blockPos) || this.client.player.isSpectator() || !this.client.player.isAlive()) {
|
||||
this.close();
|
||||
}
|
||||
} else {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
||||
this.viaFabricPlus$closeOnNextTick = this.viaFabricPlus$ready || System.currentTimeMillis() > this.loadStartTime + 2000;
|
||||
} else {
|
||||
this.viaFabricPlus$closeOnNextTick = this.viaFabricPlus$ready;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
|
||||
if (this.viaFabricPlus$ready) {
|
||||
this.close();
|
||||
@ -88,7 +68,27 @@ public abstract class MixinDownloadingTerrainScreen extends Screen implements ID
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_1)) {
|
||||
this.viaFabricPlus$tickCounter++;
|
||||
if (this.viaFabricPlus$tickCounter % 20 == 0) {
|
||||
MinecraftClient.getInstance().getNetworkHandler().sendPacket(new KeepAliveC2SPacket(0));
|
||||
this.client.getNetworkHandler().sendPacket(new KeepAliveC2SPacket(0));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (System.currentTimeMillis() > this.loadStartTime + 30000L) {
|
||||
this.close();
|
||||
} else {
|
||||
if (this.viaFabricPlus$closeOnNextTick) {
|
||||
if (this.client.player == null) return;
|
||||
|
||||
final BlockPos blockPos = this.client.player.getBlockPos();
|
||||
final boolean isOutOfHeightLimit = this.client.world != null && this.client.world.isOutOfHeightLimit(blockPos.getY());
|
||||
if (isOutOfHeightLimit || this.client.worldRenderer.isRenderingReady(blockPos) || this.client.player.isSpectator() || !this.client.player.isAlive()) {
|
||||
this.close();
|
||||
}
|
||||
} else {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
||||
this.viaFabricPlus$closeOnNextTick = this.viaFabricPlus$ready || System.currentTimeMillis() > this.loadStartTime + 2000;
|
||||
} else {
|
||||
this.viaFabricPlus$closeOnNextTick = this.viaFabricPlus$ready;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ public abstract class MixinDownloadingTerrainScreen extends Screen implements ID
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$setReady() {
|
||||
viaFabricPlus$ready = true;
|
||||
this.viaFabricPlus$ready = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class TextComponentTranslator {
|
||||
* Converts a ViaVersion 1.14 text component to a native text component, both in JSON format
|
||||
*
|
||||
* @param component The ViaVersion 1.14 text component
|
||||
* @return The native text component
|
||||
* @return The ViaVersion text component for the native version
|
||||
*/
|
||||
public static Tag via1_14toViaLatest(final JsonElement component) {
|
||||
try {
|
||||
|
@ -66,6 +66,7 @@
|
||||
"fixes.minecraft.block.MixinCauldronBlock",
|
||||
"fixes.minecraft.block.MixinChestBlock",
|
||||
"fixes.minecraft.block.MixinCropBlock",
|
||||
"fixes.minecraft.block.MixinDecoratedPotBlock",
|
||||
"fixes.minecraft.block.MixinEnderChestBlock",
|
||||
"fixes.minecraft.block.MixinEndPortalBlock",
|
||||
"fixes.minecraft.block.MixinEndPortalFrameBlock",
|
||||
@ -87,6 +88,7 @@
|
||||
"fixes.minecraft.block.MixinSoulSandBlock",
|
||||
"fixes.minecraft.block.MixinWallBlock",
|
||||
"fixes.minecraft.entity.MixinAbstractClientPlayerEntity",
|
||||
"fixes.minecraft.entity.MixinAbstractHorseEntity",
|
||||
"fixes.minecraft.entity.MixinAnimalEntity",
|
||||
"fixes.minecraft.entity.MixinBipedEntityModel",
|
||||
"fixes.minecraft.entity.MixinBoatEntity",
|
||||
@ -195,9 +197,7 @@
|
||||
"viaversion.MixinAbstractFenceConnectionHandler",
|
||||
"viaversion.MixinConfig",
|
||||
"viaversion.MixinGlassConnectionHandler",
|
||||
"viaversion.MixinProtocolVersion",
|
||||
"fixes.minecraft.block.MixinDecoratedPotBlock",
|
||||
"fixes.minecraft.entity.MixinAbstractHorseEntity"
|
||||
"viaversion.MixinProtocolVersion"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
Loading…
Reference in New Issue
Block a user