Reformat Code

This commit is contained in:
Kam committed 2026-02-18 05:13:51 -05:00
1 parent 21e920426e
commit 1de1c4e710
169 files changed
+3967 -1556

No files matched your search

@@ -33,7 +33,7 @@ public class AnnotatedGui<T> extends SubGuiInterface {
int i = 0;
for (EditableField field : metadata.getParent().getDeclaredFields()) {
addLabel(new GuiNpcLabel(i++, field.getName(), guiLeft+8, guiTop+i*15+5));
addLabel(new GuiNpcLabel(i++, field.getName(), guiLeft + 8, guiTop + i * 15 + 5));
}
}
@@ -5,7 +5,7 @@ import net.minecraft.client.gui.FontRenderer;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import somehussar.gui.annotationHandling.field.EditableField;
public class ImmediateTextField extends GuiNpcTextField{
public class ImmediateTextField extends GuiNpcTextField {
private final EditableField editableField;
//
// private final GuiNpcTextField encapsulatedField;
@@ -13,6 +13,7 @@ public class ImmediateTextField extends GuiNpcTextField{
public ImmediateTextField(int id, EditableField field, int xPos, int yPos) {
this(id, field, Minecraft.getMinecraft().fontRenderer, xPos, yPos);
}
public ImmediateTextField(int id, EditableField field, FontRenderer fontRenderer, int xPos, int yPos) {
super(id, null, fontRenderer, xPos, yPos, 0, 0, null);
@@ -27,6 +27,7 @@ public @interface GuiEditable {
@Retention(RetentionPolicy.RUNTIME)
@interface Size {
int labelWidth() default 60;
int fieldWidth() default 50;
GuiEditable.Size DEFAULT_SIZE = new GuiEditable.Size() {
@@ -39,7 +40,11 @@ public @interface GuiEditable {
public int fieldWidth() {
return 50;
}
@Override public Class<? extends Annotation> annotationType() { return GuiEditable.Size.class; }
@Override
public Class<? extends Annotation> annotationType() {
return GuiEditable.Size.class;
}
};
}
@@ -26,7 +26,8 @@ public final class GuiFieldHandler {
}
private GuiFieldHandler() {}
private GuiFieldHandler() {
}
public static ClassMetadata getMetadata(Class<?> type) {
return CACHE.computeIfAbsent(type, GuiFieldHandler::scanClass);
@@ -69,7 +70,8 @@ public final class GuiFieldHandler {
if (Modifier.isFinal(field.getModifiers())) return null;
GuiEditable.Size size = field.getAnnotation(GuiEditable.Size.class);
if (size == null) size = GuiEditable.Size.DEFAULT_SIZE;;
if (size == null) size = GuiEditable.Size.DEFAULT_SIZE;
;
field.setAccessible(true);
EditableField.Builder builder = new EditableField.Builder()
@@ -9,5 +9,6 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
public @interface NumericConstraint {
double min() default Double.NEGATIVE_INFINITY;
double max() default Double.POSITIVE_INFINITY;
}
@@ -46,7 +46,9 @@ public final class EditableField<T> {
return this.constraints;
}
public int getOrder() { return this.order; }
public int getOrder() {
return this.order;
}
EditableField(Builder<T> b) {
this.name = b.name;
@@ -69,14 +71,45 @@ public final class EditableField<T> {
private String group = null;
private GuiEditable.Size size;
public Builder<T> name(String v) { this.name = v; return this; }
public Builder<T> type(Class<T> v) { this.type = v; return this; }
public Builder<T> getter(MethodHandle v) { this.getter = v; return this; }
public Builder<T> setter(MethodHandle v) { this.setter = v; return this; }
public Builder<T> constraints(FieldConstraints v) { this.constraints = v; return this; }
public Builder<T> order(int order) { this.order = order; return this; }
public Builder<T> group(String value) { this.group = value; return this; }
public Builder<T> size(GuiEditable.Size size) { this.size = size; return this; }
public Builder<T> name(String v) {
this.name = v;
return this;
}
public Builder<T> type(Class<T> v) {
this.type = v;
return this;
}
public Builder<T> getter(MethodHandle v) {
this.getter = v;
return this;
}
public Builder<T> setter(MethodHandle v) {
this.setter = v;
return this;
}
public Builder<T> constraints(FieldConstraints v) {
this.constraints = v;
return this;
}
public Builder<T> order(int order) {
this.order = order;
return this;
}
public Builder<T> group(String value) {
this.group = value;
return this;
}
public Builder<T> size(GuiEditable.Size size) {
this.size = size;
return this;
}
public EditableField<T> build() {
return new EditableField<>(this);