aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/RangedAttribute.cpp
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
committerLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
commit42aec6dac53dffa6afe072560a7e1d4986112538 (patch)
tree0836426857391df1b6a83f6368a183f83ec9b104 /Minecraft.World/RangedAttribute.cpp
parentc9d58eeac7c72f0b3038e084667b4d89a6249fce (diff)
parentef9b6fd500dfabd9463267b0dd9e29577eea8a2b (diff)
Merge branch 'main' into pr/win64-world-saves
# Conflicts: # Minecraft.Client/MinecraftServer.cpp # README.md
Diffstat (limited to 'Minecraft.World/RangedAttribute.cpp')
-rw-r--r--Minecraft.World/RangedAttribute.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/Minecraft.World/RangedAttribute.cpp b/Minecraft.World/RangedAttribute.cpp
new file mode 100644
index 00000000..d61d77ce
--- /dev/null
+++ b/Minecraft.World/RangedAttribute.cpp
@@ -0,0 +1,31 @@
+#include "stdafx.h"
+
+#include "RangedAttribute.h"
+
+RangedAttribute::RangedAttribute(eATTRIBUTE_ID id, double defaultValue, double minValue, double maxValue) : BaseAttribute(id, defaultValue)
+{
+ this->minValue = minValue;
+ this->maxValue = maxValue;
+
+ //if (minValue > maxValue) throw new IllegalArgumentException("Minimum value cannot be bigger than maximum value!");
+ //if (defaultValue < minValue) throw new IllegalArgumentException("Default value cannot be lower than minimum value!");
+ //if (defaultValue > maxValue) throw new IllegalArgumentException("Default value cannot be bigger than maximum value!");
+}
+
+double RangedAttribute::getMinValue()
+{
+ return minValue;
+}
+
+double RangedAttribute::getMaxValue()
+{
+ return maxValue;
+}
+
+double RangedAttribute::sanitizeValue(double value)
+{
+ if (value < minValue) value = minValue;
+ if (value > maxValue) value = maxValue;
+
+ return value;
+} \ No newline at end of file