Start porting to previous versions
This commit is contained in:
+1
-1
@@ -30,7 +30,7 @@ build:
|
||||
stage: build
|
||||
parallel:
|
||||
matrix:
|
||||
- MC_VER: ["1.20.1", "1.20.2", "1.20.4"]
|
||||
- MC_VER: ["1.17.1", "1.18.2", "1.19.2", "1.19.4", "1.20.1", "1.20.2", "1.20.4"]
|
||||
# - MC_VER: ["1.16.5", "1.17.1", "1.18.2", "1.19.2", "1.19.4", "1.20.1", "1.20.2", "1.20.4"]
|
||||
script:
|
||||
# this both runs the unit tests and assembles the code
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapp
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Vec3d;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
@@ -42,7 +43,7 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper
|
||||
}
|
||||
|
||||
public Vec3d getPosition() {
|
||||
var position = serverPlayer.position();
|
||||
Vec3 position = serverPlayer.position();
|
||||
return new Vec3d(position.x, position.y, position.z);
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -64,8 +64,11 @@ dependencies {
|
||||
addModJar(fabricApi.module("fabric-rendering-v1", rootProject.fabric_api_version)) // TODO: Remove this as it is only needed in 1 line (FabricClientProxy)
|
||||
addModJar(fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-entity-events-v1", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-command-api-v2", rootProject.fabric_api_version))
|
||||
|
||||
if (minecraft_version >= "1.19.2")
|
||||
addModJar(fabricApi.module("fabric-command-api-v2", rootProject.fabric_api_version))
|
||||
else // < 1.19.2
|
||||
addModJar(fabricApi.module("fabric-command-api-v1", rootProject.fabric_api_version))
|
||||
|
||||
// Mod Menu
|
||||
modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}")
|
||||
|
||||
|
||||
@@ -19,12 +19,13 @@
|
||||
|
||||
package com.seibel.distanthorizons.fabric;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.seibel.distanthorizons.common.rendering.SeamlessOverdraw;
|
||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||
@@ -47,6 +48,10 @@ import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
@@ -56,8 +61,7 @@ import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.HashSet;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
/**
|
||||
* This handles all events sent to the client,
|
||||
|
||||
+28
-5
@@ -20,11 +20,16 @@ import com.seibel.distanthorizons.core.util.objects.Pair;
|
||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
#if MC_VER > MC_1_19_2
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
#else // < 1.19.2
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
#endif
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -65,7 +70,12 @@ public class FabricDedicatedServerMain implements DedicatedServerModInitializer
|
||||
server_proxy = new FabricServerProxy(true);
|
||||
server_proxy.registerEvents();
|
||||
|
||||
|
||||
#if MC_VER > MC_1_19_2
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||
#else // < 1.19.2
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
|
||||
#endif
|
||||
this.commandDispatcher = dispatcher;
|
||||
});
|
||||
|
||||
@@ -97,28 +107,41 @@ public class FabricDedicatedServerMain implements DedicatedServerModInitializer
|
||||
|
||||
for (AbstractConfigType<?, ?> type : ConfigBase.INSTANCE.entries)
|
||||
{
|
||||
if (!(type instanceof ConfigEntry configEntry)) continue;
|
||||
if (!(type instanceof ConfigEntry)) continue;
|
||||
ConfigEntry configEntry = (ConfigEntry) type;
|
||||
if (configEntry.getServersideShortName() == null) continue;
|
||||
|
||||
Function<
|
||||
Function<CommandContext<CommandSourceStack>, Object>,
|
||||
Command<CommandSourceStack>
|
||||
> makeConfigUpdater = getter -> c -> {
|
||||
var value = getter.apply(c);
|
||||
Object value = getter.apply(c);
|
||||
#if MC_VER >= MC_1_20_1
|
||||
c.getSource().sendSuccess(() -> Component.literal("Changed the value of "+configEntry.getServersideShortName()+" to "+value), true);
|
||||
#elif MC_VER >= MC_1_19_2
|
||||
c.getSource().sendSuccess(Component.literal("Changed the value of "+configEntry.getServersideShortName()+" to "+value), true);
|
||||
#else // < 1.19.2
|
||||
c.getSource().sendSuccess(new TranslatableComponent("Changed the value of "+configEntry.getServersideShortName()+" to "+value), true);
|
||||
#endif
|
||||
configEntry.set(value);
|
||||
return 1;
|
||||
};
|
||||
|
||||
var subcommand = literal(configEntry.getServersideShortName())
|
||||
LiteralArgumentBuilder<CommandSourceStack> subcommand = literal(configEntry.getServersideShortName())
|
||||
.executes(c -> {
|
||||
#if MC_VER >= MC_1_20_1
|
||||
c.getSource().sendSuccess(() -> Component.literal("Current value of "+configEntry.getServersideShortName()+" is "+configEntry.get()), true);
|
||||
#elif MC_VER >= MC_1_19_2
|
||||
c.getSource().sendSuccess(Component.literal("Current value of "+configEntry.getServersideShortName()+" is "+configEntry.get()), true);
|
||||
#else // < 1.19.2
|
||||
c.getSource().sendSuccess(new TranslatableComponent("Current value of "+configEntry.getServersideShortName()+" is "+configEntry.get()), true);
|
||||
#endif
|
||||
return 1;
|
||||
});
|
||||
|
||||
if (Enum.class.isAssignableFrom(configEntry.getType()))
|
||||
{
|
||||
for (var choice : configEntry.getType().getEnumConstants())
|
||||
for (Object choice : configEntry.getType().getEnumConstants())
|
||||
{
|
||||
subcommand.then(
|
||||
literal(choice.toString())
|
||||
@@ -130,7 +153,7 @@ public class FabricDedicatedServerMain implements DedicatedServerModInitializer
|
||||
{
|
||||
boolean setterAdded = false;
|
||||
|
||||
for (var pair : new HashMap<
|
||||
for (java.util.Map.Entry<Class<?>, Pair<Supplier<ArgumentType<?>>, BiFunction<CommandContext<?>, String, ?>>> pair : new HashMap<
|
||||
Class<?>,
|
||||
Pair<
|
||||
Supplier<ArgumentType<?>>,
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.seibel.distanthorizons.core.api.internal.ServerApi;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
@@ -19,17 +18,12 @@ import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
||||
import static net.minecraft.commands.Commands.*;
|
||||
|
||||
/**
|
||||
* This handles all events sent to the server,
|
||||
* and is the starting point for most of the mod.
|
||||
|
||||
Reference in New Issue
Block a user