Skip to content

Commit

Permalink
Fix non-compound offset method returning a compound region
Browse files Browse the repository at this point in the history
  • Loading branch information
andantet committed Sep 4, 2024
1 parent 8263dc1 commit 2856416
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 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=7
loader_version=0.15.11

# Mod Properties
mod_version=1.6.2
mod_version=1.7.0
maven_group=net.mcbrawls
mod_id=blueprint

Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/net/mcbrawls/blueprint/region/CuboidRegion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ data class CuboidRegion(
return entity.boundingBox.intersects(box)
}

override fun withOffset(offset: Vec3d): Region {
return copy(rootPosition = rootPosition.add(offset))
}

companion object {
/**
* The codec of a cuboid region.
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/net/mcbrawls/blueprint/region/PointRegion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ data class PointRegion(
return entity.blockPos.equals(pointPosition.add(offset))
}

override fun withOffset(offset: Vec3d): Region {
return copy(pointPosition = pointPosition.add(offset))
}

companion object {
/**
* The codec of a cuboid region.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ data class SphericalRegion(
return entity.squaredDistanceTo(rootPosition.add(offset)) <= radius
}

override fun withOffset(offset: Vec3d): Region {
return copy(rootPosition = rootPosition.add(offset))
}

companion object {
/**
* The codec of a spherical region.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package net.mcbrawls.blueprint.region.serialization

import com.mojang.serialization.Codec
import com.mojang.serialization.MapCodec
import net.mcbrawls.blueprint.region.CompoundRegion
import net.mcbrawls.blueprint.region.Region
import net.minecraft.util.math.Vec3d

Expand All @@ -19,9 +18,7 @@ abstract class SerializableRegion(
* Creates a compound of this region with the given offset.
* @return a compound region
*/
fun withOffset(offset: Vec3d): CompoundRegion {
return CompoundRegion.ofRegionsOffset(offset, this)
}
abstract fun withOffset(offset: Vec3d): Region

/**
* A type of serializable region.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ data class PlacedBlueprint(
}

// return offset compound region
return CompoundRegion.ofRegionsOffset(offset, region)
return region.withOffset(offset)
}

/**
Expand Down

0 comments on commit 2856416

Please sign in to comment.