Skip to content

Commit

Permalink
Priorities in datapacks
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoudje committed Jan 29, 2024
1 parent d3a84b5 commit 42ce6f5
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import net.minecraft.world.level.block.entity.BlockEntity
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
import net.minecraft.world.level.material.Material
import net.minecraft.world.phys.shapes.VoxelShape
import org.joml.Vector3f
import org.joml.Vector3i
Expand All @@ -26,6 +25,7 @@ import org.valkyrienskies.core.game.VSBlockType
import org.valkyrienskies.core.impl.collision.Lod1SolidShapeUtils
import org.valkyrienskies.core.impl.game.BlockTypeImpl
import org.valkyrienskies.mod.common.BlockStateInfoProvider
import org.valkyrienskies.mod.common.ValkyrienSkiesMod
import org.valkyrienskies.mod.common.hooks.VSGameEvents
import org.valkyrienskies.mod.common.vsCore
import org.valkyrienskies.mod.mixin.accessors.world.level.block.SlabBlockAccessor
Expand Down Expand Up @@ -160,7 +160,7 @@ object MassDatapackResolver : BlockStateInfoProvider {
val friction = element.asJsonObject["friction"]?.asDouble ?: DEFAULT_FRICTION
val elasticity = element.asJsonObject["elasticity"]?.asDouble ?: DEFAULT_ELASTICITY

val priority = element.asJsonObject["priority"]?.asInt ?: 100
val priority = element.asJsonObject["priority"]?.asInt ?: decideDefaultPriority(origin)

if (tag != null) {
addToBeAddedTags(VSBlockStateInfo(ResourceLocation(tag), priority, weight, friction, elasticity, null))
Expand All @@ -173,6 +173,13 @@ object MassDatapackResolver : BlockStateInfoProvider {
}
}

fun decideDefaultPriority(resourceLocation: ResourceLocation) = when {
resourceLocation.namespace.equals(ValkyrienSkiesMod.MOD_ID) -> 1000
resourceLocation.namespace.equals("custom") -> 50
else -> 100
}


private fun generateStairCollisionShapes(stairShapes: Array<VoxelShape>): Map<VoxelShape, Lod1SolidCollisionShape> {
val testPoints = listOf(
CollisionPoint(Vector3f(.25f, .25f, .25f), .25f),
Expand Down

0 comments on commit 42ce6f5

Please sign in to comment.