mirror of
https://github.com/TeamMidnightDust/BlinkingSkinPort.git
synced 2025-12-17 11:15:10 +01:00
Upload 2.0.0 rewrite
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package eu.midnightdust.blinkingskinport;
|
||||
|
||||
import eu.midnightdust.blinkingskinport.config.BlinkingSkinConfig;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.minecraft.client.render.entity.PlayerModelPart;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BlinkingSkinClient implements ClientModInitializer {
|
||||
|
||||
public static BlinkingSkinConfig BS_CONFIG;
|
||||
private final Map<PlayerModelPart, Integer> intervals = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
AutoConfig.register(BlinkingSkinConfig.class, JanksonConfigSerializer::new);
|
||||
BS_CONFIG = AutoConfig.getConfigHolder(BlinkingSkinConfig.class).getConfig();
|
||||
|
||||
for (PlayerModelPart part : PlayerModelPart.values()) {
|
||||
this.intervals.put(part, 0);
|
||||
}
|
||||
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
if (BS_CONFIG.enabled) {
|
||||
for (Map.Entry<PlayerModelPart,Integer> interval : this.intervals.entrySet()) {
|
||||
if (!BS_CONFIG.isEnabled(interval.getKey())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int counter = this.intervals.get(interval.getKey());
|
||||
if (counter++ >= BS_CONFIG.getToggleInterval(interval.getKey())) {
|
||||
this.intervals.put(interval.getKey(), 0);
|
||||
client.options.togglePlayerModelPart(interval.getKey());
|
||||
}
|
||||
else {
|
||||
this.intervals.put(interval.getKey(), counter);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package eu.midnightdust.blinkingskinport.config;
|
||||
|
||||
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment;
|
||||
import net.minecraft.client.render.entity.PlayerModelPart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Config(name = "blinkingskinport")
|
||||
public class BlinkingSkinConfig implements ConfigData {
|
||||
|
||||
@ConfigEntry.Gui.PrefixText // Blink Intervals lower than 5 are disabled, because they can be used to trigger epileptic episodes, which isn't fun for affected people!
|
||||
public boolean enabled = false;
|
||||
|
||||
@ConfigEntry.Gui.PrefixText
|
||||
public boolean capeEnabled = true;
|
||||
@ConfigEntry.BoundedDiscrete(min = 5, max = 200)
|
||||
@Comment("(20 ticks = 1 second)")
|
||||
public int capeBlinkInterval = 20;
|
||||
public boolean hatEnabled = true;
|
||||
@ConfigEntry.BoundedDiscrete(min = 5, max = 200)
|
||||
@Comment("(20 ticks = 1 second)")
|
||||
public int hatBlinkInterval = 20;
|
||||
public boolean jacketEnabled = true;
|
||||
@ConfigEntry.BoundedDiscrete(min = 5, max = 200)
|
||||
@Comment("(20 ticks = 1 second)")
|
||||
public int jacketBlinkInterval = 20;
|
||||
public boolean leftSleeveEnabled = true;
|
||||
@ConfigEntry.BoundedDiscrete(min = 5, max = 200)
|
||||
@Comment("(20 ticks = 1 second)")
|
||||
public int leftSleeveBlinkInterval = 20;
|
||||
public boolean rightSleeveEnabled = true;
|
||||
@ConfigEntry.BoundedDiscrete(min = 5, max = 200)
|
||||
@Comment("(20 ticks = 1 second)")
|
||||
public int rightSleeveBlinkInterval = 20;
|
||||
public boolean leftPantsLegEnabled = true;
|
||||
@ConfigEntry.BoundedDiscrete(min = 5, max = 200)
|
||||
@Comment("(20 ticks = 1 second)")
|
||||
public int leftPantsLegBlinkInterval = 20;
|
||||
public boolean rightPantsLegEnabled = true;
|
||||
@ConfigEntry.BoundedDiscrete(min = 5, max = 200)
|
||||
@Comment("(20 ticks = 1 second)")
|
||||
public int rightPantsLegBlinkInterval = 20;
|
||||
|
||||
|
||||
public boolean isEnabled(PlayerModelPart part) {
|
||||
switch (part) {
|
||||
case HAT:
|
||||
return hatEnabled;
|
||||
case CAPE:
|
||||
return capeEnabled;
|
||||
case JACKET:
|
||||
return jacketEnabled;
|
||||
case LEFT_SLEEVE:
|
||||
return leftSleeveEnabled;
|
||||
case RIGHT_SLEEVE:
|
||||
return rightSleeveEnabled;
|
||||
case LEFT_PANTS_LEG:
|
||||
return leftPantsLegEnabled;
|
||||
case RIGHT_PANTS_LEG:
|
||||
return rightPantsLegEnabled;
|
||||
default:
|
||||
throw new AssertionError("Could not get value for " + part);
|
||||
}
|
||||
}
|
||||
|
||||
public int getToggleInterval(PlayerModelPart part) {
|
||||
switch (part) {
|
||||
case HAT:
|
||||
return hatBlinkInterval;
|
||||
case CAPE:
|
||||
return capeBlinkInterval;
|
||||
case JACKET:
|
||||
return jacketBlinkInterval;
|
||||
case LEFT_SLEEVE:
|
||||
return leftSleeveBlinkInterval;
|
||||
case RIGHT_SLEEVE:
|
||||
return rightSleeveBlinkInterval;
|
||||
case LEFT_PANTS_LEG:
|
||||
return leftPantsLegBlinkInterval;
|
||||
case RIGHT_PANTS_LEG:
|
||||
return rightPantsLegBlinkInterval;
|
||||
default:
|
||||
throw new AssertionError("Could not get interval for " + part);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package eu.midnightdust.blinkingskinport.config;
|
||||
|
||||
import io.github.prospector.modmenu.api.ConfigScreenFactory;
|
||||
import io.github.prospector.modmenu.api.ModMenuApi;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ModMenuIntegration implements ModMenuApi {
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return parent -> AutoConfig.getConfigScreen(BlinkingSkinConfig.class, parent).get();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user