Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 44cf6f6955 | |||
| 00b69dcc68 | |||
| cd74e33c54 | |||
| 3f14e5dfa5 | |||
| 8c9e6ea79a | |||
| c71de31f57 | |||
| ac869bf06e | |||
| 3175bc0439 | |||
| 23ac6ec957 | |||
| f080a59b41 | |||
| 603200ed8b | |||
| b0774052a0 | |||
| 7e163ce626 | |||
| d19654cf15 | |||
| 838d8be08b | |||
| 2de82b1223 | |||
| 650012fb08 | |||
| a1ef3466ad | |||
| 97421feb33 | |||
| 0c90af6515 | |||
| 9cebd0298c | |||
| 9afcddca4f | |||
| 02fb7eedba | |||
| 4aa9bec15c | |||
| a6eeaa5b3e | |||
| c462325ce6 |
+2
-2
@@ -538,7 +538,7 @@ ij_groovy_wrap_chain_calls_after_dot = false
|
|||||||
ij_groovy_wrap_long_lines = false
|
ij_groovy_wrap_long_lines = false
|
||||||
|
|
||||||
[{*.har,*.json,*.png.mcmeta,mcmod.info,pack.mcmeta}]
|
[{*.har,*.json,*.png.mcmeta,mcmod.info,pack.mcmeta}]
|
||||||
indent_size = 2
|
indent_size = 4
|
||||||
ij_json_array_wrapping = split_into_lines
|
ij_json_array_wrapping = split_into_lines
|
||||||
ij_json_keep_blank_lines_in_code = 0
|
ij_json_keep_blank_lines_in_code = 0
|
||||||
ij_json_keep_indents_on_empty_lines = false
|
ij_json_keep_indents_on_empty_lines = false
|
||||||
@@ -688,7 +688,7 @@ ij_markdown_wrap_text_inside_blockquotes = true
|
|||||||
ij_toml_keep_indents_on_empty_lines = false
|
ij_toml_keep_indents_on_empty_lines = false
|
||||||
|
|
||||||
[{*.yaml,*.yml}]
|
[{*.yaml,*.yml}]
|
||||||
indent_size = 2
|
indent_size = 4
|
||||||
ij_yaml_align_values_properties = do_not_align
|
ij_yaml_align_values_properties = do_not_align
|
||||||
ij_yaml_autoinsert_sequence_marker = true
|
ij_yaml_autoinsert_sequence_marker = true
|
||||||
ij_yaml_block_mapping_on_new_line = false
|
ij_yaml_block_mapping_on_new_line = false
|
||||||
|
|||||||
+3
-3
@@ -18,7 +18,7 @@ variables:
|
|||||||
.build_java:
|
.build_java:
|
||||||
#image: eclipse-temurin:17
|
#image: eclipse-temurin:17
|
||||||
cache:
|
cache:
|
||||||
key: "gradleCache_$CI_JOB_NAME_SLUG"
|
key: "gradleCache"
|
||||||
policy: pull-push
|
policy: pull-push
|
||||||
paths:
|
paths:
|
||||||
- .gradle
|
- .gradle
|
||||||
@@ -68,7 +68,7 @@ build:
|
|||||||
extends: .build_java
|
extends: .build_java
|
||||||
|
|
||||||
|
|
||||||
.api:
|
api:
|
||||||
stage: api
|
stage: api
|
||||||
needs: []
|
needs: []
|
||||||
script:
|
script:
|
||||||
@@ -92,7 +92,7 @@ build:
|
|||||||
|
|
||||||
|
|
||||||
# generate and publish API javadocs
|
# generate and publish API javadocs
|
||||||
.pages:
|
pages:
|
||||||
stage: pages
|
stage: pages
|
||||||
needs: []
|
needs: []
|
||||||
script:
|
script:
|
||||||
|
|||||||
+1
-1
@@ -329,7 +329,7 @@ subprojects { p ->
|
|||||||
"META-INF/neoforge.mods.toml",
|
"META-INF/neoforge.mods.toml",
|
||||||
|
|
||||||
// The mixins for each of the loaders
|
// The mixins for each of the loaders
|
||||||
"DistantHorizons." + p.name + ".fabricLike.mixins.json"
|
"DistantHorizons."+ p.name +".fabricLike.mixins.json"
|
||||||
]
|
]
|
||||||
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
echo ==================== Note: All build jars will be in the folder called 'buildAllJars' ====================
|
echo ==================== Note: All build jars will be in the folder called 'buildAllJars' ====================
|
||||||
mkdir buildAllJars
|
mkdir buildAllJars
|
||||||
|
del buildAllJars/*
|
||||||
|
|
||||||
@rem Loop trough everything in the version properties folder
|
@rem Loop trough everything in the version properties folder
|
||||||
for %%f in (versionProperties\*) do (
|
for %%f in (versionProperties\*) do (
|
||||||
@@ -13,11 +14,11 @@ for %%f in (versionProperties\*) do (
|
|||||||
|
|
||||||
@rem Clean out the folders, build it, and merge it
|
@rem Clean out the folders, build it, and merge it
|
||||||
echo ==================== Cleaning workspace to build !version! ====================
|
echo ==================== Cleaning workspace to build !version! ====================
|
||||||
call .\gradlew.bat clean -PmcVer="!version!" --no-daemon
|
call .\gradlew.bat clean -PmcVer="!version!"
|
||||||
echo ==================== Building !version! ====================
|
echo ==================== Building !version! ====================
|
||||||
call .\gradlew.bat build -PmcVer="!version!" --no-daemon
|
call .\gradlew.bat build -PmcVer="!version!"
|
||||||
echo ==================== Merging !version! ====================
|
echo ==================== Merging !version! ====================
|
||||||
call .\gradlew.bat mergeJars -PmcVer="!version!" --no-daemon
|
call .\gradlew.bat mergeJars -PmcVer="!version!"
|
||||||
echo ==================== Moving jar ====================
|
echo ==================== Moving jar ====================
|
||||||
move Merged\*.jar buildAllJars\
|
move Merged\*.jar buildAllJars\
|
||||||
)
|
)
|
||||||
|
|||||||
+9
-7
@@ -1,10 +1,11 @@
|
|||||||
buildscript {
|
// TODO can this be removed?
|
||||||
configurations.configureEach {
|
//buildscript {
|
||||||
resolutionStrategy {
|
// configurations.configureEach {
|
||||||
force 'org.spongepowered:vanillagradle:0.2.1-20240507.024226-82'
|
// resolutionStrategy {
|
||||||
}
|
// force 'org.spongepowered:vanillagradle:0.2.1-20240507.024226-82'
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
// temporary fix for broken spongepowered version
|
// temporary fix for broken spongepowered version
|
||||||
buildscript {
|
buildscript {
|
||||||
@@ -43,3 +44,4 @@ publishing {
|
|||||||
// Add repositories to publish to here.
|
// Add repositories to publish to here.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
-22
@@ -8,7 +8,7 @@ import com.mojang.brigadier.context.CommandContext;
|
|||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
|
||||||
import com.seibel.distanthorizons.common.wrappers.DependencySetup;
|
import com.seibel.distanthorizons.common.wrappers.DependencySetup;
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftDedicatedServerWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftServerWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
||||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
@@ -20,11 +20,9 @@ import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
|||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.jar.ModJarInfo;
|
import com.seibel.distanthorizons.core.jar.ModJarInfo;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.network.messages.MessageRegistry;
|
|
||||||
import com.seibel.distanthorizons.core.network.messages.base.CodecCrashMessage;
|
import com.seibel.distanthorizons.core.network.messages.base.CodecCrashMessage;
|
||||||
import com.seibel.distanthorizons.core.util.objects.Pair;
|
import com.seibel.distanthorizons.core.util.objects.Pair;
|
||||||
import com.seibel.distanthorizons.core.world.DhServerWorld;
|
import com.seibel.distanthorizons.core.world.DhServerWorld;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModAccessor;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModAccessor;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||||
@@ -44,7 +42,7 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
import static com.mojang.brigadier.arguments.DoubleArgumentType.doubleArg;
|
import static com.mojang.brigadier.arguments.DoubleArgumentType.doubleArg;
|
||||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
||||||
import static com.seibel.distanthorizons.core.network.messages.MessageRegistry.DEBUG_ENABLE_CODEC_CRASH_MESSAGE;
|
import static com.seibel.distanthorizons.core.network.messages.MessageRegistry.DEBUG_CODEC_CRASH_MESSAGE;
|
||||||
import static net.minecraft.commands.Commands.argument;
|
import static net.minecraft.commands.Commands.argument;
|
||||||
import static net.minecraft.commands.Commands.literal;
|
import static net.minecraft.commands.Commands.literal;
|
||||||
|
|
||||||
@@ -95,7 +93,7 @@ public abstract class AbstractModInitializer
|
|||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null);
|
||||||
|
|
||||||
this.startup();
|
this.startup();
|
||||||
this.printModInfo();
|
this.logBuildInfo();
|
||||||
|
|
||||||
this.createClientProxy().registerEvents();
|
this.createClientProxy().registerEvents();
|
||||||
this.createServerProxy(false).registerEvents();
|
this.createServerProxy(false).registerEvents();
|
||||||
@@ -119,7 +117,7 @@ public abstract class AbstractModInitializer
|
|||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null);
|
||||||
|
|
||||||
this.startup();
|
this.startup();
|
||||||
this.printModInfo();
|
this.logBuildInfo();
|
||||||
|
|
||||||
// This prevents returning uninitialized Config values,
|
// This prevents returning uninitialized Config values,
|
||||||
// resulting from a circular reference mid-initialization in a static class
|
// resulting from a circular reference mid-initialization in a static class
|
||||||
@@ -137,7 +135,7 @@ public abstract class AbstractModInitializer
|
|||||||
|
|
||||||
this.subscribeServerStartingEvent(server ->
|
this.subscribeServerStartingEvent(server ->
|
||||||
{
|
{
|
||||||
MinecraftDedicatedServerWrapper.INSTANCE.dedicatedServer = (DedicatedServer)server;
|
MinecraftServerWrapper.INSTANCE.dedicatedServer = (DedicatedServer)server;
|
||||||
|
|
||||||
this.initConfig();
|
this.initConfig();
|
||||||
this.postInit();
|
this.postInit();
|
||||||
@@ -160,14 +158,17 @@ public abstract class AbstractModInitializer
|
|||||||
this.createInitialBindings();
|
this.createInitialBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printModInfo()
|
private void logBuildInfo()
|
||||||
{
|
{
|
||||||
LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
|
LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
|
||||||
|
|
||||||
// Useful for dev builds
|
// if the build is stable the branch/commit/etc shouldn't be needed
|
||||||
LOGGER.info("DH Branch: " + ModJarInfo.Git_Branch);
|
if (ModInfo.IS_DEV_BUILD)
|
||||||
LOGGER.info("DH Commit: " + ModJarInfo.Git_Commit);
|
{
|
||||||
LOGGER.info("DH Jar Build Source: " + ModJarInfo.Build_Source);
|
LOGGER.info("DH Branch: " + ModJarInfo.Git_Branch);
|
||||||
|
LOGGER.info("DH Commit: " + ModJarInfo.Git_Commit);
|
||||||
|
LOGGER.info("DH Jar Build Source: " + ModJarInfo.Build_Source);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T extends IModAccessor> void tryCreateModCompatAccessor(String modId, Class<? super T> accessorClass, Supplier<T> accessorConstructor)
|
protected <T extends IModAccessor> void tryCreateModCompatAccessor(String modId, Class<? super T> accessorClass, Supplier<T> accessorConstructor)
|
||||||
@@ -215,10 +216,10 @@ public abstract class AbstractModInitializer
|
|||||||
Function<
|
Function<
|
||||||
Function<CommandContext<CommandSourceStack>, Object>,
|
Function<CommandContext<CommandSourceStack>, Object>,
|
||||||
Command<CommandSourceStack>
|
Command<CommandSourceStack>
|
||||||
> makeConfigUpdater = getter -> c -> {
|
> makeConfigUpdater = (getter) -> (commandContext) -> {
|
||||||
Object value = getter.apply(c);
|
Object value = getter.apply(commandContext);
|
||||||
|
|
||||||
c.getSource().sendSuccess(
|
commandContext.getSource().sendSuccess(
|
||||||
#if MC_VER >= MC_1_20_1
|
#if MC_VER >= MC_1_20_1
|
||||||
() -> Component.literal("Changed the value of "+configEntry.getServersideShortName()+" to "+value),
|
() -> Component.literal("Changed the value of "+configEntry.getServersideShortName()+" to "+value),
|
||||||
#elif MC_VER >= MC_1_19_2
|
#elif MC_VER >= MC_1_19_2
|
||||||
@@ -232,13 +233,13 @@ public abstract class AbstractModInitializer
|
|||||||
};
|
};
|
||||||
|
|
||||||
LiteralArgumentBuilder<CommandSourceStack> subcommand = literal(configEntry.getServersideShortName())
|
LiteralArgumentBuilder<CommandSourceStack> subcommand = literal(configEntry.getServersideShortName())
|
||||||
.executes(c -> {
|
.executes((commandContext) -> {
|
||||||
#if MC_VER >= MC_1_20_1
|
#if MC_VER >= MC_1_20_1
|
||||||
c.getSource().sendSuccess(() -> Component.literal("Current value of "+configEntry.getServersideShortName()+" is "+configEntry.get()), true);
|
commandContext.getSource().sendSuccess(() -> Component.literal("Current value of "+configEntry.getServersideShortName()+" is "+configEntry.get()), true);
|
||||||
#elif MC_VER >= MC_1_19_2
|
#elif MC_VER >= MC_1_19_2
|
||||||
c.getSource().sendSuccess(Component.literal("Current value of "+configEntry.getServersideShortName()+" is "+configEntry.get()), true);
|
commandContext.getSource().sendSuccess(Component.literal("Current value of "+configEntry.getServersideShortName()+" is "+configEntry.get()), true);
|
||||||
#else // < 1.19.2
|
#else // < 1.19.2
|
||||||
c.getSource().sendSuccess(new TranslatableComponent("Current value of "+configEntry.getServersideShortName()+" is "+configEntry.get()), true);
|
commandContext.getSource().sendSuccess(new TranslatableComponent("Current value of "+configEntry.getServersideShortName()+" is "+configEntry.get()), true);
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
@@ -292,7 +293,7 @@ public abstract class AbstractModInitializer
|
|||||||
|
|
||||||
this.commandDispatcher.register(builder);
|
this.commandDispatcher.register(builder);
|
||||||
|
|
||||||
if (DEBUG_ENABLE_CODEC_CRASH_MESSAGE)
|
if (DEBUG_CODEC_CRASH_MESSAGE)
|
||||||
{
|
{
|
||||||
LiteralArgumentBuilder<CommandSourceStack> dhcrash = literal("dhcrash")
|
LiteralArgumentBuilder<CommandSourceStack> dhcrash = literal("dhcrash")
|
||||||
.requires(source -> source.hasPermission(4))
|
.requires(source -> source.hasPermission(4))
|
||||||
@@ -305,7 +306,7 @@ public abstract class AbstractModInitializer
|
|||||||
#else
|
#else
|
||||||
.getConnectedPlayer(ServerPlayerWrapper.getWrapper(Objects.requireNonNull(c.getSource().getPlayerOrException())))
|
.getConnectedPlayer(ServerPlayerWrapper.getWrapper(Objects.requireNonNull(c.getSource().getPlayerOrException())))
|
||||||
#endif
|
#endif
|
||||||
.session.sendMessage(new CodecCrashMessage(CodecCrashMessage.ECrashPhase.ENCODE));
|
.networkSession.sendMessage(new CodecCrashMessage(CodecCrashMessage.ECrashPhase.ENCODE));
|
||||||
return 1;
|
return 1;
|
||||||
}))
|
}))
|
||||||
.then(literal("decode")
|
.then(literal("decode")
|
||||||
@@ -317,7 +318,7 @@ public abstract class AbstractModInitializer
|
|||||||
#else
|
#else
|
||||||
.getConnectedPlayer(ServerPlayerWrapper.getWrapper(Objects.requireNonNull(c.getSource().getPlayerOrException())))
|
.getConnectedPlayer(ServerPlayerWrapper.getWrapper(Objects.requireNonNull(c.getSource().getPlayerOrException())))
|
||||||
#endif
|
#endif
|
||||||
.session.sendMessage(new CodecCrashMessage(CodecCrashMessage.ECrashPhase.DECODE));
|
.networkSession.sendMessage(new CodecCrashMessage(CodecCrashMessage.ECrashPhase.DECODE));
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
this.commandDispatcher.register(dhcrash);
|
this.commandDispatcher.register(dhcrash);
|
||||||
|
|||||||
+16
-17
@@ -2,10 +2,10 @@ package com.seibel.distanthorizons.common;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.logging.ConfigBasedLogger;
|
import com.seibel.distanthorizons.core.logging.ConfigBasedLogger;
|
||||||
import com.seibel.distanthorizons.core.network.event.internal.IncompatibleMessageEvent;
|
import com.seibel.distanthorizons.core.network.event.internal.IncompatibleMessageInternalEvent;
|
||||||
import com.seibel.distanthorizons.core.network.event.internal.ProtocolErrorEvent;
|
import com.seibel.distanthorizons.core.network.event.internal.ProtocolErrorInternalEvent;
|
||||||
import com.seibel.distanthorizons.core.network.messages.MessageRegistry;
|
import com.seibel.distanthorizons.core.network.messages.MessageRegistry;
|
||||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage;
|
||||||
import com.seibel.distanthorizons.core.network.messages.base.CloseReasonMessage;
|
import com.seibel.distanthorizons.core.network.messages.base.CloseReasonMessage;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||||
@@ -33,19 +33,18 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void sendPluginPacketServer(IServerPlayerWrapper serverPlayer, NetworkMessage message)
|
public final void sendToClient(IServerPlayerWrapper serverPlayer, AbstractNetworkMessage message)
|
||||||
{
|
{
|
||||||
this.sendPluginPacketServer((ServerPlayer) serverPlayer.getWrappedMcObject(), message);
|
this.sendToClient((ServerPlayer) serverPlayer.getWrappedMcObject(), message);
|
||||||
}
|
}
|
||||||
|
public abstract void sendToClient(ServerPlayer serverPlayer, AbstractNetworkMessage message);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract void sendPluginPacketClient(NetworkMessage message);
|
public abstract void sendToServer(AbstractNetworkMessage message);
|
||||||
public abstract void sendPluginPacketServer(ServerPlayer serverPlayer, NetworkMessage message);
|
|
||||||
|
|
||||||
@Nullable
|
public static AbstractNetworkMessage decodeMessage(FriendlyByteBuf in)
|
||||||
public static NetworkMessage decodeMessage(FriendlyByteBuf in)
|
|
||||||
{
|
{
|
||||||
NetworkMessage message = null;
|
AbstractNetworkMessage message = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -54,7 +53,7 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender
|
|||||||
int protocolVersion = in.readShort();
|
int protocolVersion = in.readShort();
|
||||||
if (protocolVersion != ModInfo.PROTOCOL_VERSION)
|
if (protocolVersion != ModInfo.PROTOCOL_VERSION)
|
||||||
{
|
{
|
||||||
return new IncompatibleMessageEvent(protocolVersion);
|
return new IncompatibleMessageInternalEvent(protocolVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
message = MessageRegistry.INSTANCE.createMessage(in.readUnsignedShort());
|
message = MessageRegistry.INSTANCE.createMessage(in.readUnsignedShort());
|
||||||
@@ -72,10 +71,10 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender
|
|||||||
in.resetReaderIndex();
|
in.resetReaderIndex();
|
||||||
|
|
||||||
LOGGER.error("Failed to decode message", e);
|
LOGGER.error("Failed to decode message", e);
|
||||||
LOGGER.error("Buffer: {}", in);
|
LOGGER.error("Buffer: ["+in+"]");
|
||||||
LOGGER.error("Buffer contents: [{}]", ByteBufUtil.hexDump(in));
|
LOGGER.error("Buffer contents: ["+ByteBufUtil.hexDump(in)+"]");
|
||||||
|
|
||||||
return new ProtocolErrorEvent(e, message, true);
|
return new ProtocolErrorInternalEvent(e, message, true);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -84,7 +83,7 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void encodeMessage(FriendlyByteBuf out, NetworkMessage message)
|
public static void encodeMessage(FriendlyByteBuf out, AbstractNetworkMessage message)
|
||||||
{
|
{
|
||||||
// This is intentionally unhandled, because errors related to this are unlikely to appear in wild
|
// This is intentionally unhandled, because errors related to this are unlikely to appear in wild
|
||||||
Objects.requireNonNull(message);
|
Objects.requireNonNull(message);
|
||||||
@@ -99,9 +98,9 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LOGGER.error("Failed to encode message", e);
|
LOGGER.error("Failed to encode message", e);
|
||||||
LOGGER.error("Message: {}", message);
|
LOGGER.error("Message: ["+message+"]");
|
||||||
|
|
||||||
message.getSession().tryHandleMessage(new ProtocolErrorEvent(e, message, false));
|
message.getSession().tryHandleMessage(new ProtocolErrorInternalEvent(e, message, false));
|
||||||
|
|
||||||
// Encode close reason message instead
|
// Encode close reason message instead
|
||||||
out.resetWriterIndex();
|
out.resetWriterIndex();
|
||||||
|
|||||||
@@ -2,25 +2,20 @@ package com.seibel.distanthorizons.common;
|
|||||||
|
|
||||||
#if MC_VER >= MC_1_20_6
|
#if MC_VER >= MC_1_20_6
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public record CommonPacketPayload(
|
public record CommonPacketPayload(@Nullable AbstractNetworkMessage message) implements CustomPacketPayload
|
||||||
@Nullable NetworkMessage message
|
|
||||||
) implements CustomPacketPayload
|
|
||||||
{
|
{
|
||||||
public static final Type<CommonPacketPayload> TYPE = new Type<>(AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE);
|
public static final Type<CommonPacketPayload> TYPE = new Type<>(AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Type<? extends CustomPacketPayload> type()
|
public Type<? extends CustomPacketPayload> type() { return TYPE; }
|
||||||
{
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static class Codec implements StreamCodec<FriendlyByteBuf, CommonPacketPayload>
|
public static class Codec implements StreamCodec<FriendlyByteBuf, CommonPacketPayload>
|
||||||
@@ -28,15 +23,11 @@ public record CommonPacketPayload(
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommonPacketPayload decode(@NotNull FriendlyByteBuf in)
|
public CommonPacketPayload decode(@NotNull FriendlyByteBuf in)
|
||||||
{
|
{ return new CommonPacketPayload(AbstractPluginPacketSender.decodeMessage(in)); }
|
||||||
return new CommonPacketPayload(AbstractPluginPacketSender.decodeMessage(in));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(@NotNull FriendlyByteBuf out, CommonPacketPayload payload)
|
public void encode(@NotNull FriendlyByteBuf out, CommonPacketPayload payload)
|
||||||
{
|
{ AbstractPluginPacketSender.encodeMessage(out, payload.message()); }
|
||||||
AbstractPluginPacketSender.encodeMessage(out, payload.message());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -22,7 +22,7 @@ package com.seibel.distanthorizons.common.wrappers;
|
|||||||
import com.seibel.distanthorizons.common.wrappers.gui.ClassicConfigGUI;
|
import com.seibel.distanthorizons.common.wrappers.gui.ClassicConfigGUI;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.LangWrapper;
|
import com.seibel.distanthorizons.common.wrappers.gui.LangWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.level.KeyedClientLevelManager;
|
import com.seibel.distanthorizons.common.wrappers.level.KeyedClientLevelManager;
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftDedicatedServerWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftServerWrapper;
|
||||||
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
|
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper;
|
||||||
@@ -60,7 +60,7 @@ public class DependencySetup
|
|||||||
//@Environment(EnvType.SERVER)
|
//@Environment(EnvType.SERVER)
|
||||||
public static void createServerBindings()
|
public static void createServerBindings()
|
||||||
{
|
{
|
||||||
SingletonInjector.INSTANCE.bind(IMinecraftSharedWrapper.class, MinecraftDedicatedServerWrapper.INSTANCE);
|
SingletonInjector.INSTANCE.bind(IMinecraftSharedWrapper.class, MinecraftServerWrapper.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Environment(EnvType.CLIENT)
|
//@Environment(EnvType.CLIENT)
|
||||||
|
|||||||
+22
-1
@@ -133,6 +133,26 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can be faster than {@link BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)}
|
||||||
|
* in cases where the same block state is expected to be referenced multiple times.
|
||||||
|
*/
|
||||||
|
public static BlockStateWrapper fromBlockState(BlockState blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess)
|
||||||
|
{
|
||||||
|
BlockState guessBlockState = (guess == null || guess.isAir()) ? null : (BlockState) guess.getWrappedMcObject();
|
||||||
|
BlockState inputBlockState = (blockState == null || blockState.isAir()) ? null : blockState;
|
||||||
|
|
||||||
|
if (guess instanceof BlockStateWrapper guessWrapper
|
||||||
|
&& guessBlockState == inputBlockState)
|
||||||
|
{
|
||||||
|
return guessWrapper;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return fromBlockState(blockState, levelWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private BlockStateWrapper(BlockState blockState, ILevelWrapper levelWrapper)
|
private BlockStateWrapper(BlockState blockState, ILevelWrapper levelWrapper)
|
||||||
{
|
{
|
||||||
this.blockState = blockState;
|
this.blockState = blockState;
|
||||||
@@ -541,7 +561,8 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
{
|
{
|
||||||
|
|
||||||
#if MC_VER > MC_1_17_1
|
#if MC_VER > MC_1_17_1
|
||||||
Level level = (Level)Objects.requireNonNull(levelWrapper.getWrappedMcObject());
|
LodUtil.assertTrue(levelWrapper != null && levelWrapper.getWrappedMcObject() != null);
|
||||||
|
Level level = (Level)levelWrapper.getWrappedMcObject();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Block block;
|
Block block;
|
||||||
|
|||||||
+26
-157
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.common.wrappers.chunk;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
|
import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
|
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.misc.MutableBlockPosWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
|
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
|
||||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
@@ -31,6 +32,7 @@ import com.seibel.distanthorizons.core.world.EWorldEnvironment;
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.ChunkLightStorage;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.ChunkLightStorage;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IMutableBlockPosWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||||
@@ -87,6 +89,7 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
|
|
||||||
/** can be used for interactions with the underlying chunk where creating new BlockPos objects could cause issues for the garbage collector. */
|
/** can be used for interactions with the underlying chunk where creating new BlockPos objects could cause issues for the garbage collector. */
|
||||||
private static final ThreadLocal<BlockPos.MutableBlockPos> MUTABLE_BLOCK_POS_REF = ThreadLocal.withInitial(() -> new BlockPos.MutableBlockPos());
|
private static final ThreadLocal<BlockPos.MutableBlockPos> MUTABLE_BLOCK_POS_REF = ThreadLocal.withInitial(() -> new BlockPos.MutableBlockPos());
|
||||||
|
private static final ThreadLocal<MutableBlockPosWrapper> MUTABLE_BLOCK_POS_WRAPPER_REF = ThreadLocal.withInitial(() -> new MutableBlockPosWrapper());
|
||||||
|
|
||||||
|
|
||||||
private final ChunkAccess chunk;
|
private final ChunkAccess chunk;
|
||||||
@@ -94,7 +97,8 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
private final LevelReader lightSource;
|
private final LevelReader lightSource;
|
||||||
private final ILevelWrapper wrappedLevel;
|
private final ILevelWrapper wrappedLevel;
|
||||||
|
|
||||||
private boolean isDhLightCorrect = false;
|
private boolean isDhBlockLightCorrect = false;
|
||||||
|
private boolean isDhSkyLightCorrect = false;
|
||||||
/** only used when connected to a dedicated server */
|
/** only used when connected to a dedicated server */
|
||||||
private boolean isMcClientLightingCorrect = false;
|
private boolean isMcClientLightingCorrect = false;
|
||||||
|
|
||||||
@@ -103,26 +107,9 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
|
|
||||||
private ArrayList<DhBlockPos> blockLightPosList = null;
|
private ArrayList<DhBlockPos> blockLightPosList = null;
|
||||||
|
|
||||||
private boolean useDhLighting;
|
|
||||||
|
|
||||||
private int minNonEmptyHeight = Integer.MIN_VALUE;
|
private int minNonEmptyHeight = Integer.MIN_VALUE;
|
||||||
private int maxNonEmptyHeight = Integer.MAX_VALUE;
|
private int maxNonEmptyHeight = Integer.MAX_VALUE;
|
||||||
|
|
||||||
private int blockBiomeHashCode = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Due to vanilla `isClientLightReady()` not being designed for use by a non-render thread, it may return 'true'
|
|
||||||
* before the light engine has ticked, (right after all light changes is marked by the engine to be processed).
|
|
||||||
* To fix this, on client-only mode, we mixin-redirect the `isClientLightReady()` so that after the call, it will
|
|
||||||
* trigger a synchronous update of this flag here on all chunks that are wrapped. <br><br>
|
|
||||||
*
|
|
||||||
* Note: Using a static weak hash map to store the chunks that need to be updated, as instance of chunk wrapper
|
|
||||||
* can be duplicated, with same chunk instance. And the data stored here are all temporary, and thus will not be
|
|
||||||
* visible when a chunk is re-wrapped later. <br>
|
|
||||||
* (Also, thread safety done via a reader writer lock)
|
|
||||||
*/
|
|
||||||
private static final ConcurrentLinkedQueue<ChunkWrapper> chunksNeedingClientLightUpdating = new ConcurrentLinkedQueue<>();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=============//
|
//=============//
|
||||||
@@ -136,15 +123,6 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
this.wrappedLevel = wrappedLevel;
|
this.wrappedLevel = wrappedLevel;
|
||||||
this.chunkPos = new DhChunkPos(chunk.getPos().x, chunk.getPos().z);
|
this.chunkPos = new DhChunkPos(chunk.getPos().x, chunk.getPos().z);
|
||||||
|
|
||||||
// TODO is this the best way to differentiate between when we are generating chunks and when MC gave us a chunk?
|
|
||||||
boolean isDhGeneratedChunk = (this.lightSource.getClass() == DhLitWorldGenRegion.class);
|
|
||||||
// MC loaded chunks should get their lighting from MC, DH generated chunks should get their lighting from DH
|
|
||||||
this.useDhLighting = isDhGeneratedChunk;
|
|
||||||
|
|
||||||
// FIXME +1 is to handle the fact that LodDataBuilder adds +1 to all block lighting calculations, also done in the relative position validator
|
|
||||||
|
|
||||||
if (SharedApi.getEnvironment() != EWorldEnvironment.Server_Only)
|
|
||||||
chunksNeedingClientLightUpdating.add(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -301,6 +279,22 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
return BlockStateWrapper.fromBlockState(this.chunk.getBlockState(blockPos), this.wrappedLevel);
|
return BlockStateWrapper.fromBlockState(this.chunk.getBlockState(blockPos), this.wrappedLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockStateWrapper getBlockState(int relX, int relY, int relZ, IMutableBlockPosWrapper mcBlockPos, IBlockStateWrapper guess)
|
||||||
|
{
|
||||||
|
this.throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, relY, relZ);
|
||||||
|
|
||||||
|
BlockPos.MutableBlockPos pos = (BlockPos.MutableBlockPos)mcBlockPos.getWrappedMcObject();
|
||||||
|
pos.setX(relX);
|
||||||
|
pos.setY(relY);
|
||||||
|
pos.setZ(relZ);
|
||||||
|
|
||||||
|
return BlockStateWrapper.fromBlockState(this.chunk.getBlockState(pos), this.wrappedLevel, guess);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMutableBlockPosWrapper getMutableBlockPosWrapper() { return MUTABLE_BLOCK_POS_WRAPPER_REF.get(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DhChunkPos getChunkPos() { return this.chunkPos; }
|
public DhChunkPos getChunkPos() { return this.chunkPos; }
|
||||||
|
|
||||||
@@ -332,44 +326,14 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
//==========//
|
//==========//
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIsDhLightCorrect(boolean isDhLightCorrect) { this.isDhLightCorrect = isDhLightCorrect; }
|
public void setIsDhSkyLightCorrect(boolean isDhLightCorrect) { this.isDhSkyLightCorrect = isDhLightCorrect; }
|
||||||
|
@Override
|
||||||
|
public void setIsDhBlockLightCorrect(boolean isDhLightCorrect) { this.isDhBlockLightCorrect = isDhLightCorrect; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUseDhLighting(boolean useDhLighting) { this.useDhLighting = useDhLighting; }
|
public boolean isDhBlockLightingCorrect() { return this.isDhBlockLightCorrect; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLightCorrect()
|
public boolean isDhSkyLightCorrect() { return this.isDhSkyLightCorrect; }
|
||||||
{
|
|
||||||
if (this.useDhLighting)
|
|
||||||
{
|
|
||||||
return this.isDhLightCorrect;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
|
|
||||||
return false; // MC's lighting engine doesn't work consistently enough to trust for 1.16 or 1.17
|
|
||||||
#else
|
|
||||||
if (this.chunk instanceof LevelChunk)
|
|
||||||
{
|
|
||||||
LevelChunk levelChunk = (LevelChunk) this.chunk;
|
|
||||||
if (levelChunk.getLevel().isClientSide())
|
|
||||||
{
|
|
||||||
// connected to a server
|
|
||||||
return this.isMcClientLightingCorrect;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// in a single player world
|
|
||||||
return this.chunk.isLightCorrect() && levelChunk.loaded;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// called when in a single player world and the chunk is a proto chunk (in world gen, and not active)
|
|
||||||
return this.chunk.isLightCorrect();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -424,44 +388,6 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
public void setSkyLightStorage(ChunkLightStorage lightStorage) { this.skyLightStorage = lightStorage; }
|
public void setSkyLightStorage(ChunkLightStorage lightStorage) { this.skyLightStorage = lightStorage; }
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBlockLight(int relX, int y, int relZ)
|
|
||||||
{
|
|
||||||
this.throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, y, relZ);
|
|
||||||
|
|
||||||
// use the full lighting engine when the chunks are within render distance or the config requests it
|
|
||||||
if (this.useDhLighting)
|
|
||||||
{
|
|
||||||
// DH lighting method
|
|
||||||
return this.getBlockLightStorage().get(relX, y, relZ);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// note: this returns 0 if the chunk is unload
|
|
||||||
|
|
||||||
// MC lighting method
|
|
||||||
return this.lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(relX + this.getMinBlockX(), y, relZ + this.getMinBlockZ()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSkyLight(int relX, int y, int relZ)
|
|
||||||
{
|
|
||||||
this.throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, y, relZ);
|
|
||||||
|
|
||||||
// use the full lighting engine when the chunks are within render distance or the config requests it
|
|
||||||
if (this.useDhLighting)
|
|
||||||
{
|
|
||||||
// DH lighting method
|
|
||||||
return this.getSkyLightStorage().get(relX, y, relZ);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// MC lighting method
|
|
||||||
return this.lightSource.getBrightness(LightLayer.SKY, new BlockPos(relX + this.getMinBlockX(), y, relZ + this.getMinBlockZ()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME synchronized is necessary for a rare issue where this method is called from two separate threads at the same time
|
* FIXME synchronized is necessary for a rare issue where this method is called from two separate threads at the same time
|
||||||
* before the list has finished populating.
|
* before the list has finished populating.
|
||||||
@@ -497,63 +423,6 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
return this.blockLightPosList;
|
return this.blockLightPosList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void syncedUpdateClientLightStatus()
|
|
||||||
{
|
|
||||||
#if MC_VER < MC_1_18_2
|
|
||||||
// TODO: Check what to do in 1.18.1 and older
|
|
||||||
|
|
||||||
// since we don't currently handle this list,
|
|
||||||
// clear it to prevent memory leaks
|
|
||||||
chunksNeedingClientLightUpdating.clear();
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// update the chunks client lighting
|
|
||||||
ChunkWrapper chunkWrapper = chunksNeedingClientLightUpdating.poll();
|
|
||||||
while (chunkWrapper != null)
|
|
||||||
{
|
|
||||||
chunkWrapper.updateIsClientLightingCorrect();
|
|
||||||
chunkWrapper = chunksNeedingClientLightUpdating.poll();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/** Should be called after client light updates are triggered. */
|
|
||||||
private void updateIsClientLightingCorrect()
|
|
||||||
{
|
|
||||||
if (this.chunk instanceof LevelChunk && ((LevelChunk) this.chunk).getLevel() instanceof ClientLevel)
|
|
||||||
{
|
|
||||||
LevelChunk levelChunk = (LevelChunk) this.chunk;
|
|
||||||
ClientChunkCache clientChunkCache = ((ClientLevel) levelChunk.getLevel()).getChunkSource();
|
|
||||||
this.isMcClientLightingCorrect = clientChunkCache.getChunkForLighting(this.chunk.getPos().x, this.chunk.getPos().z) != null &&
|
|
||||||
#if MC_VER <= MC_1_17_1
|
|
||||||
levelChunk.isLightCorrect();
|
|
||||||
#elif MC_VER < MC_1_20_1
|
|
||||||
levelChunk.isClientLightReady();
|
|
||||||
#else
|
|
||||||
checkLightSectionsOnChunk(levelChunk, levelChunk.getLevel().getLightEngine());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if MC_VER >= MC_1_20_1
|
|
||||||
private static boolean checkLightSectionsOnChunk(LevelChunk chunk, LevelLightEngine engine)
|
|
||||||
{
|
|
||||||
LevelChunkSection[] sections = chunk.getSections();
|
|
||||||
int minY = chunk.getMinSection();
|
|
||||||
int maxY = chunk.getMaxSection();
|
|
||||||
for (int y = minY; y < maxY; ++y)
|
|
||||||
{
|
|
||||||
LevelChunkSection section = sections[chunk.getSectionIndexFromSectionY(y)];
|
|
||||||
if (section.hasOnlyAir()) continue;
|
|
||||||
if (!engine.lightOnInSection(SectionPos.of(chunk.getPos(), y)))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===============//
|
//===============//
|
||||||
|
|||||||
+3
-22
@@ -13,7 +13,6 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
|||||||
/** This is set and managed by the ClientApi for servers with support for DH. */
|
/** This is set and managed by the ClientApi for servers with support for DH. */
|
||||||
@Nullable
|
@Nullable
|
||||||
private IServerKeyedClientLevel serverKeyedLevel = null;
|
private IServerKeyedClientLevel serverKeyedLevel = null;
|
||||||
private boolean enabled = false;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -29,39 +28,21 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
|||||||
// level override logic //
|
// level override logic //
|
||||||
//======================//
|
//======================//
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public IServerKeyedClientLevel getServerKeyedLevel()
|
public IServerKeyedClientLevel getServerKeyedLevel() { return this.serverKeyedLevel; }
|
||||||
{
|
|
||||||
return this.serverKeyedLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IServerKeyedClientLevel setServerKeyedLevel(IClientLevelWrapper clientLevel, String levelKey)
|
public IServerKeyedClientLevel setServerKeyedLevel(IClientLevelWrapper clientLevel, String levelKey)
|
||||||
{
|
{
|
||||||
IServerKeyedClientLevel keyedLevel = new ServerKeyedClientLevel((ClientLevel) clientLevel.getWrappedMcObject(), levelKey);
|
IServerKeyedClientLevel keyedLevel = new ServerKeyedClientLevel((ClientLevel) clientLevel.getWrappedMcObject(), levelKey);
|
||||||
this.serverKeyedLevel = keyedLevel;
|
this.serverKeyedLevel = keyedLevel;
|
||||||
this.enabled = true;
|
|
||||||
return keyedLevel;
|
return keyedLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearServerKeyedLevel()
|
public void clearKeyedLevel() { this.serverKeyedLevel = null; }
|
||||||
{
|
|
||||||
this.serverKeyedLevel = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled()
|
public boolean hasLevelSet() { return this.serverKeyedLevel != null; }
|
||||||
{
|
|
||||||
return this.enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disable()
|
|
||||||
{
|
|
||||||
this.enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-5
@@ -18,11 +18,7 @@ public class ServerKeyedClientLevel extends ClientLevelWrapper implements IServe
|
|||||||
@Override
|
@Override
|
||||||
public String getServerLevelKey() { return this.serverLevelKey; }
|
public String getServerLevelKey() { return this.serverLevelKey; }
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDimensionName()
|
public String getDimensionName() { return this.getServerLevelKey(); }
|
||||||
{
|
|
||||||
return this.getServerLevelKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+4
-11
@@ -54,7 +54,6 @@ import net.minecraft.network.chat.TextComponent;
|
|||||||
#endif
|
#endif
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -222,14 +221,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public IClientLevelWrapper getWrappedClientLevel()
|
public IClientLevelWrapper getWrappedClientLevel() { return this.getWrappedClientLevel(false); }
|
||||||
{
|
|
||||||
return this.getWrappedClientLevel(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public IClientLevelWrapper getWrappedClientLevel(boolean bypassMultiverse)
|
public IClientLevelWrapper getWrappedClientLevel(boolean bypassLevelKeyManager)
|
||||||
{
|
{
|
||||||
ClientLevel level = MINECRAFT.level;
|
ClientLevel level = MINECRAFT.level;
|
||||||
if (level == null)
|
if (level == null)
|
||||||
@@ -237,7 +233,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ClientLevelWrapper.getWrapper(level, bypassMultiverse);
|
return ClientLevelWrapper.getWrapper(level, bypassLevelKeyManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -320,9 +316,6 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
public void executeOnRenderThread(Runnable runnable) { MINECRAFT.execute(runnable); }
|
public void executeOnRenderThread(Runnable runnable) { MINECRAFT.execute(runnable); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWorldInitialized()
|
public boolean isWorldNew() { throw new UnsupportedOperationException("Not Implemented"); }
|
||||||
{
|
|
||||||
throw new NotImplementedException("TODO");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-8
@@ -6,19 +6,34 @@ import net.minecraft.server.dedicated.DedicatedServer;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
//@Environment(EnvType.SERVER)
|
//@Environment(EnvType.SERVER)
|
||||||
public class MinecraftDedicatedServerWrapper implements IMinecraftSharedWrapper
|
public class MinecraftServerWrapper implements IMinecraftSharedWrapper
|
||||||
{
|
{
|
||||||
public static final MinecraftDedicatedServerWrapper INSTANCE = new MinecraftDedicatedServerWrapper();
|
public static final MinecraftServerWrapper INSTANCE = new MinecraftServerWrapper();
|
||||||
private MinecraftDedicatedServerWrapper() { }
|
|
||||||
public DedicatedServer dedicatedServer = null;
|
public DedicatedServer dedicatedServer = null;
|
||||||
|
|
||||||
|
|
||||||
|
//=============//
|
||||||
|
// constructor //
|
||||||
|
//=============//
|
||||||
|
|
||||||
|
private MinecraftServerWrapper() { }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=========//
|
||||||
|
// methods //
|
||||||
|
//=========//
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDedicatedServer() { return true; }
|
public boolean isDedicatedServer() { return true; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getInstallationDirectory()
|
public File getInstallationDirectory()
|
||||||
{
|
{
|
||||||
if (this.dedicatedServer == null)
|
if (this.dedicatedServer == null)
|
||||||
{
|
{
|
||||||
throw new IllegalStateException("Trying to get Installation Direction before Dedicated server complete initialization!");
|
throw new IllegalStateException("Trying to get Installation Direction before Dedicated server completed initialization!");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER < MC_1_21_1
|
#if MC_VER < MC_1_21_1
|
||||||
@@ -29,9 +44,7 @@ public class MinecraftDedicatedServerWrapper implements IMinecraftSharedWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWorldInitialized()
|
public boolean isWorldNew()
|
||||||
{
|
{ return this.dedicatedServer.getWorldData().overworldData().isInitialized(); }
|
||||||
return this.dedicatedServer.getWorldData().overworldData().isInitialized();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+4
@@ -8,4 +8,8 @@ public interface IMixinServerPlayer
|
|||||||
@Nullable
|
@Nullable
|
||||||
ServerLevel distantHorizons$getDimensionChangeDestination();
|
ServerLevel distantHorizons$getDimensionChangeDestination();
|
||||||
|
|
||||||
|
#if MC_VER == MC_1_16_5
|
||||||
|
void distantHorizons$setDimensionChangeDestination(ServerLevel dimensionChangeDestination);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package com.seibel.distanthorizons.common.wrappers.misc;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IMutableBlockPosWrapper;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
|
public class MutableBlockPosWrapper implements IMutableBlockPosWrapper
|
||||||
|
{
|
||||||
|
public final BlockPos.MutableBlockPos pos;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=============//
|
||||||
|
// constructor //
|
||||||
|
//=============//
|
||||||
|
|
||||||
|
public MutableBlockPosWrapper()
|
||||||
|
{
|
||||||
|
this.pos = new BlockPos.MutableBlockPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//===========//
|
||||||
|
// overrides //
|
||||||
|
//===========//
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getWrappedMcObject() { return this.pos; }
|
||||||
|
|
||||||
|
}
|
||||||
+38
-43
@@ -15,7 +15,7 @@ import java.net.SocketAddress;
|
|||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This wrapper transparently ensures that underlying {@link ServerPlayer} is always valid,
|
* This wrapper transparently ensures that the underlying {@link ServerPlayer} is always valid,
|
||||||
* unless the player has disconnected.
|
* unless the player has disconnected.
|
||||||
*/
|
*/
|
||||||
public class ServerPlayerWrapper implements IServerPlayerWrapper
|
public class ServerPlayerWrapper implements IServerPlayerWrapper
|
||||||
@@ -23,38 +23,39 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper
|
|||||||
private static final ConcurrentMap<ServerGamePacketListenerImpl, ServerPlayerWrapper> serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap();
|
private static final ConcurrentMap<ServerGamePacketListenerImpl, ServerPlayerWrapper> serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap();
|
||||||
|
|
||||||
private final ServerGamePacketListenerImpl connection;
|
private final ServerGamePacketListenerImpl connection;
|
||||||
private ServerPlayer serverPlayer()
|
|
||||||
{
|
|
||||||
return this.connection.player;
|
|
||||||
}
|
//=============//
|
||||||
|
// constructor //
|
||||||
|
//=============//
|
||||||
|
|
||||||
public static ServerPlayerWrapper getWrapper(ServerPlayer serverPlayer)
|
public static ServerPlayerWrapper getWrapper(ServerPlayer serverPlayer)
|
||||||
{
|
{ return serverPlayerWrapperMap.computeIfAbsent(serverPlayer.connection, ignored -> new ServerPlayerWrapper(serverPlayer.connection)); }
|
||||||
return serverPlayerWrapperMap.computeIfAbsent(serverPlayer.connection, ignored -> new ServerPlayerWrapper(serverPlayer.connection));
|
|
||||||
}
|
|
||||||
|
|
||||||
private ServerPlayerWrapper(ServerGamePacketListenerImpl connection)
|
private ServerPlayerWrapper(ServerGamePacketListenerImpl connection) { this.connection = connection; }
|
||||||
{
|
|
||||||
this.connection = connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=========//
|
||||||
|
// getters //
|
||||||
|
//=========//
|
||||||
|
|
||||||
|
private ServerPlayer getServerPlayer() { return this.connection.player; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName() { return this.getServerPlayer().getName().getString(); }
|
||||||
{
|
|
||||||
return this.serverPlayer().getName().getString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IServerLevelWrapper getLevel()
|
public IServerLevelWrapper getLevel()
|
||||||
{
|
{
|
||||||
ServerLevel level = ((IMixinServerPlayer) this.serverPlayer()).distantHorizons$getDimensionChangeDestination();
|
ServerLevel level = ((IMixinServerPlayer) this.getServerPlayer()).distantHorizons$getDimensionChangeDestination();
|
||||||
if (level == null)
|
if (level == null)
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_20_1
|
#if MC_VER < MC_1_20_1
|
||||||
level = this.serverPlayer().getLevel();
|
level = this.getServerPlayer().getLevel();
|
||||||
#else
|
#else
|
||||||
level = this.serverPlayer().serverLevel();
|
level = this.getServerPlayer().serverLevel();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,57 +65,51 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper
|
|||||||
@Override
|
@Override
|
||||||
public Vec3d getPosition()
|
public Vec3d getPosition()
|
||||||
{
|
{
|
||||||
Vec3 position = this.serverPlayer().position();
|
Vec3 position = this.getServerPlayer().position();
|
||||||
return new Vec3d(position.x, position.y, position.z);
|
return new Vec3d(position.x, position.y, position.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getViewDistance()
|
public int getViewDistance() { return this.getServerPlayer().server.getPlayerList().getViewDistance(); }
|
||||||
{
|
|
||||||
return this.serverPlayer().server.getPlayerList().getViewDistance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SocketAddress getRemoteAddress()
|
public SocketAddress getRemoteAddress()
|
||||||
{
|
{
|
||||||
#if MC_VER >= MC_1_19_4
|
#if MC_VER >= MC_1_19_4
|
||||||
return this.serverPlayer().connection.getRemoteAddress();
|
return this.getServerPlayer().connection.getRemoteAddress();
|
||||||
#else // < 1.19.4
|
#else // < 1.19.4
|
||||||
return this.serverPlayer().connection.connection.getRemoteAddress();
|
return this.getServerPlayer().connection.connection.getRemoteAddress();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getWrappedMcObject()
|
|
||||||
{
|
//================//
|
||||||
return this.serverPlayer();
|
// base overrides //
|
||||||
}
|
//================//
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public Object getWrappedMcObject() { return this.getServerPlayer(); }
|
||||||
{
|
|
||||||
return "Wrapped{" + this.serverPlayer() + "}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o)
|
public String toString() { return "Wrapped{" + this.getServerPlayer() + "}"; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if (this == o)
|
if (this == obj)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(o instanceof ServerPlayerWrapper))
|
if (!(obj instanceof ServerPlayerWrapper))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ServerPlayerWrapper that = (ServerPlayerWrapper) o;
|
ServerPlayerWrapper that = (ServerPlayerWrapper) obj;
|
||||||
return Objects.equal(this.connection, that.connection);
|
return Objects.equal(this.connection, that.connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode() { return Objects.hashCode(this.connection); }
|
||||||
{
|
|
||||||
return Objects.hashCode(this.connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+2
-8
@@ -70,10 +70,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
// wrapper logic //
|
// wrapper logic //
|
||||||
//===============//
|
//===============//
|
||||||
|
|
||||||
public static IClientLevelWrapper getWrapper(@NotNull ClientLevel level)
|
public static IClientLevelWrapper getWrapper(@NotNull ClientLevel level) { return getWrapper(level, false); }
|
||||||
{
|
|
||||||
return getWrapper(level, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static IClientLevelWrapper getWrapper(@Nullable ClientLevel level, boolean bypassLevelKeyManager)
|
public static IClientLevelWrapper getWrapper(@Nullable ClientLevel level, boolean bypassLevelKeyManager)
|
||||||
@@ -189,10 +186,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDimensionName()
|
public String getDimensionName() { return this.level.dimension().location().toString(); }
|
||||||
{
|
|
||||||
return this.level.dimension().location().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EDhApiLevelType getLevelType() { return EDhApiLevelType.CLIENT_LEVEL; }
|
public EDhApiLevelType getLevelType() { return EDhApiLevelType.CLIENT_LEVEL; }
|
||||||
|
|||||||
+3
-9
@@ -65,11 +65,11 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper
|
|||||||
|
|
||||||
private String getDimensionName()
|
private String getDimensionName()
|
||||||
{
|
{
|
||||||
#if MC_VER >= MC_1_17_1
|
#if MC_VER <= MC_1_16_5
|
||||||
return this.dimensionType.effectsLocation().getPath();
|
|
||||||
#else // < 1.17.1
|
|
||||||
// effectsLocation() is marked as client only, so using the backing field directly
|
// effectsLocation() is marked as client only, so using the backing field directly
|
||||||
return dimensionType.effectsLocation.getPath();
|
return dimensionType.effectsLocation.getPath();
|
||||||
|
#else
|
||||||
|
return this.dimensionType.effectsLocation().getPath();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,12 +91,6 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper
|
|||||||
return this.dimensionType;
|
return this.dimensionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getTeleportationScale(IDimensionTypeWrapper to)
|
|
||||||
{
|
|
||||||
return DimensionType.getTeleportationScale(this.dimensionType, (DimensionType) to.getWrappedMcObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
// there's definitely a better way of doing this, but it should work well enough for now
|
// there's definitely a better way of doing this, but it should work well enough for now
|
||||||
@Override
|
@Override
|
||||||
public boolean isTheEnd() { return this.getDimensionName().equalsIgnoreCase("the_end"); }
|
public boolean isTheEnd() { return this.getDimensionName().equalsIgnoreCase("the_end"); }
|
||||||
|
|||||||
+9
-28
@@ -81,48 +81,27 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
//=========//
|
//=========//
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getSaveFolder()
|
public File getSaveFolder() { return this.level.getChunkSource().getDataStorage().dataFolder; }
|
||||||
{
|
|
||||||
return this.level.getChunkSource().getDataStorage().dataFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DimensionTypeWrapper getDimensionType()
|
public DimensionTypeWrapper getDimensionType() { return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType()); }
|
||||||
{
|
|
||||||
return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDimensionName()
|
public String getDimensionName() { return this.level.dimension().location().toString(); }
|
||||||
{
|
|
||||||
return this.level.dimension().location().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EDhApiLevelType getLevelType() { return EDhApiLevelType.SERVER_LEVEL; }
|
public EDhApiLevelType getLevelType() { return EDhApiLevelType.SERVER_LEVEL; }
|
||||||
|
|
||||||
public ServerLevel getLevel()
|
public ServerLevel getLevel() { return this.level; }
|
||||||
{
|
|
||||||
return this.level;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCeiling()
|
public boolean hasCeiling() { return this.level.dimensionType().hasCeiling(); }
|
||||||
{
|
|
||||||
return this.level.dimensionType().hasCeiling();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSkyLight()
|
public boolean hasSkyLight() { return this.level.dimensionType().hasSkyLight(); }
|
||||||
{
|
|
||||||
return this.level.dimensionType().hasSkyLight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxHeight()
|
public int getMaxHeight() { return this.level.getHeight(); }
|
||||||
{
|
|
||||||
return this.level.getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMinHeight()
|
public int getMinHeight()
|
||||||
@@ -141,11 +120,13 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChunkAccess chunk = this.level.getChunk(pos.getX(), pos.getZ(), ChunkStatus.FULL, false);
|
ChunkAccess chunk = this.level.getChunk(pos.getX(), pos.getZ(), ChunkStatus.FULL, false);
|
||||||
if (chunk == null)
|
if (chunk == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ChunkWrapper(chunk, this.level, this);
|
return new ChunkWrapper(chunk, this.level, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+24
-23
@@ -134,7 +134,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < 11; i++)
|
for (int i = 0; i < 11; i++)
|
||||||
{
|
{
|
||||||
times.add(new Rolling(SIZE));
|
this.times.add(new Rolling(SIZE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,19 +144,25 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
|||||||
{
|
{
|
||||||
String name = e.name;
|
String name = e.name;
|
||||||
int index = Arrays.asList(TIME_NAMES).indexOf(name);
|
int index = Arrays.asList(TIME_NAMES).indexOf(name);
|
||||||
if (index == -1) continue;
|
if (index == -1)
|
||||||
times.get(index).add(e.timeNs);
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.times.get(index).add(e.timeNs);
|
||||||
}
|
}
|
||||||
times.get(0).add(event.getTotalTimeNs());
|
this.times.get(0).add(event.getTotalTimeNs());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
@Override public String toString()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < times.size(); i++)
|
for (int i = 0; i < this.times.size(); i++)
|
||||||
{
|
{
|
||||||
if (times.get(i).getAverage() == 0) continue;
|
if (this.times.get(i).getAverage() == 0)
|
||||||
sb.append(TIME_NAMES[i]).append(": ").append(times.get(i).getAverage()).append("\n");
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sb.append(TIME_NAMES[i]).append(": ").append(this.times.get(i).getAverage()).append("\n");
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
@@ -186,13 +192,13 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
|||||||
|
|
||||||
public RegionFileStorageExternalCache getOrCreateRegionFileCache(RegionFileStorage storage)
|
public RegionFileStorageExternalCache getOrCreateRegionFileCache(RegionFileStorage storage)
|
||||||
{
|
{
|
||||||
RegionFileStorageExternalCache cache = regionFileStorageCacheRef.get();
|
RegionFileStorageExternalCache cache = this.regionFileStorageCacheRef.get();
|
||||||
if (cache == null)
|
if (cache == null)
|
||||||
{
|
{
|
||||||
cache = new RegionFileStorageExternalCache(storage);
|
cache = new RegionFileStorageExternalCache(storage);
|
||||||
if (!regionFileStorageCacheRef.compareAndSet(null, cache))
|
if (!this.regionFileStorageCacheRef.compareAndSet(null, cache))
|
||||||
{
|
{
|
||||||
cache = regionFileStorageCacheRef.get();
|
cache = this.regionFileStorageCacheRef.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cache;
|
return cache;
|
||||||
@@ -304,17 +310,17 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
|||||||
|
|
||||||
public <T> T joinSync(CompletableFuture<T> future)
|
public <T> T joinSync(CompletableFuture<T> future)
|
||||||
{
|
{
|
||||||
if (!unsafeThreadingRecorded && !future.isDone())
|
if (!this.unsafeThreadingRecorded && !future.isDone())
|
||||||
{
|
{
|
||||||
EVENT_LOGGER.error("Unsafe MultiThreading in Chunk Generator: ", new RuntimeException("Concurrent future"));
|
EVENT_LOGGER.error("Unsafe MultiThreading in Chunk Generator: ", new RuntimeException("Concurrent future"));
|
||||||
EVENT_LOGGER.error("To increase stability, it is recommended to set world generation threads count to 1.");
|
EVENT_LOGGER.error("To increase stability, it is recommended to set world generation threads count to 1.");
|
||||||
unsafeThreadingRecorded = true;
|
this.unsafeThreadingRecorded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return future.join();
|
return future.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateAllFutures()
|
@Override public void updateAllFutures()
|
||||||
{
|
{
|
||||||
if (this.unknownExceptionCount > 0)
|
if (this.unknownExceptionCount > 0)
|
||||||
{
|
{
|
||||||
@@ -488,8 +494,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
|||||||
{
|
{
|
||||||
chunkWrapper.setBlockLightStorage(chunkBlockLightingByDhPos.get(chunkWrapper.getChunkPos()));
|
chunkWrapper.setBlockLightStorage(chunkBlockLightingByDhPos.get(chunkWrapper.getChunkPos()));
|
||||||
chunkWrapper.setSkyLightStorage(chunkSkyLightingByDhPos.get(chunkWrapper.getChunkPos()));
|
chunkWrapper.setSkyLightStorage(chunkSkyLightingByDhPos.get(chunkWrapper.getChunkPos()));
|
||||||
chunkWrapper.setUseDhLighting(true);
|
chunkWrapper.setIsDhBlockLightCorrect(true);
|
||||||
chunkWrapper.setIsDhLightCorrect(true);
|
chunkWrapper.setIsDhSkyLightCorrect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
chunkWrappersByDhPos.put(chunkPos, chunkWrapper);
|
chunkWrappersByDhPos.put(chunkPos, chunkWrapper);
|
||||||
@@ -531,11 +537,6 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wrappedChunk.isLightCorrect())
|
|
||||||
{
|
|
||||||
throw new RuntimeException("The generated chunk somehow has isLightCorrect() returning false");
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isFull = ChunkWrapper.getStatus(target) == ChunkStatus.FULL || target instanceof LevelChunk;
|
boolean isFull = ChunkWrapper.getStatus(target) == ChunkStatus.FULL || target instanceof LevelChunk;
|
||||||
#if MC_VER >= MC_1_18_2
|
#if MC_VER >= MC_1_18_2
|
||||||
boolean isPartial = target.isOldNoiseGeneration();
|
boolean isPartial = target.isOldNoiseGeneration();
|
||||||
@@ -823,9 +824,9 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
|||||||
Heightmap.primeHeightmaps(((ChunkWrapper)centerChunk).getChunk(), ChunkStatus.FEATURES.heightmapsAfter());
|
Heightmap.primeHeightmaps(((ChunkWrapper)centerChunk).getChunk(), ChunkStatus.FEATURES.heightmapsAfter());
|
||||||
|
|
||||||
// pre-generated chunks should have lighting but new ones won't
|
// pre-generated chunks should have lighting but new ones won't
|
||||||
if (!centerChunk.isLightCorrect())
|
if (!centerChunk.isDhBlockLightingCorrect())
|
||||||
{
|
{
|
||||||
DhLightingEngine.INSTANCE.lightChunk(centerChunk, iChunkWrapperList, maxSkyLight);
|
DhLightingEngine.INSTANCE.bakeChunkBlockLighting(centerChunk, iChunkWrapperList, maxSkyLight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
Submodule coreSubProjects updated: 7cd1a37914...5b746a9534
+2
-5
@@ -5,17 +5,14 @@ plugins {
|
|||||||
loom {
|
loom {
|
||||||
accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
|
accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
|
||||||
|
|
||||||
// Custom logging
|
|
||||||
log4jConfigs.from(file("log4j-dev.xml"))
|
|
||||||
|
|
||||||
// "runs" isn't required, but when we do need it then it can be useful
|
// "runs" isn't required, but when we do need it then it can be useful
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
client()
|
client()
|
||||||
setConfigName("Fabric Client")
|
setConfigName("Fabric Client")
|
||||||
ideConfigGenerated(true)
|
ideConfigGenerated(true) // When true a run configuration file will be generated for IDE's. By default only set to true for the root project.
|
||||||
runDir("../run/client")
|
runDir("../run/client")
|
||||||
vmArgs("-Dio.netty.leakDetection.level=advanced")
|
vmArgs("-Dio.netty.leakDetection.level=advanced") // https://netty.io/wiki/reference-counted-objects.html#leak-detection-levels
|
||||||
programArgs("--username", "Dev")
|
programArgs("--username", "Dev")
|
||||||
}
|
}
|
||||||
server {
|
server {
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Configuration name="Dev" monitorInterval="10">
|
|
||||||
<Loggers>
|
|
||||||
<Logger name="com.seibel.distanthorizons.core.network" level="trace" additivity="false">
|
|
||||||
<AppenderRef ref="DebugFile" level="${sys:fabric.log.debug.level:-debug}" />
|
|
||||||
<AppenderRef ref="SysOut" />
|
|
||||||
<AppenderRef ref="LatestFile" level="${sys:fabric.log.level:-info}" />
|
|
||||||
<AppenderRef ref="ServerGuiConsole" />
|
|
||||||
</Logger>
|
|
||||||
</Loggers>
|
|
||||||
</Configuration>
|
|
||||||
@@ -52,7 +52,7 @@ import net.minecraft.client.gui.screens.TitleScreen;
|
|||||||
import com.seibel.distanthorizons.common.CommonPacketPayload;
|
import com.seibel.distanthorizons.common.CommonPacketPayload;
|
||||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||||
#else
|
#else
|
||||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER < MC_1_19_4
|
#if MC_VER < MC_1_19_4
|
||||||
@@ -268,7 +268,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
{
|
{
|
||||||
// Forge packet ID
|
// Forge packet ID
|
||||||
buffer.readByte();
|
buffer.readByte();
|
||||||
NetworkMessage message = AbstractPluginPacketSender.decodeMessage(buffer);
|
AbstractNetworkMessage message = AbstractPluginPacketSender.decodeMessage(buffer);
|
||||||
if (message != null)
|
if (message != null)
|
||||||
{
|
{
|
||||||
ClientApi.INSTANCE.pluginMessageReceived(message);
|
ClientApi.INSTANCE.pluginMessageReceived(message);
|
||||||
|
|||||||
@@ -119,9 +119,12 @@ public class FabricMain extends AbstractModInitializer implements ClientModIniti
|
|||||||
@Override
|
@Override
|
||||||
protected void subscribeRegisterCommandsEvent(Consumer<CommandDispatcher<CommandSourceStack>> eventHandler)
|
protected void subscribeRegisterCommandsEvent(Consumer<CommandDispatcher<CommandSourceStack>> eventHandler)
|
||||||
{
|
{
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess #if MC_VER >= MC_1_19_2 , environment #endif ) -> {
|
CommandRegistrationCallback.EVENT.register(
|
||||||
eventHandler.accept(dispatcher);
|
(dispatcher, registryAccess #if MC_VER >= MC_1_19_2 , environment #endif ) ->
|
||||||
});
|
{
|
||||||
|
eventHandler.accept(dispatcher);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
package com.seibel.distanthorizons.fabric;
|
package com.seibel.distanthorizons.fabric;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
||||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage;
|
||||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
@@ -16,7 +16,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
|||||||
public class FabricPluginPacketSender extends AbstractPluginPacketSender
|
public class FabricPluginPacketSender extends AbstractPluginPacketSender
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void sendPluginPacketClient(NetworkMessage message)
|
public void sendToServer(AbstractNetworkMessage message)
|
||||||
{
|
{
|
||||||
#if MC_VER >= MC_1_20_6
|
#if MC_VER >= MC_1_20_6
|
||||||
ClientPlayNetworking.send(new CommonPacketPayload(message));
|
ClientPlayNetworking.send(new CommonPacketPayload(message));
|
||||||
@@ -30,7 +30,7 @@ public class FabricPluginPacketSender extends AbstractPluginPacketSender
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPluginPacketServer(ServerPlayer serverPlayer, NetworkMessage message)
|
public void sendToClient(ServerPlayer serverPlayer, AbstractNetworkMessage message)
|
||||||
{
|
{
|
||||||
#if MC_VER >= MC_1_20_6
|
#if MC_VER >= MC_1_20_6
|
||||||
ServerPlayNetworking.send(serverPlayer, new CommonPacketPayload(message));
|
ServerPlayNetworking.send(serverPlayer, new CommonPacketPayload(message));
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import com.seibel.distanthorizons.common.CommonPacketPayload;
|
import com.seibel.distanthorizons.common.CommonPacketPayload;
|
||||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||||
#else
|
#else
|
||||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage;
|
||||||
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -50,21 +50,26 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
private static final ServerApi SERVER_API = ServerApi.INSTANCE;
|
private static final ServerApi SERVER_API = ServerApi.INSTANCE;
|
||||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||||
|
|
||||||
private final boolean isDedicated;
|
private final boolean isDedicatedServer;
|
||||||
public static Supplier<Boolean> isGenerationThreadChecker = null;
|
public static Supplier<Boolean> isGenerationThreadChecker = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public FabricServerProxy(boolean isDedicated)
|
//=============//
|
||||||
|
// constructor //
|
||||||
|
//=============//
|
||||||
|
|
||||||
|
public FabricServerProxy(boolean isDedicatedServer)
|
||||||
{
|
{
|
||||||
this.isDedicated = isDedicated;
|
this.isDedicatedServer = isDedicatedServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO rename
|
||||||
private boolean isValidTime()
|
private boolean isValidTime()
|
||||||
{
|
{
|
||||||
if (this.isDedicated)
|
if (this.isDedicatedServer)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -103,7 +108,7 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
{
|
{
|
||||||
if (this.isValidTime())
|
if (this.isValidTime())
|
||||||
{
|
{
|
||||||
ServerApi.INSTANCE.serverLoadEvent(this.isDedicated);
|
ServerApi.INSTANCE.serverLoadEvent(this.isDedicatedServer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// ServerWorldUnloadEvent
|
// ServerWorldUnloadEvent
|
||||||
@@ -159,19 +164,19 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
ServerApi.INSTANCE.serverPlayerDisconnectEvent(this.getServerPlayerWrapper(handler.player));
|
ServerApi.INSTANCE.serverPlayerDisconnectEvent(this.getServerPlayerWrapper(handler.player));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, dest) ->
|
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, originLevel, destinationLevel) ->
|
||||||
{
|
{
|
||||||
if (this.isValidTime())
|
if (this.isValidTime())
|
||||||
{
|
{
|
||||||
ServerApi.INSTANCE.serverPlayerLevelChangeEvent(
|
ServerApi.INSTANCE.serverPlayerLevelChangeEvent(
|
||||||
this.getServerPlayerWrapper(player),
|
this.getServerPlayerWrapper(player),
|
||||||
this.getServerLevelWrapper(origin),
|
this.getServerLevelWrapper(originLevel),
|
||||||
this.getServerLevelWrapper(dest)
|
this.getServerLevelWrapper(destinationLevel)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.isDedicated)
|
if (this.isDedicatedServer)
|
||||||
{
|
{
|
||||||
#if MC_VER >= MC_1_20_6
|
#if MC_VER >= MC_1_20_6
|
||||||
PayloadTypeRegistry.playC2S().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
PayloadTypeRegistry.playC2S().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
||||||
@@ -189,7 +194,7 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
{
|
{
|
||||||
// Forge packet ID
|
// Forge packet ID
|
||||||
buffer.readByte();
|
buffer.readByte();
|
||||||
NetworkMessage message = AbstractPluginPacketSender.decodeMessage(buffer);
|
AbstractNetworkMessage message = AbstractPluginPacketSender.decodeMessage(buffer);
|
||||||
if (message != null)
|
if (message != null)
|
||||||
{
|
{
|
||||||
ServerApi.INSTANCE.pluginMessageReceived(ServerPlayerWrapper.getWrapper(serverPlayer), message);
|
ServerApi.INSTANCE.pluginMessageReceived(ServerPlayerWrapper.getWrapper(serverPlayer), message);
|
||||||
|
|||||||
-18
@@ -131,22 +131,4 @@ public class MixinLevelRenderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER < MC_1_19_4
|
|
||||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I"), method = "renderLevel")
|
|
||||||
public void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
|
|
||||||
#elif MC_VER < MC_1_20_1
|
|
||||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I"), method = "renderLevel")
|
|
||||||
public void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
|
|
||||||
#elif MC_VER < MC_1_20_6
|
|
||||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I"), method = "renderLevel")
|
|
||||||
private void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
|
|
||||||
#else
|
|
||||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I"), method = "renderLevel")
|
|
||||||
private void callAfterRunUpdates(CallbackInfo ci)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
ChunkWrapper.syncedUpdateClientLightStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -130,10 +130,12 @@ public abstract class MixinMinecraft
|
|||||||
{
|
{
|
||||||
ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(this.lastLevel));
|
ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(this.lastLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level != null)
|
if (level != null)
|
||||||
{
|
{
|
||||||
ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(level, true));
|
ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(level, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastLevel = level;
|
this.lastLevel = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#if MC_VER == MC_1_16_5
|
||||||
|
package com.seibel.distanthorizons.fabric.mixins.server;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.misc.IMixinServerPlayer;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(Entity.class)
|
||||||
|
public class MixinEntity
|
||||||
|
{
|
||||||
|
@Inject(at = @At("TAIL"), method = "setLevel")
|
||||||
|
public void setLevel(Level level, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
if (this instanceof IMixinServerPlayer)
|
||||||
|
{
|
||||||
|
((IMixinServerPlayer) this).distantHorizons$setDimensionChangeDestination((ServerLevel) level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
package com.seibel.distanthorizons.fabric.mixins.server;
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(Entity.class)
|
||||||
|
public class MixinEntity
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
+12
-13
@@ -46,32 +46,31 @@ public class MixinServerPlayer implements IMixinServerPlayer
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public ServerLevel distantHorizons$getDimensionChangeDestination()
|
public ServerLevel distantHorizons$getDimensionChangeDestination()
|
||||||
{
|
{ return this.dimensionChangeDestination; }
|
||||||
return this.dimensionChangeDestination;
|
|
||||||
}
|
#if MC_VER == MC_1_16_5
|
||||||
|
@Override
|
||||||
|
public void distantHorizons$setDimensionChangeDestination(ServerLevel dimensionChangeDestination)
|
||||||
|
{ this.dimensionChangeDestination = dimensionChangeDestination; }
|
||||||
|
#endif
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "changeDimension")
|
@Inject(at = @At("HEAD"), method = "changeDimension")
|
||||||
#if MC_VER >= MC_1_21_1
|
#if MC_VER >= MC_1_21_1
|
||||||
public void changeDimension(DimensionTransition dimensionTransition, CallbackInfoReturnable<Entity> cir)
|
public void changeDimension(DimensionTransition dimensionTransition, CallbackInfoReturnable<Entity> cir)
|
||||||
{
|
{ this.dimensionChangeDestination = dimensionTransition.newLevel(); }
|
||||||
this.dimensionChangeDestination = dimensionTransition.newLevel();
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
public void changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> cir)
|
public void changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> cir)
|
||||||
{
|
{ this.dimensionChangeDestination = destination; }
|
||||||
this.dimensionChangeDestination = destination;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER >= MC_1_20_1
|
#if MC_VER >= MC_1_20_1
|
||||||
@Inject(at = @At("RETURN"), method = "setServerLevel")
|
@Inject(at = @At("RETURN"), method = "setServerLevel")
|
||||||
public void setServerLevel(ServerLevel level, CallbackInfo ci)
|
public void setServerLevel(ServerLevel level, CallbackInfo ci)
|
||||||
#else
|
{ this.dimensionChangeDestination = null; }
|
||||||
|
#elif MC_VER >= MC_1_17_1
|
||||||
@Inject(at = @At("RETURN"), method = "setLevel")
|
@Inject(at = @At("RETURN"), method = "setLevel")
|
||||||
public void setLevel(ServerLevel level, CallbackInfo ci)
|
public void setLevel(ServerLevel level, CallbackInfo ci)
|
||||||
|
{ this.dimensionChangeDestination = null; }
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
this.dimensionChangeDestination = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,8 @@
|
|||||||
"server.MixinChunkGenerator",
|
"server.MixinChunkGenerator",
|
||||||
"server.MixinChunkMap",
|
"server.MixinChunkMap",
|
||||||
"server.MixinUtilBackgroundThread",
|
"server.MixinUtilBackgroundThread",
|
||||||
"server.MixinServerPlayer"
|
"server.MixinServerPlayer",
|
||||||
|
"server.MixinEntity"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"client.MixinClientLevel",
|
"client.MixinClientLevel",
|
||||||
|
|||||||
+2
-2
@@ -37,9 +37,9 @@ loom {
|
|||||||
client {
|
client {
|
||||||
client()
|
client()
|
||||||
setConfigName("Forge Client")
|
setConfigName("Forge Client")
|
||||||
ideConfigGenerated(false)
|
ideConfigGenerated(false) // When true a run configuration file will be generated for IDE's. By default only set to true for the root project.
|
||||||
runDir("../run/client")
|
runDir("../run/client")
|
||||||
vmArgs("-Dio.netty.leakDetection.level=advanced")
|
vmArgs("-Dio.netty.leakDetection.level=advanced") // https://netty.io/wiki/reference-counted-objects.html#leak-detection-levels
|
||||||
programArgs("--username", "Dev")
|
programArgs("--username", "Dev")
|
||||||
}
|
}
|
||||||
server {
|
server {
|
||||||
|
|||||||
@@ -297,4 +297,5 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ package com.seibel.distanthorizons.forge;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
||||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
||||||
@@ -45,11 +45,11 @@ public class ForgePluginPacketSender extends AbstractPluginPacketSender
|
|||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public static void setPacketHandler(Consumer<NetworkMessage> consumer)
|
public static void setPacketHandler(Consumer<AbstractNetworkMessage> consumer)
|
||||||
{
|
{
|
||||||
setPacketHandler((player, message) -> consumer.accept(message));
|
setPacketHandler((player, message) -> consumer.accept(message));
|
||||||
}
|
}
|
||||||
public static void setPacketHandler(BiConsumer<IServerPlayerWrapper, NetworkMessage> consumer)
|
public static void setPacketHandler(BiConsumer<IServerPlayerWrapper, AbstractNetworkMessage> consumer)
|
||||||
{
|
{
|
||||||
#if MC_VER >= MC_1_20_2
|
#if MC_VER >= MC_1_20_2
|
||||||
PLUGIN_CHANNEL.messageBuilder(MessageWrapper.class, 0)
|
PLUGIN_CHANNEL.messageBuilder(MessageWrapper.class, 0)
|
||||||
@@ -95,7 +95,7 @@ public class ForgePluginPacketSender extends AbstractPluginPacketSender
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPluginPacketClient(NetworkMessage message)
|
public void sendToServer(AbstractNetworkMessage message)
|
||||||
{
|
{
|
||||||
#if MC_VER >= MC_1_20_2
|
#if MC_VER >= MC_1_20_2
|
||||||
PLUGIN_CHANNEL.send(new MessageWrapper(message), PacketDistributor.SERVER.noArg());
|
PLUGIN_CHANNEL.send(new MessageWrapper(message), PacketDistributor.SERVER.noArg());
|
||||||
@@ -105,7 +105,7 @@ public class ForgePluginPacketSender extends AbstractPluginPacketSender
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPluginPacketServer(ServerPlayer serverPlayer, NetworkMessage message)
|
public void sendToClient(ServerPlayer serverPlayer, AbstractNetworkMessage message)
|
||||||
{
|
{
|
||||||
#if MC_VER >= MC_1_20_2
|
#if MC_VER >= MC_1_20_2
|
||||||
PLUGIN_CHANNEL.send(new MessageWrapper(message), PacketDistributor.PLAYER.with(serverPlayer));
|
PLUGIN_CHANNEL.send(new MessageWrapper(message), PacketDistributor.PLAYER.with(serverPlayer));
|
||||||
@@ -118,12 +118,9 @@ public class ForgePluginPacketSender extends AbstractPluginPacketSender
|
|||||||
@SuppressWarnings({"ClassCanBeRecord", "RedundantSuppression"})
|
@SuppressWarnings({"ClassCanBeRecord", "RedundantSuppression"})
|
||||||
public static class MessageWrapper
|
public static class MessageWrapper
|
||||||
{
|
{
|
||||||
public final NetworkMessage message;
|
public final AbstractNetworkMessage message;
|
||||||
|
|
||||||
public MessageWrapper(NetworkMessage message)
|
public MessageWrapper(AbstractNetworkMessage message) { this.message = message; }
|
||||||
{
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,14 +154,10 @@ public class ForgeServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event)
|
public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event)
|
||||||
{
|
{ this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event)); }
|
||||||
this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event));
|
|
||||||
}
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void playerLoggedOutEvent(PlayerEvent.PlayerLoggedOutEvent event)
|
public void playerLoggedOutEvent(PlayerEvent.PlayerLoggedOutEvent event)
|
||||||
{
|
{ this.serverApi.serverPlayerDisconnectEvent(getServerPlayerWrapper(event)); }
|
||||||
this.serverApi.serverPlayerDisconnectEvent(getServerPlayerWrapper(event));
|
|
||||||
}
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent event)
|
public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent event)
|
||||||
{
|
{
|
||||||
|
|||||||
-14
@@ -158,18 +158,4 @@ public class MixinLevelRenderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER < MC_1_19_4
|
|
||||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I"), method = "renderLevel")
|
|
||||||
public void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
|
|
||||||
#elif MC_VER < MC_1_20_1
|
|
||||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I"), method = "renderLevel")
|
|
||||||
public void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
|
|
||||||
#else
|
|
||||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I"), method = "renderLevel")
|
|
||||||
private void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
ChunkWrapper.syncedUpdateClientLightStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package com.seibel.distanthorizons.forge.mixins.client;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.updater.UpdateModScreen;
|
import com.seibel.distanthorizons.common.wrappers.gui.updater.UpdateModScreen;
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
|
||||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.jar.installer.GitlabGetter;
|
import com.seibel.distanthorizons.core.jar.installer.GitlabGetter;
|
||||||
@@ -13,9 +11,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.gui.screens.TitleScreen;
|
import net.minecraft.client.gui.screens.TitleScreen;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#if MC_VER == MC_1_16_5
|
||||||
|
|
||||||
|
package com.seibel.distanthorizons.forge.mixins.server;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.misc.IMixinServerPlayer;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(Entity.class)
|
||||||
|
public class MixinEntity
|
||||||
|
{
|
||||||
|
@Inject(at = @At("TAIL"), method = "setLevel")
|
||||||
|
public void setLevel(Level level, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
if (this instanceof IMixinServerPlayer)
|
||||||
|
{
|
||||||
|
((IMixinServerPlayer) this).distantHorizons$setDimensionChangeDestination((ServerLevel) level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
package com.seibel.distanthorizons.forge.mixins.server;
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(Entity.class)
|
||||||
|
public class MixinEntity
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
+11
-10
@@ -43,25 +43,26 @@ public class MixinServerPlayer implements IMixinServerPlayer
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public ServerLevel distantHorizons$getDimensionChangeDestination()
|
public ServerLevel distantHorizons$getDimensionChangeDestination()
|
||||||
{
|
{ return this.distantHorizons$dimensionChangeDestination; }
|
||||||
return this.distantHorizons$dimensionChangeDestination;
|
|
||||||
}
|
#if MC_VER == MC_1_16_5
|
||||||
|
@Override
|
||||||
|
public void distantHorizons$setDimensionChangeDestination(ServerLevel dimensionChangeDestination)
|
||||||
|
{ this.distantHorizons$dimensionChangeDestination = dimensionChangeDestination; }
|
||||||
|
#endif
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "changeDimension", remap = false)
|
@Inject(at = @At("HEAD"), method = "changeDimension", remap = false)
|
||||||
public void changeDimension(ServerLevel destination, ITeleporter teleporter, CallbackInfoReturnable<Entity> cir)
|
public void changeDimension(ServerLevel destination, ITeleporter teleporter, CallbackInfoReturnable<Entity> cir)
|
||||||
{
|
{ this.distantHorizons$dimensionChangeDestination = destination; }
|
||||||
this.distantHorizons$dimensionChangeDestination = destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MC_VER >= MC_1_20_1
|
#if MC_VER >= MC_1_20_1
|
||||||
@Inject(at = @At("RETURN"), method = "setServerLevel")
|
@Inject(at = @At("RETURN"), method = "setServerLevel")
|
||||||
public void setServerLevel(ServerLevel level, CallbackInfo ci)
|
public void setServerLevel(ServerLevel level, CallbackInfo ci)
|
||||||
#else
|
{ this.distantHorizons$dimensionChangeDestination = null; }
|
||||||
|
#elif MC_VER >= MC_1_17_1
|
||||||
@Inject(at = @At("RETURN"), method = "setLevel")
|
@Inject(at = @At("RETURN"), method = "setLevel")
|
||||||
public void setLevel(ServerLevel level, CallbackInfo ci)
|
public void setLevel(ServerLevel level, CallbackInfo ci)
|
||||||
|
{ this.distantHorizons$dimensionChangeDestination = null; }
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
this.distantHorizons$dimensionChangeDestination = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
"server.MixinChunkGenerator",
|
"server.MixinChunkGenerator",
|
||||||
"server.MixinTFChunkGenerator",
|
"server.MixinTFChunkGenerator",
|
||||||
"server.MixinChunkMap",
|
"server.MixinChunkMap",
|
||||||
"server.MixinServerPlayer"
|
"server.MixinServerPlayer",
|
||||||
|
"server.MixinEntity"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"client.MixinClientPacketListener",
|
"client.MixinClientPacketListener",
|
||||||
|
|||||||
+2
-2
@@ -5,8 +5,8 @@ org.gradle.caching=true
|
|||||||
|
|
||||||
# Mod Info
|
# Mod Info
|
||||||
mod_name=DistantHorizons
|
mod_name=DistantHorizons
|
||||||
mod_version=2.2.2-a-dev
|
mod_version=2.3.0-a-dev
|
||||||
api_version=3.0.0
|
api_version=4.0.0
|
||||||
maven_group=com.seibel.distanthorizons
|
maven_group=com.seibel.distanthorizons
|
||||||
mod_readable_name=Distant Horizons
|
mod_readable_name=Distant Horizons
|
||||||
mod_description=This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow.
|
mod_description=This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow.
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ loom {
|
|||||||
client {
|
client {
|
||||||
client()
|
client()
|
||||||
setConfigName("NeoForge Client")
|
setConfigName("NeoForge Client")
|
||||||
ideConfigGenerated(false)
|
ideConfigGenerated(false) // When true a run configuration file will be generated for IDE's. By default only set to true for the root project.
|
||||||
runDir("../run/client")
|
runDir("../run/client")
|
||||||
vmArgs("-Dio.netty.leakDetection.level=advanced")
|
vmArgs("-Dio.netty.leakDetection.level=advanced") // https://netty.io/wiki/reference-counted-objects.html#leak-detection-levels
|
||||||
programArgs("--username", "Dev")
|
programArgs("--username", "Dev")
|
||||||
}
|
}
|
||||||
server {
|
server {
|
||||||
|
|||||||
@@ -87,10 +87,7 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerEvents()
|
public void registerEvents() { NeoForge.EVENT_BUS.register(this); }
|
||||||
{
|
|
||||||
NeoForge.EVENT_BUS.register(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -80,13 +80,9 @@ public class NeoforgeMain extends AbstractModInitializer
|
|||||||
// networking //
|
// networking //
|
||||||
//============//
|
//============//
|
||||||
public void registerNetworkingClient(RegisterPayloadHandlersEvent event)
|
public void registerNetworkingClient(RegisterPayloadHandlersEvent event)
|
||||||
{
|
{ NeoforgePluginPacketSender.setPacketHandler(event, ClientApi.INSTANCE::pluginMessageReceived); }
|
||||||
NeoforgePluginPacketSender.setPacketHandler(event, ClientApi.INSTANCE::pluginMessageReceived);
|
|
||||||
}
|
|
||||||
public void registerNetworkingServer(RegisterPayloadHandlersEvent event)
|
public void registerNetworkingServer(RegisterPayloadHandlersEvent event)
|
||||||
{
|
{ NeoforgePluginPacketSender.setPacketHandler(event, ServerApi.INSTANCE::pluginMessageReceived); }
|
||||||
NeoforgePluginPacketSender.setPacketHandler(event, ServerApi.INSTANCE::pluginMessageReceived);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+9
-15
@@ -3,7 +3,7 @@ package com.seibel.distanthorizons.neoforge;
|
|||||||
import com.seibel.distanthorizons.common.CommonPacketPayload;
|
import com.seibel.distanthorizons.common.CommonPacketPayload;
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
||||||
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
||||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
@@ -16,13 +16,11 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
public class NeoforgePluginPacketSender extends AbstractPluginPacketSender
|
public class NeoforgePluginPacketSender extends AbstractPluginPacketSender
|
||||||
{
|
{
|
||||||
private static BiConsumer<IServerPlayerWrapper, NetworkMessage> packetConsumer;
|
private static BiConsumer<IServerPlayerWrapper, AbstractNetworkMessage> packetConsumer;
|
||||||
|
|
||||||
public static void setPacketHandler(RegisterPayloadHandlersEvent event, Consumer<NetworkMessage> consumer)
|
public static void setPacketHandler(RegisterPayloadHandlersEvent event, Consumer<AbstractNetworkMessage> consumer)
|
||||||
{
|
{ setPacketHandler(event, (player, buffer) -> consumer.accept(buffer)); }
|
||||||
setPacketHandler(event, (player, buffer) -> consumer.accept(buffer));
|
public static void setPacketHandler(RegisterPayloadHandlersEvent event, BiConsumer<IServerPlayerWrapper, AbstractNetworkMessage> consumer)
|
||||||
}
|
|
||||||
public static void setPacketHandler(RegisterPayloadHandlersEvent event, BiConsumer<IServerPlayerWrapper, NetworkMessage> consumer)
|
|
||||||
{
|
{
|
||||||
packetConsumer = consumer;
|
packetConsumer = consumer;
|
||||||
|
|
||||||
@@ -42,15 +40,11 @@ public class NeoforgePluginPacketSender extends AbstractPluginPacketSender
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPluginPacketClient(NetworkMessage message)
|
public void sendToServer(AbstractNetworkMessage message)
|
||||||
{
|
{ PacketDistributor.sendToServer(new CommonPacketPayload(message)); }
|
||||||
PacketDistributor.sendToServer(new CommonPacketPayload(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPluginPacketServer(ServerPlayer serverPlayer, NetworkMessage message)
|
public void sendToClient(ServerPlayer serverPlayer, AbstractNetworkMessage message)
|
||||||
{
|
{ PacketDistributor.sendToPlayer(serverPlayer, new CommonPacketPayload(message)); }
|
||||||
PacketDistributor.sendToPlayer(serverPlayer, new CommonPacketPayload(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+3
-11
@@ -129,15 +129,10 @@ public class NeoforgeServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event)
|
public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event) { this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event)); }
|
||||||
{
|
|
||||||
this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event));
|
|
||||||
}
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void playerLoggedOutEvent(PlayerEvent.PlayerLoggedOutEvent event)
|
public void playerLoggedOutEvent(PlayerEvent.PlayerLoggedOutEvent event)
|
||||||
{
|
{ this.serverApi.serverPlayerDisconnectEvent(getServerPlayerWrapper(event)); }
|
||||||
this.serverApi.serverPlayerDisconnectEvent(getServerPlayerWrapper(event));
|
|
||||||
}
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent event)
|
public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent event)
|
||||||
{
|
{
|
||||||
@@ -161,9 +156,6 @@ public class NeoforgeServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
return getServerLevelWrapper(event.getEntity().getServer().getLevel(resourceKey));
|
return getServerLevelWrapper(event.getEntity().getServer().getLevel(resourceKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ServerPlayerWrapper getServerPlayerWrapper(PlayerEvent event)
|
private static ServerPlayerWrapper getServerPlayerWrapper(PlayerEvent event) { return ServerPlayerWrapper.getWrapper((ServerPlayer) event.getEntity()); }
|
||||||
{
|
|
||||||
return ServerPlayerWrapper.getWrapper((ServerPlayer) event.getEntity());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-17
@@ -142,22 +142,5 @@ public class MixinLevelRenderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER < MC_1_19_4
|
|
||||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I"), method = "renderLevel")
|
|
||||||
public void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
|
|
||||||
#elif MC_VER < MC_1_20_1
|
|
||||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I"), method = "renderLevel")
|
|
||||||
public void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
|
|
||||||
#elif MC_VER < MC_1_20_6
|
|
||||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I"), method = "renderLevel")
|
|
||||||
private void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
|
|
||||||
#else
|
|
||||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I"), method = "renderLevel")
|
|
||||||
private void callAfterRunUpdates(CallbackInfo ci)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
ChunkWrapper.syncedUpdateClientLightStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-9
@@ -43,24 +43,20 @@ public class MixinServerPlayer implements IMixinServerPlayer
|
|||||||
@Nullable
|
@Nullable
|
||||||
private ServerLevel distantHorizons$dimensionChangeDestination;
|
private ServerLevel distantHorizons$dimensionChangeDestination;
|
||||||
|
|
||||||
|
|
||||||
|
@Unique
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public ServerLevel distantHorizons$getDimensionChangeDestination()
|
public ServerLevel distantHorizons$getDimensionChangeDestination()
|
||||||
{
|
{ return this.distantHorizons$dimensionChangeDestination; }
|
||||||
return this.distantHorizons$dimensionChangeDestination;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "changeDimension")
|
@Inject(at = @At("HEAD"), method = "changeDimension")
|
||||||
#if MC_VER >= MC_1_21_1
|
#if MC_VER >= MC_1_21_1
|
||||||
public void changeDimension(DimensionTransition dimensionTransition, CallbackInfoReturnable<Entity> cir)
|
public void changeDimension(DimensionTransition dimensionTransition, CallbackInfoReturnable<Entity> cir)
|
||||||
{
|
{ this.distantHorizons$dimensionChangeDestination = dimensionTransition.newLevel(); }
|
||||||
this.distantHorizons$dimensionChangeDestination = dimensionTransition.newLevel();
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
public void changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> cir)
|
public void changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> cir)
|
||||||
{
|
{ this.distantHorizons$dimensionChangeDestination = destination; }
|
||||||
this.distantHorizons$dimensionChangeDestination = destination;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER >= MC_1_20_1
|
#if MC_VER >= MC_1_20_1
|
||||||
|
|||||||
Executable → Regular
Executable → Regular
@@ -24,7 +24,7 @@ fabric_api_version=0.42.0+1.16
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ "iris": "*" }
|
fabric_incompatibility_list={ "iris": "*", "oculus": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ fabric_api_version=0.46.1+1.17
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ "iris": "*" }
|
fabric_incompatibility_list={ "iris": "*", "oculus": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ fabric_api_version=0.76.0+1.18.2
|
|||||||
immersive_portals_version=v1.4.11-1.18
|
immersive_portals_version=v1.4.11-1.18
|
||||||
canvas_version=mc118:1.0.2616
|
canvas_version=mc118:1.0.2616
|
||||||
|
|
||||||
fabric_incompatibility_list={ "iris": "*" }
|
fabric_incompatibility_list={ "iris": "*", "oculus": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ fabric_api_version=0.76.1+1.19.2
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=mc119-1.0.2480
|
canvas_version=mc119-1.0.2480
|
||||||
|
|
||||||
fabric_incompatibility_list={ "iris": "*" }
|
fabric_incompatibility_list={ "iris": "*", "oculus": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ fabric_api_version=0.87.1+1.19.4
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ "iris": "*" }
|
fabric_incompatibility_list={ "iris": "*", "oculus": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ fabric_api_version=0.90.4+1.20.1
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ "iris": "<=1.7.4" }
|
fabric_incompatibility_list={ "iris": "<=1.7.4", "oculus": "<=1.7.0" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ fabric_api_version=0.90.4+1.20.2
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ "iris": "<=1.7.4" }
|
fabric_incompatibility_list={ "iris": "<=1.7.4", "oculus": "<=1.7.0" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ fabric_api_version=0.91.2+1.20.4
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ "iris": "<=1.7.4" }
|
fabric_incompatibility_list={ "iris": "<=1.7.4", "oculus": "<=1.7.0" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ fabric_api_version=0.97.8+1.20.6
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ "iris": "<=1.7.4" }
|
fabric_incompatibility_list={ "iris": "<=1.7.4", "oculus": "<=1.7.0" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ fabric_api_version=0.100.1+1.21
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ "iris": "<=1.7.4" }
|
fabric_incompatibility_list={ "iris": "<=1.7.4", "oculus": "<=1.7.0" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
Reference in New Issue
Block a user