classpublicPriority 3
ExportedDensityAsset
com.hypixel.hytale.builtin.hytalegenerator.assets.density.ExportedDensityAsset
extends DensityAsset
3
Methods
3
Public Methods
1
Fields
1
Constructors
Constants
BuilderCodec<ExportedDensityAsset>CODEC= BuilderCodec.builder(
ExportedDensityAsset.class, ExportedDensityAsset::new, DensityAsse...
Constructors
public
ExportedDensityAsset()Methods
Public Methods (3)
public
Density build(DensityAsset.Argument argument)@Nonnull@Override
public
void cleanUp()@Override
public
boolean isSingleInstance()Fields
Private/Package Fields (1)
private
boolean singleInstanceInheritance
Parent
Current
Interface
Child
Use mouse wheel to zoom, drag to pan. Click nodes to navigate.
Related Classes
Source Code
package com.hypixel.hytale.builtin.hytalegenerator.assets.density;
import com.hypixel.hytale.builtin.hytalegenerator.LoggerUtil;
import com.hypixel.hytale.builtin.hytalegenerator.density.Density;
import com.hypixel.hytale.builtin.hytalegenerator.density.nodes.ConstantValueDensity;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import javax.annotation.Nonnull;
public class ExportedDensityAsset extends DensityAsset {
public static final BuilderCodec<ExportedDensityAsset> CODEC = BuilderCodec.builder(
ExportedDensityAsset.class, ExportedDensityAsset::new, DensityAsset.ABSTRACT_CODEC
)
.append(new KeyedCodec<>("SingleInstance", Codec.BOOLEAN, false), (asset, value) -> asset.singleInstance = value, asset -> asset.singleInstance)
.add()
.build();
private boolean singleInstance = false;
public ExportedDensityAsset() {
}
@Nonnull
@Override
public Density build(@Nonnull DensityAsset.Argument argument) {
if (!this.isSkipped() && this.inputs().length != 0) {
DensityAsset.Exported exported = getExportedAsset(this.exportName);
if (exported == null) {
LoggerUtil.getLogger()
.severe("Couldn't find Density asset exported with name: '" + this.exportName + "'. This could indicate a defect in the HytaleGenerator assets.");
return this.firstInput().build(argument);
} else if (exported.singleInstance) {
if (exported.builtInstance == null) {
exported.builtInstance = this.firstInput().build(argument);
}
return exported.builtInstance;
} else {
return this.firstInput().build(argument);
}
} else {
return new ConstantValueDensity(0.0);
}
}
@Override
public void cleanUp() {
this.cleanUpInputs();
DensityAsset.Exported exported = getExportedAsset(this.exportName);
if (exported != null) {
exported.builtInstance = null;
for (DensityAsset input : this.inputs()) {
input.cleanUp();
}
}
}
public boolean isSingleInstance() {
return this.singleInstance;
}
}