Compare commits

...

16 Commits

Author SHA1 Message Date
Johannes Frohnmeyer 5db7c4c867
chore: update to 1.20.5
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2024-04-25 22:20:18 +02:00
Johannes Frohnmeyer 8ca745196d
chore: update to 1.20.4
ci/woodpecker/push/jfmod Pipeline was successful Details
2023-12-07 20:12:48 +01:00
Johannes Frohnmeyer e722a1cf0c
chore: update to 1.20.2
ci/woodpecker/push/jfmod Pipeline was successful Details
2023-09-22 21:03:17 +02:00
Johannes Frohnmeyer 2c63ac2efe
Update to 1.20
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2023-06-09 17:44:55 +02:00
Johannes Frohnmeyer f003d6febb
Bump to 1.19.4
ci/woodpecker/push/jfmod Pipeline failed Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2023-03-14 22:11:32 +01:00
Johannes Frohnmeyer 390a704d5c
Use new config compiler
ci/woodpecker/push/jfmod Pipeline was successful Details
2022-12-29 14:31:08 +01:00
Johannes Frohnmeyer 6c5c26f0be
Update to 1.19.3
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2022-12-07 22:40:06 +01:00
Johannes Frohnmeyer c498fddaeb
Update to new infrastructure
ci/woodpecker/manual/jfmod Pipeline was successful Details
2022-12-02 17:42:14 +01:00
Johannes Frohnmeyer 74879cadb4
Update to LibJF 3 2022-08-28 15:21:37 +02:00
Johannes Frohnmeyer ef6b31b8fb
Don't reference DamageSource class in config to prevent crash in ultra early loading 2022-08-27 17:21:07 +02:00
Johannes Frohnmeyer 36d1415292
Update to 1.19.1 2022-07-28 15:43:08 +02:00
Johannes Frohnmeyer 2702bab886
Update for 1.19 2022-06-08 11:46:10 +02:00
Johannes Frohnmeyer 524b561539
Update LibJF 2022-04-04 20:29:21 +02:00
Johannes Frohnmeyer e20da6b82a
Add README from modrinth 2022-03-13 16:51:24 +01:00
Johannes Frohnmeyer 2c519c005e Delete settings.gradle 2022-03-02 17:21:05 +00:00
Johannes Frohnmeyer 6e23d4c206
Remove ModMenu workaround 2022-03-02 18:11:08 +01:00
22 changed files with 245 additions and 174 deletions

View File

@ -1,2 +0,0 @@
include:
- remote: 'https://jfmods.gitlab.io/scripts/jfmod.yml'

1
.woodpecker.yml Normal file
View File

@ -0,0 +1 @@
#link https://pages.frohnmeyer-wds.de/scripts/jfmod.yml

3
README.md Normal file
View File

@ -0,0 +1,3 @@
ComBit allows you to disable I-Frames, remove cool-downs from weapons and modify the health of entities as well as the attack damage of weapons.
Every tweak is optional and disabled by default.
If you want 1.8-like combat, load the "Minecraft 1.8.9" preset in the config screen

View File

@ -1,16 +0,0 @@
apply from: "https://jfmods.gitlab.io/scripts/jfmod.gradle"
dependencies {
include modImplementation("io.gitlab.jfronny.libjf:libjf-config-v0:${project.jfapi_version}")
include("io.gitlab.jfronny.libjf:libjf-unsafe-v0:${project.jfapi_version}")
include("io.gitlab.jfronny.libjf:libjf-base:${project.jfapi_version}")
modRuntimeOnly("io.gitlab.jfronny.libjf:libjf-devutil-v0:${project.jfapi_version}")
modImplementation "com.terraformersmc:modmenu:3.0.1"
// Compat fix
modRuntimeOnly(fabricApi.module("fabric-api-base", "${project.fabric_version}"))
modRuntimeOnly(fabricApi.module("fabric-resource-loader-v0", "${project.fabric_version}"))
modRuntimeOnly(fabricApi.module("fabric-screen-api-v1", "${project.fabric_version}"))
modRuntimeOnly(fabricApi.module("fabric-command-api-v1", "${project.fabric_version}"))
}

40
build.gradle.kts Normal file
View File

@ -0,0 +1,40 @@
plugins {
id("jfmod") version "1.6-SNAPSHOT"
}
allprojects { group = "io.gitlab.jfronny" }
base.archivesName = "combit"
jfMod {
minecraftVersion = "1.20.5"
yarn("build.1")
loaderVersion = "0.15.10"
libJfVersion = "3.15.5"
fabricApiVersion = "0.97.6+1.20.5"
modrinth {
projectId = "combit"
requiredDependencies.add("libjf")
optionalDependencies.add("modmenu")
}
curseforge {
projectId = "561742"
requiredDependencies.add("libjf")
optionalDependencies.add("modmenu")
}
}
dependencies {
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v2")
modImplementation("net.fabricmc.fabric-api:fabric-api-base")
// Dev env
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil")
modLocalRuntime("com.terraformersmc:modmenu:10.0.0-beta.1")
// for modmenu
modLocalRuntime("net.fabricmc.fabric-api:fabric-resource-loader-v0")
modLocalRuntime("net.fabricmc.fabric-api:fabric-screen-api-v1")
modLocalRuntime("net.fabricmc.fabric-api:fabric-key-binding-api-v1")
}

View File

@ -1,13 +0,0 @@
# https://fabricmc.net/develop/
minecraft_version=1.18.2
yarn_mappings=build.1
loader_version=0.13.3
maven_group=io.gitlab.jfronny
archives_base_name=combit
fabric_version=0.47.8+1.18.2
jfapi_version=2.5.0
modrinth_id=oPRrsg3M
curseforge_id=561742

View File

@ -1,10 +0,0 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}

9
settings.gradle.kts Normal file
View File

@ -0,0 +1,9 @@
pluginManagement {
repositories {
maven("https://maven.fabricmc.net/") // FabricMC
maven("https://maven.frohnmeyer-wds.de/artifacts") // scripts
gradlePluginPortal()
}
}
rootProject.name = "combit"

View File

@ -0,0 +1,32 @@
package io.gitlab.jfronny.combit.mixin;
import io.gitlab.jfronny.combit.*;
import net.minecraft.client.*;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.*;
import net.minecraft.client.option.*;
import net.minecraft.client.util.math.*;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.*;
@Mixin(InGameHud.class)
public class InGameHudMixin {
@Shadow @Final private MinecraftClient client;
private AttackIndicator combit$attackIndicator;
@Inject(at = @At("HEAD"), method = "renderCrosshair(Lnet/minecraft/client/gui/DrawContext;F)V")
private void renderCrosshair(DrawContext context, float tickDelta, CallbackInfo info) {
if (CombitConfig.cooldownProgressOverride >= 0) {
combit$attackIndicator = this.client.options.getAttackIndicator().getValue();
this.client.options.getAttackIndicator().setValue(AttackIndicator.OFF);
}
}
@Inject(at = @At("RETURN"), method = "renderCrosshair(Lnet/minecraft/client/gui/DrawContext;F)V")
private void renderCrosshairPost(DrawContext context, float tickDelta, CallbackInfo info) {
if (CombitConfig.cooldownProgressOverride >= 0) {
this.client.options.getAttackIndicator().setValue(combit$attackIndicator);
}
}
}

View File

@ -0,0 +1,12 @@
{
"required": true,
"minVersion": "0.8",
"package": "io.gitlab.jfronny.combit.mixin",
"compatibilityLevel": "JAVA_17",
"client": [
"InGameHudMixin"
],
"injectors": {
"defaultRequire": 1
}
}

View File

@ -1,21 +1,15 @@
package io.gitlab.jfronny.combit;
import io.gitlab.jfronny.combit.events.EntityHurtEvent;
import io.gitlab.jfronny.combit.events.EntityKnockbackEvent;
import io.gitlab.jfronny.combit.events.PlayerAttackEvent;
import io.gitlab.jfronny.combit.events.*;
import net.fabricmc.api.ModInitializer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import java.util.Set;
import java.util.UUID;
public class Combit implements ModInitializer {
private static final UUID debugUUID = new UUID(0L, 0L);
@Override
public void onInitialize() {
EntityHurtEvent.EVENT.register((entity, source, amount) -> {
@ -30,7 +24,7 @@ public class Combit implements ModInitializer {
}
String message = String.format("Type of damage received: %s\nAmount: %.3f\nTrue Source (mob id): %s\n",
source.getName(), amount, debugSource);
entity.sendSystemMessage(new LiteralText(message), debugUUID);
entity.sendMessage(Text.literal(message));
}
if (CombitConfig.excludePlayers && entity instanceof PlayerEntity) return ActionResult.PASS;
@ -66,7 +60,7 @@ public class Combit implements ModInitializer {
return ActionResult.PASS;
if (CombitConfig.debug) {
player.sendMessage(new LiteralText(
player.sendMessage(Text.literal(
target instanceof LivingEntity le
? String.format("LivingEntity attacked: %s (%s/%s)", EntityType.getId(target.getType()), le.getHealth(), le.getMaxHealth())
: String.format("Entity attacked: %s", EntityType.getId(target.getType()))

View File

@ -1,46 +1,47 @@
package io.gitlab.jfronny.combit;
import io.gitlab.jfronny.libjf.config.api.Entry;
import io.gitlab.jfronny.libjf.config.api.JfConfig;
import io.gitlab.jfronny.libjf.config.api.Preset;
import io.gitlab.jfronny.libjf.config.api.Verifier;
import io.gitlab.jfronny.libjf.config.api.v2.*;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.entity.damage.DamageSource;
import java.util.HashSet;
public class CombitConfig implements JfConfig {
@JfConfig
public class CombitConfig {
// Invulnerability
@Entry public static Integer iFrameInterval = -1;
@Entry(min=-1, max = 1) public static Double attackCancelThreshold = -1d;
@Entry(min=-1, max = 1) public static Double knockbackCancelThreshold = -1d;
@Entry public static int iFrameInterval = -1;
@Entry(min=-1, max = 1) public static double attackCancelThreshold = -1d;
@Entry(min=-1, max = 1) public static double knockbackCancelThreshold = -1d;
@Entry public static HashSet<String> attackerWhitelist = null;
@Entry public static HashSet<String> damageSourceWhitelist = null;
@Entry public static HashSet<String> targetEntityWhitelist = null;
@Entry public static Boolean excludeAllMobs = false;
@Entry public static Boolean excludePlayers = false;
@Entry public static boolean excludeAllMobs = false;
@Entry public static boolean excludePlayers = false;
// Entity Modification
@Entry public static Boolean skeletonsBurn = true;
@Entry public static Boolean zombiesBurn = true;
@Entry public static Boolean creepersBurn = false;
@Entry public static Boolean creepersExplodeWhenBurning = false;
@Entry public static Boolean alwaysBurn = false;
@Entry public static boolean skeletonsBurn = true;
@Entry public static boolean zombiesBurn = true;
@Entry public static boolean creepersBurn = false;
@Entry public static boolean creepersExplodeWhenBurning = false;
@Entry public static boolean alwaysBurn = false;
// Health
@Entry public static Double entityHealthFactor = 1.5;
@Entry public static double entityHealthFactor = 1.5;
@Entry public static HashSet<String> entityHealthBlacklist = null;
// Weapons
@Entry public static Double cooldownProgressOverride = -1d;
@Entry public static Double cooldownProgressPerTickOverride = -1d;
@Entry public static Double weaponAttackDamageFactor = 1d;
@Entry public static Double axeAttackDamageFactor = 1d;
@Entry public static float cooldownProgressOverride = -1f;
@Entry public static float cooldownProgressPerTickOverride = -1f;
@Entry public static double weaponAttackDamageFactor = 1d;
@Entry public static double axeAttackDamageFactor = 1d;
// Knockback
@Entry public static Double snowballKnockbackFactor = 0d;
@Entry public static Float snowballDamage = 0f;
@Entry public static Double eggKnockbackFactor = 0d;
@Entry public static Float eggDamage = 0f;
@Entry public static Double fishingBobberPullFactor = 1d;
@Entry public static double snowballKnockbackFactor = 0d;
@Entry public static float snowballDamage = 0f;
@Entry public static double eggKnockbackFactor = 0d;
@Entry public static float eggDamage = 0f;
@Entry public static double fishingBobberPullFactor = 1d;
// Debug
@Entry public static Boolean debug = FabricLoader.getInstance().isDevelopmentEnvironment();
@Entry public static boolean debug = FabricLoader.getInstance().isDevelopmentEnvironment();
static {
validate();
}
@Verifier public static void validate() {
if (attackerWhitelist == null) {
@ -55,14 +56,16 @@ public class CombitConfig implements JfConfig {
}
if (damageSourceWhitelist == null) {
damageSourceWhitelist = new HashSet<>();
damageSourceWhitelist.add(DamageSource.IN_FIRE.getName());
damageSourceWhitelist.add(DamageSource.LIGHTNING_BOLT.getName());
damageSourceWhitelist.add(DamageSource.LAVA.getName());
damageSourceWhitelist.add(DamageSource.HOT_FLOOR.getName());
damageSourceWhitelist.add(DamageSource.IN_WALL.getName());
damageSourceWhitelist.add(DamageSource.CACTUS.getName());
damageSourceWhitelist.add(DamageSource.OUT_OF_WORLD.getName());
damageSourceWhitelist.add(DamageSource.SWEET_BERRY_BUSH.getName());
// net.minecraft.entity.damage.DamageSource
damageSourceWhitelist.add("inFire");
damageSourceWhitelist.add("lightningBolt");
damageSourceWhitelist.add("lava");
damageSourceWhitelist.add("hotFloor");
damageSourceWhitelist.add("inWall");
damageSourceWhitelist.add("cactus");
damageSourceWhitelist.add("outOfWorld");
damageSourceWhitelist.add("sweetBerryBush");
damageSourceWhitelist.add("dryout");
}
if (entityHealthBlacklist == null) {
entityHealthBlacklist = new HashSet<>();
@ -86,8 +89,8 @@ public class CombitConfig implements JfConfig {
alwaysBurn = false;
entityHealthFactor = 1.0;
entityHealthBlacklist = null;
cooldownProgressOverride = 0.8;
cooldownProgressPerTickOverride = Double.MIN_VALUE;
cooldownProgressOverride = 0.8f;
cooldownProgressPerTickOverride = Float.MIN_VALUE;
weaponAttackDamageFactor = 1d;
axeAttackDamageFactor = 0.5;
snowballKnockbackFactor = 1d;
@ -113,8 +116,8 @@ public class CombitConfig implements JfConfig {
alwaysBurn = true;
entityHealthFactor = 10d;
entityHealthBlacklist = null;
cooldownProgressOverride = 1d;
cooldownProgressPerTickOverride = Double.MAX_VALUE;
cooldownProgressOverride = 1f;
cooldownProgressPerTickOverride = Float.MAX_VALUE;
weaponAttackDamageFactor = 0.5;
axeAttackDamageFactor = 5d;
snowballKnockbackFactor = -1d;
@ -127,4 +130,8 @@ public class CombitConfig implements JfConfig {
@Preset public static void noInvulnerability() {
iFrameInterval = 0;
}
static {
JFC_CombitConfig.ensureInitialized();
}
}

View File

@ -0,0 +1,13 @@
package io.gitlab.jfronny.combit.mixin;
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
import net.minecraft.component.ComponentMap;
import net.minecraft.component.DataComponentType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ComponentMap.Builder.class)
public interface ComponentMapBuilderAccessor {
@Accessor("components") Reference2ObjectMap<DataComponentType<?>, Object> combit$getComponents();
@Accessor("components") void combit$setComponents(Reference2ObjectMap<DataComponentType<?>, Object> components);
}

View File

@ -3,7 +3,6 @@ package io.gitlab.jfronny.combit.mixin;
import io.gitlab.jfronny.combit.CombitConfig;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.thrown.EggEntity;
import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
@ -29,7 +28,7 @@ public abstract class EggEntityMixin extends ThrownItemEntity {
e.velocityModified = true;
}
if (CombitConfig.eggDamage > 0) {
e.damage(DamageSource.thrownProjectile(this, this.getOwner()), CombitConfig.eggDamage);
e.damage(getDamageSources().thrown(this, this.getOwner()), CombitConfig.eggDamage);
}
}
}

View File

@ -1,34 +0,0 @@
package io.gitlab.jfronny.combit.mixin;
import io.gitlab.jfronny.combit.CombitConfig;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.option.AttackIndicator;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.Final;
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;
@Mixin(InGameHud.class)
public class InGameHudMixin {
@Shadow @Final private MinecraftClient client;
private AttackIndicator combit$attackIndicator;
@Inject(at = @At("HEAD"), method = "renderCrosshair(Lnet/minecraft/client/util/math/MatrixStack;)V")
private void renderCrosshair(MatrixStack matrices, CallbackInfo info) {
if (CombitConfig.cooldownProgressOverride >= 0) {
combit$attackIndicator = this.client.options.attackIndicator;
this.client.options.attackIndicator = AttackIndicator.OFF;
}
}
@Inject(at = @At("RETURN"), method = "renderCrosshair(Lnet/minecraft/client/util/math/MatrixStack;)V")
private void renderCrosshairPost(MatrixStack matrices, CallbackInfo info) {
if (CombitConfig.cooldownProgressOverride >= 0) {
this.client.options.attackIndicator = combit$attackIndicator;
}
}
}

View File

@ -0,0 +1,12 @@
package io.gitlab.jfronny.combit.mixin;
import net.minecraft.component.ComponentMap;
import net.minecraft.item.Item;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(Item.Settings.class)
public interface ItemSettingsAccessor {
@Accessor("components") ComponentMap.Builder combit$getComponents();
@Accessor("components") void combit$setComponents(ComponentMap.Builder components);
}

View File

@ -10,6 +10,7 @@ import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeInstance;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.ActionResult;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
@ -23,7 +24,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public abstract class LivingEntityMixin {
@Shadow public abstract float getMaxHealth();
@Shadow public abstract void setHealth(float health);
@Shadow @Nullable public abstract EntityAttributeInstance getAttributeInstance(EntityAttribute attribute);
@Shadow @Nullable public abstract EntityAttributeInstance getAttributeInstance(RegistryEntry<EntityAttribute> attribute);
@Inject(at = @At("TAIL"), method = "applyDamage", cancellable = true)
private void onEntityHurt(final DamageSource source, final float amount, CallbackInfo ci) {

View File

@ -1,48 +1,71 @@
package io.gitlab.jfronny.combit.mixin;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import io.gitlab.jfronny.combit.CombitConfig;
import net.minecraft.block.Block;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.component.ComponentMap;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.AttributeModifierSlot;
import net.minecraft.component.type.AttributeModifiersComponent;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.item.*;
import net.minecraft.tag.TagKey;
import org.spongepowered.asm.mixin.Final;
import net.minecraft.registry.tag.TagKey;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
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.ArrayList;
import java.util.List;
@Mixin(MiningToolItem.class)
public abstract class MiningToolItemMixin extends ToolItem {
@Shadow @Final @Mutable private Multimap<EntityAttribute, EntityAttributeModifier> attributeModifiers;
@Shadow @Final @Mutable private float attackDamage;
public MiningToolItemMixin(ToolMaterial material, Settings settings) {
super(material, settings);
}
@Inject(at = @At("RETURN"), method = "<init>(FFLnet/minecraft/item/ToolMaterial;Lnet/minecraft/tag/TagKey;Lnet/minecraft/item/Item$Settings;)V")
private void modifyAttackDamage(float attackDamage, float attackSpeed, ToolMaterial material, TagKey<Block> effectiveBlocks, Settings settings, CallbackInfo ci) {
@Inject(at = @At("RETURN"), method = "<init>(Lnet/minecraft/item/ToolMaterial;Lnet/minecraft/registry/tag/TagKey;Lnet/minecraft/item/Item$Settings;)V")
private void modifyAttackDamage(ToolMaterial material, TagKey<Block> effectiveBlocks, Settings settings, CallbackInfo ci) {
double factor = ((MiningToolItem)(Object)this) instanceof AxeItem ? CombitConfig.axeAttackDamageFactor : CombitConfig.weaponAttackDamageFactor;
if (factor >= 0) {
this.attackDamage *= factor;
ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder();
builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE,
new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID,
"Tool modifier",
this.attackDamage,
EntityAttributeModifier.Operation.ADDITION));
this.attributeModifiers.forEach((k, v) -> {
if (!k.getTranslationKey().equals(EntityAttributes.GENERIC_ATTACK_DAMAGE.getTranslationKey())) {
builder.put(k, v);
ItemSettingsAccessor isa = (ItemSettingsAccessor) settings;
ComponentMap.Builder cb = isa.combit$getComponents();
if (cb == null) {
cb = ComponentMap.builder().addAll(DataComponentTypes.DEFAULT_ITEM_COMPONENTS);
isa.combit$setComponents(cb);
}
ComponentMapBuilderAccessor cbi = (ComponentMapBuilderAccessor) cb;
List<AttributeModifiersComponent.Entry> entries = new ArrayList<>();
boolean showInTooltip = false;
AttributeModifiersComponent amcOrig = (AttributeModifiersComponent) cbi.combit$getComponents().get(DataComponentTypes.ATTRIBUTE_MODIFIERS);
if (amcOrig != null) {
entries.addAll(amcOrig.modifiers());
showInTooltip = amcOrig.showInTooltip();
}
AttributeModifiersComponent.Entry damageEntry = null;
for (AttributeModifiersComponent.Entry entry : entries) {
if (entry.attribute().equals(EntityAttributes.GENERIC_ATTACK_DAMAGE)) {
damageEntry = entry;
}
});
this.attributeModifiers = builder.build();
}
double damage = 5;
if (damageEntry != null) {
entries.remove(damageEntry);
damage = damageEntry.modifier().value();
}
damageEntry = new AttributeModifiersComponent.Entry(
EntityAttributes.GENERIC_ATTACK_DAMAGE,
new EntityAttributeModifier(
ATTACK_DAMAGE_MODIFIER_ID,
"Tool modifier",
damage * factor,
EntityAttributeModifier.Operation.ADD_VALUE),
AttributeModifierSlot.MAINHAND);
entries.add(damageEntry);
cb.add(DataComponentTypes.ATTRIBUTE_MODIFIERS, new AttributeModifiersComponent(entries, showInTooltip));
}
}
}

View File

@ -34,14 +34,14 @@ public class PlayerEntityMixin {
@Inject(at = @At("HEAD"), method = "getAttackCooldownProgress(F)F", cancellable = true)
public void getAttackCooldownProgress(float baseTime, CallbackInfoReturnable<Float> info) {
if (CombitConfig.cooldownProgressOverride >= 0) {
info.setReturnValue(CombitConfig.cooldownProgressOverride.floatValue());
info.setReturnValue(CombitConfig.cooldownProgressOverride);
}
}
@Inject(at = @At("HEAD"), method = "getAttackCooldownProgressPerTick()F", cancellable = true)
public void getAttackCooldownProgressPerTick(CallbackInfoReturnable<Float> info) {
if (CombitConfig.cooldownProgressPerTickOverride >= 0) {
info.setReturnValue(CombitConfig.cooldownProgressPerTickOverride.floatValue());
info.setReturnValue(CombitConfig.cooldownProgressPerTickOverride);
}
}
}

View File

@ -3,7 +3,6 @@ package io.gitlab.jfronny.combit.mixin;
import io.gitlab.jfronny.combit.CombitConfig;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.thrown.SnowballEntity;
import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
@ -29,7 +28,7 @@ public abstract class SnowballEntityMixin extends ThrownItemEntity {
e.velocityModified = true;
}
if (CombitConfig.snowballDamage > 0) {
e.damage(DamageSource.thrownProjectile(this, this.getOwner()), CombitConfig.snowballDamage);
e.damage(getDamageSources().thrown(this, this.getOwner()), CombitConfig.snowballDamage);
}
}
}

View File

@ -5,9 +5,11 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"AbstractSkeletonEntityMixin",
"ComponentMapBuilderAccessor",
"EggEntityMixin",
"FishingBobberEntityMixin",
"HostileEntityMixin",
"ItemSettingsAccessor",
"LivingEntityMixin",
"MiningToolItemMixin",
"MobEntityMixin",
@ -15,9 +17,6 @@
"SnowballEntityMixin",
"ZombieEntityMixin"
],
"client": [
"InGameHudMixin"
],
"injectors": {
"defaultRequire": 1
}

View File

@ -1,31 +1,33 @@
{
"schemaVersion": 1,
"id": "combit",
"version": "${version}",
"name": "ComBit",
"description": "Removes delays in combat",
"authors": [
"JFronny"
],
"contact": {},
"version": "${version}",
"description": "Configurable tweaks for combat-related mechanics",
"authors": ["JFronny"],
"contact": {
"email": "projects.contact@frohnmeyer-wds.de",
"homepage": "https://jfronny.gitlab.io",
"issues": "https://git.frohnmeyer-wds.de/JfMods/Combit/issues",
"sources": "https://git.frohnmeyer-wds.de/JfMods/Combit"
},
"license": "MIT",
"icon": "assets/combit/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"io.gitlab.jfronny.combit.Combit"
],
"libjf:config": [
"io.gitlab.jfronny.combit.CombitConfig"
]
"main": ["io.gitlab.jfronny.combit.Combit"],
"libjf:config": ["io.gitlab.jfronny.combit.JFC_CombitConfig"]
},
"mixins": [
"combit.mixins.json"
"combit.mixins.json",
{
"config": "combit.client.mixins.json",
"environment": "client"
}
],
"depends": {
"fabricloader": ">=0.12.12",
"minecraft": "*",
"libjf-unsafe-v0": ">=2.2.0",
"libjf-config-v0": ">=2.2.0"
"libjf-config-core-v1": ">=3.0.0"
}
}