|
@@ -14,24 +14,35 @@ import net.minecraft.server.dedicated.DedicatedPlayerList;
|
|
|
import net.minecraft.server.dedicated.DedicatedServer;
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
+import net.minecraft.util.registry.DynamicRegistries;
|
|
|
import net.minecraft.world.World;
|
|
|
import net.minecraft.world.server.ServerWorld;
|
|
|
+import net.minecraft.world.storage.PlayerData;
|
|
|
|
|
|
public class Hooks {
|
|
|
- private static Consumer<DedicatedServer> playerListFunction = null;
|
|
|
+ @FunctionalInterface
|
|
|
+ public interface PlayerListFunction {
|
|
|
+ public void accept(DedicatedServer server, DynamicRegistries.Impl impl, PlayerData pd);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static PlayerListFunction playerListFunction = null;
|
|
|
private static BlockHarvest blockHarvest = (state, w, pos, tileEnt, ent, stack) -> Collections.EMPTY_LIST;
|
|
|
- private static Craft craft = (id, w, p, cInv, slot) -> {};
|
|
|
+ private static Craft craft = (id, w, p, cInv, slot) -> {
|
|
|
+ };
|
|
|
|
|
|
- public static void setPlayerListFunction(Consumer<DedicatedServer> c) {
|
|
|
+ public static void setPlayerListFunction(PlayerListFunction c) {
|
|
|
playerListFunction = c;
|
|
|
}
|
|
|
|
|
|
- public static void setPlayerList(DedicatedServer server) {
|
|
|
+ public static void setPlayerList(DedicatedServer server, DynamicRegistries.Impl impl, PlayerData pd) {
|
|
|
+ System.out.println("trying to update player list ...");
|
|
|
if(playerListFunction != null) {
|
|
|
- playerListFunction.accept(server);
|
|
|
+ playerListFunction.accept(server, impl, pd);
|
|
|
+ System.out.println("succeeded with custom function");
|
|
|
} else {
|
|
|
try {
|
|
|
- server.setPlayerList(new DedicatedPlayerList(server));
|
|
|
+ server.setPlayerList(new DedicatedPlayerList(server, impl, pd));
|
|
|
+ System.out.println("succeeded with vanilla function");
|
|
|
} catch(Exception ex) {
|
|
|
// this is stupid and should not be needed
|
|
|
ex.printStackTrace();
|
|
@@ -42,7 +53,7 @@ public class Hooks {
|
|
|
public static void setBlockHarvest(BlockHarvest c) {
|
|
|
blockHarvest = c;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static void setCraft(Craft c) {
|
|
|
craft = c;
|
|
|
}
|
|
@@ -54,7 +65,7 @@ public class Hooks {
|
|
|
public static List<ItemStack> getDropsB(BlockState state, ServerWorld w, BlockPos pos, @Nullable TileEntity tileEnt, @Nullable Entity ent, ItemStack stack) {
|
|
|
return blockHarvest.onBlockHarvest(state, w, pos, tileEnt, ent, stack);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static void onCraft(int id, World w, PlayerEntity p, CraftingInventory cInv, CraftResultInventory slot) {
|
|
|
craft.onCraft(id, w, p, cInv, slot);
|
|
|
}
|