|
| 1 | +/* |
| 2 | + * Copyright 2024 Lambda |
| 3 | + * |
| 4 | + * This program is free software: you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation, either version 3 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License |
| 15 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | + */ |
| 17 | + |
| 18 | +package com.lambda.config.settings.complex |
| 19 | + |
| 20 | +import com.google.gson.reflect.TypeToken |
| 21 | +import com.lambda.brigadier.argument.double |
| 22 | +import com.lambda.brigadier.argument.integer |
| 23 | +import com.lambda.brigadier.argument.value |
| 24 | +import com.lambda.brigadier.execute |
| 25 | +import com.lambda.brigadier.required |
| 26 | +import com.lambda.config.AbstractSetting |
| 27 | +import com.lambda.util.extension.CommandBuilder |
| 28 | +import net.minecraft.command.CommandRegistryAccess |
| 29 | +import net.minecraft.util.math.BlockPos |
| 30 | +import net.minecraft.util.math.Vec3d |
| 31 | + |
| 32 | +class Vec3dSetting( |
| 33 | + override val name: String, |
| 34 | + defaultValue: Vec3d, |
| 35 | + description: String, |
| 36 | + visibility: () -> Boolean, |
| 37 | +) : AbstractSetting<Vec3d>( |
| 38 | + defaultValue, |
| 39 | + TypeToken.get(Vec3d::class.java).type, |
| 40 | + description, |
| 41 | + visibility |
| 42 | +) { |
| 43 | + override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { |
| 44 | + required(double("X", -30000000.0, 30000000.0)) { x -> |
| 45 | + required(double("Y", -64.0, 255.0)) { y -> |
| 46 | + required(double("Z", -30000000.0, 30000000.0)) { z -> |
| 47 | + execute { |
| 48 | + trySetValue(Vec3d(x().value(), y().value(), z().value())) |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | +} |
0 commit comments