classpublicPriority 3
CustomConnectedBlockTemplateAsset
com.hypixel.hytale.server.core.universe.world.connectedblocks.CustomConnectedBlockTemplateAsset
implements JsonAssetWithMap<String, DefaultAssetMap<String, CustomConnectedBlockTemplateAsset>>
4
Methods
4
Public Methods
7
Fields
1
Constructors
Constants
AssetBuilderCodec<String, CustomConnectedBlockTemplateAsset>CODEC= AssetBuilderCodec.builder(
CustomConnectedBlockTemplateAsset.class,
CustomConne...
ValidatorCache<String>VALIDATOR_CACHE= new ValidatorCache<>(new AssetKeyValidator<>(CustomConnectedBlockTemplateAsset::getAssetStore))
Constructors
public
CustomConnectedBlockTemplateAsset()Methods
Public Methods (4)
publicstatic
DefaultAssetMap<String, CustomConnectedBlockTemplateAsset> getAssetMap()publicstatic
AssetStore<String, CustomConnectedBlockTemplateAsset, DefaultAssetMap<String, CustomConnectedBlockTemplateAsset>> getAssetStore()public
String getId()public
boolean isDontUpdateAfterInitialPlacement()Fields
Protected Fields (2)
protected
Map<String, ConnectedBlockShape> connectedBlockShapesprotected
boolean connectsToOtherMaterialsPrivate/Package Fields (5)
private
AssetStore<String, CustomConnectedBlockTemplateAsset, DefaultAssetMap<String, CustomConnectedBlockTemplateAsset>> ASSET_STOREprivate
AssetExtraInfo.Data dataprivate
String defaultShapeNameprivate
boolean dontUpdateAfterInitialPlacementprivate
String idInheritance
Parent
Current
Interface
Child
Use mouse wheel to zoom, drag to pan. Click nodes to navigate.
Related Classes
Source Code
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.assetstore.AssetExtraInfo;
import com.hypixel.hytale.assetstore.AssetKeyValidator;
import com.hypixel.hytale.assetstore.AssetStore;
import com.hypixel.hytale.assetstore.codec.AssetBuilderCodec;
import com.hypixel.hytale.assetstore.map.DefaultAssetMap;
import com.hypixel.hytale.assetstore.map.JsonAssetWithMap;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.codecs.map.MapCodec;
import com.hypixel.hytale.codec.validation.ValidatorCache;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.prefab.selection.mask.BlockPattern;
import com.hypixel.hytale.server.core.universe.world.World;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Map.Entry;
import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Nonnull;
public class CustomConnectedBlockTemplateAsset implements JsonAssetWithMap<String, DefaultAssetMap<String, CustomConnectedBlockTemplateAsset>> {
public static final AssetBuilderCodec<String, CustomConnectedBlockTemplateAsset> CODEC = AssetBuilderCodec.builder(
CustomConnectedBlockTemplateAsset.class,
CustomConnectedBlockTemplateAsset::new,
Codec.STRING,
(builder, id) -> builder.id = id,
builder -> builder.id,
(builder, data) -> builder.data = data,
builder -> builder.data
)
.append(
new KeyedCodec<>("DontUpdateAfterInitialPlacement", Codec.BOOLEAN, false),
(o, dontUpdateAfterInitialPlacement) -> o.dontUpdateAfterInitialPlacement = dontUpdateAfterInitialPlacement,
o -> o.dontUpdateAfterInitialPlacement
)
.documentation(
"Default to false. When true, will not update the connected block after initial placement. Neighboring block updates won't affect this block when true."
)
.add()
.<Boolean>append(
new KeyedCodec<>("ConnectsToOtherMaterials", Codec.BOOLEAN, false),
(o, connectsToOtherMaterials) -> o.connectsToOtherMaterials = connectsToOtherMaterials,
o -> o.connectsToOtherMaterials
)
.documentation(
"Defaults to true. If true, the material will connect to other materials of different block type sets, if false, the material will only connect to its own block types within the material"
)
.add()
.append(new KeyedCodec<>("DefaultShape", Codec.STRING, false), (o, defaultShapeName) -> o.defaultShapeName = defaultShapeName, o -> o.defaultShapeName)
.add()
.append(
new KeyedCodec<>("Shapes", new MapCodec<>(ConnectedBlockShape.CODEC, HashMap::new), true),
(o, connectedBlockShapes) -> o.connectedBlockShapes = connectedBlockShapes,
o -> o.connectedBlockShapes
)
.add()
.build();
public static final ValidatorCache<String> VALIDATOR_CACHE = new ValidatorCache<>(new AssetKeyValidator<>(CustomConnectedBlockTemplateAsset::getAssetStore));
private static AssetStore<String, CustomConnectedBlockTemplateAsset, DefaultAssetMap<String, CustomConnectedBlockTemplateAsset>> ASSET_STORE;
private String id;
private AssetExtraInfo.Data data;
protected boolean connectsToOtherMaterials = true;
private boolean dontUpdateAfterInitialPlacement;
private String defaultShapeName;
protected Map<String, ConnectedBlockShape> connectedBlockShapes;
public CustomConnectedBlockTemplateAsset() {
}
public static AssetStore<String, CustomConnectedBlockTemplateAsset, DefaultAssetMap<String, CustomConnectedBlockTemplateAsset>> getAssetStore() {
// $VF: Couldn't be decompiled
// Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
// java.lang.StackOverflowError
// at java.base/java.util.HashMap.put(HashMap.java:619)
// at org.jetbrains.java.decompiler.struct.gen.generics.GenericType.mapGenVarsTo(GenericType.java:623)
// at org.jetbrains.java.decompiler.struct.gen.generics.GenericType.getGenericSuperType(GenericType.java:677)
// at org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent.lambda$isMappingInBounds$18(InvocationExprent.java:1608)
// at org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent.lambda$isMappingInBounds$19(InvocationExprent.java:1648)
//
// Bytecode:
// 00: getstatic com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockTemplateAsset.ASSET_STORE Lcom/hypixel/hytale/assetstore/AssetStore;
// 03: ifnonnull 0e
// 06: ldc com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockTemplateAsset
// 08: invokestatic com/hypixel/hytale/assetstore/AssetRegistry.getAssetStore (Ljava/lang/Class;)Lcom/hypixel/hytale/assetstore/AssetStore;
// 0b: putstatic com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockTemplateAsset.ASSET_STORE Lcom/hypixel/hytale/assetstore/AssetStore;
// 0e: getstatic com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockTemplateAsset.ASSET_STORE Lcom/hypixel/hytale/assetstore/AssetStore;
// 11: areturn
}
public static DefaultAssetMap<String, CustomConnectedBlockTemplateAsset> getAssetMap() {
// $VF: Couldn't be decompiled
// Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
// java.lang.StackOverflowError
// at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:587)
// at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:574)
// at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)
// at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
// at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
// at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
// at java.base/java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:668)
// at org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent.lambda$isMappingInBounds$20(InvocationExprent.java:1648)
//
// Bytecode:
// 0: invokestatic com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockTemplateAsset.getAssetStore ()Lcom/hypixel/hytale/assetstore/AssetStore;
// 3: invokevirtual com/hypixel/hytale/assetstore/AssetStore.getAssetMap ()Lcom/hypixel/hytale/assetstore/AssetMap;
// 6: checkcast com/hypixel/hytale/assetstore/map/DefaultAssetMap
// 9: areturn
}
@Nonnull
public Optional<ConnectedBlocksUtil.ConnectedBlockResult> getConnectedBlockType(
World world,
Vector3i coordinate,
CustomTemplateConnectedBlockRuleSet ruleSet,
BlockType blockType,
int rotation,
Vector3i placementNormal,
boolean useDefaultShapeIfNoMatch,
boolean isPlacement
) {
for (Entry<String, ConnectedBlockShape> entry : this.connectedBlockShapes.entrySet()) {
ConnectedBlockShape connectedBlockShape = entry.getValue();
if (connectedBlockShape != null) {
CustomTemplateConnectedBlockPattern[] patterns = connectedBlockShape.getPatternsToMatchAnyOf();
if (patterns != null) {
for (CustomTemplateConnectedBlockPattern connectedBlockPattern : patterns) {
Optional<ConnectedBlocksUtil.ConnectedBlockResult> blockRotationIfMatchedOptional = connectedBlockPattern.getConnectedBlockTypeKey(
entry.getKey(), world, coordinate, ruleSet, blockType, rotation, placementNormal, isPlacement
);
if (!blockRotationIfMatchedOptional.isEmpty()) {
return blockRotationIfMatchedOptional;
}
}
}
}
}
if (useDefaultShapeIfNoMatch) {
BlockPattern defaultShapeBlockPattern = ruleSet.getShapeNameToBlockPatternMap().get(this.defaultShapeName);
if (defaultShapeBlockPattern == null) {
return Optional.empty();
} else {
BlockPattern.BlockEntry defaultBlock = defaultShapeBlockPattern.nextBlockTypeKey(ThreadLocalRandom.current());
return Optional.of(new ConnectedBlocksUtil.ConnectedBlockResult(defaultBlock.blockTypeKey(), rotation));
}
} else {
return Optional.empty();
}
}
public boolean isDontUpdateAfterInitialPlacement() {
return this.dontUpdateAfterInitialPlacement;
}
public String getId() {
return this.id;
}
}