use of org.lanternpowered.server.data.ValueCollection in project LanternServer by LanternPowered.
the class LanternEntity method registerKeys.
public void registerKeys() {
final ValueCollection c = getValueCollection();
c.register(Keys.DISPLAY_NAME, Text.EMPTY);
c.register(Keys.CUSTOM_NAME_VISIBLE, true);
c.registerNonRemovable(Keys.VELOCITY, Vector3d.ZERO);
c.registerNonRemovable(Keys.FIRE_TICKS, 0);
c.registerNonRemovable(Keys.FALL_DISTANCE, 0f);
c.registerNonRemovable(Keys.GLOWING, false);
c.registerNonRemovable(Keys.INVISIBLE, false);
c.registerNonRemovable(Keys.INVULNERABLE, false);
c.registerNonRemovable(LanternKeys.PORTAL_COOLDOWN_TICKS, 0);
}
use of org.lanternpowered.server.data.ValueCollection in project LanternServer by LanternPowered.
the class AbstractUser method registerKeys.
@Override
public void registerKeys() {
super.registerKeys();
final ValueCollection c = getValueCollection();
c.register(LanternKeys.ACCESSORIES, new ArrayList<>());
c.register(LanternKeys.MAX_EXHAUSTION, 40.0, 0.0, Double.MAX_VALUE);
c.register(Keys.EXHAUSTION, DEFAULT_EXHAUSTION, 0.0, LanternKeys.MAX_EXHAUSTION);
c.register(LanternKeys.MAX_FOOD_LEVEL, 20, 0, Integer.MAX_VALUE);
c.register(Keys.FOOD_LEVEL, 20, 0, LanternKeys.MAX_FOOD_LEVEL);
c.registerWithSuppliedMax(Keys.SATURATION, DEFAULT_SATURATION, 0.0, container -> container.get(Keys.FOOD_LEVEL).orElse(20).doubleValue());
c.register(Keys.LAST_DATE_PLAYED, null);
c.register(Keys.FIRST_DATE_PLAYED, null);
c.registerNonRemovable(Keys.WALKING_SPEED, 0.1);
c.registerNonRemovable(LanternKeys.FIELD_OF_VIEW_MODIFIER, 1.0);
c.registerNonRemovable(Keys.IS_FLYING, false);
c.registerNonRemovable(Keys.IS_SNEAKING, false);
c.registerNonRemovable(Keys.IS_SPRINTING, false);
c.registerNonRemovable(Keys.FLYING_SPEED, 0.1);
c.registerNonRemovable(Keys.CAN_FLY, false);
c.registerNonRemovable(Keys.RESPAWN_LOCATIONS, new HashMap<>());
c.registerNonRemovable(Keys.GAME_MODE, GameModes.NOT_SET).addListener((oldElement, newElement) -> {
((LanternGameMode) newElement).getAbilityApplier().accept(this);
// This MUST be updated, unless you want strange behavior on the client,
// the client has 3 different concepts of 'isCreative', and each combination
// gives a different outcome...
// For example:
// - Disable noClip and glow in spectator, but you can place blocks
// - NoClip in creative, but you cannot change your hotbar, or drop items
// Not really worth the trouble right now
// TODO: Differentiate the 'global tab list entry' and the entry to update
// TODO: these kind of settings to avoid possible 'strange' behavior.
GlobalTabList.getInstance().get(getProfile()).ifPresent(e -> e.setGameMode(newElement));
});
c.registerNonRemovable(Keys.DOMINANT_HAND, HandPreferences.RIGHT);
c.registerNonRemovable(LanternKeys.IS_ELYTRA_FLYING, false);
c.registerNonRemovable(LanternKeys.ELYTRA_GLIDE_SPEED, 0.1);
c.registerNonRemovable(LanternKeys.ELYTRA_SPEED_BOOST, false);
c.registerNonRemovable(LanternKeys.SUPER_STEVE, false);
c.registerNonRemovable(LanternKeys.CAN_WALL_JUMP, false);
c.registerNonRemovable(LanternKeys.CAN_DUAL_WIELD, false);
c.registerNonRemovable(LanternKeys.SCORE, 0);
c.registerNonRemovable(LanternKeys.ACTIVE_HAND, Optional.empty());
c.registerNonRemovable(LanternKeys.RECIPE_BOOK_FILTER_ACTIVE, false);
c.registerNonRemovable(LanternKeys.RECIPE_BOOK_GUI_OPEN, false);
c.registerProcessor(Keys.STATISTICS).add(builder -> builder.offerHandler((key, valueContainer, map) -> {
this.statisticMap.setStatisticValues(map);
return DataTransactionResult.successNoData();
}).retrieveHandler((key, valueContainer) -> Optional.of(this.statisticMap.getStatisticValues())).failAlwaysRemoveHandler());
c.registerNonRemovable(LanternKeys.OPEN_ADVANCEMENT_TREE, Optional.empty());
}
use of org.lanternpowered.server.data.ValueCollection in project LanternServer by LanternPowered.
the class LanternPlayer method registerKeys.
@Override
public void registerKeys() {
super.registerKeys();
final ValueCollection c = getValueCollection();
((ElementKeyRegistration<?, Optional<AdvancementTree>>) c.get(LanternKeys.OPEN_ADVANCEMENT_TREE).get()).addListener((oldElement, newElement) -> {
if (getWorld() != null) {
this.session.send(new MessagePlayOutSelectAdvancementTree(newElement.map(AdvancementTree::getId).orElse(null)));
}
});
}
use of org.lanternpowered.server.data.ValueCollection in project LanternServer by LanternPowered.
the class LanternItem method registerKeys.
@Override
public void registerKeys() {
super.registerKeys();
final ValueCollection c = getValueCollection();
c.register(Keys.REPRESENTED_ITEM, null);
c.register(Keys.PICKUP_DELAY, 10);
c.register(Keys.DESPAWN_DELAY, 6000);
c.register(LanternKeys.GRAVITY_FACTOR, 0.002);
}
use of org.lanternpowered.server.data.ValueCollection 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