Skip to content

Commit

Permalink
chore: remove silly logger and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
andantet committed Jan 12, 2025
1 parent fc60730 commit 8ab748c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_build=2
loader_version=0.16.7

# Mod Properties
mod_version=1.12
mod_version=1.13
maven_group=net.mcbrawls
mod_id=blueprint

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import net.mcbrawls.blueprint.region.CompoundRegion
import net.mcbrawls.blueprint.region.EmptyRegion
import net.mcbrawls.blueprint.region.PointRegion
import net.mcbrawls.blueprint.region.Region
import net.minecraft.block.Block
import net.minecraft.block.Blocks
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.math.BlockPos
Expand Down Expand Up @@ -66,14 +67,8 @@ data class PlacedBlueprint(
* Retrieves a single region from the source blueprint.
* @return an offset region
*/
fun getRegion(key: String): Region {
val region = blueprint.regions[key]

// verify region
if (region == null) {
logger.warn("Tried to access blueprint region but was not present: $key")
return EmptyRegion
}
fun getRegion(key: String): Region? {
val region = blueprint.regions[key] ?: return null

// return offset compound region
return region.withOffset(offset)
Expand Down Expand Up @@ -105,19 +100,11 @@ data class PlacedBlueprint(
* Gets the position of a point region.
*/
fun getPointRegionPos(id: String): Vec3d {
val region = getRegion(id)
val region = getRegion(id) ?: throw IllegalArgumentException("Not a valid region: $id")
val pointRegion = region as? PointRegion ?: throw IllegalArgumentException("Not a point region: $id")
return pointRegion.pointPosition
}

/**
* Gets the block position of a point region.
*/
fun getPointRegionBlockPos(id: String, function: (Vec3d) -> BlockPos = BlockPos::ofFloored): BlockPos {
val pos = getPointRegionPos(id)
return function.invoke(pos)
}

/**
* Performs an action for every position in this placed blueprint.
*/
Expand All @@ -130,7 +117,7 @@ data class PlacedBlueprint(
*/
fun clear(world: ServerWorld) {
forEachPosition { pos ->
world.setBlockState(pos, Blocks.AIR.defaultState)
world.setBlockState(pos, Blocks.AIR.defaultState, Block.NOTIFY_LISTENERS or Block.FORCE_STATE or Block.NO_REDRAW)
}
}

Expand Down

0 comments on commit 8ab748c

Please sign in to comment.