forked from sorceress/EasyAuth
Forge works!
This commit is contained in:
parent
6e5257514e
commit
6c8d80ac20
|
@ -11,16 +11,17 @@ import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.util.registry.RegistryKey;
|
import net.minecraft.util.registry.RegistryKey;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.samo_lego.simpleauth.storage.PlayerCache;
|
import org.samo_lego.simpleauth.storage.PlayerCache;
|
||||||
|
import org.samo_lego.simpleauth.utils.PlatformSpecific;
|
||||||
import org.samo_lego.simpleauth.utils.PlayerAuth;
|
import org.samo_lego.simpleauth.utils.PlayerAuth;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import static org.samo_lego.simpleauth.SimpleAuth.*;
|
import static org.samo_lego.simpleauth.SimpleAuth.*;
|
||||||
import static org.samo_lego.simpleauth.utils.CarpetHelper.isPlayerCarpetFake;
|
|
||||||
import static org.samo_lego.simpleauth.utils.SimpleLogger.logInfo;
|
import static org.samo_lego.simpleauth.utils.SimpleLogger.logInfo;
|
||||||
|
|
||||||
@Mixin(ServerPlayerEntity.class)
|
@Mixin(ServerPlayerEntity.class)
|
||||||
|
@ -29,10 +30,9 @@ public class MixinServerPlayerEntity implements PlayerAuth {
|
||||||
private final ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
|
private final ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
|
||||||
|
|
||||||
// * 20 for 20 ticks in second
|
// * 20 for 20 ticks in second
|
||||||
|
@Unique
|
||||||
private int kickTimer = config.main.kickTime * 20;
|
private int kickTimer = config.main.kickTime * 20;
|
||||||
|
|
||||||
private final boolean isRunningCarpet = false;//FabricLoader.getInstance().isModLoaded("carpet"); //todo
|
|
||||||
|
|
||||||
@Final
|
@Final
|
||||||
@Shadow
|
@Shadow
|
||||||
public MinecraftServer server;
|
public MinecraftServer server;
|
||||||
|
@ -158,8 +158,7 @@ public class MixinServerPlayerEntity implements PlayerAuth {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canSkipAuth() {
|
public boolean canSkipAuth() {
|
||||||
// We ask CarpetHelper class since it has the imports needed
|
return PlatformSpecific.isPlayerFake(this.player) || (isUsingMojangAccount() && config.main.premiumAutologin);
|
||||||
return (this.isRunningCarpet && isPlayerCarpetFake(this.player)) || (isUsingMojangAccount() && config.main.premiumAutologin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package org.samo_lego.simpleauth.utils;
|
||||||
|
|
||||||
|
import me.shedaniel.architectury.annotations.ExpectPlatform;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
|
public class PlatformSpecific {
|
||||||
|
@ExpectPlatform
|
||||||
|
public static boolean isPlayerFake(PlayerEntity player) {
|
||||||
|
// Replaced by Architectury
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,17 +1,16 @@
|
||||||
package org.samo_lego.simpleauth.utils;
|
package org.samo_lego.simpleauth.utils;
|
||||||
|
|
||||||
//import carpet.patches.EntityPlayerMPFake;
|
import carpet.patches.EntityPlayerMPFake;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
public class CarpetHelper {
|
public class CarpetHelper {
|
||||||
/**
|
/**
|
||||||
* Checks if player is actually a fake one.
|
* Checks if player is actually a fake one.
|
||||||
* Fake players are counted as ones, summoned with Carpet mod.
|
|
||||||
*
|
*
|
||||||
* @param player player to check
|
* @param player player to check
|
||||||
* @return true if it's fake, otherwise false
|
* @return true if it's fake, otherwise false
|
||||||
*/
|
*/
|
||||||
public static boolean isPlayerCarpetFake(PlayerEntity player) {
|
public static boolean isPlayerFake(PlayerEntity player) {
|
||||||
return false;//player instanceof EntityPlayerMPFake;
|
return player instanceof EntityPlayerMPFake;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.samo_lego.simpleauth.utils.fabric;
|
||||||
|
|
||||||
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import org.samo_lego.simpleauth.utils.CarpetHelper;
|
||||||
|
|
||||||
|
public class PlatformSpecificImpl {
|
||||||
|
/**
|
||||||
|
* Checks if player is actually a fake one.
|
||||||
|
*
|
||||||
|
* @param player player to check
|
||||||
|
* @return true if it's fake, otherwise false
|
||||||
|
*/
|
||||||
|
public static boolean isPlayerFake(PlayerEntity player) {
|
||||||
|
return FabricLoader.getInstance().isModLoaded("carpet") && CarpetHelper.isPlayerFake(player);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package org.samo_lego.simpleauth;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import me.shedaniel.architectury.platform.forge.EventBuses;
|
import me.shedaniel.architectury.platform.forge.EventBuses;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
@ -15,8 +16,9 @@ import org.samo_lego.simpleauth.commands.*;
|
||||||
public class SimpleAuthForge {
|
public class SimpleAuthForge {
|
||||||
public SimpleAuthForge() {
|
public SimpleAuthForge() {
|
||||||
// Submit our event bus to let architectury register our content on the right time
|
// Submit our event bus to let architectury register our content on the right time
|
||||||
EventBuses.registerModEventBus(SimpleAuth.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus());
|
//EventBuses.registerModEventBus(SimpleAuth.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus());
|
||||||
SimpleAuth.init(FMLPaths.GAMEDIR.get());
|
SimpleAuth.init(FMLPaths.GAMEDIR.get());
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.samo_lego.simpleauth.utils.forge;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
|
public class PlatformSpecificImpl {
|
||||||
|
public static boolean isPlayerFake(PlayerEntity player) {
|
||||||
|
// Are there any forge mods with NPCs that don't work with SimpleAuth?
|
||||||
|
// Let me know!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ forge_version=36.0.4
|
||||||
|
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.7.4
|
mod_version = 1.7.5
|
||||||
maven_group = org.samo_lego
|
maven_group = org.samo_lego
|
||||||
archives_base_name = simpleauth
|
archives_base_name = simpleauth
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue