Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
7219df485f | |||
1087941efb | |||
b3e6ec189a |
@@ -3,8 +3,8 @@ package wtf.hak.survivalfabric;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import wtf.hak.survivalfabric.config.client.ClientConfigManager;
|
||||
import wtf.hak.survivalfabric.features.AngleViewer;
|
||||
import wtf.hak.survivalfabric.features.RemoveDarknessEffect;
|
||||
import wtf.hak.survivalfabric.features.CameraShortcut;
|
||||
import wtf.hak.survivalfabric.features.RemoveDarknessEffect;
|
||||
import wtf.hak.survivalfabric.features.Zoom;
|
||||
|
||||
public class SurvivalFabricClient implements ClientModInitializer {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package wtf.hak.survivalfabric.config.client;
|
||||
|
||||
public class ClientConfig {
|
||||
public String configVersion = "1.1";
|
||||
public String configVersion = "1.2";
|
||||
|
||||
public boolean renderNetherFog = false;
|
||||
public boolean renderOverworldFog = false;
|
||||
@@ -17,4 +17,6 @@ public class ClientConfig {
|
||||
public float initialZoom = 20f;
|
||||
public boolean scrollToZoom = true;
|
||||
public float zoomStep = 2.5f;
|
||||
public boolean enableFullBright = true;
|
||||
public double fullBrightValue = 100f;
|
||||
}
|
||||
|
@@ -3,12 +3,18 @@ package wtf.hak.survivalfabric.config.client;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.option.SimpleOption;
|
||||
import wtf.hak.survivalfabric.SurvivalFabric;
|
||||
import wtf.hak.survivalfabric.SurvivalFabricClient;
|
||||
import wtf.hak.survivalfabric.config.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ClientConfigManager {
|
||||
|
||||
@@ -28,6 +34,7 @@ public class ClientConfigManager {
|
||||
try (FileReader reader = new FileReader(CONFIG_FILE)) {
|
||||
INSTANCE = GSON.fromJson(reader, ClientConfig.class);
|
||||
if (INSTANCE.configVersion.equalsIgnoreCase(new Config().configVersion)) {
|
||||
apply(INSTANCE);
|
||||
return INSTANCE;
|
||||
}
|
||||
INSTANCE.configVersion = new ClientConfig().configVersion;
|
||||
@@ -51,5 +58,20 @@ public class ClientConfigManager {
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error saving config: " + e.getMessage());
|
||||
}
|
||||
apply(config);
|
||||
}
|
||||
|
||||
public static void apply(ClientConfig config) {
|
||||
if(config.enableFullBright) {
|
||||
try {
|
||||
SimpleOption<Double> gammaOption = MinecraftClient.getInstance().options.getGamma();
|
||||
Field valueField = SimpleOption.class.getDeclaredField("value");
|
||||
valueField.setAccessible(true);
|
||||
valueField.set(gammaOption, config.fullBrightValue);
|
||||
} catch (Exception e) {
|
||||
SurvivalFabric.LOGGER.error("Failed to set fullbright value!");
|
||||
}
|
||||
} else if(MinecraftClient.getInstance().options.getGamma().getValue() == config.fullBrightValue)
|
||||
MinecraftClient.getInstance().options.getGamma().setValue(1d);
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.text.Text;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@@ -20,14 +19,12 @@ public class Zoom {
|
||||
|
||||
@Unique
|
||||
private static boolean initialSmoothZoom;
|
||||
@Unique
|
||||
private static boolean initialRenderHand;
|
||||
|
||||
public static void register() {
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
|
||||
if (ZOOM_BIND.isPressed() && !SHOULD_ZOOM) {
|
||||
if(getConfig().smoothCamera) {
|
||||
if (getConfig().smoothCamera) {
|
||||
initialSmoothZoom = MinecraftClient.getInstance().options.smoothCameraEnabled;
|
||||
MinecraftClient.getInstance().options.smoothCameraEnabled = true;
|
||||
}
|
||||
@@ -35,7 +32,7 @@ public class Zoom {
|
||||
} else if (!ZOOM_BIND.isPressed() && SHOULD_ZOOM) {
|
||||
SHOULD_ZOOM = false;
|
||||
ZOOM_STEP = 0;
|
||||
if(getConfig().smoothCamera) {
|
||||
if (getConfig().smoothCamera) {
|
||||
MinecraftClient.getInstance().options.smoothCameraEnabled = initialSmoothZoom;
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,9 @@ import wtf.hak.survivalfabric.config.client.ClientConfigManager;
|
||||
@Mixin(BlockEntityRenderer.class)
|
||||
public interface BlockEntityRendererMixin<T extends BlockEntity> {
|
||||
|
||||
/**
|
||||
* Manipulate Block Entity Render Distance
|
||||
*/
|
||||
@Inject(method = "getRenderDistance", at = @At("HEAD"), cancellable = true)
|
||||
private void getRenderDistance(CallbackInfoReturnable<Integer> cir) {
|
||||
if (ClientConfigManager.getConfig().manipulateBlockEntityDistance)
|
||||
|
@@ -12,6 +12,9 @@ import wtf.hak.survivalfabric.features.AngleViewer;
|
||||
@Mixin(Entity.class)
|
||||
public abstract class EntityMixin {
|
||||
|
||||
/**
|
||||
* Lock Teleport Head Movement
|
||||
*/
|
||||
@Inject(method = "setYaw", at = @At("HEAD"), cancellable = true)
|
||||
private void preventYawChange(float yaw, CallbackInfo ci) {
|
||||
if ((Object) this instanceof ClientPlayerEntity player) {
|
||||
@@ -21,6 +24,9 @@ public abstract class EntityMixin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock Teleport Head Movement
|
||||
*/
|
||||
@Inject(method = "setPitch", at = @At("HEAD"), cancellable = true)
|
||||
private void preventPitchChange(float pitch, CallbackInfo ci) {
|
||||
if ((Object) this instanceof ClientPlayerEntity player) {
|
||||
|
@@ -14,6 +14,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static wtf.hak.survivalfabric.config.client.ClientConfigManager.getConfig;
|
||||
|
||||
/**
|
||||
* Stop fog from rendering (if configured)
|
||||
*/
|
||||
public class FogMixins {
|
||||
|
||||
@Mixin(DimensionOrBossFogModifier.class)
|
||||
|
@@ -4,10 +4,7 @@ import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElement;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -29,7 +26,7 @@ public class GameRendererMixin {
|
||||
*/
|
||||
@WrapMethod(method = "renderHand")
|
||||
public void render(float tickProgress, boolean sleeping, Matrix4f positionMatrix, Operation<Void> original) {
|
||||
if(!Zoom.isZooming())
|
||||
if (!Zoom.isZooming())
|
||||
original.call(tickProgress, sleeping, positionMatrix);
|
||||
}
|
||||
|
||||
|
@@ -1,179 +1,105 @@
|
||||
package wtf.hak.survivalfabric.modmenu;
|
||||
|
||||
import dev.isxander.yacl3.api.*;
|
||||
import dev.isxander.yacl3.api.controller.*;
|
||||
import dev.isxander.yacl3.api.controller.DoubleSliderControllerBuilder;
|
||||
import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder;
|
||||
import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder;
|
||||
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import wtf.hak.survivalfabric.config.client.ClientConfig;
|
||||
import wtf.hak.survivalfabric.config.client.ClientConfigManager;
|
||||
|
||||
public class YACLConfigScreen {
|
||||
|
||||
public static Screen createConfigScreen(Screen parent) {
|
||||
ClientConfig defaultConfig = new ClientConfig();
|
||||
return YetAnotherConfigLib.createBuilder()
|
||||
.title(Text.literal("Survival Fabric Configuration").formatted(Formatting.BOLD))
|
||||
.category(createMainCategory())
|
||||
.category(createMainCategory(defaultConfig))
|
||||
.category(createRenderingCategory(defaultConfig))
|
||||
.save(ClientConfigManager::save)
|
||||
.build()
|
||||
.generateScreen(parent);
|
||||
}
|
||||
|
||||
private static ConfigCategory createMainCategory() {
|
||||
private static ConfigCategory createMainCategory(ClientConfig defaultConfig) {
|
||||
ConfigCategory.Builder categoryBuilder = ConfigCategory.createBuilder()
|
||||
.name(Text.literal("General Settings").formatted(Formatting.YELLOW))
|
||||
.tooltip(Text.literal("Common configuration options for Survival Fabric"));
|
||||
|
||||
// Create groups for different types of options
|
||||
OptionGroup.Builder renderingGroup = OptionGroup.createBuilder()
|
||||
.name(Text.literal("Rendering Options"))
|
||||
.description(OptionDescription.of(Text.literal("Options that control fog rendering and visual effects")))
|
||||
.collapsed(false);
|
||||
|
||||
OptionGroup.Builder gameplayGroup = OptionGroup.createBuilder()
|
||||
.name(Text.literal("Gameplay Options"))
|
||||
.description(OptionDescription.of(Text.literal("Options that affect gameplay mechanics")))
|
||||
.collapsed(false);
|
||||
|
||||
OptionGroup.Builder cameraGroup = OptionGroup.createBuilder()
|
||||
.name(Text.literal("Camera & Zoom"))
|
||||
.description(OptionDescription.of(Text.literal("Camera and zoom-related settings")))
|
||||
OptionGroup.Builder zoomGroup = OptionGroup.createBuilder()
|
||||
.name(Text.literal("Zoom Options"))
|
||||
.description(OptionDescription.of(Text.literal("Zoom-related settings")))
|
||||
.collapsed(false);
|
||||
|
||||
// === RENDERING OPTIONS ===
|
||||
|
||||
// Nether Fog
|
||||
renderingGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Render Nether Fog"))
|
||||
.description(OptionDescription.of(Text.literal("Enable or disable fog rendering in the Nether dimension")))
|
||||
.binding(
|
||||
false, // default
|
||||
() -> ClientConfigManager.getConfig().renderNetherFog,
|
||||
newValue -> ClientConfigManager.getConfig().renderNetherFog = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// Overworld Fog
|
||||
renderingGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Render Overworld Fog"))
|
||||
.description(OptionDescription.of(Text.literal("Enable or disable fog rendering in the Overworld dimension")))
|
||||
.binding(
|
||||
false, // default
|
||||
() -> ClientConfigManager.getConfig().renderOverworldFog,
|
||||
newValue -> ClientConfigManager.getConfig().renderOverworldFog = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// End Fog
|
||||
renderingGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Render End Fog"))
|
||||
.description(OptionDescription.of(Text.literal("Enable or disable fog rendering in the End dimension")))
|
||||
.binding(
|
||||
false, // default
|
||||
() -> ClientConfigManager.getConfig().renderEndFog,
|
||||
newValue -> ClientConfigManager.getConfig().renderEndFog = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// Lava Fog
|
||||
renderingGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Render Lava Fog"))
|
||||
.description(OptionDescription.of(Text.literal("Enable or disable fog when submerged in lava")))
|
||||
.binding(
|
||||
false, // default
|
||||
() -> ClientConfigManager.getConfig().renderLavaFog,
|
||||
newValue -> ClientConfigManager.getConfig().renderLavaFog = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// Water Fog
|
||||
renderingGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Render Water Fog"))
|
||||
.description(OptionDescription.of(Text.literal("Enable or disable fog when submerged in water")))
|
||||
.binding(
|
||||
false, // default
|
||||
() -> ClientConfigManager.getConfig().renderWaterFog,
|
||||
newValue -> ClientConfigManager.getConfig().renderWaterFog = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// Snow Fog
|
||||
renderingGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Render Snow Fog"))
|
||||
.description(OptionDescription.of(Text.literal("Enable or disable fog during snow weather")))
|
||||
.binding(
|
||||
false, // default
|
||||
() -> ClientConfigManager.getConfig().renderSnowFog,
|
||||
newValue -> ClientConfigManager.getConfig().renderSnowFog = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
//#region Gameplay Options
|
||||
|
||||
// Remove Darkness Effect
|
||||
renderingGroup.option(Option.<Boolean>createBuilder()
|
||||
gameplayGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Remove Darkness Effect"))
|
||||
.description(OptionDescription.of(Text.literal("Remove the darkness effect applied by the Warden and sculk shriekers")))
|
||||
.binding(
|
||||
true, // default
|
||||
defaultConfig.removeDarknessEffect, // default
|
||||
() -> ClientConfigManager.getConfig().removeDarknessEffect,
|
||||
newValue -> ClientConfigManager.getConfig().removeDarknessEffect = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// === GAMEPLAY OPTIONS ===
|
||||
|
||||
// Lock Teleport Head Movement
|
||||
gameplayGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Lock Teleport Head Movement"))
|
||||
.description(OptionDescription.of(Text.literal("Prevent head movement changes during teleportation")))
|
||||
.description(OptionDescription.of(Text.literal("Prevent head movement changes during angle teleportation")))
|
||||
.binding(
|
||||
true, // default
|
||||
defaultConfig.lockTeleportHeadMovement, // default
|
||||
() -> ClientConfigManager.getConfig().lockTeleportHeadMovement,
|
||||
newValue -> ClientConfigManager.getConfig().lockTeleportHeadMovement = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// Manipulate Block Entity Distance
|
||||
gameplayGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Manipulate Block Entity Distance"))
|
||||
.description(OptionDescription.of(Text.literal("Enable custom block entity rendering distance")))
|
||||
.name(Text.literal("Enable Fullbright"))
|
||||
.description(OptionDescription.of(Text.literal("See everything without constantly needing torches")))
|
||||
.binding(
|
||||
true, // default
|
||||
() -> ClientConfigManager.getConfig().manipulateBlockEntityDistance,
|
||||
newValue -> ClientConfigManager.getConfig().manipulateBlockEntityDistance = newValue
|
||||
defaultConfig.enableFullBright, // default
|
||||
() -> ClientConfigManager.getConfig().enableFullBright,
|
||||
newValue -> ClientConfigManager.getConfig().enableFullBright = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// Block Entity Range
|
||||
gameplayGroup.option(Option.<Integer>createBuilder()
|
||||
.name(Text.literal("Block Entity Range"))
|
||||
.description(OptionDescription.of(Text.literal("Maximum distance for block entity rendering (in blocks)")))
|
||||
gameplayGroup.option(Option.<Double>createBuilder()
|
||||
.name(Text.literal("Fullbright Value"))
|
||||
.description(OptionDescription.of(Text.literal("Select how bright you want the fullbright to be")))
|
||||
.binding(
|
||||
512, // default
|
||||
() -> ClientConfigManager.getConfig().blockEntityRange,
|
||||
newValue -> ClientConfigManager.getConfig().blockEntityRange = newValue
|
||||
defaultConfig.fullBrightValue, // default
|
||||
() -> ClientConfigManager.getConfig().fullBrightValue,
|
||||
newValue -> ClientConfigManager.getConfig().fullBrightValue = newValue
|
||||
)
|
||||
.controller(opt -> IntegerSliderControllerBuilder.create(opt)
|
||||
.range(16, 2048)
|
||||
.step(16)
|
||||
.formatValue(value -> Text.literal(value + " blocks")))
|
||||
.controller(opt -> DoubleSliderControllerBuilder.create(opt)
|
||||
.range(1d, 100d)
|
||||
.step(1d)
|
||||
.formatValue(value -> Text.literal(String.format("%.0f", value))))
|
||||
.build());
|
||||
|
||||
// === CAMERA & ZOOM OPTIONS ===
|
||||
//#endregion
|
||||
|
||||
//#region Zoom Options
|
||||
|
||||
// Smooth Camera
|
||||
cameraGroup.option(Option.<Boolean>createBuilder()
|
||||
zoomGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Smooth Camera"))
|
||||
.description(OptionDescription.of(Text.literal("Enable smooth camera transitions")))
|
||||
.binding(
|
||||
true, // default
|
||||
defaultConfig.smoothCamera, // default
|
||||
() -> ClientConfigManager.getConfig().smoothCamera,
|
||||
newValue -> ClientConfigManager.getConfig().smoothCamera = newValue
|
||||
)
|
||||
@@ -181,26 +107,26 @@ public class YACLConfigScreen {
|
||||
.build());
|
||||
|
||||
// Initial Zoom
|
||||
cameraGroup.option(Option.<Float>createBuilder()
|
||||
zoomGroup.option(Option.<Float>createBuilder()
|
||||
.name(Text.literal("Initial Zoom Level"))
|
||||
.description(OptionDescription.of(Text.literal("Default zoom level when activating zoom")))
|
||||
.binding(
|
||||
20f, // default
|
||||
defaultConfig.initialZoom, // default
|
||||
() -> ClientConfigManager.getConfig().initialZoom,
|
||||
newValue -> ClientConfigManager.getConfig().initialZoom = newValue
|
||||
)
|
||||
.controller(opt -> FloatSliderControllerBuilder.create(opt)
|
||||
.range(1.0f, 50.0f)
|
||||
.step(0.5f)
|
||||
.formatValue(value -> Text.literal(String.format("%.1fx", value))))
|
||||
.formatValue(value -> Text.literal(String.format("%.1f", value))))
|
||||
.build());
|
||||
|
||||
// Scroll to Zoom
|
||||
cameraGroup.option(Option.<Boolean>createBuilder()
|
||||
zoomGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Scroll to Zoom"))
|
||||
.description(OptionDescription.of(Text.literal("Allow using mouse wheel to adjust zoom level")))
|
||||
.binding(
|
||||
true, // default
|
||||
defaultConfig.scrollToZoom, // default
|
||||
() -> ClientConfigManager.getConfig().scrollToZoom,
|
||||
newValue -> ClientConfigManager.getConfig().scrollToZoom = newValue
|
||||
)
|
||||
@@ -208,11 +134,11 @@ public class YACLConfigScreen {
|
||||
.build());
|
||||
|
||||
// Zoom Step
|
||||
cameraGroup.option(Option.<Float>createBuilder()
|
||||
zoomGroup.option(Option.<Float>createBuilder()
|
||||
.name(Text.literal("Zoom Step"))
|
||||
.description(OptionDescription.of(Text.literal("Amount of zoom change per scroll wheel step")))
|
||||
.binding(
|
||||
2.5f, // default
|
||||
defaultConfig.zoomStep, // default
|
||||
() -> ClientConfigManager.getConfig().zoomStep,
|
||||
newValue -> ClientConfigManager.getConfig().zoomStep = newValue
|
||||
)
|
||||
@@ -222,10 +148,139 @@ public class YACLConfigScreen {
|
||||
.formatValue(value -> Text.literal(String.format("%.1f", value))))
|
||||
.build());
|
||||
|
||||
//#endregion
|
||||
|
||||
return categoryBuilder
|
||||
.group(renderingGroup.build())
|
||||
.group(gameplayGroup.build())
|
||||
.group(cameraGroup.build())
|
||||
.group(zoomGroup.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
private static ConfigCategory createRenderingCategory(ClientConfig defaultConfig) {
|
||||
ConfigCategory.Builder categoryBuilder = ConfigCategory.createBuilder()
|
||||
.name(Text.literal("Rendering Settings").formatted(Formatting.YELLOW))
|
||||
.tooltip(Text.literal("Common configuration options for Survival Fabric"));
|
||||
|
||||
OptionGroup.Builder fogGroup = OptionGroup.createBuilder()
|
||||
.name(Text.literal("Fog Options"))
|
||||
.description(OptionDescription.of(Text.literal("Options that control fog rendering")))
|
||||
.collapsed(false);
|
||||
|
||||
OptionGroup.Builder distanceGroup = OptionGroup.createBuilder()
|
||||
.name(Text.literal("Render Distance Options"))
|
||||
.description(OptionDescription.of(Text.literal("Options that control render distance related things")))
|
||||
.collapsed(false);
|
||||
|
||||
//#region Fog Options
|
||||
|
||||
// Nether Fog
|
||||
fogGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Render Nether Fog"))
|
||||
.description(OptionDescription.of(Text.literal("Enable or disable fog rendering in the Nether dimension")))
|
||||
.binding(
|
||||
defaultConfig.renderNetherFog, // default
|
||||
() -> ClientConfigManager.getConfig().renderNetherFog,
|
||||
newValue -> ClientConfigManager.getConfig().renderNetherFog = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// Overworld Fog
|
||||
fogGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Render Overworld Fog"))
|
||||
.description(OptionDescription.of(Text.literal("Enable or disable fog rendering in the Overworld dimension")))
|
||||
.binding(
|
||||
defaultConfig.renderOverworldFog, // default
|
||||
() -> ClientConfigManager.getConfig().renderOverworldFog,
|
||||
newValue -> ClientConfigManager.getConfig().renderOverworldFog = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// End Fog
|
||||
fogGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Render End Fog"))
|
||||
.description(OptionDescription.of(Text.literal("Enable or disable fog rendering in the End dimension")))
|
||||
.binding(
|
||||
defaultConfig.renderEndFog, // default
|
||||
() -> ClientConfigManager.getConfig().renderEndFog,
|
||||
newValue -> ClientConfigManager.getConfig().renderEndFog = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// Lava Fog
|
||||
fogGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Render Lava Fog"))
|
||||
.description(OptionDescription.of(Text.literal("Enable or disable fog when submerged in lava")))
|
||||
.binding(
|
||||
defaultConfig.renderLavaFog, // default
|
||||
() -> ClientConfigManager.getConfig().renderLavaFog,
|
||||
newValue -> ClientConfigManager.getConfig().renderLavaFog = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// Water Fog
|
||||
fogGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Render Water Fog"))
|
||||
.description(OptionDescription.of(Text.literal("Enable or disable fog when submerged in water")))
|
||||
.binding(
|
||||
defaultConfig.renderWaterFog, // default
|
||||
() -> ClientConfigManager.getConfig().renderWaterFog,
|
||||
newValue -> ClientConfigManager.getConfig().renderWaterFog = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// Snow Fog
|
||||
fogGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Render Snow Fog"))
|
||||
.description(OptionDescription.of(Text.literal("Enable or disable fog during snow weather")))
|
||||
.binding(
|
||||
defaultConfig.renderSnowFog, // default
|
||||
() -> ClientConfigManager.getConfig().renderSnowFog,
|
||||
newValue -> ClientConfigManager.getConfig().renderSnowFog = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Render Distance Options
|
||||
|
||||
// Manipulate Block Entity Distance
|
||||
distanceGroup.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.literal("Manipulate Block Entity Distance"))
|
||||
.description(OptionDescription.of(Text.literal("Enable custom block entity rendering distance")))
|
||||
.binding(
|
||||
defaultConfig.manipulateBlockEntityDistance, // default
|
||||
() -> ClientConfigManager.getConfig().manipulateBlockEntityDistance,
|
||||
newValue -> ClientConfigManager.getConfig().manipulateBlockEntityDistance = newValue
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build());
|
||||
|
||||
// Block Entity Range
|
||||
distanceGroup.option(Option.<Integer>createBuilder()
|
||||
.name(Text.literal("Block Entity Range"))
|
||||
.description(OptionDescription.of(Text.literal("Maximum distance for block entity rendering (in blocks)")))
|
||||
.binding(
|
||||
defaultConfig.blockEntityRange, // default
|
||||
() -> ClientConfigManager.getConfig().blockEntityRange,
|
||||
newValue -> ClientConfigManager.getConfig().blockEntityRange = newValue
|
||||
)
|
||||
.controller(opt -> IntegerSliderControllerBuilder.create(opt)
|
||||
.range(16, 1024)
|
||||
.step(16)
|
||||
.formatValue(value -> Text.literal(value + " blocks")))
|
||||
.build());
|
||||
|
||||
//#endregion
|
||||
|
||||
return categoryBuilder
|
||||
.group(fogGroup.build())
|
||||
.group(distanceGroup.build())
|
||||
.build();
|
||||
}
|
||||
}
|
@@ -32,7 +32,7 @@ public class TelekinesisHandler {
|
||||
}
|
||||
|
||||
public static int handleBlockExp(int original) {
|
||||
if(blockThreadLocal.get() != null && ConfigManager.getConfig().blockTelekinesisEnabled) {
|
||||
if (blockThreadLocal.get() != null && ConfigManager.getConfig().blockTelekinesisEnabled) {
|
||||
ServerPlayerEntity player = blockThreadLocal.get();
|
||||
ExperienceOrbEntity fakeExperienceOrb = new ExperienceOrbEntity(player.getWorld(), 0.0, 0.0, 0.0, original);
|
||||
((ExperienceOrbEntityInvoker) fakeExperienceOrb).invokeRepairPlayerGears(player, original);
|
||||
@@ -43,7 +43,7 @@ public class TelekinesisHandler {
|
||||
}
|
||||
|
||||
public static void registerLoot(DamageSource source) {
|
||||
if(source.getAttacker() instanceof ServerPlayerEntity && ConfigManager.getConfig().entityTelekinesisEnabled) {
|
||||
if (source.getAttacker() instanceof ServerPlayerEntity && ConfigManager.getConfig().entityTelekinesisEnabled) {
|
||||
entityThreadLocal.set(source);
|
||||
Scheduler.get().scheduleTask(entityThreadLocal::remove);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class TelekinesisHandler {
|
||||
}
|
||||
|
||||
public static int handleEntityExp(int original) {
|
||||
if(entityThreadLocal.get() != null) {
|
||||
if (entityThreadLocal.get() != null) {
|
||||
ServerPlayerEntity player = (ServerPlayerEntity) entityThreadLocal.get().getAttacker();
|
||||
ExperienceOrbEntity fakeExperienceOrb = new ExperienceOrbEntity(player.getWorld(), 0.0, 0.0, 0.0, original);
|
||||
((ExperienceOrbEntityInvoker) fakeExperienceOrb).invokeRepairPlayerGears(player, original);
|
||||
|
@@ -12,9 +12,7 @@ import wtf.hak.survivalfabric.features.veinminer.Drill;
|
||||
import wtf.hak.survivalfabric.features.veinminer.VeinMinerSession;
|
||||
import wtf.hak.survivalfabric.utils.Scheduler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static wtf.hak.survivalfabric.SurvivalFabric.LOGGER;
|
||||
|
@@ -21,11 +21,12 @@ import wtf.hak.survivalfabric.features.TelekinesisHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.minecraft.block.Block.getDroppedStacks;
|
||||
|
||||
@Mixin(Block.class)
|
||||
public abstract class BlockMixin {
|
||||
|
||||
/**
|
||||
* Handle Telekinesis & Replenish
|
||||
*/
|
||||
@ModifyExpressionValue(
|
||||
method = "dropStacks(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/entity/BlockEntity;Lnet/minecraft/entity/Entity;Lnet/minecraft/item/ItemStack;)V",
|
||||
at = @At(
|
||||
@@ -34,7 +35,7 @@ public abstract class BlockMixin {
|
||||
)
|
||||
)
|
||||
private static List<ItemStack> modifyDrops(List<ItemStack> original, BlockState state, World world, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) {
|
||||
if(entity instanceof ServerPlayerEntity player) {
|
||||
if (entity instanceof ServerPlayerEntity player) {
|
||||
if (state.getBlock() instanceof CropBlock && ConfigManager.getConfig().replenishEnabled) {
|
||||
ItemStack mainHand = player.getStackInHand(Hand.MAIN_HAND);
|
||||
if (mainHand.getItem() instanceof HoeItem) {
|
||||
@@ -49,11 +50,14 @@ public abstract class BlockMixin {
|
||||
return TelekinesisHandler.handleBlock(original, state, world, pos, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Telekinesis Exp
|
||||
*/
|
||||
@ModifyExpressionValue(
|
||||
method = "dropExperienceWhenMined",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/enchantment/EnchantmentHelper;getBlockExperience(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/item/ItemStack;I)I")
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/enchantment/EnchantmentHelper;getBlockExperience(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/item/ItemStack;I)I")
|
||||
)
|
||||
private int modifyExp(int original) {
|
||||
return TelekinesisHandler.handleBlockExp(original);
|
||||
|
@@ -1,22 +1,15 @@
|
||||
package wtf.hak.survivalfabric.mixin;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.LootTable;
|
||||
import net.minecraft.loot.context.LootWorldContext;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import wtf.hak.survivalfabric.features.TelekinesisHandler;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@@ -24,13 +17,19 @@ import java.util.function.Consumer;
|
||||
@Mixin(LivingEntity.class)
|
||||
public abstract class LivingEntityMixin {
|
||||
|
||||
/**
|
||||
* Register loot for Telekinesis
|
||||
*/
|
||||
@Inject(method = "drop", at = @At("HEAD"))
|
||||
private void drop(ServerWorld world, DamageSource damageSource, CallbackInfo ci) {
|
||||
if(damageSource.getAttacker() instanceof ServerPlayerEntity) {
|
||||
if (damageSource.getAttacker() instanceof ServerPlayerEntity) {
|
||||
TelekinesisHandler.registerLoot(damageSource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Telekinesis for Entity Loot
|
||||
*/
|
||||
@ModifyArg(
|
||||
method = "dropLoot",
|
||||
at = @At(
|
||||
@@ -43,6 +42,10 @@ public abstract class LivingEntityMixin {
|
||||
return TelekinesisHandler.handleLoot(lootConsumer, (LivingEntity) (Object) this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Telekinesis for Entity Exp
|
||||
*/
|
||||
@ModifyArg(method = "dropExperience",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/ExperienceOrbEntity;spawn(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/Vec3d;I)V"),
|
||||
|
@@ -81,7 +81,8 @@ public abstract class PlayerManagerMixin {
|
||||
|
||||
sb.append(result.endsWith(".0") ? result.substring(0, result.length() - 2) : result);
|
||||
processedMessage = sb.toString();
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isMsgEnabled) {
|
||||
|
@@ -2,7 +2,6 @@ package wtf.hak.survivalfabric.utils;
|
||||
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -14,13 +13,13 @@ public class Scheduler {
|
||||
|
||||
public Scheduler() {
|
||||
ServerTickEvents.END_SERVER_TICK.register((server) -> {
|
||||
for(Runnable task : tasks.keySet()) {
|
||||
for (Runnable task : tasks.keySet()) {
|
||||
long delay = tasks.get(task);
|
||||
if(delay <= 0) {
|
||||
if (delay <= 0) {
|
||||
task.run();
|
||||
tasks.remove(task);
|
||||
} else {
|
||||
tasks.put(task, delay-1);
|
||||
tasks.put(task, delay - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user