basic inits

This commit is contained in:
gnembon committed 2019-05-11 01:06:48 -03:00
1 parent 394891ab5f
commit ec66779474
8 files changed
+93 -10

No files matched your search

-1
View File
@@ -44,7 +44,6 @@ public class CarpetServer // static for now - easier to handle all around the co
public static void tick(MinecraftServer server)
{
CarpetSettings.LOG.error("ticking...");
//TickSpeed.tick(server);
//HUDController.update_hud(server);
}
+1 -1
View File
@@ -221,7 +221,7 @@ public class CarpetSettings
private static void notifyPlayersCommandsChanged()
{
if (CarpetServer.minecraft_server == null)
if (CarpetServer.minecraft_server == null || CarpetServer.minecraft_server.getPlayerManager() == null)
{
return;
}
@@ -1,4 +1,4 @@
package carpet.mixins;
package carpet.mixins.carpetServer;
import carpet.CarpetServer;
import com.mojang.brigadier.CommandDispatcher;
@@ -0,0 +1,23 @@
package carpet.mixins.carpetServer;
import carpet.CarpetServer;
import net.minecraft.server.integrated.IntegratedServer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(IntegratedServer.class)
public class IntegratedServerMixin
{
@Inject(method = "setupServer",
at = @At(
value = "INVOKE",
shift = At.Shift.AFTER,
target = "Lnet/minecraft/server/integrated/IntegratedServer;setKeyPair(Ljava/security/KeyPair;)V"
)
)
private void onSetupServerIntegrated(CallbackInfoReturnable<Boolean> cir) {
CarpetServer.onServerLoaded((IntegratedServer) (Object) this);
}
}
@@ -0,0 +1,21 @@
package carpet.mixins.carpetServer;
import carpet.CarpetServer;
import net.minecraft.client.MinecraftClient;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MinecraftClient.class)
public class MinecraftClientMixin
{
//to inject right before
// this.tickWorlds(booleanSupplier_1);
@Inject(method = "init", at = @At(value = "RETURN")
)
private void onInit(CallbackInfo ci) {
//CM start game hook
CarpetServer.onGameStarted();
}
}
@@ -0,0 +1,30 @@
package carpet.mixins.carpetServer;
import carpet.CarpetServer;
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(MinecraftDedicatedServer.class)
public class MinecraftDedicatedServerMixin
{
//to inject right before
// this.tickWorlds(booleanSupplier_1);
@Inject(
method = "setupServer",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/util/UserCache;setUseRemote(Z)V",
shift = At.Shift.AFTER,
ordinal = 0
)
)
private void onSetupServer(CallbackInfoReturnable<Boolean> cir) {
//CM init - all stuff loaded from the server, just before worlds loading
CarpetServer.onServerLoaded((MinecraftDedicatedServer) (Object) this);
//CM start game hook
CarpetServer.onGameStarted();
}
}
@@ -1,4 +1,4 @@
package carpet.mixins;
package carpet.mixins.carpetServer;
import carpet.CarpetServer;
import com.mojang.authlib.GameProfileRepository;
@@ -21,22 +21,27 @@ import java.util.function.BooleanSupplier;
@Mixin(MinecraftServer.class)
public abstract class MinecraftServerMixin
{
// Called during game start
@Inject(method = "<init>", at = @At(value = "HEAD"))
@Inject(method = "<init>", at = @At(value = "RETURN"))
private void onMinecraftServerCTOR(File file_1, Proxy proxy_1, DataFixer dataFixer_1,
CommandManager serverCommandManager_1, YggdrasilAuthenticationService yggdrasilAuthenticationService_1,
MinecraftSessionService minecraftSessionService_1, GameProfileRepository gameProfileRepository_1,
UserCache userCache_1, WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory_1,
String string_1, CallbackInfo ci)
{
// Called during game start
CarpetServer.init((MinecraftServer) (Object) this);
}
//to inject right before
// this.tickWorlds(booleanSupplier_1);
@Inject(
method = "Lnet/minecraft/server/MinecraftServer;tick(Ljava/util/function/BooleanSupplier;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;tickWorlds(Ljava/util/function/BooleanSupplier;)V", shift = At.Shift.BEFORE, ordinal = 0)
method = "tick",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/MinecraftServer;tickWorlds(Ljava/util/function/BooleanSupplier;)V",
shift = At.Shift.BEFORE,
ordinal = 0
)
)
private void onTick(BooleanSupplier booleanSupplier_1, CallbackInfo ci) {
CarpetServer.tick((MinecraftServer) (Object) this);
+7 -2
View File
@@ -3,10 +3,15 @@
"package": "carpet.mixins",
"compatibilityLevel": "JAVA_8",
"mixins": [
"CommandManagerMixin"
"carpetServer/CommandManagerMixin",
"carpetServer/MinecraftServerMixin"
],
"client": [
"CommandManagerMixin"
"carpetServer/MinecraftClientMixin",
"carpetServer/IntegratedServerMixin"
],
"server": [
"carpetServer/MinecraftDedicatedServerMixin"
],
"injectors": {
"defaultRequire": 1