Code cleanup
This commit is contained in:
@ -7,10 +7,10 @@ import wtf.hak.survivalfabric.features.RemoveDarknessEffect;
|
||||
|
||||
public class SurvivalFabricClient implements ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ClientConfigManager.getConfig();
|
||||
AngleViewer.register();
|
||||
RemoveDarknessEffect.register();
|
||||
}
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ClientConfigManager.getConfig();
|
||||
AngleViewer.register();
|
||||
RemoveDarknessEffect.register();
|
||||
}
|
||||
}
|
@ -4,8 +4,8 @@ import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||
|
||||
public class SurvivalFabricDataGenerator implements DataGeneratorEntrypoint {
|
||||
@Override
|
||||
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
|
||||
@Override
|
||||
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class ClientConfigManager {
|
||||
}
|
||||
|
||||
public static ClientConfig load() {
|
||||
try(FileReader reader = new FileReader(CONFIG_FILE)) {
|
||||
try (FileReader reader = new FileReader(CONFIG_FILE)) {
|
||||
INSTANCE = GSON.fromJson(reader, ClientConfig.class);
|
||||
if (INSTANCE.configVersion.equalsIgnoreCase(new Config().configVersion)) {
|
||||
return INSTANCE;
|
||||
@ -41,12 +41,12 @@ public class ClientConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(){
|
||||
public static void save() {
|
||||
save(INSTANCE);
|
||||
}
|
||||
|
||||
public static void save(ClientConfig config) {
|
||||
try(FileWriter writer = new FileWriter(CONFIG_FILE)) {
|
||||
try (FileWriter writer = new FileWriter(CONFIG_FILE)) {
|
||||
GSON.toJson(config, writer);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error saving config: " + e.getMessage());
|
||||
|
@ -17,7 +17,7 @@ public class AngleViewer {
|
||||
public static boolean PREVENT_HEAD_MOVEMENT = false;
|
||||
|
||||
public static void register() {
|
||||
for(Angle angle : Angle.values()) {
|
||||
for (Angle angle : Angle.values()) {
|
||||
KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
||||
"key.survivalfabric." + angle.name().toLowerCase(),
|
||||
InputUtil.Type.KEYSYM,
|
||||
@ -28,14 +28,14 @@ public class AngleViewer {
|
||||
ClientTickEvents.END_CLIENT_TICK.register(mc -> {
|
||||
while (keyBinding.wasPressed()) {
|
||||
ClientPlayerEntity player = mc.player;
|
||||
if(player == null) return;
|
||||
if (player == null) return;
|
||||
player.setYaw(angle.yaw);
|
||||
player.setPitch(angle.pitch);
|
||||
|
||||
PREVENT_HEAD_MOVEMENT = true;
|
||||
|
||||
scheduler.schedule(() -> {
|
||||
if(player == null) return;
|
||||
if (player == null) return;
|
||||
PREVENT_HEAD_MOVEMENT = false;
|
||||
player.setPitch(-90);
|
||||
PREVENT_HEAD_MOVEMENT = true;
|
||||
|
@ -9,9 +9,9 @@ public class RemoveDarknessEffect {
|
||||
|
||||
public static void register() {
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
if(client.player != null && ClientConfigManager.getConfig().removeDarknessEffect){
|
||||
if (client.player != null && ClientConfigManager.getConfig().removeDarknessEffect) {
|
||||
StatusEffectInstance darknessEffect = client.player.getStatusEffect(StatusEffects.DARKNESS);
|
||||
if(darknessEffect != null)
|
||||
if (darknessEffect != null)
|
||||
client.player.removeStatusEffect(darknessEffect.getEffectType());
|
||||
}
|
||||
});
|
||||
|
@ -19,28 +19,28 @@ import static wtf.hak.survivalfabric.config.client.ClientConfigManager.getConfig
|
||||
public abstract class BackgroundRendererMixin {
|
||||
|
||||
@Unique
|
||||
private static final Fog EMPTY_FOG = new Fog(-8.0f, 1_000_000.0F, FogShape.CYLINDER, 0,0,0,0);
|
||||
private static final Fog EMPTY_FOG = new Fog(-8.0f, 1_000_000.0F, FogShape.CYLINDER, 0, 0, 0, 0);
|
||||
|
||||
@Inject(method = "applyFog", at = @At("RETURN"), cancellable = true)
|
||||
private static void applyFog(Camera camera, BackgroundRenderer.FogType fogType, Vector4f color, float viewDistance, boolean thickenFog, float tickProgress, CallbackInfoReturnable<Fog> cir) {
|
||||
boolean renderFog = true;
|
||||
CameraSubmersionType subType = camera.getSubmersionType();
|
||||
if(subType == CameraSubmersionType.NONE) {
|
||||
if (subType == CameraSubmersionType.NONE) {
|
||||
World world = camera.getFocusedEntity().getWorld();
|
||||
if(world.getRegistryKey() == World.OVERWORLD && !getConfig().renderOverworldFog)
|
||||
if (world.getRegistryKey() == World.OVERWORLD && !getConfig().renderOverworldFog)
|
||||
renderFog = false;
|
||||
else if(world.getRegistryKey() == World.NETHER && !getConfig().renderNetherFog)
|
||||
else if (world.getRegistryKey() == World.NETHER && !getConfig().renderNetherFog)
|
||||
renderFog = false;
|
||||
else if(world.getRegistryKey() == World.END && !getConfig().renderEndFog)
|
||||
else if (world.getRegistryKey() == World.END && !getConfig().renderEndFog)
|
||||
renderFog = false;
|
||||
} else if(subType == CameraSubmersionType.WATER && !getConfig().renderWaterFog)
|
||||
} else if (subType == CameraSubmersionType.WATER && !getConfig().renderWaterFog)
|
||||
renderFog = false;
|
||||
else if(subType == CameraSubmersionType.LAVA && !getConfig().renderLavaFog)
|
||||
else if (subType == CameraSubmersionType.LAVA && !getConfig().renderLavaFog)
|
||||
renderFog = false;
|
||||
else if(subType == CameraSubmersionType.POWDER_SNOW && !getConfig().renderSnowFog)
|
||||
else if (subType == CameraSubmersionType.POWDER_SNOW && !getConfig().renderSnowFog)
|
||||
renderFog = false;
|
||||
|
||||
if(!renderFog)
|
||||
if (!renderFog)
|
||||
cir.setReturnValue(EMPTY_FOG);
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ public abstract class EntityMixin {
|
||||
|
||||
@Inject(method = "setYaw", at = @At("HEAD"), cancellable = true)
|
||||
private void preventYawChange(float yaw, CallbackInfo ci) {
|
||||
if((Object) this instanceof ClientPlayerEntity player) {
|
||||
if(player.isMainPlayer() && AngleViewer.PREVENT_HEAD_MOVEMENT) {
|
||||
if ((Object) this instanceof ClientPlayerEntity player) {
|
||||
if (player.isMainPlayer() && AngleViewer.PREVENT_HEAD_MOVEMENT) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
@ -22,8 +22,8 @@ public abstract class EntityMixin {
|
||||
|
||||
@Inject(method = "setPitch", at = @At("HEAD"), cancellable = true)
|
||||
private void preventPitchChange(float pitch, CallbackInfo ci) {
|
||||
if((Object) this instanceof ClientPlayerEntity player) {
|
||||
if(player.isMainPlayer() && AngleViewer.PREVENT_HEAD_MOVEMENT) {
|
||||
if ((Object) this instanceof ClientPlayerEntity player) {
|
||||
if (player.isMainPlayer() && AngleViewer.PREVENT_HEAD_MOVEMENT) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user