use of org.spongepowered.api.data.value.mutable.MutableBoundedValue in project modules-extra by CubeEngine.
the class ModifyBlockReport method showReport.
@Override
public void showReport(List<Action> actions, Receiver receiver) {
Action action = actions.get(0);
Optional<BlockSnapshot> orig = action.getCached(BLOCKS_ORIG, Recall::origSnapshot);
Optional<BlockSnapshot> repl = action.getCached(BLOCKS_REPL, Recall::replSnapshot);
Text cause = Recall.cause(action);
if (!repl.isPresent() || !orig.isPresent()) {
throw new IllegalStateException();
}
Optional<MutableBoundedValue<Integer>> growth = repl.get().getValue(Keys.GROWTH_STAGE);
if (growth.isPresent()) {
if (growth.get().get().equals(growth.get().getMaxValue())) {
receiver.sendReport(this, actions, actions.size(), "{txt} let {txt} grow to maturity", "{txt} let {txt} grow to maturity x{}", cause, name(orig.get(), receiver), actions.size());
return;
}
receiver.sendReport(this, actions, actions.size(), "{txt} let {txt} grow", "{txt} let {txt} grow x{}", cause, name(orig.get(), receiver), actions.size());
return;
}
// TODO other modifyables
receiver.sendReport(this, actions, actions.size(), "{txt} modified {txt}", "{txt} modified {txt} x{}", cause, name(orig.get(), receiver), actions.size());
}
use of org.spongepowered.api.data.value.mutable.MutableBoundedValue in project LanternServer by LanternPowered.
the class LanternLiving method registerKeys.
@Override
public void registerKeys() {
super.registerKeys();
final ValueCollection c = getValueCollection();
c.register(Keys.MAX_AIR, 300, 0, Integer.MAX_VALUE);
c.register(Keys.REMAINING_AIR, 300, 0, Keys.MAX_AIR);
c.register(Keys.MAX_HEALTH, 20.0, 0.0, 1024.0);
c.register(Keys.HEALTH, 20.0, 0.0, Keys.MAX_HEALTH).addListener((oldElement, newElement) -> {
if (newElement <= 0) {
handleDeath();
}
});
// noinspection unchecked
c.register((Key<MutableBoundedValue<Double>>) (Key) Keys.ABSORPTION, 0.0, 0.0, 1024.0);
c.register(Keys.POTION_EFFECTS, new ArrayList<>());
}
Aggregations