本文整理汇总了Java中org.spongepowered.api.data.merge.MergeFunction类的典型用法代码示例。如果您正苦于以下问题:Java MergeFunction类的具体用法?Java MergeFunction怎么用?Java MergeFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MergeFunction类属于org.spongepowered.api.data.merge包,在下文中一共展示了MergeFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fluidStack
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
LanternFluidStack fluidStack(@Nullable FluidType fluidType) {
if (fluidType != null) {
if (this.fluidStack == null) {
this.fluidStack = new LanternFluidStack(fluidType, 0);
} else if (this.fluidStack.getFluid() != fluidType) {
final FluidStack old = this.fluidStack;
this.fluidStack = new LanternFluidStack(fluidType, 0);
this.fluidStack.setVolume(old.getVolume());
this.fluidStack.copyFromNoEvents(old, MergeFunction.IGNORE_ALL);
}
this.fluidTypeSet = true;
} else if (this.fluidStack == null) {
this.fluidStack = new LanternFluidStack(FluidTypes.WATER, 0);
}
return this.fluidStack;
}
示例2: merge
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
public BlockState merge(BlockState that, MergeFunction function) {
if (!getType().equals(that.getType())) {
return this;
} else {
BlockState temp = this;
for (ImmutableDataManipulator<?, ?> manipulator : that.getManipulators()) {
final ImmutableDataManipulator old = temp.get(manipulator.getClass()).orElse(null);
final Optional<BlockState> optional = temp.with(checkNotNull(function.merge(old, manipulator)));
if (optional.isPresent()) {
temp = optional.get();
} else {
return temp;
}
}
return temp;
}
}
示例3: itemStack
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
private LanternItemStack itemStack(@Nullable ItemType itemType) {
if (itemType != null) {
if (this.itemStack == null) {
this.itemStack = new LanternItemStack(itemType);
} else if (this.itemStack.getType() != itemType) {
final LanternItemStack old = this.itemStack;
this.itemStack = new LanternItemStack(itemType);
this.itemStack.setQuantity(old.getQuantity());
this.itemStack.copyFromNoEvents(old, MergeFunction.IGNORE_ALL);
}
this.itemTypeSet = true;
} else if (this.itemStack == null) {
this.itemStack = new LanternItemStack(ItemTypes.APPLE);
}
return this.itemStack;
}
示例4: fill
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
public Optional<SafeLoginData> fill(DataHolder dataHolder, MergeFunction overlap)
{
Optional<Boolean> flymode = dataHolder.get(FLYMODE);
if (flymode.isPresent())
{
SafeLoginData data = new SafeLoginData(flymode.get());
overlap.merge(this, data);
if (data != this)
{
this.setValue(flymode.get());
}
return Optional.of(this);
}
return Optional.empty();
}
示例5: fill
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
public Optional<DuctData> fill(DataHolder dataHolder, MergeFunction overlap)
{
Optional<Map<Direction, List<ItemStack>>> filters = dataHolder.get(FILTERS);
if (filters.isPresent())
{
DuctData data = this.copy();
data.setFilters(filters.get());
data = overlap.merge(this, data);
if (data != this)
{
this.setFilters(data.getFilters());
}
return Optional.of(this);
}
return Optional.empty();
}
示例6: fill
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
public Optional<PowertoolData> fill(DataHolder dataHolder, MergeFunction overlap)
{
Optional<List<String>> powers = dataHolder.get(POWERS);
if (powers.isPresent())
{
PowertoolData data = this.copy();
data.powers = powers.get();
data = overlap.merge(this, data);
if (data != this)
{
this.powers = data.powers;
}
return Optional.of(this);
}
return Optional.empty();
}
示例7: fill
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
public Optional<MarketSignData> fill(DataHolder dataholder, MergeFunction mergeFunction)
{
if (!supports(dataholder))
{
return Optional.empty();
}
MarketSignData merged = mergeFunction.merge(this,
new MarketSignData().with(
dataholder.get(ID).orElse(null),
dataholder.get(SIGN_TYPE).orElse(null),
dataholder.get(OWNER).orElse(null),
dataholder.get(AMOUNT).orElse(null),
dataholder.get(DEMAND).orElse(null),
dataholder.get(PRICE).orElse(null),
dataholder.get(ITEM).orElse(null),
dataholder.get(STOCK).orElse(null),
dataholder.get(SIZE).orElse(null)));
if (merged != this)
{
this.with(merged.id, merged.type, merged.owner, merged.amount, merged.demand, merged.price, merged.item, merged.stock, merged.size);
}
return Optional.of(this);
}
示例8: fill
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
public Optional<UnbreakableData> fill(DataHolder dataHolder, MergeFunction overlap)
{
Optional<Boolean> flymode = dataHolder.get(UNBREAKING);
if (flymode.isPresent())
{
UnbreakableData data = new UnbreakableData(flymode.get());
overlap.merge(this, data);
if (data != this)
{
this.setValue(flymode.get());
}
return Optional.of(this);
}
return Optional.empty();
}
示例9: fill
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
public Optional<ElevatorData> fill(DataHolder dataholder, MergeFunction mergeFunction)
{
if (!supports(dataholder))
{
return Optional.empty();
}
ElevatorData merged = mergeFunction.merge(this,
new ElevatorData().with(
dataholder.get(OWNER).orElse(null),
dataholder.get(TARGET).orElse(null)));
if (merged != this)
{
this.with(merged.owner, merged.target);
}
return Optional.of(this);
}
示例10: fill
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
public Optional<KitData> fill(DataHolder dataHolder, MergeFunction overlap)
{
Optional<Map<String, Integer>> times = dataHolder.get(TIMES);
Optional<Map<String, Long>> time = dataHolder.get(TIME);
if (times.isPresent() || time.isPresent())
{
KitData data = this.copy();
data.times = times.orElse(new HashMap<>());
data.time = time.orElse(new HashMap<>());
data = overlap.merge(this, data);
if (data != this)
{
this.times = data.times;
this.time = data.time;
}
return Optional.of(this);
}
return Optional.empty();
}
示例11: fill
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
public Optional<ViewerData> fill(DataHolder dataHolder, MergeFunction mergeFunction) {
ViewerData jobDataManipulator = Preconditions.checkNotNull(mergeFunction).merge(copy(),
dataHolder.get(ViewerData.class).orElse(copy()));
return Optional.of(jobDataManipulator);
}
示例12: fill
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
public Optional<AnnointmentFlagData> fill(DataHolder dataHolder,
MergeFunction overlap) {
AnnointmentFlagData dataHolderAsAFD =
getFlags(dataHolder).map(AnnointmentFlagData::new).orElse(null);
return Optional.of(overlap.merge(this, dataHolderAsAFD));
}
示例13: fill
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
@Nonnull
public Optional<RepresentedCustomItemSnapshotData> fill(@Nonnull DataHolder dataHolder, @Nonnull MergeFunction mergeFunction) {
RepresentedCustomItemSnapshotData data = new RepresentedCustomItemSnapshotData();
dataHolder.get(CustomItemLibraryKeys.REPRESENTED_CUSTOM_ITEM_SNAPSHOT)
.ifPresent(itemStackSnapshot -> data.representedCustomItemSnapshot = itemStackSnapshot);
return Optional.of(data);
}
示例14: fill
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
@Nonnull
public Optional<CustomFeatureData> fill(@Nonnull DataHolder dataHolder, @Nonnull MergeFunction mergeFunction) {
CustomFeatureData data = new CustomFeatureData();
dataHolder.get(CustomItemLibraryKeys.CUSTOM_FEATURE_PLUGIN_ID)
.ifPresent(pluginId -> data.customFeaturePluginId = pluginId);
dataHolder.get(CustomItemLibraryKeys.CUSTOM_FEATURE_TYPE_ID)
.ifPresent(typeId -> data.customFeatureTypeId = typeId);
dataHolder.get(CustomItemLibraryKeys.CUSTOM_FEATURE_MODEL)
.ifPresent(model -> data.customFeatureModel = model);
return Optional.of(data);
}
示例15: fill
import org.spongepowered.api.data.merge.MergeFunction; //导入依赖的package包/类
@Override
@Nonnull
public Optional<CustomBlockData> fill(@Nonnull DataHolder dataHolder, @Nonnull MergeFunction mergeFunction) {
CustomBlockData data = new CustomBlockData();
dataHolder.get(CustomItemLibraryKeys.CUSTOM_BLOCK_DAMAGE_INDICATOR_ARMOR_STAND_ID)
.ifPresent(damageIndicatorArmorStandId -> data.damageIndicatorArmorStandId = damageIndicatorArmorStandId);
return Optional.of(data);
}