Merge remote-tracking branch 'upstream/main'

# Conflicts:
#	common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java
#	common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java
#	common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java
#	common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java
#	common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ServerLevelWrapper.java
#	coreSubProjects
#	fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java
#	forge/src/main/java/com/seibel/distanthorizons/forge/ForgeClientProxy.java
This commit is contained in:
Steveplays28
2023-08-15 15:55:33 +02:00
114 changed files with 5031 additions and 3870 deletions
@@ -60,7 +60,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
/**
* This handles all events sent to the client,
* and is the starting point for most of the mod.
*
*
* @author James_Seibel
* @version 2023-7-27
*/
@@ -213,7 +213,7 @@ public class ForgeClientProxy
if (GetLevel(event) instanceof ClientLevel)
{
IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) GetLevel(event));
IChunkWrapper chunk = new ChunkWrapper(event.getChunk() , GetLevel(event), wrappedLevel);
IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetLevel(event), wrappedLevel);
ClientApi.INSTANCE.clientChunkSaveEvent(chunk, ClientLevelWrapper.getWrapper((ClientLevel) GetLevel(event)));
}
}
@@ -257,7 +257,7 @@ public class ForgeClientProxy
// server accepted versions
ForgeClientProxy::isReceivedProtocolVersionAcceptable
);
multiversePluginChannel.registerMessage(0/*should be incremented for each simple channel we listen to*/, ByteBuf.class,
// encoder
(pack, friendlyByteBuf) -> { },
@@ -66,6 +66,7 @@ import org.apache.logging.log4j.Logger;
// these imports change due to forge refactoring classes in 1.19
#if PRE_MC_1_19_2
import net.minecraftforge.client.model.data.ModelDataMap;
import java.util.Random;
#else
import net.minecraft.util.RandomSource;
@@ -92,7 +93,7 @@ public class ForgeMain implements LodForgeMethodCaller
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
public static ForgeClientProxy client_proxy = null;
public static ForgeServerProxy server_proxy = null;
public ForgeMain()
{
DependencySetup.createClientBindings();
@@ -103,27 +104,28 @@ public class ForgeMain implements LodForgeMethodCaller
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::initClient);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::initDedicated);
}
private void initClient(final FMLClientSetupEvent event)
{
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null);
LOGGER.info("Initializing Mod");
LodCommonMain.startup(this);
ForgeDependencySetup.createInitialBindings();
LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
// Print git info (Useful for dev builds)
LOGGER.info("DH Branch: "+ ModGitInfo.Git_Main_Branch);
LOGGER.info("DH Commit: "+ ModGitInfo.Git_Main_Commit);
LOGGER.info("DH-Core Commit: "+ ModGitInfo.Git_Core_Commit);
LOGGER.info("DH Branch: " + ModGitInfo.Git_Main_Branch);
LOGGER.info("DH Commit: " + ModGitInfo.Git_Main_Commit);
LOGGER.info("DH-Core Commit: " + ModGitInfo.Git_Core_Commit);
client_proxy = new ForgeClientProxy();
MinecraftForge.EVENT_BUS.register(client_proxy);
server_proxy = new ForgeServerProxy(false);
MinecraftForge.EVENT_BUS.register(server_proxy);
if (ReflectionHandler.INSTANCE.optifinePresent()) {
if (ReflectionHandler.INSTANCE.optifinePresent())
{
ModAccessorInjector.INSTANCE.bind(IOptifineAccessor.class, new OptifineAccessor());
}
@@ -141,14 +143,14 @@ public class ForgeMain implements LodForgeMethodCaller
ForgeClientProxy.setupNetworkingListeners(event);
LOGGER.info(ModInfo.READABLE_NAME + " Initialized");
ApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null);
// Init config
// The reason im initialising in this rather than the post init process is cus im using this for the auto updater
LodCommonMain.initConfig();
}
private void initDedicated(final FMLDedicatedServerSetupEvent event)
{
// DependencySetup.createServerBindings();
@@ -159,39 +161,43 @@ public class ForgeMain implements LodForgeMethodCaller
//
postInitCommon();
}
private void postInitCommon()
{
LOGGER.info("Post-Initializing Mod");
ForgeDependencySetup.runDelayedSetup();
LOGGER.info("Mod Post-Initialized");
}
#if PRE_MC_1_19_2
private final ModelDataMap modelData = new ModelDataMap.Builder().build();
#else
private final ModelData modelData = ModelData.EMPTY;
#endif
@Override
#if PRE_MC_1_19_2
public List<BakedQuad> getQuads(MinecraftClientWrapper mc, Block block, BlockState blockState, Direction direction, Random random) {
public List<BakedQuad> getQuads(MinecraftClientWrapper mc, Block block, BlockState blockState, Direction direction, Random random)
{
return mc.getModelManager().getBlockModelShaper().getBlockModel(block.defaultBlockState()).getQuads(blockState, direction, random, modelData);
}
#else
public List<BakedQuad> getQuads(MinecraftClientWrapper mc, Block block, BlockState blockState, Direction direction, RandomSource random) {
return mc.getModelManager().getBlockModelShaper().getBlockModel(block.defaultBlockState()).getQuads(blockState, direction, random, modelData #if POST_MC_1_19_2, RenderType.solid() #endif);
public List<BakedQuad> getQuads(MinecraftClientWrapper mc, Block block, BlockState blockState, Direction direction, RandomSource random)
{
return mc.getModelManager().getBlockModelShaper().getBlockModel(block.defaultBlockState()).getQuads(blockState, direction, random, modelData #if POST_MC_1_19_2 , RenderType.solid() #endif );
}
#endif
@Override //TODO: Check this if its still needed
public int colorResolverGetColor(ColorResolver resolver, Biome biome, double x, double z) {
public int colorResolverGetColor(ColorResolver resolver, Biome biome, double x, double z)
{
#if MC_1_17_1______Still_needed
return resolver.m_130045_(biome, x, z);
#else
return resolver.getColor(biome, x, z);
#endif
}
}
@@ -38,38 +38,38 @@ import java.util.function.Supplier;
public class ForgeServerProxy
{
#if PRE_MC_1_19_2
private static LevelAccessor GetLevel(WorldEvent e) { return e.getWorld(); }
#else
private static LevelAccessor GetLevel(LevelEvent e) { return e.getLevel(); }
#if PRE_MC_1_19_2
private static LevelAccessor GetLevel(WorldEvent e) { return e.getWorld(); }
#else
private static LevelAccessor GetLevel(LevelEvent e) { return e.getLevel(); }
#endif
private final ServerApi serverApi = ServerApi.INSTANCE;
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
private final boolean isDedicated;
public static Supplier<Boolean> isGenerationThreadChecker = null;
public ForgeServerProxy(boolean isDedicated)
private final ServerApi serverApi = ServerApi.INSTANCE;
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
private final boolean isDedicated;
public static Supplier<Boolean> isGenerationThreadChecker = null;
public ForgeServerProxy(boolean isDedicated)
{
this.isDedicated = isDedicated;
isGenerationThreadChecker = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
}
private boolean isValidTime()
private boolean isValidTime()
{
if (this.isDedicated)
{
return true;
}
//FIXME: This may cause init issue...
return !(Minecraft.getInstance().screen instanceof TitleScreen);
}
private ServerLevelWrapper getLevelWrapper(ServerLevel level) { return ServerLevelWrapper.getWrapper(level); }
// ServerTickEvent (at end)
@SubscribeEvent
public void serverTickEvent(TickEvent.ServerTickEvent event)
private ServerLevelWrapper getLevelWrapper(ServerLevel level) { return ServerLevelWrapper.getWrapper(level); }
// ServerTickEvent (at end)
@SubscribeEvent
public void serverTickEvent(TickEvent.ServerTickEvent event)
{
if (event.phase == TickEvent.Phase.END)
{
@@ -79,81 +79,86 @@ public class ForgeServerProxy
}
}
}
// ServerWorldLoadEvent
@SubscribeEvent
public void dedicatedWorldLoadEvent(#if MC_1_16_5 || MC_1_17_1 FMLServerAboutToStartEvent #else ServerAboutToStartEvent #endif event)
// ServerWorldLoadEvent
@SubscribeEvent
public void dedicatedWorldLoadEvent(#if MC_1_16_5 || MC_1_17_1 FMLServerAboutToStartEvent #else ServerAboutToStartEvent #endif event)
{
if (this.isValidTime())
{
this.serverApi.serverLoadEvent(this.isDedicated);
}
}
// ServerWorldUnloadEvent
@SubscribeEvent
public void serverWorldUnloadEvent(#if MC_1_16_5 || MC_1_17_1 FMLServerStoppingEvent #else ServerStoppingEvent #endif event)
// ServerWorldUnloadEvent
@SubscribeEvent
public void serverWorldUnloadEvent(#if MC_1_16_5 || MC_1_17_1 FMLServerStoppingEvent #else ServerStoppingEvent #endif event)
{
if (this.isValidTime())
{
this.serverApi.serverUnloadEvent();
}
}
// ServerLevelLoadEvent
@SubscribeEvent
// ServerLevelLoadEvent
@SubscribeEvent
#if PRE_MC_1_19_2
public void serverLevelLoadEvent(WorldEvent.Load event)
#else
public void serverLevelLoadEvent(LevelEvent.Load event)
public void serverLevelLoadEvent(LevelEvent.Load event)
#endif
{
if (isValidTime()) {
if (GetLevel(event) instanceof ServerLevel) {
serverApi.serverLevelLoadEvent(getLevelWrapper((ServerLevel) GetLevel(event)));
}
}
}
// ServerLevelUnloadEvent
@SubscribeEvent
{
if (isValidTime())
{
if (GetLevel(event) instanceof ServerLevel)
{
serverApi.serverLevelLoadEvent(getLevelWrapper((ServerLevel) GetLevel(event)));
}
}
}
// ServerLevelUnloadEvent
@SubscribeEvent
#if PRE_MC_1_19_2
public void serverLevelUnloadEvent(WorldEvent.Unload event)
#else
public void serverLevelUnloadEvent(LevelEvent.Unload event)
public void serverLevelUnloadEvent(LevelEvent.Unload event)
#endif
{
if (isValidTime()) {
if (GetLevel(event) instanceof ServerLevel) {
serverApi.serverLevelUnloadEvent(getLevelWrapper((ServerLevel) GetLevel(event)));
}
}
}
@SubscribeEvent
public void serverChunkLoadEvent(ChunkEvent.Load event)
{
if (this.isValidTime())
{
if (GetLevel(event) instanceof ServerLevel)
{
ServerLevelWrapper wrappedLevel = ServerLevelWrapper.getWrapper((ServerLevel) GetLevel(event));
IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetLevel(event), wrappedLevel);
this.serverApi.serverChunkLoadEvent(chunk, this.getLevelWrapper((ServerLevel) GetLevel(event)));
}
}
}
@SubscribeEvent
public void serverChunkSaveEvent(ChunkEvent.Unload event)
{
if (this.isValidTime())
{
if (isValidTime())
{
if (GetLevel(event) instanceof ServerLevel)
if (GetLevel(event) instanceof ServerLevel)
{
ServerLevelWrapper wrappedLevel = ServerLevelWrapper.getWrapper((ServerLevel) GetLevel(event));
IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetLevel(event), wrappedLevel);
this.serverApi.serverChunkSaveEvent(chunk, this.getLevelWrapper((ServerLevel) GetLevel(event)));
}
}
}
serverApi.serverLevelUnloadEvent(getLevelWrapper((ServerLevel) GetLevel(event)));
}
}
}
@SubscribeEvent
public void serverChunkLoadEvent(ChunkEvent.Load event)
{
if (this.isValidTime())
{
if (GetLevel(event) instanceof ServerLevel)
{
ServerLevelWrapper wrappedLevel = ServerLevelWrapper.getWrapper((ServerLevel) GetLevel(event));
IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetLevel(event), wrappedLevel);
this.serverApi.serverChunkLoadEvent(chunk, this.getLevelWrapper((ServerLevel) GetLevel(event)));
}
}
}
@SubscribeEvent
public void serverChunkSaveEvent(ChunkEvent.Unload event)
{
if (this.isValidTime())
{
if (GetLevel(event) instanceof ServerLevel)
{
ServerLevelWrapper wrappedLevel = ServerLevelWrapper.getWrapper((ServerLevel) GetLevel(event));
IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetLevel(event), wrappedLevel);
this.serverApi.serverChunkSaveEvent(chunk, this.getLevelWrapper((ServerLevel) GetLevel(event)));
}
}
}
}
@@ -12,50 +12,60 @@ import java.util.Set;
* @author coolGi
* @author cortex
*/
public class ForgeMixinPlugin implements IMixinConfigPlugin {
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (mixinClassName.contains(".mods.")) { // If the mixin wants to go into a mod then we check if that mod is loaded or not
return ModList.get().isLoaded(
mixinClassName
// What these 2 regex's do is get the mod name that we are checking out of the mixinClassName
// Eg. "com.seibel.distanthorizons.mixins.mods.sodium.MixinSodiumChunkRenderer" turns into "sodium"
.replaceAll("^.*mods.", "") // Replaces everything before the mods
.replaceAll("\\..*$", "") // Replaces everything after the mod name
);
}
return true;
}
@Override
public void onLoad(String mixinPackage) {
}
@Override
public String getRefMapperConfig() {
return null;
}
@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
}
@Override
public List<String> getMixins() {
return null;
}
@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
public class ForgeMixinPlugin implements IMixinConfigPlugin
{
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName)
{
if (mixinClassName.contains(".mods."))
{ // If the mixin wants to go into a mod then we check if that mod is loaded or not
return ModList.get().isLoaded(
mixinClassName
// What these 2 regex's do is get the mod name that we are checking out of the mixinClassName
// Eg. "com.seibel.distanthorizons.mixins.mods.sodium.MixinSodiumChunkRenderer" turns into "sodium"
.replaceAll("^.*mods.", "") // Replaces everything before the mods
.replaceAll("\\..*$", "") // Replaces everything after the mod name
);
}
return true;
}
@Override
public void onLoad(String mixinPackage)
{
}
@Override
public String getRefMapperConfig()
{
return null;
}
@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets)
{
}
@Override
public List<String> getMixins()
{
return null;
}
@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo)
{
}
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo)
{
}
}
@@ -12,13 +12,13 @@ public class MixinClientPacketListener
{
// TODO update fabric version as well
@Inject(method = "handleLogin", at = @At("HEAD"))
void onHandleLoginStart(CallbackInfo ci)
{
// not the best way to notify Core that we are no longer in the previous world, but it will have to do for now
ClientApi.INSTANCE.onClientOnlyDisconnected();
}
@Inject(method = "handleLogin", at = @At("RETURN"))
void onHandleLoginEnd(CallbackInfo ci) { ClientApi.INSTANCE.onClientOnlyConnected(); }
@Inject(method = "handleLogin", at = @At("HEAD"))
void onHandleLoginStart(CallbackInfo ci)
{
// not the best way to notify Core that we are no longer in the previous world, but it will have to do for now
ClientApi.INSTANCE.onClientOnlyDisconnected();
}
@Inject(method = "handleLogin", at = @At("RETURN"))
void onHandleLoginEnd(CallbackInfo ci) { ClientApi.INSTANCE.onClientOnlyConnected(); }
}
@@ -10,12 +10,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
@Mixin(DebugScreenOverlay.class)
public class MixinDebugScreenOverlay {
@Inject(method = "getSystemInformation", at = @At("RETURN"))
private void addCustomF3(CallbackInfoReturnable<List<String>> cir) {
List<String> messages = cir.getReturnValue();
F3Screen.addStringToDisplay(messages);
}
public class MixinDebugScreenOverlay
{
@Inject(method = "getSystemInformation", at = @At("RETURN"))
private void addCustomF3(CallbackInfoReturnable<List<String>> cir)
{
List<String> messages = cir.getReturnValue();
F3Screen.addStringToDisplay(messages);
}
}
@@ -42,15 +42,16 @@ import net.minecraft.world.level.material.FogType;
@Mixin(FogRenderer.class)
public class MixinFogRenderer {
public class MixinFogRenderer
{
// Using this instead of Float.MAX_VALUE because Sodium don't like it.
private static final float A_REALLY_REALLY_BIG_VALUE = 420694206942069.F;
private static final float A_EVEN_LARGER_VALUE = 42069420694206942069.F;
@Inject(at = @At("RETURN"),
method = "setupFog(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/FogRenderer$FogMode;FZF)V",
remap = #if MC_1_17_1 || MC_1_18_2 false #else true #endif) // Remap messiness due to this being weird in forge
remap = #if MC_1_17_1 || MC_1_18_2 false #else true #endif ) // Remap messiness due to this being weird in forge
private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, float partTick, CallbackInfo callback)
{
#if PRE_MC_1_17_1
@@ -76,4 +77,5 @@ public class MixinFogRenderer {
#endif
}
}
}
@@ -16,27 +16,31 @@ public class MixinGameRenderer
{
private static final Logger LOGGER = LogManager.getLogger(MixinGameRenderer.class.getSimpleName());
#if POST_MC_1_17_1
// FIXME: This I think will dup multiple renderStartupEvent calls...
@Inject(method = {"reloadShaders", "preloadUiShader"}, at = @At("TAIL"))
public void onStartupShaders(CallbackInfo ci) {
LOGGER.info("Starting up renderer (forge)");
if (!DependencySetupDoneCheck.isDone) {
LOGGER.warn("Dependency setup is not done yet, skipping renderer this startup event!");
return;
}
ClientApi.INSTANCE.rendererStartupEvent();
}
#if POST_MC_1_17_1
// FIXME: This I think will dup multiple renderStartupEvent calls...
@Inject(method = {"reloadShaders", "preloadUiShader"}, at = @At("TAIL"))
public void onStartupShaders(CallbackInfo ci)
{
LOGGER.info("Starting up renderer (forge)");
if (!DependencySetupDoneCheck.isDone)
{
LOGGER.warn("Dependency setup is not done yet, skipping renderer this startup event!");
return;
}
ClientApi.INSTANCE.rendererStartupEvent();
}
@Inject(method = "shutdownShaders", at = @At("HEAD"))
public void onShutdownShaders(CallbackInfo ci) {
LOGGER.info("Shutting down renderer (forge)");
if (!DependencySetupDoneCheck.isDone) {
LOGGER.warn("Dependency setup is not done yet, skipping renderer this shutdown event!");
return;
}
ClientApi.INSTANCE.rendererShutdownEvent();
}
public void onShutdownShaders(CallbackInfo ci)
{
LOGGER.info("Shutting down renderer (forge)");
if (!DependencySetupDoneCheck.isDone)
{
LOGGER.warn("Dependency setup is not done yet, skipping renderer this shutdown event!");
return;
}
ClientApi.INSTANCE.rendererShutdownEvent();
}
#else
@@ -71,12 +71,13 @@ public class MixinLevelRenderer
private ClientLevel level;
@Unique
private static float previousPartialTicks = 0;
// TODO: Is there any reason why this is here? Can it be deleted?
public MixinLevelRenderer() {
public MixinLevelRenderer()
{
throw new NullPointerException("Null cannot be cast to non-null type.");
}
#if PRE_MC_1_17_1
@Inject(at = @At("RETURN"), method = "renderSky(Lcom/mojang/blaze3d/vertex/PoseStack;F)V")
private void renderSky(PoseStack matrixStackIn, float partialTicks, CallbackInfo callback)
@@ -90,18 +91,17 @@ public class MixinLevelRenderer
previousPartialTicks = partialTicks;
}
// TODO: Can we move this to forge's client proxy similarly to how fabric does it
#if PRE_MC_1_17_1
@Inject(at = @At("HEAD"),
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDD)V",
cancellable = true)
private void renderChunkLayer(RenderType renderType, PoseStack matrixStackIn, double xIn, double yIn, double zIn, CallbackInfo callback)
#elif PRE_MC_1_19_4
@Inject(at = @At("HEAD"),
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V",
cancellable = true)
private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback)
@Inject(at = @At("HEAD"),
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V",
cancellable = true)
private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback)
#else
@Inject(at = @At("HEAD"),
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V",
@@ -147,38 +147,38 @@ public class MixinLevelRenderer
}
}
if (Config.Client.Advanced.Debugging.lodOnlyMode.get())
if (Config.Client.Advanced.Debugging.lodOnlyMode.get())
{
callback.cancel();
}
}
@Redirect(method =
"Lnet/minecraft/client/renderer/LevelRenderer;" +
"renderLevel(Lcom/mojang/blaze3d/vertex/PoseStack;" +
"FJZLnet/minecraft/client/Camera;" +
"Lnet/minecraft/client/renderer/GameRenderer;" +
"Lnet/minecraft/client/renderer/LightTexture;" +
"Lnet/minecraft/client/renderer/LevelRenderer;" +
"renderLevel(Lcom/mojang/blaze3d/vertex/PoseStack;" +
"FJZLnet/minecraft/client/Camera;" +
"Lnet/minecraft/client/renderer/GameRenderer;" +
"Lnet/minecraft/client/renderer/LightTexture;" +
#if PRE_MC_1_19_4
"Lcom/mojang/math/Matrix4f;)V"
#else
"Lorg/joml/Matrix4f;)V"
#endif
,
at = @At(
value = "INVOKE",
#if PRE_MC_1_20_1
target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I"
#else
target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I"
#endif
))
private int callAfterRunUpdates(LevelLightEngine light #if PRE_MC_1_20_1 , int pos, boolean isQueueEmpty, boolean updateBlockLight #endif)
"Lcom/mojang/math/Matrix4f;)V"
#else
"Lorg/joml/Matrix4f;)V"
#endif
,
at = @At(
value = "INVOKE",
#if PRE_MC_1_20_1
target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I"
#else
target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I"
#endif
))
private int callAfterRunUpdates(LevelLightEngine light #if PRE_MC_1_20_1 , int pos, boolean isQueueEmpty, boolean updateBlockLight #endif )
{
#if PRE_MC_1_20_1
int r = light.runUpdates(pos, isQueueEmpty, updateBlockLight);
#else
int r = light.runLightUpdates();
int r = light.runLightUpdates();
#endif
ChunkWrapper.syncedUpdateClientLightStatus();
return r;
@@ -12,16 +12,19 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LightTexture.class)
public class MixinLightmap {
@Shadow
@Final
public NativeImage lightPixels;
@Inject(method="updateLightTexture", at=@At(
value="INVOKE",
target="Lnet/minecraft/client/renderer/texture/DynamicTexture;upload()V"))
public void updateLightTexture(float f, CallbackInfo ci) {
//ApiShared.LOGGER.info("Lightmap update");
MinecraftRenderWrapper.INSTANCE.updateLightmap(lightPixels);
}
public class MixinLightmap
{
@Shadow
@Final
public NativeImage lightPixels;
@Inject(method = "updateLightTexture", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/texture/DynamicTexture;upload()V"))
public void updateLightTexture(float f, CallbackInfo ci)
{
//ApiShared.LOGGER.info("Lightmap update");
MinecraftRenderWrapper.INSTANCE.updateLightmap(lightPixels);
}
}
@@ -23,31 +23,36 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Minecraft.class)
public class MixinMinecraft
{
@Redirect(
method = "<init>(Lnet/minecraft/client/main/GameConfig;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screens/Screen;)V")
)
public void onOpenScreen(Minecraft instance, Screen guiScreen)
@Redirect(
method = "<init>(Lnet/minecraft/client/main/GameConfig;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screens/Screen;)V")
)
public void onOpenScreen(Minecraft instance, Screen guiScreen)
{
if (!Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get())
if (!Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get())
{
// Don't do anything if the user doesn't want it
instance.setScreen(guiScreen); // Sets the screen back to the vanilla screen as if nothing ever happened
return;
}
if (SelfUpdater.onStart()) {
instance.setScreen(new UpdateModScreen(
new TitleScreen(false), // We don't want to use the vanilla title screen as it would fade the buttons
ModrinthGetter.getLatestIDForVersion(SingletonInjector.INSTANCE.get(IVersionConstants.class).getMinecraftVersion())
));
} else {
instance.setScreen(guiScreen); // Sets the screen back to the vanilla screen as if nothing ever happened
}
}
@Inject(at = @At("HEAD"), method = "close()V", remap = false)
public void close(CallbackInfo ci) {
SelfUpdater.onClose();
}
instance.setScreen(guiScreen); // Sets the screen back to the vanilla screen as if nothing ever happened
return;
}
if (SelfUpdater.onStart())
{
instance.setScreen(new UpdateModScreen(
new TitleScreen(false), // We don't want to use the vanilla title screen as it would fade the buttons
ModrinthGetter.getLatestIDForVersion(SingletonInjector.INSTANCE.get(IVersionConstants.class).getMinecraftVersion())
));
}
else
{
instance.setScreen(guiScreen); // Sets the screen back to the vanilla screen as if nothing ever happened
}
}
@Inject(at = @At("HEAD"), method = "close()V", remap = false)
public void close(CallbackInfo ci)
{
SelfUpdater.onClose();
}
}
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.forge.mixins.client;
import com.seibel.distanthorizons.common.wrappers.gui.GetConfigScreen;
@@ -44,34 +44,38 @@ import java.util.Objects;
* @version 12-02-2021
*/
@Mixin(OptionsScreen.class)
public class MixinOptionsScreen extends Screen {
// Get the texture for the button
private static final ResourceLocation ICON_TEXTURE = new ResourceLocation(ModInfo.ID,"textures/gui/button.png");
protected MixinOptionsScreen(Component title) {
super(title);
}
@Inject(at = @At("HEAD"),method = "init")
private void lodconfig$init(CallbackInfo ci) {
if (Config.Client.optionsButton.get())
this. #if PRE_MC_1_17_1 addButton #else addRenderableWidget #endif
(new TexturedButtonWidget(
// Where the button is on the screen
this.width / 2 - 180, this.height / 6 - 12,
// Width and height of the button
20, 20,
// Offset
0, 0,
// Some textuary stuff
20, ICON_TEXTURE, 20, 40,
// Create the button and tell it where to go
// For now it goes to the client option by default
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(GetConfigScreen.getScreen(this)),
// Add a title to the button
public class MixinOptionsScreen extends Screen
{
// Get the texture for the button
private static final ResourceLocation ICON_TEXTURE = new ResourceLocation(ModInfo.ID, "textures/gui/button.png");
protected MixinOptionsScreen(Component title)
{
super(title);
}
@Inject(at = @At("HEAD"), method = "init")
private void lodconfig$init(CallbackInfo ci)
{
if (Config.Client.optionsButton.get())
this. #if PRE_MC_1_17_1 addButton #else addRenderableWidget #endif
(new TexturedButtonWidget(
// Where the button is on the screen
this.width / 2 - 180, this.height / 6 - 12,
// Width and height of the button
20, 20,
// Offset
0, 0,
// Some textuary stuff
20, ICON_TEXTURE, 20, 40,
// Create the button and tell it where to go
// For now it goes to the client option by default
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(GetConfigScreen.getScreen(this)),
// Add a title to the button
#if PRE_MC_1_19_2
new TranslatableComponent(ModInfo.ID + ".title")));
new TranslatableComponent(ModInfo.ID + ".title")));
#else
Component.translatable(ModInfo.ID + ".title")));
Component.translatable(ModInfo.ID + ".title")));
#endif
}
}
}
@@ -15,16 +15,17 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(TextureUtil.class)
public class MixinTextureUtil
{
@Redirect(method = "prepareImage(Lcom/mojang/blaze3d/platform/NativeImage$InternalGlFormat;IIII)V",
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_texParameter(IIF)V"), remap=false)
private static void setLodBias(int target, int pname, float param)
@Redirect(method = "prepareImage(Lcom/mojang/blaze3d/platform/NativeImage$InternalGlFormat;IIII)V",
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_texParameter(IIF)V"), remap = false)
private static void setLodBias(int target, int pname, float param)
{
float biasValue = Config.Client.Advanced.Graphics.AdvancedGraphics.lodBias.get().floatValue();
if (biasValue != 0)
float biasValue = Config.Client.Advanced.Graphics.AdvancedGraphics.lodBias.get().floatValue();
if (biasValue != 0)
{
// The target is GL11.GL_TEXTURE_2D
// And the pname is GL14.GL_TEXTURE_LOD_BIAS
GlStateManager._texParameter(target, pname, biasValue);
}
}
// The target is GL11.GL_TEXTURE_2D
// And the pname is GL14.GL_TEXTURE_LOD_BIAS
GlStateManager._texParameter(target, pname, biasValue);
}
}
}
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.forge.mixins.server;
import org.spongepowered.asm.mixin.Mixin;
@@ -33,25 +33,30 @@ import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.WorldgenRandom;
@Mixin(ChunkGenerator.class)
public class MixinChunkGenerator {
@Redirect(method = "applyBiomeDecoration", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/biome/Biome;generate(Lnet/minecraft/world/level/StructureFeatureManager;"
+ "Lnet/minecraft/world/level/chunk/ChunkGenerator;Lnet/minecraft/server/level/WorldGenRegion;J"
+ "Lnet/minecraft/world/level/levelgen/WorldgenRandom;Lnet/minecraft/core/BlockPos;)V"
))
private void wrapBiomeGenerateCall(Biome biome, StructureFeatureManager structFeatManager, ChunkGenerator generator,
WorldGenRegion genRegion, long l, WorldgenRandom random, BlockPos pos) {
synchronized(ChunkGenerator.class) {
//ApiShared.LOGGER.info("Generating Biome {} and acquired lock.", biome.getRegistryName());
biome.generate(structFeatManager, (ChunkGenerator)(Object)this, genRegion, l, random, pos);
}
//ApiShared.LOGGER.info("Released lock. Biome {} generated.", biome.getRegistryName());
}
public class MixinChunkGenerator
{
@Redirect(method = "applyBiomeDecoration", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/biome/Biome;generate(Lnet/minecraft/world/level/StructureFeatureManager;"
+ "Lnet/minecraft/world/level/chunk/ChunkGenerator;Lnet/minecraft/server/level/WorldGenRegion;J"
+ "Lnet/minecraft/world/level/levelgen/WorldgenRandom;Lnet/minecraft/core/BlockPos;)V"
))
private void wrapBiomeGenerateCall(
Biome biome, StructureFeatureManager structFeatManager, ChunkGenerator generator,
WorldGenRegion genRegion, long l, WorldgenRandom random, BlockPos pos)
{
synchronized (ChunkGenerator.class)
{
//ApiShared.LOGGER.info("Generating Biome {} and acquired lock.", biome.getRegistryName());
biome.generate(structFeatManager, (ChunkGenerator) (Object) this, genRegion, l, random, pos);
}
//ApiShared.LOGGER.info("Released lock. Biome {} generated.", biome.getRegistryName());
}
}
#else
@Mixin(ChunkGenerator.class)
public class MixinChunkGenerator {}
public class MixinChunkGenerator { }
#endif
@@ -57,5 +57,5 @@ public class MixinTFChunkGenerator
#else
@Mixin(ChunkGenerator.class)
class MixinTFChunkGenerator { }
class MixinTFChunkGenerator { }
#endif
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.forge.mixins.server;
import java.util.concurrent.ExecutorService;
@@ -35,10 +35,11 @@ import net.minecraft.Util;
@Mixin(Util.class)
public class MixinUtilBackgroundThread
{
private static boolean shouldApplyOverride() {
private static boolean shouldApplyOverride()
{
return DependencySetupDoneCheck.isDone && DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread.get();
}
@Inject(method = "backgroundExecutor", at = @At("HEAD"), cancellable = true)
private static void overrideUtil$backgroundExecutor(CallbackInfoReturnable<ExecutorService> ci)
{
@@ -48,7 +49,7 @@ public class MixinUtilBackgroundThread
ci.setReturnValue(new DummyRunExecutorService());
}
}
#if POST_MC_1_17_1
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Runnable;",
at = @At("HEAD"), cancellable = true)
@@ -73,5 +74,5 @@ public class MixinUtilBackgroundThread
}
}
#endif
}
@@ -16,8 +16,9 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.forge.mixins.server.unsafe;
import org.spongepowered.asm.mixin.Mixin;
#if POST_MC_1_18_2
@@ -35,15 +36,18 @@ import java.util.concurrent.Semaphore;
* FIXME: Recheck this // STILL check this
*/
@Mixin(ThreadingDetector.class)
public class MixinThreadingDetector {
@Mutable
@Shadow
private Semaphore lock;
@Inject(method = "<init>", at = @At("RETURN"))
private void setSemaphore(CallbackInfo ci) {
this.lock = new Semaphore(2);
}
public class MixinThreadingDetector
{
@Mutable
@Shadow
private Semaphore lock;
@Inject(method = "<init>", at = @At("RETURN"))
private void setSemaphore(CallbackInfo ci)
{
this.lock = new Semaphore(2);
}
}
#else
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.forge.wrappers;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
@@ -28,7 +28,7 @@ import com.seibel.distanthorizons.forge.wrappers.modAccessor.ModChecker;
* can access them in Core. <br>
* This needs to be called before any Core classes
* are loaded.
*
*
* @author James Seibel
* @author Ran
* @version 12-1-2021
@@ -39,8 +39,10 @@ public class ForgeDependencySetup
{
SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE);
}
public static void runDelayedSetup() {
public static void runDelayedSetup()
{
SingletonInjector.INSTANCE.runDelayedSetup();
}
}
@@ -16,17 +16,20 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.forge.wrappers.modAccessor;
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
import net.minecraftforge.fml.ModList;
public class ModChecker implements IModChecker {
public static final ModChecker INSTANCE = new ModChecker();
@Override
public boolean isModLoaded(String modid) {
return ModList.get().isLoaded(modid);
}
public class ModChecker implements IModChecker
{
public static final ModChecker INSTANCE = new ModChecker();
@Override
public boolean isModLoaded(String modid)
{
return ModList.get().isLoaded(modid);
}
}
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.forge.wrappers.modAccessor;
import java.util.HashSet;
@@ -26,13 +26,13 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.AbstractOpt
public class OptifineAccessor extends AbstractOptifineAccessor
{
@Override
public String getModName()
{
return "Optifine-Forge-1.18.X";
}
@Override
public HashSet<DhChunkPos> getNormalRenderedChunks()
{