Skip to content

Commit

Permalink
Remove yarn aliases
Browse files Browse the repository at this point in the history
See: FabricMC/fabric-loom#1153
Using layered mappings with a custom mapping is preferred.
  • Loading branch information
solonovamax committed Aug 27, 2024
1 parent fed4707 commit fe9e4f1
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import com.mojang.blaze3d.platform.InputConstants
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.minecraft.client.KeyMapping

fun keybindingOf(translationKey: String, type: InputConstants.Type, code: Int, category: String): KeyMapping {
fun keyMappingOf(translationKey: String, type: InputConstants.Type, code: Int, category: String): KeyMapping {
return KeyBindingHelper.registerKeyBinding(KeyMapping(translationKey, type, code, category))
}

fun keybindingOf(translationKey: String, code: Int, category: String): KeyMapping {
fun keyMappingOf(translationKey: String, code: Int, category: String): KeyMapping {
return KeyBindingHelper.registerKeyBinding(KeyMapping(translationKey, code, category))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,15 @@ import net.silkmc.silk.core.math.vector.unaryMinus
import org.joml.Vector3f

fun AABB.inflate(value: Int): AABB = inflate(value.toDouble())
fun AABB.expand(value: Int): AABB = inflate(value) // for yarn mappings (inflate is expand in yarn)
fun AABB.inflate(value: Number): AABB = inflate(value.toDouble())
fun AABB.expand(value: Number): AABB = inflate(value) // for yarn mappings (inflate is expand in yarn)

fun AABB.deflate(value: Int): AABB = deflate(value.toDouble())
fun AABB.contract(value: Int): AABB = deflate(value) // for yarn mappings (deflate is contract in yarn)
fun AABB.deflate(value: Number): AABB = deflate(value.toDouble())
fun AABB.contract(value: Number): AABB = deflate(value) // for yarn mappings (deflate is contract in yarn)

fun AABB.expandTowards(x: Int, y: Int, z: Int): AABB = expandTowards(x.toDouble(), y.toDouble(), z.toDouble())
fun AABB.stretch(x: Int, y: Int, z: Int): AABB = expandTowards(x, y, z) // for yarn mappings (expandTowards is stretch in yarn)
fun AABB.expandTowards(x: Number, y: Number, z: Number): AABB = expandTowards(x.toDouble(), y.toDouble(), z.toDouble())
fun AABB.stretch(x: Number, y: Number, z: Number): AABB = expandTowards(x, y, z) // for yarn mappings (expandTowards is stretch in yarn)

infix fun AABB.minmax(aabb: AABB): AABB = minmax(aabb)
infix fun AABB.union(aabb: AABB): AABB = minmax(aabb) // for yarn mappings (minmax is union in yarn)

operator fun AABB.contains(aabb: AABB) = intersects(aabb)
operator fun AABB.contains(pos: Vec3i) = contains(pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ fun vec3Of(vec: Vector3i): Vec3 = Vec3(vec.x.toDouble(), vec.y.toDouble(), vec.z
fun vec3Of(vec: Vector3f): Vec3 = Vec3(vec)
fun vec3Of(vec: Vector3d): Vec3 = Vec3(vec.x, vec.y, vec.z)

// for yarn mappings (Vec3 is Vec3d in yarn)
fun vec3dOf(x: Double, y: Double, z: Double): Vec3 = vec3Of(x, y, z)
fun vec3dOf(vec: Vec3i): Vec3 = Vec3(vec.x.toDouble(), vec.y.toDouble(), vec.z.toDouble())
fun vec3dOf(vec: Vector3i): Vec3 = Vec3(vec.x.toDouble(), vec.y.toDouble(), vec.z.toDouble())
fun vec3dOf(vec: Vector3f): Vec3 = Vec3(vec)
fun vec3dOf(vec: Vector3d): Vec3 = Vec3(vec.x, vec.y, vec.z)

fun vector3iOf(x: Int, y: Int, z: Int): Vector3i = Vector3i(x, y, z)
fun vector3iOf(vec: Vec3i): Vector3i = Vector3i(vec.x, vec.y, vec.z)
fun vector3iOf(vec: Vec3): Vector3i = Vector3i(vec.x.roundToInt(), vec.y.roundToInt(), vec.z.roundToInt())
Expand All @@ -59,7 +52,6 @@ fun vector3dOf(vec: Vector3d): Vector3d = Vector3d(vec) // copy constructor


fun vec2Of(x: Float, y: Float): Vec2 = Vec2(x, y)
fun vec2dOf(x: Float, y: Float): Vec2 = vec2Of(x, y) // for yarn mappings (Vec2 is Vec2d in yarn)

fun vector2iOf(x: Int, y: Int): Vector2i = Vector2i(x, y)
fun vector2iOf(vec: Vec2): Vector2i = Vector2i(vec.x.roundToInt(), vec.y.roundToInt())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,10 @@ inline fun blockProperties(
builder: BlockBehaviour.Properties.() -> Unit,
): BlockBehaviour.Properties = BlockBehaviour.Properties.ofFullCopy(copiedBlock).apply(builder)

// alias for yarn
inline fun blockSettings(
copiedBlock: BlockBehaviour,
builder: BlockBehaviour.Properties.() -> Unit,
): BlockBehaviour.Properties = blockProperties(copiedBlock, builder)

inline fun blockProperties(
builder: BlockBehaviour.Properties.() -> Unit,
): BlockBehaviour.Properties = BlockBehaviour.Properties.of().apply(builder)

// alias for yarn
inline fun blockSettings(
builder: BlockBehaviour.Properties.() -> Unit,
): BlockBehaviour.Properties = blockProperties(builder)

fun <T : Block> T.register(id: ResourceLocation): T {
for (blockState in stateDefinition.possibleStates) {
Block.BLOCK_STATE_REGISTRY.add(blockState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ fun creativeModeTab(displayName: Component? = null, builder: CreativeModeTab.Bui
return itemGroupBuilder.apply(builder).build()
}

// alias for yarn
fun itemGroup(displayName: Component? = null, builder: CreativeModeTab.Builder.() -> Unit) = creativeModeTab(displayName, builder)

fun <T : CreativeModeTab> T.register(id: ResourceLocation): T {
return BuiltInRegistries.CREATIVE_MODE_TAB.register(id, this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ inline fun itemProperties(
builder: Item.Properties.() -> Unit,
): Item.Properties = Item.Properties().apply(builder)

// alias for yarn
inline fun itemSettings(
builder: Item.Properties.() -> Unit,
): Item.Properties = itemProperties(builder)

fun <T : Item> T.register(id: ResourceLocation): T {
return BuiltInRegistries.ITEM.register(id, this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,10 @@ val MinecraftServer.serverPath: Path
*/
fun MinecraftServer.getLevel(id: ResourceLocation): ServerLevel? = getLevel(ResourceKey.create(Registries.DIMENSION, id))

// alias for yarn
/**
* Retrieves the world for an associated with an id is present
*
* @param id The id of the world to check
* @return The world
*/
fun MinecraftServer.getWorld(id: ResourceLocation): ServerLevel? = getLevel(id)

/**
* Checks if the level associated with an id is present
*
* @param id The id of the level to check
* @return If the level is present
*/
fun MinecraftServer.hasLevel(id: ResourceLocation): Boolean = getLevel(id) != null

// alias for yarn
/**
* Checks if the world associated with an id is present
*
* @param id The id of the world to check
* @return If the world is present
*/
fun MinecraftServer.hasWorld(id: ResourceLocation): Boolean = hasLevel(id)
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ sealed interface IPos<N : Number> {
sealed interface Pos2Dimensional<N : Number> : IPos<N> {

fun toMcVec2() = Vec2(x.toFloat(), z.toFloat())
fun toMcVec2d() = toMcVec2() // for yarn mappings (Vec2 is Vec2d in yarn)

operator fun component1() = x
operator fun component2() = z
Expand Down Expand Up @@ -128,7 +127,6 @@ sealed interface Pos3Dimensional<N : Number> : IPos<N> {
fun toMcVector3f() = Vector3f(x.toFloat(), y.toFloat(), z.toFloat())

fun toMcVec3() = Vec3(x.toDouble(), y.toDouble(), z.toDouble())
fun toMcVec3d() = toMcVec3() // for yarn mappings (Vec3 is Vec3d in yarn)
fun toMcVector3d() = Vector3d(x.toDouble(), y.toDouble(), z.toDouble())

operator fun component1() = x
Expand Down

0 comments on commit fe9e4f1

Please sign in to comment.