mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-22 16:48:25 +01:00
Move init() functions into static blocks
This commit is contained in:
parent
0c6b92b189
commit
93eb9344a3
@ -21,7 +21,6 @@ package de.florianmichael.viafabricplus.fixes.data;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.entity.EntityAttachmentType;
|
import net.minecraft.entity.EntityAttachmentType;
|
||||||
import net.minecraft.entity.EntityAttachments;
|
import net.minecraft.entity.EntityAttachments;
|
||||||
@ -29,7 +28,6 @@ import net.minecraft.entity.EntityDimensions;
|
|||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static de.florianmichael.viafabricplus.util.MapUtil.linkedHashMap;
|
import static de.florianmichael.viafabricplus.util.MapUtil.linkedHashMap;
|
||||||
|
@ -33,12 +33,14 @@ import net.minecraft.registry.RegistryKey;
|
|||||||
import net.minecraft.registry.RegistryKeys;
|
import net.minecraft.registry.RegistryKeys;
|
||||||
import net.minecraft.registry.entry.RegistryEntry;
|
import net.minecraft.registry.entry.RegistryEntry;
|
||||||
import net.minecraft.registry.tag.BlockTags;
|
import net.minecraft.registry.tag.BlockTags;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
public class EnchantmentAttributesEmulation1_20_6 {
|
public class EnchantmentAttributesEmulation1_20_6 {
|
||||||
|
|
||||||
public static void init() {
|
static {
|
||||||
ClientTickEvents.START_WORLD_TICK.register(world -> {
|
ClientTickEvents.START_WORLD_TICK.register(world -> {
|
||||||
if (ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_20_5)) {
|
if (ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_20_5)) {
|
||||||
return;
|
return;
|
||||||
@ -69,6 +71,10 @@ public class EnchantmentAttributesEmulation1_20_6 {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
// Calls the static block
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from MixinLivingEntity as well to ensure the attribute value is set at the correct place in the entity tick logic.
|
* Called from MixinLivingEntity as well to ensure the attribute value is set at the correct place in the entity tick logic.
|
||||||
* Called above just as a fallback if a mod accesses the raw attribute value directly.
|
* Called above just as a fallback if a mod accesses the raw attribute value directly.
|
||||||
|
@ -32,16 +32,18 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
|||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
public class ArmorHudEmulation1_8 {
|
public class ArmorHudEmulation1_8 {
|
||||||
|
|
||||||
private static final UUID ARMOR_POINTS_UUID = UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150");
|
private static final UUID ARMOR_POINTS_UUID = UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150");
|
||||||
|
|
||||||
private static double previousArmorPoints = 0;
|
private static double previousArmorPoints = 0;
|
||||||
|
|
||||||
public static void init() {
|
static {
|
||||||
ClientTickEvents.START_WORLD_TICK.register(world -> {
|
ClientTickEvents.START_WORLD_TICK.register(world -> {
|
||||||
if (!VisualSettings.global().emulateArmorHud.isEnabled()) {
|
if (!VisualSettings.global().emulateArmorHud.isEnabled()) {
|
||||||
return;
|
return;
|
||||||
@ -62,6 +64,10 @@ public class ArmorHudEmulation1_8 {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
// Calls the static block
|
||||||
|
}
|
||||||
|
|
||||||
private static void sendArmorUpdate(final UserConnection userConnection) {
|
private static void sendArmorUpdate(final UserConnection userConnection) {
|
||||||
// Calculate the armor points.
|
// Calculate the armor points.
|
||||||
int armor = 0;
|
int armor = 0;
|
||||||
|
@ -33,12 +33,23 @@ import net.minecraft.registry.Registry;
|
|||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
public class FootStepParticle1_12_2 extends SpriteBillboardParticle {
|
public class FootStepParticle1_12_2 extends SpriteBillboardParticle {
|
||||||
|
|
||||||
public static final Identifier ID = Identifier.of("viafabricplus", "footstep");
|
public static final Identifier ID = Identifier.of("viafabricplus", "footstep");
|
||||||
public static int RAW_ID;
|
public static int RAW_ID;
|
||||||
|
|
||||||
|
static {
|
||||||
|
final SimpleParticleType footStepType = FabricParticleTypes.simple(true);
|
||||||
|
|
||||||
|
Registry.register(Registries.PARTICLE_TYPE, ID, footStepType);
|
||||||
|
ParticleFactoryRegistry.getInstance().register(footStepType, FootStepParticle1_12_2.Factory::new);
|
||||||
|
|
||||||
|
RAW_ID = Registries.PARTICLE_TYPE.getRawId(footStepType);
|
||||||
|
}
|
||||||
|
|
||||||
protected FootStepParticle1_12_2(ClientWorld clientWorld, double x, double y, double z) {
|
protected FootStepParticle1_12_2(ClientWorld clientWorld, double x, double y, double z) {
|
||||||
super(clientWorld, x, y, z);
|
super(clientWorld, x, y, z);
|
||||||
|
|
||||||
@ -79,12 +90,7 @@ public class FootStepParticle1_12_2 extends SpriteBillboardParticle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
final SimpleParticleType footStepType = FabricParticleTypes.simple(true);
|
// Calls the static block
|
||||||
|
|
||||||
Registry.register(Registries.PARTICLE_TYPE, ID, footStepType);
|
|
||||||
ParticleFactoryRegistry.getInstance().register(footStepType, FootStepParticle1_12_2.Factory::new);
|
|
||||||
|
|
||||||
RAW_ID = Registries.PARTICLE_TYPE.getRawId(footStepType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Factory implements ParticleFactory<SimpleParticleType> {
|
public static class Factory implements ParticleFactory<SimpleParticleType> {
|
||||||
|
@ -40,7 +40,7 @@ public class UnicodeFontFix1_12_2 {
|
|||||||
private static boolean enabled = false;
|
private static boolean enabled = false;
|
||||||
private static Runnable task = null;
|
private static Runnable task = null;
|
||||||
|
|
||||||
public static void init() {
|
static {
|
||||||
ChangeProtocolVersionCallback.EVENT.register((oldVersion, newVersion) -> updateUnicodeFontOverride(newVersion));
|
ChangeProtocolVersionCallback.EVENT.register((oldVersion, newVersion) -> updateUnicodeFontOverride(newVersion));
|
||||||
|
|
||||||
ClientTickEvents.START_CLIENT_TICK.register(client -> {
|
ClientTickEvents.START_CLIENT_TICK.register(client -> {
|
||||||
@ -52,6 +52,10 @@ public class UnicodeFontFix1_12_2 {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
// Calls the static block
|
||||||
|
}
|
||||||
|
|
||||||
public static void updateUnicodeFontOverride(final ProtocolVersion version) {
|
public static void updateUnicodeFontOverride(final ProtocolVersion version) {
|
||||||
final SimpleOption<Boolean> option = MinecraftClient.getInstance().options.getForceUnicodeFont();
|
final SimpleOption<Boolean> option = MinecraftClient.getInstance().options.getForceUnicodeFont();
|
||||||
|
|
||||||
|
@ -45,9 +45,11 @@ public abstract class VFPListEntry extends AlwaysSelectedEntryListWidget.Entry<V
|
|||||||
private int entryHeight;
|
private int entryHeight;
|
||||||
|
|
||||||
public void mappedRender(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
public void mappedRender(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
||||||
|
// To be overridden
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
|
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
|
||||||
|
// To be overridden
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user