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);
}
}
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()));
}
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;
}
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);
}
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);
}
}
Aggregations