|
@@ -1,13 +1,10 @@
|
|
|
package me.km.utils;
|
|
|
|
|
|
import cpw.mods.modlauncher.api.INameMappingService;
|
|
|
-import java.lang.reflect.Constructor;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
import java.lang.reflect.Method;
|
|
|
-import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
-import java.util.function.Function;
|
|
|
import net.minecraft.block.Block;
|
|
|
import net.minecraft.block.Blocks;
|
|
|
import net.minecraft.block.FireBlock;
|
|
@@ -16,21 +13,16 @@ import net.minecraft.entity.ai.goal.GoalSelector;
|
|
|
import net.minecraft.entity.ai.goal.PrioritizedGoal;
|
|
|
import net.minecraft.entity.player.PlayerAbilities;
|
|
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
|
+import net.minecraft.resources.DataPackRegistries;
|
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
import net.minecraft.server.management.PlayerInteractionManager;
|
|
|
import net.minecraft.server.management.PlayerList;
|
|
|
import net.minecraft.util.FoodStats;
|
|
|
-import net.minecraft.util.ResourceLocation;
|
|
|
import net.minecraft.world.Explosion;
|
|
|
import net.minecraft.world.GameRules;
|
|
|
import net.minecraft.world.GameType;
|
|
|
import net.minecraft.world.IWorld;
|
|
|
-import net.minecraft.world.World;
|
|
|
-import net.minecraft.world.biome.Biome;
|
|
|
-import net.minecraft.world.biome.provider.BiomeProvider;
|
|
|
-import net.minecraft.world.gen.feature.IFeatureConfig;
|
|
|
-import net.minecraft.world.gen.feature.structure.Structure;
|
|
|
-import net.minecraft.world.storage.PlayerData;
|
|
|
+import net.minecraft.world.server.ServerWorld;
|
|
|
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
|
|
import static net.minecraftforge.fml.common.ObfuscationReflectionHelper.remapName;
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
@@ -166,11 +158,11 @@ public class ReflectionUtils {
|
|
|
// PlayerList
|
|
|
// -----------------------------------------------------------------------------------
|
|
|
private final static Method SET_GAMETYPE = getMethod(PlayerList.class, "func_72381_a",
|
|
|
- ServerPlayerEntity.class, ServerPlayerEntity.class, IWorld.class); // setPlayerGameTypeBasedOnOther
|
|
|
+ ServerPlayerEntity.class, ServerPlayerEntity.class, ServerWorld.class); // setPlayerGameTypeBasedOnOther
|
|
|
|
|
|
- public static void setPlayerGameTypeBasedOnOther(PlayerList pl, ServerPlayerEntity target, ServerPlayerEntity source, IWorld worldIn) {
|
|
|
+ public static void setPlayerGameTypeBasedOnOther(PlayerList pl, ServerPlayerEntity target, ServerPlayerEntity source, ServerWorld sw) {
|
|
|
try {
|
|
|
- SET_GAMETYPE.invoke(pl, target, source, worldIn);
|
|
|
+ SET_GAMETYPE.invoke(pl, target, source, sw);
|
|
|
} catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
|
|
LogManager.getLogger().warn("setPlayerGameTypeBasedOnOther - " + ex);
|
|
|
}
|
|
@@ -179,10 +171,10 @@ public class ReflectionUtils {
|
|
|
// -----------------------------------------------------------------------------------
|
|
|
// minecraft server
|
|
|
// -----------------------------------------------------------------------------------
|
|
|
- private final static Field COMMAND_MANAGER = getField(MinecraftServer.class, "field_195579_af"); // commandManager
|
|
|
+ private final static Field COMMAND_MANAGER = getField(DataPackRegistries.class, "field_240953_c_"); // commands
|
|
|
|
|
|
public static void setCommandManager(MinecraftServer server, Commands manager) {
|
|
|
- setFieldValue(server, COMMAND_MANAGER, manager);
|
|
|
+ setFieldValue(server.getDataPackRegistries(), COMMAND_MANAGER, manager);
|
|
|
}
|
|
|
|
|
|
private final static Field MODE = getField(Explosion.class, "field_222260_b"); // mode
|
|
@@ -218,7 +210,7 @@ public class ReflectionUtils {
|
|
|
return getFieldValue(Set.class, gs, GOALS);
|
|
|
}
|
|
|
|
|
|
- private final static Method SET_FIRE_INFO = getMethod(FireBlock.class, "func_180686_a");
|
|
|
+ private final static Method SET_FIRE_INFO = getMethod(FireBlock.class, "func_180686_a", Block.class, int.class, int.class);
|
|
|
|
|
|
public static void setFireInfo(Block b, int encouragement, int flammability) {
|
|
|
FireBlock fireblock = (FireBlock) Blocks.FIRE;
|
|
@@ -228,10 +220,4 @@ public class ReflectionUtils {
|
|
|
LogManager.getLogger().warn("setFireInfo - " + ex);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private final static Field PLAYER_DATA = getField(MinecraftServer.class, "field_240766_e_");
|
|
|
-
|
|
|
- public static PlayerData getPlayerDataManager(MinecraftServer ms) {
|
|
|
- return getFieldValue(PlayerData.class, ms, PLAYER_DATA);
|
|
|
- }
|
|
|
}
|