Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePlasticPotato committed Oct 19, 2024
1 parent 686bd75 commit d437831
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.valkyrienskies.mod.common
import com.mojang.serialization.Lifecycle
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.core.MappedRegistry
import net.minecraft.core.Registry
import net.minecraft.resources.ResourceKey
Expand Down Expand Up @@ -134,5 +135,25 @@ object BlockStateInfo {
x, y, z, level.dimensionId, prevBlockType, newBlockType, prevBlockMass,
newBlockMass
)

if (level is ServerLevel) {
if (!prevBlockState.isAir && newBlockState.isAir){
val blockNeighbors: HashSet<BlockPos> = HashSet()
for (dir in Direction.entries) {
val neighborPos = BlockPos(x, y, z).relative(dir)
val neighborState = level.getBlockState(neighborPos)
if (!neighborState.isAir) {
blockNeighbors.add(neighborPos)
}
}
for (neighborPos in blockNeighbors) {
for (otherNeighborPos in blockNeighbors) {
if (neighborPos != otherNeighborPos) {

}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.joml.Vector3i
private val AIR = Blocks.AIR.defaultBlockState()
object AssemblyUtil {

fun setBlock(level: Level, pos: BlockPos, state: BlockState?) {
fun setBlock(level: Level, pos: BlockPos, state: BlockState) {
val chunk = level.getChunk(pos) as LevelChunk
val section = chunk.getSection(chunk.getSectionIndex(pos.y))
val oldState = level.getBlockState(pos)
Expand All @@ -29,7 +29,7 @@ object AssemblyUtil {
setBlock(level, pos, Blocks.AIR.defaultBlockState())
}

fun copyBlock(level: Level, from: BlockPos?, to: BlockPos) {
fun copyBlock(level: Level, from: BlockPos, to: BlockPos) {
val state = level.getBlockState(from)
val blockentity = level.getBlockEntity(from)
setBlock(level, to, state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ object ShipAssembler {
val relative: BlockPos = itPos.subtract( BlockPos(contraptionOGPos.x(),contraptionOGPos.y(),contraptionOGPos.z()))
val shipPos: BlockPos = contraptionBlockPos.offset(relative)
AssemblyUtil.copyBlock(level, itPos, shipPos)
if (relative == BlockPos.ZERO) centerBlockReplaced = true
if (relative.equals(BlockPos.ZERO)) centerBlockReplaced = true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,11 @@ package org.valkyrienskies.mod.common.assembly

import net.minecraft.core.BlockPos
import net.minecraft.server.level.ServerLevel
import net.minecraft.world.level.ChunkPos
import org.joml.Vector3d
import org.valkyrienskies.core.api.ships.ServerShip
import org.valkyrienskies.core.impl.game.ships.ShipData
import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl
import org.valkyrienskies.core.util.datastructures.DenseBlockPosSet
import org.valkyrienskies.mod.common.dimensionId
import org.valkyrienskies.mod.common.executeIf
import org.valkyrienskies.mod.common.isTickingChunk
import org.valkyrienskies.mod.common.networking.PacketRestartChunkUpdates
import org.valkyrienskies.mod.common.networking.PacketStopChunkUpdates
import org.valkyrienskies.mod.common.playerWrapper
import org.valkyrienskies.mod.common.shipObjectWorld
import org.valkyrienskies.mod.common.util.toBlockPos
import org.valkyrienskies.mod.common.util.toJOML
import org.valkyrienskies.mod.common.vsCore
import org.valkyrienskies.mod.util.relocateBlock
import org.valkyrienskies.mod.util.updateBlock

@Deprecated("Use ShipAssembler.assembleToShip instead")
@Deprecated("Use [ShipAssembler.assembleToShip] instead")
fun createNewShipWithBlocks(
centerBlock: BlockPos, blocks: DenseBlockPosSet, level: ServerLevel
): ServerShip {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4
create_fabric_version=0.5.1-f-build.1333+mc1.18.2
flywheel_version_fabric=0.6.9-38
createbigcannons_version= 0.5.2-nightly-e815ca4
vs_core_version=1.1.0+cf7b0d3c5b
vs_core_version=1.1.0+2e644a6fea
# Prevent kotlin from autoincluding stdlib as a dependency, which breaks
# gradle's composite builds (includeBuild) for some reason. We'll add it manually
kotlin.stdlib.default.dependency=false
Expand Down

0 comments on commit d437831

Please sign in to comment.