-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
660 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,107 @@ | ||
plugins { | ||
id "fabric-loom" version "1.6+" | ||
id "com.github.johnrengelman.shadow" version "8.1+" | ||
id "maven-publish" | ||
id "me.modmuss50.mod-publish-plugin" version "0.5.2" | ||
id 'idea' | ||
id 'maven-publish' | ||
id 'me.modmuss50.mod-publish-plugin' version '0.7.4' apply false | ||
id 'net.neoforged.moddev' version '2.0.34-beta' apply false | ||
} | ||
|
||
version = project.mod_version | ||
version = "${project.mod_version}+mc${project.minecraft_version}" | ||
group = project.maven_group | ||
|
||
repositories { | ||
maven { url = "https://maven.quiltmc.org/repository/release/" } | ||
maven { url = "https://maven.terraformersmc.com/releases/" } | ||
maven { url = "https://repo.sleeping.town/" } | ||
} | ||
|
||
configurations { | ||
shadow | ||
api.extendsFrom shadow | ||
} | ||
|
||
dependencies { | ||
minecraft("com.mojang:minecraft:${project.minecraft_version}") | ||
mappings("org.quiltmc:quilt-mappings:${project.minecraft_version}+build.${project.quilt_mappings}:intermediary-v2") | ||
modImplementation("net.fabricmc:fabric-loader:${project.loader_version}") | ||
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}") | ||
|
||
implementation("folk.sisby:kaleido-config:${project.kaleido_config_version}") | ||
include("folk.sisby:kaleido-config:${project.kaleido_config_version}") | ||
|
||
modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}") | ||
} | ||
|
||
processResources { | ||
inputs.property "version", project.version | ||
inputs.property "minecraft_version", project.minecraft_version | ||
inputs.property "loader_version", project.loader_version | ||
filteringCharset "UTF-8" | ||
|
||
filesMatching("fabric.mod.json") { | ||
expand "version": project.version, | ||
"minecraft_version": project.minecraft_version, | ||
"loader_version": project.loader_version | ||
def targetJavaVersion = 21 | ||
|
||
subprojects { | ||
apply plugin: 'java-library' | ||
project.group = rootProject.group | ||
project.version = rootProject.version | ||
|
||
repositories { | ||
maven { url = 'https://maven.quiltmc.org/repository/release' } | ||
maven { url = 'https://maven.terraformersmc.com/releases' } | ||
maven { url = 'https://repo.sleeping.town' } | ||
maven { | ||
name = "ParchmentMC" | ||
url = "https://maven.parchmentmc.org" | ||
content { | ||
includeGroupAndSubgroups "org.parchmentmc" | ||
} | ||
} | ||
} | ||
} | ||
|
||
publishMods { | ||
displayName = "ramel ${project.version}" | ||
file = remapJar.archiveFile | ||
changelog = rootProject.file("CHANGELOG.md").getText() | ||
type = STABLE | ||
|
||
modLoaders.add("quilt") | ||
modLoaders.add("fabric") | ||
|
||
dryRun = !providers.environmentVariable("MODRINTH_TOKEN").isPresent() | ||
|| !providers.environmentVariable("CURSEFORGE_TOKEN").isPresent() | ||
|| property("pub.should_publish") == "false" | ||
dryRun = false | ||
|
||
var mcVersions = [project.minecraft_version] | ||
mcVersions.addAll(property("pub.additional_versions").toString().split(" ").findAll { !it.empty }) | ||
|
||
modrinth { | ||
projectId = "4Uw92C2y" | ||
accessToken = providers.environmentVariable("MODRINTH_TOKEN") | ||
mcVersions.forEach(minecraftVersions::add) | ||
java { | ||
withSourcesJar() | ||
def javaVersion = JavaVersion.toVersion(targetJavaVersion) | ||
if (JavaVersion.current() < javaVersion) { | ||
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) | ||
} | ||
} | ||
|
||
requires("fabric-api") | ||
optional("modmenu") | ||
tasks.withType(JavaCompile).configureEach { | ||
it.options.encoding = 'UTF-8' | ||
it.options.release = targetJavaVersion | ||
} | ||
|
||
curseforge { | ||
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN") | ||
projectId = "877074" | ||
mcVersions.forEach(minecraftVersions::add) | ||
javadoc { | ||
// need this so javadoc doesnt complain about mixin's @reason | ||
options.tags = ['reason'] | ||
} | ||
|
||
clientRequired = true | ||
serverRequired = false | ||
base { | ||
archivesName = "${rootProject.archives_base_name}-${project.name}" | ||
} | ||
|
||
requires("fabric-api") | ||
optional("modmenu") | ||
jar { | ||
from('LICENSE') { | ||
rename { "LICENSE_${rootProject.archives_base_name}"} | ||
} | ||
} | ||
} | ||
|
||
def targetJavaVersion = 17 | ||
tasks.withType(JavaCompile).configureEach { | ||
it.options.encoding = "UTF-8" | ||
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { | ||
it.options.release = targetJavaVersion | ||
sourcesJar { | ||
from('LICENSE') { | ||
rename { "LICENSE_${rootProject.archives_base_name}" } | ||
} | ||
} | ||
} | ||
|
||
java { | ||
def javaVersion = JavaVersion.toVersion(targetJavaVersion) | ||
if (JavaVersion.current() < javaVersion) { | ||
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) | ||
processResources { | ||
filteringCharset 'UTF-8' | ||
|
||
def expandProps = [ | ||
'version': version, | ||
'minecraft_version': project.minecraft_version, | ||
'mod_id': project.mod_id, | ||
'maven_group_id': project.maven_group, | ||
'website_url': project.website_url, | ||
'sources_url': project.sources_url, | ||
'issue_tracker_url': project.issue_tracker_url, | ||
'discord_url': project.discord_url, | ||
|
||
'fabric_loader_version': project.fabric_loader_version, | ||
'neoforge_version': project.neoforge_version, | ||
'java_version': targetJavaVersion | ||
] | ||
|
||
filesMatching(['pack.mcmeta', '*.mod.json', 'META-INF/*mods.toml', '*.mixins.json']) { | ||
expand expandProps | ||
} | ||
inputs.properties(expandProps) | ||
} | ||
archivesBaseName = project.archives_base_name | ||
} | ||
|
||
jar { | ||
from("LICENSE") { | ||
rename { "${it}_${project.archivesBaseName}"} | ||
publishing { | ||
publications { | ||
"mavenJava_${project.name}"(MavenPublication) { | ||
artifactId base.archivesName.get() | ||
from components.java | ||
} | ||
} | ||
} | ||
} | ||
|
||
// configure the maven publication | ||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
from components.java | ||
allprojects { | ||
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior. | ||
idea { | ||
module { | ||
downloadSources = true | ||
downloadJavadoc = true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
plugins { | ||
id 'net.neoforged.moddev' | ||
} | ||
|
||
dependencies { | ||
compileOnly("org.jetbrains:annotations:${project.jetbrains_annotations_version}") | ||
compileOnly("net.fabricmc:sponge-mixin:${project.mixin_version}") | ||
compileOnly("io.github.llamalad7:mixinextras-common:${project.mixin_extras_version}") | ||
annotationProcessor("io.github.llamalad7:mixinextras-common:${project.mixin_extras_version}") | ||
|
||
compileOnly("folk.sisby:kaleido-config:${project.kaleido_config_version}") | ||
} | ||
|
||
neoForge { | ||
neoFormVersion = project.neoform_version | ||
|
||
parchment { | ||
minecraftVersion = project.parchment_minecraft_version | ||
mappingsVersion = project.parchment_mappings_version | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.ix0rai.ramel; | ||
|
||
public class Ramel { | ||
|
||
public static final String MODID = "ramel"; | ||
} |
49 changes: 49 additions & 0 deletions
49
common/src/main/java/io/ix0rai/ramel/client/RamelConfigScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.ix0rai.ramel.client; | ||
|
||
import com.mojang.serialization.Codec; | ||
import folk.sisby.kaleido.lib.quiltconfig.api.Constraint; | ||
import folk.sisby.kaleido.lib.quiltconfig.api.values.TrackedValue; | ||
import io.ix0rai.ramel.Config; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.OptionInstance; | ||
import net.minecraft.client.Options; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.client.gui.screens.options.OptionsSubScreen; | ||
import net.minecraft.network.chat.Component; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.stream.StreamSupport; | ||
|
||
public class RamelConfigScreen extends OptionsSubScreen { | ||
public RamelConfigScreen(@Nullable Screen parent) { | ||
super(parent, Minecraft.getInstance().options, Component.translatable("ramel.config.title")); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings({"unchecked", "DataFlowIssue"}) | ||
protected void addOptions() { | ||
this.list.addSmall(StreamSupport.stream(Config.INSTANCE.values().spliterator(), false) | ||
.map(value -> createOptional((TrackedValue<Float>) value)).toArray(OptionInstance[]::new)); | ||
} | ||
|
||
private static OptionInstance<Float> createOptional(TrackedValue<Float> trackedValue) { | ||
Constraint.Range<Float> range = null; | ||
|
||
for (Constraint<Float> c : trackedValue.constraints()) { | ||
if (c instanceof Constraint.Range<Float> constraintRange) { | ||
range = constraintRange; | ||
} | ||
} | ||
|
||
String stringValue = trackedValue.key().toString(); | ||
|
||
if (range == null) { | ||
throw new RuntimeException("value must have float range constraint: " + stringValue); | ||
} | ||
|
||
float min = range.min(); | ||
float max = range.max(); | ||
|
||
return new OptionInstance<>("ramel.config." + stringValue, OptionInstance.cachedConstantTooltip(Component.translatable("ramel.config.tooltip." + stringValue)), (text, value) -> Options.genericValueLabel(text, Component.translatable("ramel.config.value." + stringValue, value)), (new OptionInstance.IntRange((int) (min * 10), (int) (max * 10))).xmap((intValue) -> intValue / 10.0F, (doubleValue) -> (int) (doubleValue * 10.0D)), Codec.floatRange(min, max), trackedValue.value(), trackedValue::setValue); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
common/src/main/java/io/ix0rai/ramel/mixin/CamelEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package io.ix0rai.ramel.mixin; | ||
|
||
import com.google.common.base.MoreObjects; | ||
import io.ix0rai.ramel.Config; | ||
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.effect.MobEffects; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.animal.camel.Camel; | ||
import net.minecraft.world.level.Level; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.Objects; | ||
|
||
@Mixin(Camel.class) | ||
public abstract class CamelEntityMixin extends LivingEntity { | ||
@Shadow public abstract boolean isDashing(); | ||
|
||
private CamelEntityMixin(EntityType<? extends Camel> entityType, Level level) { | ||
super(entityType, level); | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Inject(method = "tick", at = @At("HEAD")) | ||
private void inject$tick(CallbackInfo ci) { | ||
if (!this.isDashing() || this.level().isClientSide()) { | ||
return; | ||
} | ||
|
||
int speedEffectModifier = this.hasEffect(MobEffects.MOVEMENT_SPEED) ? Objects.requireNonNull(this.getEffect(MobEffects.MOVEMENT_SPEED)).getAmplifier() + 1 : 0; | ||
int slowEffectModifier = this.hasEffect(MobEffects.MOVEMENT_SLOWDOWN) ? Objects.requireNonNull(this.getEffect(MobEffects.MOVEMENT_SLOWDOWN)).getAmplifier() + 1 : 0; | ||
double speedAdjustedImpact = Mth.clamp(this.getSpeed() * 1.65, .2, 3.0) + .25 * (speedEffectModifier - slowEffectModifier); | ||
|
||
float rammingRange = Config.INSTANCE.additionalRammingRange.value() * (isBaby() ? 0.5F : 1.0F); | ||
float rammingDamage = Config.INSTANCE.rammingDamage.value() * (isBaby() ? 0.5F : 1.0F); | ||
float knockBackMultiplier = Config.INSTANCE.knockbackMultiplier.value() * (isBaby() ? 0.5F : 1.0F); | ||
|
||
DamageSource source = this.damageSources().mobAttack(MoreObjects.firstNonNull(this.getControllingPassenger(), this)); | ||
|
||
this.level().getEntities(this, this.getBoundingBox().inflate(rammingRange), Entity::isAlive).stream() | ||
.filter(e -> e instanceof LivingEntity && !this.getPassengers().contains(e)) | ||
.forEach(e -> { | ||
LivingEntity entity = (LivingEntity) e; | ||
|
||
entity.playSound(SoundEvents.PLAYER_ATTACK_KNOCKBACK); | ||
entity.hurt(source, rammingDamage); | ||
final double blockedImpact = entity.isDamageSourceBlocked(source) ? .5 : 1.0; | ||
|
||
entity.knockback(blockedImpact * speedAdjustedImpact * knockBackMultiplier, | ||
Mth.sin(this.getXRot() * (Mth.PI / 180.0F)), -Mth.cos(this.getXRot() * (Mth.PI / 180.0F))); | ||
if (entity instanceof ServerPlayer player) { | ||
// The player won't feel any effects if we don't update the velocity | ||
player.connection.send(new ClientboundSetEntityMotionPacket(player)); | ||
} | ||
}); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
common/src/main/java/io/ix0rai/ramel/service/ConfigProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.ix0rai.ramel.service; | ||
|
||
import folk.sisby.kaleido.lib.quiltconfig.api.serializers.TomlSerializer; | ||
import folk.sisby.kaleido.lib.quiltconfig.implementor_api.ConfigEnvironment; | ||
|
||
import java.nio.file.Path; | ||
import java.util.ServiceLoader; | ||
|
||
public interface ConfigProvider { | ||
|
||
Path getConfigDir(); | ||
|
||
default ConfigEnvironment createConfigEnvironment() { | ||
return new ConfigEnvironment(getConfigDir(), "toml", TomlSerializer.INSTANCE); | ||
} | ||
|
||
static ConfigProvider load() { | ||
return ServiceLoader.load(ConfigProvider.class).findFirst().orElseThrow(() -> new IllegalStateException("No platform implementation found for " + ConfigProvider.class.getCanonicalName())); | ||
} | ||
} |
File renamed without changes.
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.