use of org.spongepowered.api.data.key.Key in project SpongeCommon by SpongePowered.
the class MobSpawnerDataProcessor method getValues.
@Override
protected Map<Key<?>, ?> getValues(IMixinMobSpawner spawner) {
MobSpawnerBaseLogic logic = spawner.getLogic();
Map<Key<?>, Object> values = Maps.newIdentityHashMap();
values.put(Keys.SPAWNER_REMAINING_DELAY, (short) logic.spawnDelay);
values.put(Keys.SPAWNER_MINIMUM_DELAY, (short) logic.minSpawnDelay);
values.put(Keys.SPAWNER_MAXIMUM_DELAY, (short) logic.maxSpawnDelay);
values.put(Keys.SPAWNER_SPAWN_COUNT, (short) logic.spawnCount);
values.put(Keys.SPAWNER_MAXIMUM_NEARBY_ENTITIES, (short) logic.maxNearbyEntities);
values.put(Keys.SPAWNER_REQUIRED_PLAYER_RANGE, (short) logic.activatingRangeFromPlayer);
values.put(Keys.SPAWNER_SPAWN_RANGE, (short) logic.spawnRange);
values.put(Keys.SPAWNER_NEXT_ENTITY_TO_SPAWN, SpawnerUtils.getNextEntity(logic));
values.put(Keys.SPAWNER_ENTITIES, SpawnerUtils.getEntities(logic));
return values;
}
use of org.spongepowered.api.data.key.Key in project SpongeCommon by SpongePowered.
the class AreaEffectCloudDataProcessor method getValues.
@Override
protected Map<Key<?>, ?> getValues(EntityAreaEffectCloud dataHolder) {
final HashMap<Key<?>, Object> map = new HashMap<>();
map.put(Keys.AREA_EFFECT_CLOUD_AGE, dataHolder.ticksExisted);
map.put(Keys.AREA_EFFECT_CLOUD_COLOR, Color.ofRgb(dataHolder.getColor()));
map.put(Keys.AREA_EFFECT_CLOUD_RADIUS, dataHolder.getRadius());
final IMixinAreaEffectCloud mixinAreaEffect = (IMixinAreaEffectCloud) dataHolder;
final List<net.minecraft.potion.PotionEffect> potionEffects = mixinAreaEffect.getPotionEffects();
final List<PotionEffect> effects = new ArrayList<>(potionEffects.size());
for (net.minecraft.potion.PotionEffect potionEffect : potionEffects) {
effects.add((PotionEffect) potionEffect);
}
map.put(Keys.POTION_EFFECTS, effects);
map.put(Keys.AREA_EFFECT_CLOUD_RADIUS_ON_USE, mixinAreaEffect.getRadiusOnUse());
map.put(Keys.AREA_EFFECT_CLOUD_RADIUS_PER_TICK, mixinAreaEffect.getRadiusPerTick());
map.put(Keys.AREA_EFFECT_CLOUD_DURATION, dataHolder.getDuration());
map.put(Keys.AREA_EFFECT_CLOUD_DURATION_ON_USE, mixinAreaEffect.getDurationOnUse());
map.put(Keys.AREA_EFFECT_CLOUD_REAPPLICATION_DELAY, mixinAreaEffect.getReapplicationDelay());
map.put(Keys.AREA_EFFECT_CLOUD_WAIT_TIME, mixinAreaEffect.getWaitTime());
map.put(Keys.AREA_EFFECT_CLOUD_PARTICLE_TYPE, ParticleTypes.MOB_SPELL);
return map;
}
use of org.spongepowered.api.data.key.Key in project SpongeCommon by SpongePowered.
the class EntityCommandDataProcessor method getValues.
@Override
protected Map<Key<?>, ?> getValues(EntityMinecartCommandBlock entity) {
CommandBlockBaseLogic logic = entity.getCommandBlockLogic();
Map<Key<?>, Object> values = Maps.newHashMapWithExpectedSize(4);
Optional<Text> lastCommandOutput = logic.getLastOutput() != null ? Optional.of(SpongeTexts.toText(logic.getLastOutput())) : Optional.empty();
values.put(Keys.LAST_COMMAND_OUTPUT, lastCommandOutput);
values.put(Keys.COMMAND, logic.commandStored);
values.put(Keys.SUCCESS_COUNT, logic.successCount);
values.put(Keys.TRACKS_OUTPUT, logic.shouldTrackOutput());
return values;
}
use of org.spongepowered.api.data.key.Key in project SpongeCommon by SpongePowered.
the class MixinWorld_Data method getKeys.
@Override
public Set<Key<?>> getKeys(int x, int y, int z) {
final ImmutableSet.Builder<Key<?>> builder = ImmutableSet.builder();
final BlockState blockState = getBlock(x, y, z).withExtendedProperties(new Location<>(this, x, y, z));
builder.addAll(blockState.getKeys());
final Optional<TileEntity> tileEntity = getTileEntity(x, y, z);
if (tileEntity.isPresent()) {
builder.addAll(tileEntity.get().getKeys());
}
return builder.build();
}
use of org.spongepowered.api.data.key.Key in project SpongeCommon by SpongePowered.
the class MixinStateImplementation method cycleValue.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public BlockState cycleValue(Key<? extends BaseValue<? extends Cycleable<?>>> key) {
if (supports(key)) {
final Cycleable value = (Cycleable) get((Key) key).get();
final Cycleable next = value.cycleNext();
return with((Key<? extends BaseValue<Object>>) (Key<?>) key, next).get();
}
throw new IllegalArgumentException("Used an invalid cyclable key! Check with supports in the future!");
}
Aggregations