Fix attribute slider ranges. Fixes #22

This commit is contained in:
Marcel Konrad committed 2022-07-13 23:01:32 +02:00
1 parent 6e2328c980
commit fb071bb3fb
2 files changed
+15 -5

No files matched your search

@@ -69,10 +69,15 @@ public class ContentCustomItem extends Content
for(Attribute attribute : this.attributes.getAttributes()) for(Attribute attribute : this.attributes.getAttributes())
{ {
double value = this.attributes.get(attribute); double value = this.attributes.get(attribute);
double range = Config.getSliders().getMaxItemAttributes();
if(value > Config.getSliders().getMaxItemAttributes()) if(value > range)
{ {
this.attributes.set(attribute, Config.getSliders().getMaxItemAttributes()); this.attributes.set(attribute, range);
}
else if(value < -range)
{
this.attributes.set(attribute, -range);
} }
} }
@@ -195,7 +200,7 @@ public class ContentCustomItem extends Content
@Override @Override
public GuiButtonBase onRegister(int x, int y, int width, int height, MutableComponent text, Attribute attribute, ActionHandler actionHandler) public GuiButtonBase onRegister(int x, int y, int width, int height, MutableComponent text, Attribute attribute, ActionHandler actionHandler)
{ {
return new GuiSlider(x, y, width, height, -Config.getSliders().getMaxItemAttributes(), Config.getSliders().getMaxItemEnchantment(), 0, container, new LogicSliderAttribute(attribute, text, value -> return new GuiSlider(x, y, width, height, -Config.getSliders().getMaxItemAttributes(), Config.getSliders().getMaxItemAttributes(), 0, container, new LogicSliderAttribute(attribute, text, value ->
{ {
ContentCustomItem.this.attributes.set(attribute, value); ContentCustomItem.this.attributes.set(attribute, value);
})); }));
@@ -156,10 +156,15 @@ public class ContentSummon extends Content
for(Attribute attribute : this.attributes.getAttributes()) for(Attribute attribute : this.attributes.getAttributes())
{ {
double value = this.attributes.get(attribute); double value = this.attributes.get(attribute);
double range = Config.getSliders().getMaxSummonAttributes();
if(value > Config.getSliders().getMaxSummonAttributes()) if(value > range)
{ {
this.attributes.set(attribute, Config.getSliders().getMaxSummonAttributes()); this.attributes.set(attribute, range);
}
else if(value < -range)
{
this.attributes.set(attribute, -range);
} }
} }