Skip to content

Commit

Permalink
backport to 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed Feb 28, 2024
1 parent ece20ce commit e27cbd3
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 111 deletions.
12 changes: 6 additions & 6 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ 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.4-0.5.8"
modCompileOnly "maven.modrinth:sodium:mc1.20.2-0.5.5"

// for iris compat
modCompileOnly "maven.modrinth:iris:1.6.17+1.20.4"
modCompileOnly "maven.modrinth:iris:1.6.14+1.20.2"

// 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" }
modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:13.0.685") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" exclude group: "dev.architectury" }

// for Pehkui compat
modApi("com.github.Virtuoel:Pehkui:3.7.12") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }

// other mods
modCompileOnly "maven.modrinth:dynamic-fps:3.4.1"
// modCompileOnly("com.simibubi.create:create-fabric-1.19.2:0.5.0.i-969+1.19.2")
// modCompileOnly "maven.modrinth:lithium:mc1.20.4-0.12.1"
// modCompileOnly "maven.modrinth:indium:1.0.30+mc1.20.4"
// modCompileOnly "maven.modrinth:lithium:mc1.20.2-0.12.0"
// modCompileOnly "maven.modrinth:indium:1.0.28+mc1.20.4"
modCompileOnly "maven.modrinth:resolution-control-plus:3.0.0"
modCompileOnly "maven.modrinth:better-combat:1.8.3+1.20.1-fabric"

// for immersive portals compat
modCompileOnly('com.github.iPortalTeam:ImmersivePortalsMod:v5.1.7-mc1.20.4') { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }
modCompileOnly('com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v4.1.4-mc1.20.2') { transitive false }

//for epic fight compat
modCompileOnly("maven.modrinth:epic-fight:20.6.3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void init() {
.build());

this.addRenderableWidget(new Button.Builder(Component.translatable("vivecraft.gui.openguide"),
ConfirmLinkScreen.confirmLink(this, guideURL))
ConfirmLinkScreen.confirmLink(guideURL, this, true))
.pos(this.width / 2 - 75, this.height - 32)
.size(150, 20)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ protected void init() {
this.addRenderableWidget(new TextScrollWidget(this.width / 2 - 155, 30, 310, this.height - 30 - 60, UpdateChecker.changelog));

this.addRenderableWidget(new Button.Builder(Component.translatable("vivecraft.gui.downloadfrom", Component.literal("Modrinth")),
ConfirmLinkScreen.confirmLink(this, "https://modrinth.com/mod/vivecraft"))
ConfirmLinkScreen.confirmLink("https://modrinth.com/mod/vivecraft", this, true))
.pos(this.width / 2 - 155, this.height - 56)
.size(150, 20)
.build());

this.addRenderableWidget(new Button.Builder(Component.translatable("vivecraft.gui.downloadfrom", Component.literal("CurseForge")),
ConfirmLinkScreen.confirmLink(this, "https://www.curseforge.com/minecraft/mc-mods/vivecraft"))
ConfirmLinkScreen.confirmLink("https://www.curseforge.com/minecraft/mc-mods/vivecraft", this, true))
.pos(this.width / 2 + 5, this.height - 56)
.size(150, 20)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class GuiQuickCommandsList extends ObjectSelectionList<GuiQuickCommandsLi
private final Minecraft mc;

public GuiQuickCommandsList(GuiQuickCommandEditor parent, Minecraft mc) {
super(mc, parent.width, parent.height - 64, 32, 20);
super(mc, parent.width, parent.height, 32, parent.height - 32, 20);
this.parent = parent;
this.mc = mc;
String[] astring = this.dataholder.vrSettings.vrQuickCommands;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class GuiRadialItemsList extends ObjectSelectionList {
private int maxListLabelWidth = 0;

public GuiRadialItemsList(GuiRadialConfiguration parent, Minecraft mc) {
super(mc, parent.width, parent.height - 95, 63, 20);
super(mc, parent.width, parent.height, 63, parent.height - 32, 20);
this.parent = parent;
this.mc = mc;
this.maxListLabelWidth = 90;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class SettingsList extends ContainerObjectSelectionList<SettingsList.Base
int maxNameWidth;

public SettingsList(Screen parent, Minecraft minecraft, List<SettingsList.BaseEntry> entries) {
super(minecraft, parent.width + 45, parent.height - 52, 20, 20);
super(minecraft, parent.width + 45, parent.height, 20, parent.height - 32, 20);
this.parent = parent;
for (SettingsList.BaseEntry entry : entries) {
int i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.ComponentSerialization;
import net.minecraft.util.ExtraCodecs;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingRecipeCodecs;

public class CustomShapedRecipe {

Expand All @@ -20,10 +20,10 @@ public class CustomShapedRecipe {
.strictOptionalField(ExtraCodecs.POSITIVE_INT, "count", 1)
.forGetter(ItemStack::getCount),
ExtraCodecs
.strictOptionalField(ComponentSerialization.CODEC, "name", Component.empty())
.strictOptionalField(ExtraCodecs.COMPONENT, "name", Component.empty())
.forGetter(ItemStack::getHoverName),
ExtraCodecs
.strictOptionalField(ComponentSerialization.CODEC, "fallbackname", Component.empty())
.strictOptionalField(ExtraCodecs.COMPONENT, "fallbackname", Component.empty())
.forGetter(ItemStack::getHoverName),
ExtraCodecs
.strictOptionalField(Codec.BOOL, "unbreakable", false)
Expand Down Expand Up @@ -54,6 +54,6 @@ public class CustomShapedRecipe {
})
);

public static final Codec<ItemStack> CODEC = ExtraCodecs.either(VIVECRAFT_ITEMSTACK_OBJECT_CODEC, ItemStack.ITEM_WITH_COUNT_CODEC)
public static final Codec<ItemStack> CODEC = ExtraCodecs.either(VIVECRAFT_ITEMSTACK_OBJECT_CODEC, CraftingRecipeCodecs.ITEMSTACK_OBJECT_CODEC)
.xmap(itemStackItemStackEither -> itemStackItemStackEither.map(stack -> stack, stack -> stack), Either::right);
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,16 @@ protected ClientPacketListenerVRMixin(Minecraft minecraft, Connection connection
}

/**
* this is just needed so that neoforge doesn't crash.
* packets are handled with their events.
* {@link org.vivecraft.neoforge.event.ClientEvents#handleVivePacket}
* this is just needed for neoforge.
*/
@Surrogate
public void vivecraft$handlepacket(ClientboundCustomPayloadPacket packet, CustomPacketPayload customPacketPayload, CallbackInfo info) {
if (customPacketPayload instanceof VivecraftDataPacket dataPacket) {
FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer()).writeBytes(dataPacket.buffer());
ClientNetworking.handlePacket(dataPacket.packetid(), buffer);
buffer.release();
info.cancel();
}
}

@Inject(at = @At("HEAD"), method = "handleOpenScreen")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ public class ClientboundCustomPayloadPacketMixin {

/**
* catches the vivecraft client bound packets so that they don't get discarded.
* Neoforge handles that with the network events in {@link org.vivecraft.neoforge.event.ClientEvents#handleVivePacket}
*/
@Inject(at = @At("HEAD"), method = "readPayload(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/network/FriendlyByteBuf;)Lnet/minecraft/network/protocol/common/custom/CustomPacketPayload;", cancellable = true)
@Inject(at = @At("HEAD"), method = "readPayload", cancellable = true)
private static void vivecraft$catchVivecraftPackets(ResourceLocation resourceLocation, FriendlyByteBuf friendlyByteBuf, CallbackInfoReturnable<CustomPacketPayload> cir) {
if (CommonNetworkHelper.CHANNEL.equals(resourceLocation)) {
cir.setReturnValue(new VivecraftDataPacket(friendlyByteBuf));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ public class ServerboundCustomPayloadPacketMixin {

/**
* catches the vivecraft server bound packets and processes them.
* Neoforge handles that in {@link org.vivecraft.neoforge.event.ServerEvents#handleVivePacket}
*/
@Inject(at = @At("HEAD"), method = "readPayload(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/network/FriendlyByteBuf;)Lnet/minecraft/network/protocol/common/custom/CustomPacketPayload;", cancellable = true)
@Inject(at = @At("HEAD"), method = "readPayload", cancellable = true)
private static void vivecraft$catchVivecraftPackets(ResourceLocation resourceLocation, FriendlyByteBuf friendlyByteBuf, CallbackInfoReturnable<CustomPacketPayload> cir) {
if (CommonNetworkHelper.CHANNEL.equals(resourceLocation)) {
cir.setReturnValue(new VivecraftDataPacket(friendlyByteBuf));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public abstract class ServerCommonPacketListenerImplMixin {

/**
* handle server bound vivecraft packets
* on neoforge those are handled in {@link org.vivecraft.neoforge.event.ServerEvents#handleVivePacket}
* if connected to spigot they are still handled here
*/
@Inject(at = @At("HEAD"), method = "handleCustomPayload", cancellable = true)
public void vivecraft$handleVivecraftPackets(ServerboundCustomPayloadPacket payloadPacket, CallbackInfo ci) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.EntityHitResult;
Expand All @@ -40,8 +39,8 @@ protected AbstractArrowMixin(EntityType<? extends Projectile> p_37248_, Level p_
@Shadow
private double baseDamage;

@Inject(at = @At("RETURN"), method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;)V")
public void vivecraft$pickup(EntityType<? extends AbstractArrow> p_36717_, LivingEntity p_36718_, Level p_36719_, ItemStack itemStack, CallbackInfo info) {
@Inject(at = @At("RETURN"), method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/level/Level;)V")
public void vivecraft$pickup(EntityType<? extends AbstractArrow> p_36717_, LivingEntity p_36718_, Level p_36719_, CallbackInfo info) {
if (p_36718_ instanceof ServerPlayer player) {
ServerVivePlayer serverviveplayer = ServerVRPlayers.getVivePlayer(player);
if (serverviveplayer != null && serverviveplayer.isVR()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import org.spongepowered.asm.mixin.injection.Redirect;
import org.vivecraft.common.CustomShapedRecipe;

@Mixin(targets = "net.minecraft.world.item.crafting.ShapedRecipe$Serializer")
@Mixin(targets = "net.minecraft.world.item.crafting.ShapedRecipe$Serializer$RawShapedRecipe")
public abstract class ShapedRecipeMixin {

@Redirect(at = @At(value = "FIELD", target = "Lnet/minecraft/world/item/ItemStack;ITEM_WITH_COUNT_CODEC:Lcom/mojang/serialization/Codec;"), method = "method_55071")
@Redirect(at = @At(value = "FIELD", target = "Lnet/minecraft/world/item/crafting/CraftingRecipeCodecs;ITEMSTACK_OBJECT_CODEC:Lcom/mojang/serialization/Codec;"), method = "method_53750")
private static Codec<ItemStack> vivecraft$handleVivecraftRecipe() {
// CODEC needs to be external, or it isn't initialized, when the other static codec want's to access it
return CustomShapedRecipe.CODEC;
Expand Down
16 changes: 9 additions & 7 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,31 @@ 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.4-0.5.8"
modRuntimeOnly "maven.modrinth:sodium:mc1.20.2-0.5.5"

// for iris compat
modRuntimeOnly "maven.modrinth:iris:1.6.17+1.20.4"
modRuntimeOnly "maven.modrinth:iris:1.6.14+1.20.2"
modRuntimeOnly 'org.anarres:jcpp:1.4.14' //temp iris
modRuntimeOnly 'io.github.douira:glsl-transformer:2.0.0-pre13' //temp iris

// for REI compat
modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:14.0.688") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" exclude group: "dev.architectury" }
modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:13.0.685") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" exclude group: "dev.architectury" }

// for Pehkui compat
modCompileOnly("com.github.Virtuoel:Pehkui:3.7.12") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }

// other mods
// modRuntimeOnly("com.simibubi.create:create-fabric-1.19.2:0.5.0.i-969+1.19.2")
// modCompileOnly "maven.modrinth:lithium:mc1.20.4-0.12.1"
// modCompileOnly "maven.modrinth:indium:1.0.30+mc1.20.4"
// modCompileOnly "maven.modrinth:lithium:mc1.20.2-0.12.0"
// modCompileOnly "maven.modrinth:indium:1.0.28+mc1.20.4"

//mod menu
modApi("com.terraformersmc:modmenu:9.0.0") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }
modApi("com.terraformersmc:modmenu:8.0.1") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }

// for immersive portals compat
modCompileOnly('com.github.iPortalTeam:ImmersivePortalsMod:v5.1.7-mc1.20.4') { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }
modCompileOnly('com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v4.1.4-mc1.20.2') { transitive false }
modCompileOnly('com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:v4.1.4-mc1.20.2') { transitive false }
modCompileOnly('com.github.iPortalTeam.ImmersivePortalsMod:build:v4.1.4-mc1.20.2') { transitive false }

// needed for resource loading
include(modImplementation(fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version)))
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
],
"depends": {
"fabricloader": ">=0.14.14",
"minecraft": ["1.20.3", "1.20.4"],
"minecraft": ["1.20.2"],
"java": ">=17"
},
"breaks": {
Expand Down
6 changes: 3 additions & 3 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader = "javafml"
loaderVersion = "[49,)"
loaderVersion = "[48,)"
issueTrackerURL = "https://github.com/Vivecraft/VivecraftMod/issues"
license = "LGPLv3"

Expand All @@ -23,13 +23,13 @@ updateJSONURL = "https://raw.githubusercontent.com/Vivecraft/VivecraftMod/forge-
[[dependencies.vivecraft]]
modId = "forge"
mandatory = true
versionRange = "[49,)"
versionRange = "[48,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.vivecraft]]
modId = "minecraft"
mandatory = true
versionRange = "[1.20.3,1.20.4]"
versionRange = "[1.20.2,1.20.3)"
ordering = "NONE"
side = "BOTH"
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
org.gradle.jvmargs=-Xmx4G

minecraft_version=1.20.4
minecraft_version=1.20.2
enabled_platforms=fabric,forge,neoforge

archives_base_name=vivecraft
mod_version=1.1.7
maven_group=org.vivecraft

architectury_version=11.0.5
architectury_version=10.0.18

fabric_loader_version=0.15.7
fabric_api_version=0.91.1+1.20.4
fabric_api_version=0.91.6+1.20.2

forge_version=1.20.4-49.0.30
neoforge_version=20.4.164-beta
forge_version=1.20.2-48.1.0
neoforge_version=20.2.88



Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
Expand Down Expand Up @@ -98,7 +101,18 @@ public static double getItemEntityReach(double baseRange, ItemStack itemStack, E
}

public static void addNetworkChannel(ClientPacketListener listener, ResourceLocation resourceLocation) {
// neoforge does that automatically, since we use their networking system
// at least I have been told this
listener.send(new ServerboundCustomPayloadPacket(new CustomPacketPayload() {
public static final ResourceLocation ID = new ResourceLocation("minecraft:register");

@Override
public void write(FriendlyByteBuf friendlyByteBuf) {
friendlyByteBuf.writeBytes(resourceLocation.toString().getBytes());
}

@Override
public ResourceLocation id() {
return ID;
}
}));
}
}

This file was deleted.

Loading

0 comments on commit e27cbd3

Please sign in to comment.