neoforge can boot into singleplayer again

Signed-off-by: Polymeta <40173118+Polymeta@users.noreply.github.com>
This commit is contained in:
Polymeta
2026-05-03 17:37:09 +01:00
parent dc78e40941
commit 4ba33c2a80
7 changed files with 111 additions and 32 deletions
@@ -139,23 +139,4 @@ public abstract class ServerEntityMixin {
CobblemonNetwork.INSTANCE.sendPacketToPlayer(player, packet);
}
}
@Inject(method = "sendPairingData", at = @At("TAIL"))
private void cobblemon$sendPairingSeatAssignments(
ServerPlayer player,
Consumer<Packet<ClientGamePacketListener>> consumer,
CallbackInfo ci
) {
if (!(entity instanceof PokemonEntity pokemon)) return;
if (pokemon.getOccupiedSeats().isEmpty()) return;
pokemon.getOccupiedSeats().forEach((seat, passenger) -> {
if (seat.getLocator() == null) return;
CobblemonNetwork.INSTANCE.sendPacketToPlayer(
player,
new ClientboundSeatAssignmentPacket(passenger.getId(), pokemon.getId(), seat.getLocator())
);
});
}
}
@@ -38,15 +38,8 @@ class ShowdownThread : Thread("Cobblemon Showdown") {
override fun run() {
LOGGER.info("Starting showdown service...")
try {
ShowdownService.service.openConnection()
LOGGER.info("Showdown has been started!")
} catch (e: Exception) {
LOGGER.error("Failed to start showdown service!", e)
} finally {
this.latch.countDown()
throw RuntimeException("Showdown service failed to initialize...")
}
ShowdownService.service.openConnection()
LOGGER.info("Showdown has been started!")
this.latch.countDown()
}
}
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2023 Cobblemon Contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.fabric.mixin;
import com.cobblemon.mod.common.CobblemonNetwork;
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
import com.cobblemon.mod.common.net.messages.client.pokemon.update.evolution.ClientboundSeatAssignmentPacket;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.server.level.ServerEntity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.function.Consumer;
@Mixin(ServerEntity.class)
public class ServerEntityMixin {
@Shadow
@Final
private Entity entity;
@Inject(method = "sendPairingData", at = @At("TAIL"))
private void cobblemon$sendPairingSeatAssignments(
ServerPlayer player,
Consumer<Packet<ClientGamePacketListener>> consumer,
CallbackInfo ci
) {
if (!(entity instanceof PokemonEntity pokemon)) return;
if (pokemon.getOccupiedSeats().isEmpty()) return;
pokemon.getOccupiedSeats().forEach((seat, passenger) -> {
if (seat.getLocator() == null) return;
CobblemonNetwork.INSTANCE.sendPacketToPlayer(
player,
new ClientboundSeatAssignmentPacket(passenger.getId(), pokemon.getId(), seat.getLocator())
);
});
}
}
@@ -17,6 +17,7 @@
"FabricSoundEngineMixin",
"PlayerMixin",
"RecipeBookSettingsMixin",
"RecipeBookTypeMixin"
"RecipeBookTypeMixin",
"ServerEntityMixin"
]
}
+2 -1
View File
@@ -53,7 +53,6 @@ dependencies {
testImplementation(project(":common", configuration = "namedElements"))
listOf(
libs.bundles.graal,
libs.bundles.mongo
).forEach {
include(it)
@@ -62,6 +61,7 @@ dependencies {
forgeRuntimeLibrary(libs.bundles.graal)
listOf(
libs.bundles.graal,
libs.molang
).forEach {
forgeRuntimeLibrary(it)
@@ -75,6 +75,7 @@ tasks {
exclude("architectury-common.accessWidener")
exclude("architectury.common.json")
relocate ("org.graalvm", "com.cobblemon.mod.relocations.graalvm")
relocate ("com.ibm.icu", "com.cobblemon.mod.relocations.ibm.icu")
}
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2023 Cobblemon Contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.neoforge.mixin;
import com.cobblemon.mod.common.CobblemonNetwork;
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
import com.cobblemon.mod.common.net.messages.client.pokemon.update.evolution.ClientboundSeatAssignmentPacket;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.server.level.ServerEntity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.neoforged.neoforge.network.bundle.PacketAndPayloadAcceptor;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ServerEntity.class)
public class ServerEntityMixin {
@Shadow
@Final
private Entity entity;
@Inject(method = "sendPairingData", at = @At("TAIL"))
private void cobblemon$sendPairingSeatAssignments(
ServerPlayer player,
PacketAndPayloadAcceptor<ClientGamePacketListener> packetAndPayloadAcceptor,
CallbackInfo ci
) {
if (!(entity instanceof PokemonEntity pokemon)) return;
if (pokemon.getOccupiedSeats().isEmpty()) return;
pokemon.getOccupiedSeats().forEach((seat, passenger) -> {
if (seat.getLocator() == null) return;
CobblemonNetwork.INSTANCE.sendPacketToPlayer(
player,
new ClientboundSeatAssignmentPacket(passenger.getId(), pokemon.getId(), seat.getLocator())
);
});
}
}
@@ -14,6 +14,7 @@
"EntityMixin",
"GenericPacketSplitterMixin",
"NeoforgeBrewingStandMenuMixin",
"NeoforgeSoundEngineMixin"
"NeoforgeSoundEngineMixin",
"ServerEntityMixin"
]
}