use of org.spongepowered.common.bridge.world.storage.MapDecorationBridge in project SpongeCommon by SpongePowered.
the class SpongeMapDecorationBuilder method build.
@Override
public MapDecoration build() throws IllegalStateException {
Objects.requireNonNull(this.type, "Type has not been set");
final MapDecoration decoration = (MapDecoration) new net.minecraft.world.level.saveddata.maps.MapDecoration(((SpongeMapDecorationType) this.type).getType(), (byte) this.x, (byte) this.y, (byte) ((SpongeMapDecorationOrientation) this.rot).getOrientationNumber(), this.customName == null ? null : SpongeAdventure.asVanilla(this.customName));
// Anything that comes out of this builder should be persistent
((MapDecorationBridge) decoration).bridge$setPersistent(true);
return decoration;
}
use of org.spongepowered.common.bridge.world.storage.MapDecorationBridge in project SpongeCommon by SpongePowered.
the class MapItemSavedDataMixin method bridge$setDecorations.
@SuppressWarnings("SuspiciousMethodCalls")
@Override
public void bridge$setDecorations(final Set<org.spongepowered.api.map.decoration.MapDecoration> newDecorations) {
this.decorations.clear();
for (final org.spongepowered.api.map.decoration.MapDecoration decoration : newDecorations) {
this.impl$addDecorationToDecorationsMapIfNotExists((MapDecoration) decoration);
}
for (final MapDecoration existingDecoration : this.decorations.values()) {
if (!newDecorations.contains(existingDecoration)) {
// Removed.
((MapDecorationBridge) existingDecoration).notifyRemovedFromMap((MapInfo) this);
this.setDirty();
}
}
if (newDecorations.isEmpty()) {
((SpongeDataHolderBridge) this).bridge$remove(Keys.MAP_DECORATIONS);
} else {
((SpongeDataHolderBridge) this).bridge$offer(Keys.MAP_DECORATIONS, newDecorations);
}
}
use of org.spongepowered.common.bridge.world.storage.MapDecorationBridge in project SpongeCommon by SpongePowered.
the class MapItemSavedDataMixin method impl$addDecorationToDecorationsMapIfNotExists.
public void impl$addDecorationToDecorationsMapIfNotExists(final MapDecoration mapDecoration) {
final MapDecorationBridge bridge = (MapDecorationBridge) mapDecoration;
// Anything saved should be persistent so it can save next time too.
bridge.bridge$setPersistent(true);
if (this.decorations.containsKey(bridge.bridge$getKey())) {
return;
}
((MapDecorationBridge) mapDecoration).notifyAddedToMap((MapInfo) this);
this.decorations.put(bridge.bridge$getKey(), mapDecoration);
this.setDirty();
}
Aggregations