Skip to content

Commit

Permalink
Stage nightly (alpha.1) for 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
bibi-reden committed Aug 3, 2024
1 parent 9bf799a commit e74f3ad
Show file tree
Hide file tree
Showing 34 changed files with 310 additions and 793 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Deploy
name: Deployment (J21)
on:
push:
branches-ignore:
Expand All @@ -14,7 +14,7 @@ jobs:
BRANCH_PREFIX: $(cat gradle.properties | grep mod_version | cut -d'+' -f2)
strategy:
matrix:
java: [17]
java: [21]
runs-on: ubuntu-latest
steps:
- name: check environment variables
Expand All @@ -35,7 +35,7 @@ jobs:
run: ./gradlew build
- name: capture build artifacts
if: |
${{ matrix.java == '17' }}
${{ matrix.java == '21' }}
github.ref == 'refs/heads/${{ env.BRANCH_PREFIX }}'
uses: actions/upload-artifact@v3
with:
Expand All @@ -47,13 +47,14 @@ jobs:
run: |
loader_val=$(grep "loader" gradle.properties | cut -d'=' -f2 | tr -d '\n')
mod_version_val=$(grep "mod_version" gradle.properties | cut -d'=' -f2 | tr -d '\n')
commitish_val=$(grep "minecraft_version" gradle.properties | cut -d'=' -f2 | tr -d '\n')
echo "mod_version=$mod_version_val-$loader_val" >> $GITHUB_OUTPUT
echo "commitish=$mod_version_val/$loader_val" >> $GITHUB_OUTPUT
echo "commitish=$commitish_val/main" >> $GITHUB_OUTPUT
- name: get minecraft version
if: github.ref == 'refs/heads/${{ env.BRANCH_PREFIX }}'
id: minecraft_version
run: |
minecraft_version_val=$(grep "mod_version" gradle.properties | cut -d'+' -f2 | tr -d '\n')
minecraft_version_val=$(grep "minecraft_version" gradle.properties | cut -d'=' -f2 | tr -d '\n')
echo "minecraft_version=$minecraft_version_val" >> $GITHUB_OUTPUT
- name: deploy with mc-publish
if: github.ref == 'refs/heads/${{ env.BRANCH_PREFIX }}'
Expand Down
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
## Changes ⚙️
- Now using `WrapMethod` on computation of modifier(s) to avoid unneeded recalculation.
## Changes 🌽
- Updated dependencies to `1.21` equivalent versions.
- Changed internal networking to abide by version.
- `ItemFields` have changed to fit `1.21` definitions.
- 💖 The API now takes in `RegistryEntry` along with the targeted attribute.
- This also goes for **all events**.
- `IEntityAttribute` has also been extended to get its `RegistryEntry`.
20 changes: 15 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ plugins {
id("com.google.devtools.ksp") version "2.0.0-1.0.21"
}

java.sourceCompatibility = JavaVersion.VERSION_17
java.targetCompatibility = JavaVersion.VERSION_17
java.sourceCompatibility = JavaVersion.VERSION_21
java.targetCompatibility = JavaVersion.VERSION_21

group = "${properties["maven_group"]}"
version = "${properties["mod_version"]}-${properties["loader"]}"
Expand All @@ -23,22 +23,27 @@ repositories {
maven("https://maven.terraformersmc.com")
maven("https://api.modrinth.com/maven")
maven("https://maven.kosmx.dev/")
maven("https://maven.parchmentmc.org")
maven("https://maven.quiltmc.org/repository/release/")
}

dependencies {
minecraft("com.mojang:minecraft:${properties["minecraft_version"]}")

mappings("net.fabricmc:yarn:${properties["yarn_mappings"]}:v2")

// "mappings"(loom.layered {
// mappings("org.quiltmc:quilt-mappings:${properties["minecraft_version"]}+build.${project.properties["quilt_mappings_version"]}:intermediary-v2")
// officialMojangMappings()
// parchment("org.parchmentmc.data:parchment-${properties["minecraft_version"]}:${project.properties["parchment"]}@zip")
// })

modImplementation("net.fabricmc:fabric-loader:${properties["loader_version"]}")
modImplementation("net.fabricmc:fabric-language-kotlin:${properties["fabric_kotlin_version"]}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${properties["fabric_api_version"]}")

include("io.wispforest:owo-sentinel:${properties["owo_version"]}")

modImplementation("io.wispforest:endec:${properties["endec_version"]}")!!.let(::include)
modImplementation("io.wispforest.endec:netty:${properties["endec_netty_version"]}")!!.let(::include)

modImplementation("com.terraformersmc:modmenu:${properties["modmenu_version"]}") {
exclude("net.fabricmc.fabric-api")
}
Expand All @@ -50,6 +55,11 @@ dependencies {

modImplementation("io.wispforest:owo-lib:${properties["owo_version"]}")

modImplementation("io.wispforest:endec:${properties["endec_version"]}")!!.let(::include)
modImplementation("io.wispforest.endec:netty:${properties["endec_netty_version"]}")!!.let(::include)
modImplementation("io.wispforest.endec:gson:${properties["endec_gson_version"]}")!!.let(::include)
modImplementation("io.wispforest.endec:jankson:${properties["endec_jankson_version"]}")!!.let(::include)

implementation("com.google.devtools.ksp:symbol-processing-api:${properties["ksp_version"]}")
implementation("com.squareup:kotlinpoet-ksp:${properties["kotlinpoet_version"]}")

Expand Down
17 changes: 11 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@ archives_base_name=data-attributes
maven_group=com.bibireden.data_attributes
loom_version=1.7-SNAPSHOT

minecraft_version=1.20.1
minecraft_version=1.21
fabric_kotlin_version=1.11.0+kotlin.2.0.0
fabric_api_version=0.92.2+1.20.1
mod_version=2.0.0-beta.8+1.20.1
fabric_api_version=0.100.8+1.21
mod_version=2.0.0+1.21-alpha.1
loader=fabric

yarn_mappings=1.20.1+build.10
loader_version=0.15.11
yarn_mappings=1.21+build.9
loader_version=0.16.0

modmenu_version=7.2.2

owo_version=0.11.2+1.20
owo_version=0.12.11+1.21
ksp_owo_config_version=0.1.0

endec_version=0.1.7
endec_gson_version=0.1.4
endec_jankson_version=0.1.4
endec_netty_version=0.1.3

mixinextras_version=0.5.0-beta.1

parchment=2023.09.03
quilt_mappings_version=23

org.gradle.jvmargs=-Xmx4000m
org.gradle.parallel=true
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.bibireden.data_attributes.api.attribute;

import com.bibireden.data_attributes.config.functions.AttributeFunction;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.registry.entry.RegistryEntry;

import java.util.Map;

Expand All @@ -12,6 +14,9 @@
*
*/
public interface IEntityAttribute {
/** Gets the {@link RegistryEntry} that is associated with this attribute. */
RegistryEntry<EntityAttribute> data_attributes$entry();

/**
* @return The minimum value of the attribute.
*/
Expand All @@ -26,9 +31,9 @@ public interface IEntityAttribute {
double data_attributes$min_fallback();

/** Returns the intended maximum fallback of this attribute. */
double data_attributes$max_fallback(); /** Returns the intended maximum fallback of this attribute. */
double data_attributes$max_fallback();

/** Returns the smoothness of this attribute. */
/** Returns the smoothness of this attribute. */
double data_attributes$smoothness();

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bibireden.data_attributes.api.attribute;

import net.minecraft.util.Identifier;

import java.util.UUID;

/**
Expand All @@ -12,8 +14,8 @@ public interface IEntityAttributeInstance {

/**
* Changes the value of the input modifier (if it exists) and updates the instance and all children.
* @param uuid The uuid of the modifier.
* @param id The id of the modifier.
* @param value The value to change the modifier to.
*/
void updateModifier(final UUID uuid, final double value);
void updateModifier(final Identifier id, final double value);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bibireden.data_attributes.api.event;

import net.minecraft.registry.entry.RegistryEntry;
import org.jetbrains.annotations.Nullable;

import net.fabricmc.fabric.api.event.Event;
Expand All @@ -21,33 +22,33 @@ public final class EntityAttributeModifiedEvents {
* the value of the modifier, or by reloading the datapack and having the living entity renew its attribute container.
* Living entity and modifiers may or may not be null.
*/
public static final Event<Modified> MODIFIED = EventFactory.createArrayBacked(Modified.class, callbacks -> (attribute, livingEntity, modifier, prevValue, isWasAdded) -> {
public static final Event<Modified> MODIFIED = EventFactory.createArrayBacked(Modified.class, callbacks -> (entry, livingEntity, modifier, prevValue, isWasAdded) -> {
for(Modified callback : callbacks) {
callback.onModified(attribute, livingEntity, modifier, prevValue, isWasAdded);
callback.onModified(entry, livingEntity, modifier, prevValue, isWasAdded);
}
});

/**
* Fired after the attribute instance value was calculated, but before it was output. This offers one last chance to alter the
* value in some way (for example round a decimal to an integer).
*/
public static final Event<Clamped> CLAMPED = EventFactory.createArrayBacked(Clamped.class, callbacks -> (attribute, value) -> {
public static final Event<Clamped> CLAMPED = EventFactory.createArrayBacked(Clamped.class, callbacks -> (entry, value) -> {
double cache = value;

for(Clamped callback : callbacks) {
cache = callback.onClamped(attribute, cache);
cache = callback.onClamped(entry, cache);
}

return cache;
});

@FunctionalInterface
public interface Modified {
void onModified(final EntityAttribute attribute, final @Nullable LivingEntity livingEntity, final @Nullable EntityAttributeModifier modifier, final double prevValue, final boolean isWasAdded);
void onModified(final RegistryEntry<EntityAttribute> entry, final @Nullable LivingEntity livingEntity, final @Nullable EntityAttributeModifier modifier, final double prevValue, final boolean isWasAdded);
}

@FunctionalInterface
public interface Clamped {
double onClamped(final EntityAttribute attribute, final double value);
double onClamped(final RegistryEntry<EntityAttribute> entry, final double value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
import java.util.UUID;

import net.minecraft.item.Item;
import net.minecraft.util.Identifier;

/**
* Helper class that exposes {@link Item#ATTACK_DAMAGE_MODIFIER_ID} and {@link Item#ATTACK_SPEED_MODIFIER_ID}.
* Helper class that exposes {@link Item#BASE_ATTACK_DAMAGE_MODIFIER_ID} and {@link Item#BASE_ATTACK_SPEED_MODIFIER_ID}.
*
* @author CleverNucleus
*
*/
public final class ItemFields extends Item {
private ItemFields() { super(new Item.Settings()); }

public static UUID attackDamageModifierID() { return ATTACK_DAMAGE_MODIFIER_ID; }
public static Identifier attackDamageModifierID() { return BASE_ATTACK_DAMAGE_MODIFIER_ID; }

public static UUID attackSpeedModifierID() { return ATTACK_SPEED_MODIFIER_ID; }
public static Identifier attackSpeedModifierID() { return BASE_ATTACK_SPEED_MODIFIER_ID; }
}
Loading

0 comments on commit e74f3ad

Please sign in to comment.