ConnectedBlocksUtil.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.util.FillerBlockUtil;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIntPair;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import java.util.ArrayDeque;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Queue;
import java.util.Set;
import javax.annotation.Nonnull;
public class ConnectedBlocksUtil {
private static final int MAX_UPDATE_DEPTH = 3;
public {
}
{
(blockPosition);
(BlockType)BlockType.getAssetMap().getAsset(blockTypeId);
(blockType != ) {
blockChunkComponent.getSectionAtBlockY(blockPosition.y);
sectionAtY.getFiller(blockPosition.x, blockPosition.y, blockPosition.z);
;
(blockType.getConnectedBlockRuleSet() != && filler == ) {
blockTypeRotation.index();
Optional<ConnectedBlockResult> foundPattern = getDesiredConnectedBlockType(worldChunkComponent.getWorld(), coordinate, blockType, rotationIndex, placementNormal, );
(foundPattern.isPresent() && (!((ConnectedBlockResult)foundPattern.get()).blockTypeKey().equals(blockType.getId()) || ((ConnectedBlockResult)foundPattern.get()).rotationIndex != rotationIndex)) {
(ConnectedBlockResult)foundPattern.get();
BlockType.getAssetMap().getIndex(result.blockTypeKey());
result.rotationIndex();
worldChunkComponent.setBlock(coordinate.x, coordinate.y, coordinate.z, id, (BlockType)BlockType.getAssetMap().getAsset(id), rotation, , settings);
}
}
updateNeighborsWithDepth(worldChunkComponent, coordinate, placementNormal, settings);
}
}
{
{
}
Queue<QueueEntry> queue = ();
Set<Vector3i> visited = <Vector3i>();
queue.add( ( (startCoordinate), ));
label67:
(!queue.isEmpty()) {
(QueueEntry)queue.poll();
entry.coordinate;
entry.depth;
Map<Vector3i, ConnectedBlockResult> desiredChanges = <Vector3i, ConnectedBlockResult>();
notifyNeighborsAndCollectChanges(worldChunkComponent.getWorld(), coordinate, desiredChanges, placementNormal);
desiredChanges.entrySet().iterator();
() {
Vector3i location;
ConnectedBlockResult connectedBlockResult;
WorldChunk newWorldChunk;
() {
(!var10.hasNext()) {
label67;
}
Map.Entry<Vector3i, ConnectedBlockResult> result = (Map.Entry)var10.next();
location = (Vector3i)result.getKey();
connectedBlockResult = (ConnectedBlockResult)result.getValue();
(visited.add(location.clone()) && (location.x != coordinate.x || location.y != coordinate.y || location.z != coordinate.z)) {
newWorldChunk = worldChunkComponent;
ChunkUtil.indexChunkFromBlock(location.x, location.z);
(chunkIndex == worldChunkComponent.getIndex()) {
;
}
newWorldChunk = worldChunkComponent.getWorld().getChunkIfLoaded(chunkIndex);
(newWorldChunk != ) {
;
}
}
}
BlockType.getAssetMap().getIndex(connectedBlockResult.blockTypeKey());
(BlockType)BlockType.getAssetMap().getAsset(blockId);
newWorldChunk.setBlock(location.x, location.y, location.z, blockId, block, connectedBlockResult.rotationIndex(), , settings);
(Map.Entry<Vector3i, ObjectIntPair<String>> additionalEntry : connectedBlockResult.getAdditionalConnectedBlocks().entrySet()) {
(Vector3i)additionalEntry.getKey();
ObjectIntPair<String> blockData = (ObjectIntPair)additionalEntry.getValue();
( (location)).add(offset);
newWorldChunk;
ChunkUtil.indexChunkFromBlock(additionalLocation.x, additionalLocation.z);
(additionalChunkIndex != newWorldChunk.getIndex()) {
additionalChunk = worldChunkComponent.getWorld().getChunkIfLoaded(additionalChunkIndex);
(additionalChunk == ) {
;
}
}
BlockType.getAssetMap().getIndex((String)blockData.first());
(BlockType)BlockType.getAssetMap().getAsset(additionalBlockId);
(additionalBlock != ) {
additionalChunk.setBlock(additionalLocation.x, additionalLocation.y, additionalLocation.z, additionalBlockId, additionalBlock, blockData.rightInt(), , settings);
}
}
(depth + < ) {
queue.add( (location.clone(), depth + ));
}
}
}
}
{
origin.clone();
ChunkUtil.indexChunkFromBlock(origin.x, origin.z);
world.getChunkIfLoaded(chunkIndex);
( -; x1 <= ; ++x1) {
( -; z1 <= ; ++z1) {
( -; y1 <= ; ++y1) {
(x1 != || y1 != || z1 != ) {
coordinate.assign(origin).add(x1, y1, z1);
(coordinate.y >= && coordinate.y < && !desiredChanges.containsKey(coordinate)) {
ChunkUtil.indexChunkFromBlock(coordinate.x, coordinate.z);
(neighborChunkIndex != chunkIndex) {
chunkIndex = neighborChunkIndex;
chunk = world.getChunkIfLoaded(neighborChunkIndex);
}
(chunk != ) {
chunk.getBlockChunk();
(blockChunk != ) {
blockChunk.getSectionAtBlockY(coordinate.y);
(blockSection != ) {
blockSection.get(coordinate.x, coordinate.y, coordinate.z);
(BlockType)BlockType.getAssetMap().getAsset(neighborBlockId);
(neighborBlockType != ) {
neighborBlockType.getConnectedBlockRuleSet();
(ruleSet != && !ruleSet.onlyUpdateOnPlacement()) {
blockSection.getFiller(coordinate.x, coordinate.y, coordinate.z);
blockSection.getRotationIndex(coordinate.x, coordinate.y, coordinate.z);
(filler != ) {
coordinate.x - FillerBlockUtil.unpackX(filler);
coordinate.y - FillerBlockUtil.unpackY(filler);
coordinate.z - FillerBlockUtil.unpackZ(filler);
coordinate.assign(originX, originY, originZ);
}
Optional<ConnectedBlockResult> output = getDesiredConnectedBlockType(world, coordinate, neighborBlockType, existingRotation, placementNormal, );
(output.isPresent() && (!neighborBlockType.getId().equals(((ConnectedBlockResult)output.get()).blockTypeKey()) || ((ConnectedBlockResult)output.get()).rotationIndex != existingRotation)) {
desiredChanges.put(coordinate.clone(), (ConnectedBlockResult)output.get());
}
}
}
}
}
}
}
}
}
}
}
}
Optional<ConnectedBlockResult> {
currentBlockType.getConnectedBlockRuleSet();
ruleSet == ? Optional.empty() : ruleSet.getConnectedBlockType(world, coordinate, currentBlockType, currentRotation, placementNormal, isPlacement);
}
{
String blockTypeKey;
rotationIndex;
Map<Vector3i, ObjectIntPair<String>> additionalConnectedBlocks = <Vector3i, ObjectIntPair<String>>();
{
.blockTypeKey = blockTypeKey;
.rotationIndex = rotationIndex;
}
String {
.blockTypeKey;
}
{
.rotationIndex;
}
Map<Vector3i, ObjectIntPair<String>> {
.additionalConnectedBlocks;
}
{
.additionalConnectedBlocks.put(offset, ObjectIntPair.of(blockTypeKey, rotationIndex));
}
{
(obj == ) {
;
} (obj != && obj.getClass() == .getClass()) {
(ConnectedBlockResult)obj;
Objects.equals(.blockTypeKey, that.blockTypeKey) && .rotationIndex == that.rotationIndex && Objects.equals(.additionalConnectedBlocks, that.additionalConnectedBlocks);
} {
;
}
}
{
Objects.hash( []{.blockTypeKey, .rotationIndex, .additionalConnectedBlocks});
}
String {
.blockTypeKey;
+ var10000 + + .rotationIndex + + String.valueOf(.additionalConnectedBlocks) + ;
}
}
}