Search in sources :

Example 6 with IntegerRange

use of ivorius.ivtoolkit.gui.IntegerRange in project RecurrentComplex by Ivorforce.

the class TableDataSourceBlockSurfacePos method cellForIndexInSegment.

@Override
public TableCell cellForIndexInSegment(GuiTable table, int index, int segment) {
    IntegerRange range;
    int val;
    String title;
    switch(index) {
        case 0:
            range = rangeX;
            val = coord.getX();
            title = titleX;
            break;
        default:
            range = rangeZ;
            val = coord.getZ();
            title = titleZ;
            break;
    }
    if (range != null) {
        TableCellInteger cell = new TableCellInteger(null, val, range.min, range.max);
        cell.addPropertyConsumer(createConsumer(index));
        return new TitledCell(title, cell);
    } else {
        TableCellStringInt cell = new TableCellStringInt(null, val);
        cell.addPropertyConsumer(createConsumer(index));
        return new TitledCell(title, cell);
    }
}
Also used : TitledCell(ivorius.reccomplex.gui.table.cell.TitledCell) IntegerRange(ivorius.ivtoolkit.gui.IntegerRange) TableCellInteger(ivorius.reccomplex.gui.table.cell.TableCellInteger) TableCellStringInt(ivorius.reccomplex.gui.table.cell.TableCellStringInt)

Example 7 with IntegerRange

use of ivorius.ivtoolkit.gui.IntegerRange in project RecurrentComplex by Ivorforce.

the class ItemInventoryGenMultiTag method addInformation.

@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean advancedInformation) {
    super.addInformation(stack, player, list, advancedInformation);
    IntegerRange range = getGenerationCount(stack);
    list.add(String.format("%d - %d Items", range.getMin(), range.getMax()));
}
Also used : IntegerRange(ivorius.ivtoolkit.gui.IntegerRange)

Example 8 with IntegerRange

use of ivorius.ivtoolkit.gui.IntegerRange in project RecurrentComplex by Ivorforce.

the class GenericPlacer method place.

@Override
public int place(StructurePlaceContext context, @Nullable IvBlockCollection blockCollection) {
    if (factors.isEmpty())
        return DONT_GENERATE;
    WorldServer world = context.environment.world;
    WorldCache cache = new WorldCache(world, StructureBoundingBoxes.wholeHeightBoundingBox(world, context.boundingBox));
    LineSelection considerable = LineSelection.fromRange(new IntegerRange(0, world.getHeight() - context.boundingBox.getYSize()), true);
    List<Pair<LineSelection, Float>> considerations = new ArrayList<>();
    factors.forEach(factor -> {
        List<Pair<LineSelection, Float>> consideration = factor.consider(cache, considerable, blockCollection, context);
        consideration.stream().filter(p -> p.getRight() <= 0).forEach(p -> considerable.set(p.getLeft(), true, false));
        consideration = consideration.stream().filter(p -> p.getRight() > 0).collect(Collectors.toList());
        considerable.set(LineSelections.combine(consideration.stream().map(Pair::getLeft), true), false, false);
        considerations.addAll(consideration);
    });
    Set<Pair<Integer, Double>> applicable = considerable.streamElements(null, true).mapToObj(y -> Pair.of(y, considerations.stream().mapToDouble(pair -> pair.getLeft().isSectionAdditive(pair.getLeft().sectionForIndex(y)) ? pair.getRight() : 1).reduce(1f, (left, right) -> left * right))).filter(p -> p.getRight() > 0).collect(Collectors.toSet());
    return applicable.size() > 0 ? WeightedSelector.select(context.random, applicable, Pair::getRight).getLeft() : DONT_GENERATE;
}
Also used : IvTranslations(ivorius.ivtoolkit.tools.IvTranslations) IvBlockCollection(ivorius.ivtoolkit.blocks.IvBlockCollection) java.util(java.util) RayMove(ivorius.reccomplex.world.gen.feature.structure.generic.placement.rays.RayMove) RayMatcher(ivorius.reccomplex.world.gen.feature.structure.generic.placement.rays.RayMatcher) TableDataSource(ivorius.reccomplex.gui.table.datasource.TableDataSource) TypeToken(com.google.common.reflect.TypeToken) WeightedSelector(ivorius.ivtoolkit.random.WeightedSelector) RayDynamicPosition(ivorius.reccomplex.world.gen.feature.structure.generic.placement.rays.RayDynamicPosition) StructureBoundingBoxes(ivorius.ivtoolkit.world.chunk.gen.StructureBoundingBoxes) Pair(org.apache.commons.lang3.tuple.Pair) Placer(ivorius.reccomplex.world.gen.feature.structure.Placer) LineSelections(ivorius.ivtoolkit.util.LineSelections) WorldServer(net.minecraft.world.WorldServer) Nonnull(javax.annotation.Nonnull) JsonUtils(ivorius.reccomplex.json.JsonUtils) Nullable(javax.annotation.Nullable) WorldCache(ivorius.ivtoolkit.world.WorldCache) RayAverageMatcher(ivorius.reccomplex.world.gen.feature.structure.generic.placement.rays.RayAverageMatcher) LineSelection(ivorius.ivtoolkit.util.LineSelection) SerializedName(com.google.gson.annotations.SerializedName) Collectors(java.util.stream.Collectors) TableNavigator(ivorius.reccomplex.gui.table.TableNavigator) GenericPlacerPresets(ivorius.reccomplex.world.gen.feature.structure.generic.presets.GenericPlacerPresets) Type(java.lang.reflect.Type) TableDelegate(ivorius.reccomplex.gui.table.TableDelegate) com.google.gson(com.google.gson) IntegerRange(ivorius.ivtoolkit.gui.IntegerRange) PresettedObject(ivorius.reccomplex.utils.presets.PresettedObject) LineSelection(ivorius.ivtoolkit.util.LineSelection) IntegerRange(ivorius.ivtoolkit.gui.IntegerRange) WorldServer(net.minecraft.world.WorldServer) WorldCache(ivorius.ivtoolkit.world.WorldCache) Pair(org.apache.commons.lang3.tuple.Pair)

Example 9 with IntegerRange

use of ivorius.ivtoolkit.gui.IntegerRange in project RecurrentComplex by Ivorforce.

the class TableDataSourceSelectionArea method cellForIndexInSegment.

@Override
public TableCell cellForIndexInSegment(GuiTable table, int index, int segment) {
    if (segment == 0) {
        TableCellBoolean cell = new TableCellBoolean("additive", area.isAdditive(), TextFormatting.GREEN + IvTranslations.get("reccomplex.selection.area.additive"), TextFormatting.GOLD + IvTranslations.get("reccomplex.selection.area.subtractive"));
        cell.addPropertyConsumer(area::setAdditive);
        return new TitledCell(cell);
    } else if (segment == 1) {
        String title = IvTranslations.get("reccomplex.selection.area.range." + COORD_NAMES[index]);
        IntegerRange intRange = new IntegerRange(area.getMinCoord()[index], area.getMaxCoord()[index]);
        TableCellIntegerRange cell = new TableCellIntegerRange("area" + index, intRange, 0, dimensions[index] - 1);
        cell.addPropertyConsumer(val -> area.setCoord(index, val.getMin(), val.getMax()));
        return new TitledCell(title, cell).withTitleTooltip(IvTranslations.getLines("reccomplex.selection.area.range." + COORD_NAMES[index] + ".tooltip"));
    } else if (segment == 2) {
        TableCellString cell = new TableCellString("", area.getIdentifier() != null ? area.getIdentifier() : "");
        cell.addPropertyConsumer(area::setIdentifier);
        return new TitledCell(IvTranslations.get("reccomplex.selection.area.identifier"), cell);
    }
    return super.cellForIndexInSegment(table, index, segment);
}
Also used : IvTranslations(ivorius.ivtoolkit.tools.IvTranslations) ivorius.reccomplex.gui.table(ivorius.reccomplex.gui.table) TableDataSourceSegmented(ivorius.reccomplex.gui.table.datasource.TableDataSourceSegmented) TextFormatting(net.minecraft.util.text.TextFormatting) ivorius.reccomplex.gui.table.cell(ivorius.reccomplex.gui.table.cell) Selection(ivorius.reccomplex.world.gen.feature.structure.generic.Selection) Nonnull(javax.annotation.Nonnull) IntegerRange(ivorius.ivtoolkit.gui.IntegerRange) IntegerRange(ivorius.ivtoolkit.gui.IntegerRange)

Example 10 with IntegerRange

use of ivorius.ivtoolkit.gui.IntegerRange in project RecurrentComplex by Ivorforce.

the class TableDataSourceMazeRoom method cellForIndexInSegment.

@Override
public TableCell cellForIndexInSegment(GuiTable table, int index, int segment) {
    IntegerRange range = ranges.get(index);
    int val = room.getCoordinate(index);
    String title = titles.get(index);
    List<String> tooltip = tooltips.get(index);
    if (range != null) {
        TableCellInteger cell = new TableCellInteger(null, val, range.min, range.max);
        cell.addPropertyConsumer(createConsumer(index));
        return new TitledCell(title, cell).withTitleTooltip(tooltip);
    } else {
        TableCellStringInt cell = new TableCellStringInt(null, val);
        cell.addPropertyConsumer(createConsumer(index));
        return new TitledCell(title, cell).withTitleTooltip(tooltip);
    }
}
Also used : TitledCell(ivorius.reccomplex.gui.table.cell.TitledCell) IntegerRange(ivorius.ivtoolkit.gui.IntegerRange) TableCellInteger(ivorius.reccomplex.gui.table.cell.TableCellInteger) TableCellStringInt(ivorius.reccomplex.gui.table.cell.TableCellStringInt)

Aggregations

IntegerRange (ivorius.ivtoolkit.gui.IntegerRange)10 Nullable (javax.annotation.Nullable)4 TableCellInteger (ivorius.reccomplex.gui.table.cell.TableCellInteger)3 TableCellStringInt (ivorius.reccomplex.gui.table.cell.TableCellStringInt)3 TitledCell (ivorius.reccomplex.gui.table.cell.TitledCell)3 Nonnull (javax.annotation.Nonnull)3 com.google.gson (com.google.gson)2 IvBlockCollection (ivorius.ivtoolkit.blocks.IvBlockCollection)2 IvTranslations (ivorius.ivtoolkit.tools.IvTranslations)2 LineSelection (ivorius.ivtoolkit.util.LineSelection)2 WorldCache (ivorius.ivtoolkit.world.WorldCache)2 StructureBoundingBoxes (ivorius.ivtoolkit.world.chunk.gen.StructureBoundingBoxes)2 TableDelegate (ivorius.reccomplex.gui.table.TableDelegate)2 TableNavigator (ivorius.reccomplex.gui.table.TableNavigator)2 TableDataSource (ivorius.reccomplex.gui.table.datasource.TableDataSource)2 JsonUtils (ivorius.reccomplex.json.JsonUtils)2 Type (java.lang.reflect.Type)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 Pair (org.apache.commons.lang3.tuple.Pair)2