Merge branch 'minecraft-lod-mod-main'
This commit is contained in:
@@ -30,15 +30,21 @@ import com.seibel.distanthorizons.core.config.ConfigBase;
|
||||
* This is the common main class
|
||||
* @author Ran
|
||||
*/
|
||||
public class LodCommonMain {
|
||||
public class LodCommonMain
|
||||
{
|
||||
public static boolean forge = false;
|
||||
public static LodForgeMethodCaller forgeMethodCaller;
|
||||
public static void startup(LodForgeMethodCaller caller) {
|
||||
if (caller != null) {
|
||||
|
||||
|
||||
|
||||
public static void startup(LodForgeMethodCaller forgeMethodCaller)
|
||||
{
|
||||
if (forgeMethodCaller != null)
|
||||
{
|
||||
LodCommonMain.forge = true;
|
||||
forgeMethodCaller = caller;
|
||||
LodCommonMain.forgeMethodCaller = forgeMethodCaller;
|
||||
}
|
||||
|
||||
|
||||
DependencySetup.createSharedBindings();
|
||||
SharedApi.init();
|
||||
// if (!serverSided) {
|
||||
@@ -53,4 +59,5 @@ public class LodCommonMain {
|
||||
ConfigBase.INSTANCE = new ConfigBase(ModInfo.ID, ModInfo.NAME, Config.class,1);
|
||||
Config.completeDelayedSetup();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.common.networking;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
/**
|
||||
* This is packet handler for our mod
|
||||
* It basically handles the packets sent from the server & client
|
||||
*
|
||||
* @author Ran
|
||||
*/
|
||||
|
||||
// TODO: Server sided stuff here
|
||||
public class NetworkHandler {
|
||||
public static void receivePacketClient(Minecraft client, FriendlyByteBuf buf, Player player) {
|
||||
// This just exists here for testing purposes, it'll be removed in the future
|
||||
System.out.println("Received int " + buf.readInt());
|
||||
}
|
||||
|
||||
public static void receivePacketServer(FriendlyByteBuf buf, Player player) {
|
||||
|
||||
}
|
||||
}
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.common.networking;
|
||||
|
||||
/*
|
||||
#if MC_1_16_5
|
||||
import me.shedaniel.architectury.networking.NetworkManager;
|
||||
#else
|
||||
import dev.architectury.networking.NetworkManager;
|
||||
#endif
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Ran
|
||||
*/
|
||||
// Comment: What does the 'server' side mean? Dedicated server? Or does it include the internal server?
|
||||
// (I removed the hookup that calls the register method, since I'm not sure what it is doing yet)
|
||||
public class NetworkReceiver {
|
||||
/*
|
||||
public void register_Client() {
|
||||
NetworkManager.registerReceiver(NetworkManager.serverToClient(), Networking.RESOURCE_LOCATION, new ClientReceiver());
|
||||
}
|
||||
|
||||
public void register_Server() {
|
||||
NetworkManager.registerReceiver(NetworkManager.clientToServer(), Networking.RESOURCE_LOCATION, new ServerReceiver());
|
||||
}
|
||||
|
||||
static class ServerReceiver implements NetworkManager.NetworkReceiver {
|
||||
@Override
|
||||
public void receive(FriendlyByteBuf buf, NetworkManager.PacketContext context) {
|
||||
com.seibel.distanthorizons.common.networking.NetworkHandler.receivePacketServer(buf, context.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
static class ClientReceiver implements NetworkManager.NetworkReceiver {
|
||||
@Override
|
||||
public void receive(FriendlyByteBuf buf, NetworkManager.PacketContext context) {
|
||||
com.seibel.distanthorizons.common.networking.NetworkHandler.receivePacketClient(Minecraft.getInstance(), buf, context.getPlayer());
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.common.networking;
|
||||
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
//#if MC_1_16_5
|
||||
//import me.shedaniel.architectury.networking.NetworkManager;
|
||||
//#else
|
||||
//import dev.architectury.networking.NetworkManager;
|
||||
//#endif
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
/**
|
||||
* This class holds most of the networking code for the mod.
|
||||
* @author Ran
|
||||
*/
|
||||
public class Networking {
|
||||
public static final ResourceLocation RESOURCE_LOCATION = new ResourceLocation("lod", "data");
|
||||
|
||||
public static FriendlyByteBuf createNew() {
|
||||
// TODO: Probably replace the Unpooled.buffer()
|
||||
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
buf.writeInt(ModInfo.PROTOCOL_VERSION);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a packet to a player.
|
||||
*
|
||||
* @param player the player to send the packet to
|
||||
* @param buf the payload of the packet.
|
||||
*/
|
||||
public static void send(ServerPlayer player, FriendlyByteBuf buf) {
|
||||
// NetworkManager.sendToPlayer(player, RESOURCE_LOCATION, buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a packet to the connected server.
|
||||
*
|
||||
* @param buf the payload of the packet
|
||||
* @throws IllegalStateException if the client is not connected to a server
|
||||
*/
|
||||
public static void send(FriendlyByteBuf buf) throws IllegalStateException {
|
||||
// NetworkManager.sendToServer(RESOURCE_LOCATION, buf);
|
||||
}
|
||||
|
||||
}
|
||||
+8
-3
@@ -45,7 +45,9 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftSha
|
||||
* @author Ran
|
||||
* @version 12-1-2021
|
||||
*/
|
||||
public class DependencySetup {
|
||||
public class DependencySetup
|
||||
{
|
||||
|
||||
public static void createSharedBindings()
|
||||
{
|
||||
SingletonInjector.INSTANCE.bind(ILangWrapper.class, LangWrapper.INSTANCE);
|
||||
@@ -56,15 +58,18 @@ public class DependencySetup {
|
||||
}
|
||||
|
||||
//@Environment(EnvType.SERVER)
|
||||
public static void createServerBindings() {
|
||||
public static void createServerBindings()
|
||||
{
|
||||
SingletonInjector.INSTANCE.bind(IMinecraftSharedWrapper.class, MinecraftDedicatedServerWrapper.INSTANCE);
|
||||
}
|
||||
|
||||
//@Environment(EnvType.CLIENT)
|
||||
public static void createClientBindings() {
|
||||
public static void createClientBindings()
|
||||
{
|
||||
SingletonInjector.INSTANCE.bind(IMinecraftClientWrapper.class, MinecraftClientWrapper.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IMinecraftSharedWrapper.class, MinecraftClientWrapper.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IMinecraftRenderWrapper.class, MinecraftRenderWrapper.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IReflectionHandler.class, ReflectionHandler.INSTANCE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
@@ -23,7 +23,9 @@ import java.util.function.Supplier;
|
||||
|
||||
public class DependencySetupDoneCheck
|
||||
{
|
||||
// TODO move to DependencySetup
|
||||
public static boolean isDone = false;
|
||||
// TODO why is this here and what is its purpose?
|
||||
public static Supplier<Boolean> getIsCurrentThreadDistantGeneratorThread = (() -> {return false;});
|
||||
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class WrapperFactory implements IWrapperFactory
|
||||
// Intentional compiler error to bring attention to the missing wrapper function.
|
||||
// If you need to work on an unimplemented version but don't have the ability to implement this yet
|
||||
// you can comment it out, but please don't commit it. Someone will have to implement it .
|
||||
|
||||
|
||||
// After implementing the new version please read this method's javadocs for instructions
|
||||
// on what other locations also need to be updated, the DhAPI specifically needs to
|
||||
// be updated to state which objects this method accepts.
|
||||
|
||||
+6
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.common.wrappers.minecraft;
|
||||
import java.io.File;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||
@@ -148,6 +149,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
return mc.player != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getPlayerUUID() {
|
||||
return getPlayer().getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DhBlockPos getPlayerBlockPos()
|
||||
{
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.misc;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class ServerPlayerWrapper implements IServerPlayerWrapper {
|
||||
private static final ConcurrentMap<ServerPlayer, ServerPlayerWrapper>
|
||||
serverPlayerWrapperMap = new MapMaker().weakKeys().makeMap();
|
||||
|
||||
private final ServerPlayer serverPlayer;
|
||||
|
||||
public static ServerPlayerWrapper getWrapper(ServerPlayer serverPlayer)
|
||||
{
|
||||
return serverPlayerWrapperMap.computeIfAbsent(serverPlayer, ServerPlayerWrapper::new);
|
||||
}
|
||||
|
||||
private ServerPlayerWrapper(ServerPlayer serverPlayer) {
|
||||
this.serverPlayer = serverPlayer;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return serverPlayer.getUUID();
|
||||
}
|
||||
|
||||
public IServerLevelWrapper getLevel() {
|
||||
return ServerLevelWrapper.getWrapper(serverPlayer.getLevel());
|
||||
}
|
||||
|
||||
public Object getWrappedMcObject() {
|
||||
return serverPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Wrapped{" + serverPlayer.toString() + "}";
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -31,7 +31,7 @@ import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
#if POST_MC_1_18_2
|
||||
#if POST_MC_1_18_2
|
||||
#endif
|
||||
|
||||
public final class StepFeatures {
|
||||
|
||||
Reference in New Issue
Block a user