Skip to content

Commit

Permalink
update to 1.20.6
Browse files Browse the repository at this point in the history
readd forge
fix fishing line in hand
fix fireball deflecting (broken on forge until they allow mixin into interfaces)
fix server setting reset on dimension change
fix roomscale interact
  • Loading branch information
fayer3 committed May 8, 2024
1 parent c9ceba5 commit 3edcb74
Show file tree
Hide file tree
Showing 23 changed files with 145 additions and 179 deletions.
4 changes: 2 additions & 2 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ dependencies {
modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }

// for sodium compat
modCompileOnly "maven.modrinth:sodium:mc1.20.5-0.5.8"
modCompileOnly "maven.modrinth:sodium:mc1.20.6-0.5.8"

// for iris compat
modCompileOnly "maven.modrinth:iris:1.7.0+1.20.5"
modCompileOnly "maven.modrinth:iris:1.7.0+1.20.6"

// for REI compat
modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:14.0.688") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" exclude group: "dev.architectury" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,26 @@ public void doProcess(LocalPlayer player) {
Class<?> oclass = object.getClass();

try {
if (oclass.getMethod(name,
oclass.getDeclaredMethod(name,
BlockState.class,
net.minecraft.world.level.Level.class,
BlockPos.class,
net.minecraft.world.entity.player.Player.class,
InteractionHand.class,
BlockHitResult.class).getDeclaringClass() == oclass) {
this.rightClickable.add(oclass);
}
BlockHitResult.class);
this.rightClickable.add(oclass);
} catch (Throwable throwable1) {
}

oclass = oclass.getSuperclass();

try {
if (oclass.getMethod(name,
oclass.getDeclaredMethod(name,
BlockState.class,
net.minecraft.world.level.Level.class,
BlockPos.class,
net.minecraft.world.entity.player.Player.class,
InteractionHand.class,
BlockHitResult.class).getDeclaringClass() == oclass) {
this.rightClickable.add(oclass);
}
BlockHitResult.class);
this.rightClickable.add(oclass);
} catch (Throwable throwable) {
}
}
Expand Down Expand Up @@ -265,7 +261,8 @@ public void processBindings() {

flag = this.mc.gameMode.interactAt(this.mc.player, this.inEntity[i], this.inEntityHit[i], interactionhand).consumesAction() || this.mc.gameMode.interact(this.mc.player, this.inEntity[i], interactionhand).consumesAction();
} else if (this.inBlockHit[i] != null) {
flag = this.mc.gameMode.useItemOn(this.mc.player, interactionhand, this.inBlockHit[i]).consumesAction();
// force main hand, since 1.20.5 only checks no item interactions for the main hand
flag = this.mc.gameMode.useItemOn(this.mc.player, InteractionHand.MAIN_HAND, this.inBlockHit[i]).consumesAction();
} else if (this.bukkit[i]) {
flag = this.mc.gameMode.useItem(this.mc.player, interactionhand).consumesAction();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL43;
import org.lwjgl.system.MemoryUtil;
import org.vivecraft.client.Xplat;
import org.vivecraft.client.extensions.RenderTargetExtension;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.VRTextureTarget;
Expand Down Expand Up @@ -492,6 +493,9 @@ public void setupRenderConfiguration() throws Exception {
// main render target
((RenderTargetExtension) WorldRenderPass.stereoXR.target).vivecraft$setUseStencil(dataholder.vrSettings.vrUseStencil);
WorldRenderPass.stereoXR.resize(eyeFBWidth, eyeFBHeight);
if (dataholder.vrSettings.vrUseStencil) {
Xplat.enableRenderTargetStencil(WorldRenderPass.stereoXR.target);
}
if (dataholder.vrSettings.useFsaa) {
this.fsaaFirstPassResultFBO.resize(eyew, eyeFBHeight, Minecraft.ON_OSX);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected ClientPacketListenerVRMixin(Minecraft minecraft, Connection connection
}
}

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;setLevel(Lnet/minecraft/client/multiplayer/ClientLevel;)V", shift = At.Shift.AFTER), method = "handleRespawn")
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;setLevel(Lnet/minecraft/client/multiplayer/ClientLevel;Lnet/minecraft/client/gui/screens/ReceivingLevelScreen$Reason;)V", shift = At.Shift.AFTER), method = "handleRespawn")
public void vivecraft$resetOnDimensionChange(ClientboundRespawnPacket clientboundRespawnPacket, CallbackInfo ci) {
// clear old data
ClientNetworking.resetServerSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.FishingHookRenderer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.FishingHook;
import net.minecraft.world.item.FishingRodItem;
import net.minecraft.world.item.Items;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.ItemTags;
import org.vivecraft.client_vr.render.helpers.RenderHelper;
import org.vivecraft.client_xr.render_pass.RenderPassType;

Expand All @@ -22,52 +25,16 @@ protected FishingHookRendererVRMixin(EntityRendererProvider.Context context) {
super(context);
}

private Vec3 vivecraft$CachedHandPos;

@ModifyVariable(at = @At(value = "LOAD"),
method = "render(Lnet/minecraft/world/entity/projectile/FishingHook;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", index = 25)
private double vivecraft$fishingLineStartX(double value, FishingHook fishingHook) {
if (!RenderPassType.isVanilla() && (this.entityRenderDispatcher.options == null || this.entityRenderDispatcher.options.getCameraType().isFirstPerson()) && fishingHook.getPlayerOwner() == Minecraft.getInstance().player) {
int j = 1;
if (fishingHook.getPlayerOwner().getMainHandItem().getItem() instanceof FishingRodItem) {
j = 0;
@Inject(at = @At("HEAD"), method = "getPlayerHandPos", cancellable = true)
private void vivecraft$getVRHandPos(Player player, float f, float g, CallbackInfoReturnable<Vec3> cir) {
if (!RenderPassType.isVanilla() && (this.entityRenderDispatcher.options.getCameraType().isFirstPerson()) && player == Minecraft.getInstance().player) {
int c = 1;
if (player.getMainHandItem().is(Items.FISHING_ROD) || player.getMainHandItem().is(ItemTags.VIVECRAFT_FISHING_RODS)) {
c = 0;
}
Vec3 vec31 = RenderHelper.getControllerRenderPos(j);
Vec3 vec32 = ClientDataHolderVR.getInstance().vrPlayer.vrdata_world_render.getHand(j).getDirection();
vivecraft$CachedHandPos = vec31.add(vec32.scale(0.47 * ClientDataHolderVR.getInstance().vrPlayer.vrdata_world_render.worldScale));
return vivecraft$CachedHandPos.x;
} else {
return value;
}
}

@ModifyVariable(at = @At(value = "LOAD"),
method = "render(Lnet/minecraft/world/entity/projectile/FishingHook;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", index = 27)
private double vivecraft$fishingLineStartY(double value, FishingHook fishingHook) {
if (!RenderPassType.isVanilla() && (this.entityRenderDispatcher.options == null || this.entityRenderDispatcher.options.getCameraType().isFirstPerson()) && fishingHook.getPlayerOwner() == Minecraft.getInstance().player) {
return vivecraft$CachedHandPos.y;
} else {
return value;
}
}

@ModifyVariable(at = @At(value = "LOAD"),
method = "render(Lnet/minecraft/world/entity/projectile/FishingHook;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", index = 29)
private double vivecraft$fishingLineStartZ(double value, FishingHook fishingHook) {
if (!RenderPassType.isVanilla() && (this.entityRenderDispatcher.options == null || this.entityRenderDispatcher.options.getCameraType().isFirstPerson()) && fishingHook.getPlayerOwner() == Minecraft.getInstance().player) {
return vivecraft$CachedHandPos.z;
} else {
return value;
}
}

@ModifyVariable(at = @At(value = "LOAD"),
method = "render(Lnet/minecraft/world/entity/projectile/FishingHook;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", index = 31)
private float vivecraft$fishingLineStartOffset(float value, FishingHook fishingHook) {
if (!RenderPassType.isVanilla() && (this.entityRenderDispatcher.options == null || this.entityRenderDispatcher.options.getCameraType().isFirstPerson()) && fishingHook.getPlayerOwner() == Minecraft.getInstance().player) {
return 0.0F;
} else {
return value;
Vec3 handPos = RenderHelper.getControllerRenderPos(c);
Vec3 rodOffset = ClientDataHolderVR.getInstance().vrPlayer.vrdata_world_render.getHand(c).getDirection();
cir.setReturnValue(handPos.add(rodOffset.scale(0.47 * ClientDataHolderVR.getInstance().vrPlayer.vrdata_world_render.worldScale)));
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.projectile.AbstractHurtingProjectile;
import net.minecraft.world.entity.projectile.ProjectileDeflection;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.vivecraft.server.ServerVRPlayers;
import org.vivecraft.server.ServerVivePlayer;

@Mixin(AbstractHurtingProjectile.class)
public abstract class AbstractHurtingProjectileMixin {
@Mixin(ProjectileDeflection.class)
public interface ProjectileDeflectionMixin {

@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getLookAngle()Lnet/minecraft/world/phys/Vec3;"), method = "hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z")
public Vec3 vivecraft$hurtvive(Entity instance) {
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getLookAngle()Lnet/minecraft/world/phys/Vec3;"), method = "method_59862")
private static Vec3 vivecraft$deflectLook(Entity instance) {
if (instance instanceof ServerPlayer player) {
ServerVivePlayer serverviveplayer = ServerVRPlayers.getVivePlayer(player);
if (serverviveplayer != null && serverviveplayer.isVR()) {
Expand Down
4 changes: 1 addition & 3 deletions common/src/main/resources/vivecraft.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"client_vr.gui.screens.PauseScreenVRMixin",
"client_vr.gui.screens.ScreenVRMixin",
"client_vr.gui.screens.SoundOptionsScreenVRMixin",
"client_vr.gui.screens.WinScreenVRMixin",
"client_vr.gui.screens.inventory.AbstractContainerScreenVRMixin",
"client_vr.gui.screens.inventory.AbstractSignEditScreenVRMixin",
"client_vr.gui.screens.inventory.BookEditScreenVRMixin",
Expand Down Expand Up @@ -72,7 +71,6 @@
"client_vr.world.FishingHookVRMixin",
"client_vr.world.ItemVRMixin",
"client_vr.world.PotionItemVRMixin",
"client_vr.world.entity.player.PlayerVRMixin",
"client_vr.world.entity.projectile.FireworkRocketEntityVRMixin",
"client_vr.world.level.block.DoorBlockVRMixin",
"client_vr.world.level.block.FenceGateBlockVRMixin",
Expand All @@ -93,8 +91,8 @@
"world.entity.monster.EndermanFreezeWhenLookedAtMixin",
"world.entity.monster.EndermanMixin",
"world.entity.projectile.AbstractArrowMixin",
"world.entity.projectile.AbstractHurtingProjectileMixin",
"world.entity.projectile.FishingHookMixin",
"world.entity.projectile.ProjectileDeflectionMixin",
"world.entity.projectile.ProjectileMixin",
"world.entity.projectile.ThrowableProjectileMixin",
"world.entity.projectile.ThrownTridentMixin",
Expand Down
4 changes: 2 additions & 2 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ dependencies {
modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }

// for sodium compat
modRuntimeOnly "maven.modrinth:sodium:mc1.20.5-0.5.8"
modRuntimeOnly "maven.modrinth:sodium:mc1.20.6-0.5.8"

// for iris compat
modRuntimeOnly "maven.modrinth:iris:1.7.0+1.20.5"
modRuntimeOnly "maven.modrinth:iris:1.7.0+1.20.6"
modRuntimeOnly 'org.anarres:jcpp:1.4.14' //temp iris
modRuntimeOnly 'io.github.douira:glsl-transformer:2.0.0-pre13' //temp iris

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ public static Path getJarPath() {
public static String getUseMethodName() {
return FabricLoader.getInstance().getMappingResolver().mapMethodName(
"intermediary",
"net.minecraft.class_4970", "method_9534",
"net.minecraft.class_4970", "method_55766",
"(Lnet/minecraft/class_2680;" +
"Lnet/minecraft/class_1937;" +
"Lnet/minecraft/class_2338;" +
"Lnet/minecraft/class_1657;" +
"Lnet/minecraft/class_1268;" +
"Lnet/minecraft/class_3965;)" +
"Lnet/minecraft/class_1269;");
}
Expand Down
3 changes: 3 additions & 0 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ dependencies {
bundle("org.lwjgl:lwjgl-openvr:3.3.3:natives-linux") { transitive = false }
bundle("org.lwjgl:lwjgl-openvr:3.3.3:natives-macos") { transitive = false }
bundle("org.lwjgl:lwjgl-openvr:3.3.3:natives-windows") { transitive = false }

compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.5"))
implementation(include("io.github.llamalad7:mixinextras-forge:0.3.5"))
}

processResources {
Expand Down
13 changes: 3 additions & 10 deletions forge/src/main/java/org/vivecraft/client/forge/XplatImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,7 @@ public static Path getJarPath() {
}

public static String getUseMethodName() {
return ObfuscationReflectionHelper.findMethod(
net.minecraft.world.level.block.state.BlockBehaviour.class,
"m_6227_",
net.minecraft.world.level.block.state.BlockState.class,
net.minecraft.world.level.Level.class,
net.minecraft.core.BlockPos.class,
net.minecraft.world.entity.player.Player.class,
net.minecraft.world.InteractionHand.class,
net.minecraft.world.phys.BlockHitResult.class).getName();
return "useWithoutItem";
}

public static TextureAtlasSprite[] getFluidTextures(BlockAndTintGetter level, BlockPos pos, FluidState fluidStateIn) {
Expand All @@ -89,10 +81,11 @@ public static BiomeSpecialEffects getBiomeEffects(Biome biome) {
}

public static void addNetworkChannel(ClientPacketListener listener, ResourceLocation resourceLocation) {
/*
// Forge I really don't know why you are insisting on this being a DiscardedPayload
listener.send(new ServerboundCustomPayloadPacket(new DiscardedPayload(
new ResourceLocation("minecraft:register"),
new FriendlyByteBuf(Unpooled.buffer())
.writeBytes(resourceLocation.toString().getBytes()))));
.writeBytes(resourceLocation.toString().getBytes()))));*/
}
}
34 changes: 34 additions & 0 deletions forge/src/main/java/org/vivecraft/forge/Vivecraft.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
package org.vivecraft.forge;

import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.event.network.CustomPayloadEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.network.ChannelBuilder;
import net.minecraftforge.network.EventNetworkChannel;
import net.minecraftforge.network.NetworkDirection;
import org.vivecraft.client.network.ClientNetworking;
import org.vivecraft.common.network.CommonNetworkHelper;
import org.vivecraft.server.ServerNetworking;
import org.vivecraft.server.config.ServerConfig;

@Mod(Vivecraft.MODID)
Expand All @@ -10,5 +18,31 @@ public class Vivecraft {
public Vivecraft() {
// init server config
ServerConfig.init(null);

EventNetworkChannel channel = ChannelBuilder.named(CommonNetworkHelper.CHANNEL)
.acceptedVersions((status, version) -> true)
.optional()
.networkProtocolVersion(0)
.eventNetworkChannel();
channel.addListener(event -> {
if (event.getSource().getDirection() == NetworkDirection.PLAY_TO_SERVER) {
handleServerVivePacket(event.getPayload(), event.getSource());
} else {
handleClientVivePacket(event.getPayload(), event.getSource());
}
});
}

private static void handleClientVivePacket(FriendlyByteBuf buffer, CustomPayloadEvent.Context context) {
context.enqueueWork(() -> {
ClientNetworking.handlePacket(CommonNetworkHelper.PacketDiscriminators.values()[buffer.readByte()], buffer);
});
}

private static void handleServerVivePacket(FriendlyByteBuf buffer, CustomPayloadEvent.Context context) {
context.enqueueWork(() -> {
ServerNetworking.handlePacket(CommonNetworkHelper.PacketDiscriminators.values()[buffer.readByte()], buffer, context.getSender(), p -> context.getConnection().send(p));
buffer.release();
});
}
}
Loading

0 comments on commit 3edcb74

Please sign in to comment.