package com.hypixel.hytale.builtin.buildertools.scriptedbrushes.operations.sequential.dimensions;
import com.hypixel.hytale.builtin.buildertools.scriptedbrushes.BrushConfig;
import com.hypixel.hytale.builtin.buildertools.scriptedbrushes.BrushConfigCommandExecutor;
import com.hypixel.hytale.builtin.buildertools.scriptedbrushes.operations.system.SequenceBrushOperation;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.server.core.command.system.arguments.types.RelativeInteger;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
publicclassDimensionsOperationextendsSequenceBrushOperation {
publicstaticfinal BuilderCodec<DimensionsOperation> CODEC;
@NonnullpublicRelativeIntegerwidthArg=newRelativeInteger(3, false);
@NonnullpublicRelativeIntegerheightArg=newRelativeInteger(3, false);
publicDimensionsOperation() {
super("Modify Dimensions", "Set, add, or subtract from the dimensions of the brush area", false);
}
publicvoidmodifyBrushConfig(@Nonnull Ref<EntityStore> ref, @Nonnull BrushConfig brushConfig, @Nonnull BrushConfigCommandExecutor brushConfigCommandExecutor, @Nonnull ComponentAccessor<EntityStore> componentAccessor) {
intwidth=this.widthArg.resolve(brushConfig.getShapeWidth());
intheight=this.heightArg.resolve(brushConfig.getShapeHeight());
brushConfig.setShapeWidth(MathUtil.clamp(width, 1, 75));
brushConfig.setShapeHeight(MathUtil.clamp(height, 1, 75));
}
static {
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(DimensionsOperation.class, DimensionsOperation::new).append(newKeyedCodec("Width", RelativeInteger.CODEC), (op, val) -> op.widthArg = val, (op) -> op.widthArg).documentation("Sets the width of the brush to the specified amount, optionally relative to the existing amount when using prefixing with tilde").add()).append(newKeyedCodec("Height", RelativeInteger.CODEC), (op, val) -> op.heightArg = val, (op) -> op.heightArg).documentation("Sets the height of the brush to the specified amount, optionally relative to the existing amount when using prefixing with tilde").add()).documentation("Set, add, or subtract from the dimensions of the brush area")).build();
}
}