Skip to content

Commit

Permalink
1.1.6 for 1.19.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandra-Myers committed May 27, 2023
1 parent 26aca1d commit 6ab1d57
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 48 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ minecraft_version=1.19.2
loader_version=0.14.17

# Mod Properties
version = 1.1.5+1.19.2
version = 1.1.6+1.19.2
maven_group = net.alexandra.atlas
archives_base_name = atlas_combat

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class AtlasConfigModel {
public boolean fistDamage = false;
public boolean swordBlocking = false;
public boolean saturationHealing = false;
public boolean autoAttackAllowed = true;
@RestartRequired
public boolean axeReachBuff = false;
@RestartRequired
Expand Down Expand Up @@ -53,18 +54,60 @@ public class AtlasConfigModel {
public float eggDamage = 0.0F;
@RangeConstraint(min = 0, max = 4)
public float bowUncertainty = 0.25F;
@RangeConstraint(min = 0, max = 10)
@RestartRequired
@RangeConstraint(min = 0, max = 1000)
public float swordAttackDamage = 1;
@RangeConstraint(min = 0, max = 10)
@RestartRequired
@RangeConstraint(min = 0, max = 1000)
public float axeAttackDamage = 2;
@RangeConstraint(min = 0, max = 10)
@RestartRequired
@RangeConstraint(min = 0, max = 1000)
public float baseHoeAttackDamage = 0;
@RangeConstraint(min = 0, max = 10)
@RestartRequired
@RangeConstraint(min = 0, max = 1000)
public float ironDiaHoeAttackDamage = 1;
@RangeConstraint(min = 0, max = 10)
@RestartRequired
@RangeConstraint(min = 0, max = 1000)
public float netheriteHoeAttackDamage = 2;
@RangeConstraint(min = 0, max = 10)
@RestartRequired
@RangeConstraint(min = 0, max = 1000)
public float tridentAttackDamage = 5;
@RestartRequired
@RangeConstraint(min = -1, max = 7.5)
public float swordAttackSpeed = 0.5F;
@RestartRequired
@RangeConstraint(min = -1, max = 7.5)
public float axeAttackSpeed = -0.5F;
@RestartRequired
@RangeConstraint(min = -1, max = 7.5)
public float woodenHoeAttackSpeed = -0.5F;
@RestartRequired
@RangeConstraint(min = -1, max = 7.5)
public float stoneHoeAttackSpeed = 0;
@RestartRequired
@RangeConstraint(min = -1, max = 7.5)
public float ironHoeAttackSpeed = 0.5F;
@RestartRequired
@RangeConstraint(min = -1, max = 7.5)
public float goldDiaNethHoeAttackSpeed = 1;
@RestartRequired
@RangeConstraint(min = -1, max = 7.5)
public float tridentAttackSpeed = -0.5F;
@RestartRequired
@RangeConstraint(min = -1, max = 7.5)
public float defaultAttackSpeed = 0F;
@RestartRequired
@RangeConstraint(min = -1, max = 7.5)
public float slowestToolAttackSpeed = -1F;
@RestartRequired
@RangeConstraint(min = -1, max = 7.5)
public float slowToolAttackSpeed = -0.5F;
@RestartRequired
@RangeConstraint(min = -1, max = 7.5)
public float fastToolAttackSpeed = 0.5F;
@RestartRequired
@RangeConstraint(min = -1, max = 7.5)
public float fastestToolAttackSpeed = 1F;
public static class UseDurations {
}
public static class Cooldowns {
Expand Down
50 changes: 29 additions & 21 deletions src/main/java/net/alexandra/atlas/atlas_combat/item/WeaponType.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public void addCombatAttributes(Tier var1, ImmutableMultimap.Builder<Attribute,
float var5 = this.getReach();
float var6 = this.getBlockReach();
var2.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Weapon modifier", var4, AttributeModifier.Operation.ADDITION));
if(AtlasCombat.CONFIG.attackSpeed())
var2.put(NewAttributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", var3, AttributeModifier.Operation.ADDITION));
var2.put(NewAttributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", var3, AttributeModifier.Operation.ADDITION));
if (var5 != 0.0F && AtlasCombat.CONFIG.attackReach()) {
var2.put(NewAttributes.ATTACK_REACH, new AttributeModifier(BASE_ATTACK_REACH_UUID, "Weapon modifier", var5, AttributeModifier.Operation.ADDITION));
}
Expand All @@ -61,35 +60,35 @@ public float getDamage(Tier var1) {
}
case SWORD -> {
if (bl) {
return var2 + AtlasCombat.CONFIG.swordAttackDamage();
return var2 + min(AtlasCombat.CONFIG.swordAttackDamage(), 0);
} else {
return var2 + AtlasCombat.CONFIG.swordAttackDamage() + 1.0F;
return var2 + min(AtlasCombat.CONFIG.swordAttackDamage(), 0) + 1.0F;
}
}
case AXE -> {
if(!AtlasCombat.CONFIG.ctsAttackBalancing()) {
return !isTier1 ? var1 == Tiers.NETHERITE ? 10 : 9 : 7;
} else if (bl) {
return var2 + AtlasCombat.CONFIG.axeAttackDamage();
return var2 + min(AtlasCombat.CONFIG.axeAttackDamage(), 0);
} else {
return var2 + AtlasCombat.CONFIG.axeAttackDamage() + 1.0F;
return var2 + min(AtlasCombat.CONFIG.axeAttackDamage(), 0) + 1.0F;
}
}
case LONGSWORD, HOE -> {
if (var1 != Tiers.IRON && var1 != Tiers.DIAMOND) {
if (var1 == Tiers.NETHERITE || var1.getLevel() >= 4) {
return var1 == Tiers.NETHERITE ? AtlasCombat.CONFIG.netheriteHoeAttackDamage() + modifier : AtlasCombat.CONFIG.netheriteHoeAttackDamage() + var2 - 4 + modifier;
return var1 == Tiers.NETHERITE ? min(AtlasCombat.CONFIG.netheriteHoeAttackDamage(), 0) + modifier : min(AtlasCombat.CONFIG.netheriteHoeAttackDamage(), 0) + var2 - 4 + modifier;
}

return AtlasCombat.CONFIG.baseHoeAttackDamage() + modifier;
return min(AtlasCombat.CONFIG.baseHoeAttackDamage(), 0) + modifier;
}
return AtlasCombat.CONFIG.ironDiaHoeAttackDamage() + modifier;
return min(AtlasCombat.CONFIG.ironDiaHoeAttackDamage(), 0) + modifier;
}
case SHOVEL -> {
return var2;
}
case TRIDENT -> {
return AtlasCombat.CONFIG.tridentAttackDamage() + modifier + (AtlasCombat.CONFIG.ctsAttackBalancing() ? 0 : 1);
return min(AtlasCombat.CONFIG.tridentAttackDamage(), 0) + modifier + (AtlasCombat.CONFIG.ctsAttackBalancing() ? 0 : 1);
}
default -> {
return 0.0F + modifier;
Expand All @@ -100,33 +99,36 @@ public float getDamage(Tier var1) {
public float getSpeed(Tier var1) {
switch (this) {
case KNIFE -> {
return 1.0F;
return AtlasCombat.CONFIG.goldDiaNethHoeAttackSpeed();
}
case LONGSWORD, SWORD -> {
return 0.5F;
return AtlasCombat.CONFIG.swordAttackSpeed();
}
case AXE, SHOVEL, TRIDENT -> {
return -0.5F;
case AXE, SHOVEL -> {
return AtlasCombat.CONFIG.axeAttackSpeed();
}
case TRIDENT -> {
return AtlasCombat.CONFIG.tridentAttackSpeed();
}
case HOE -> {
if (var1 == Tiers.WOOD) {
return -0.5F;
return AtlasCombat.CONFIG.woodenHoeAttackSpeed();
} else if (var1 == Tiers.IRON) {
return 0.5F;
return AtlasCombat.CONFIG.ironHoeAttackSpeed();
} else if (var1 == Tiers.DIAMOND) {
return 1.0F;
return AtlasCombat.CONFIG.goldDiaNethHoeAttackSpeed();
} else if (var1 == Tiers.GOLD) {
return 1.0F;
return AtlasCombat.CONFIG.goldDiaNethHoeAttackSpeed();
} else {
if (var1 == Tiers.NETHERITE || var1.getLevel() >= 4) {
return 1.0F;
return AtlasCombat.CONFIG.goldDiaNethHoeAttackSpeed();
}

return 0.0F;
return AtlasCombat.CONFIG.stoneHoeAttackSpeed();
}
}
default -> {
return 0.0F;
return AtlasCombat.CONFIG.defaultAttackSpeed();
}
}
}
Expand All @@ -149,4 +151,10 @@ public float getBlockReach() {
default -> 0.0F;
};
}
public static float min(float f, float j) {
if(f < j) {
return j;
}
return f;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package net.alexandra.atlas.atlas_combat.mixin;

import net.alexandra.atlas.atlas_combat.AtlasCombat;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.item.Item;
import org.spongepowered.asm.mixin.Final;
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.UUID;
import java.util.function.Supplier;

@Mixin(AttributeModifier.class)
public class AttributeModifierMixin {
@Shadow
@Mutable
@Final
private double amount;

@Inject(method = "<init>(Ljava/util/UUID;Ljava/util/function/Supplier;DLnet/minecraft/world/entity/ai/attributes/AttributeModifier$Operation;)V", at = @At(value = "RETURN"))
private void injectChanges(UUID uUID, Supplier<String> supplier, double d, AttributeModifier.Operation operation, CallbackInfo ci) {
if (uUID == Item.BASE_ATTACK_SPEED_UUID) {
if(d >= 0) {
amount = AtlasCombat.CONFIG.fastestToolAttackSpeed();
} else if(d >= -1) {
amount = AtlasCombat.CONFIG.fastToolAttackSpeed();
} else if(d == -2) {
amount = AtlasCombat.CONFIG.defaultAttackSpeed();
} else if(d >= -2.5) {
amount = AtlasCombat.CONFIG.fastToolAttackSpeed();
} else if(d > -3) {
amount = AtlasCombat.CONFIG.defaultAttackSpeed();
} else if (d > -3.5) {
amount = AtlasCombat.CONFIG.slowToolAttackSpeed();
} else {
amount = AtlasCombat.CONFIG.slowestToolAttackSpeed();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,14 @@ private void modifyBowCode(PoseStack instance, double d, double e, double f) {
@Redirect(method = "renderArmWithItem", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V", ordinal = 6))
private void modifyBowCode1(PoseStack instance, double d, double e, double f) {
double r = itemStack.getUseDuration() - (this.minecraft.player.getUseItemRemainingTicks() - f + 1.0);
double l = r / 20.0F;
l = (l * l + l * 2.0F) / 3.0F;
if (l > 1.0F) {
l = 1.0F;
}
float m = Mth.sin((float) ((r - 0.1) * 1.3));
double n = ((IBowItem)itemStack.getItem()).getFatigueForTime((int) r) - 0.1;
Item item = itemStack.getItem();
double n = (item instanceof IBowItem ? ((IBowItem)item).getFatigueForTime((int) r) : l) - 0.1F;
double o = m * n;
instance.translate(o * 0.0, o * 0.004, o * 0.0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public boolean preventOutcome(boolean original) {
double d = attributeModifier.getAmount();
boolean bl = false;
if (player != null) {
if (attributeModifier.getId() == WeaponType.BASE_ATTACK_DAMAGE_UUID) {
if (attributeModifier.getId() == WeaponType.BASE_ATTACK_DAMAGE_UUID || attributeModifier.getId() == Item.BASE_ATTACK_DAMAGE_UUID) {
d += player.getAttribute(Attributes.ATTACK_DAMAGE).getBaseValue();
d += EnchantmentHelper.getDamageBonus((ItemStack) (Object) this, player.getMobType());
bl = true;
} else if (attributeModifier.getId() == WeaponType.BASE_ATTACK_SPEED_UUID) {
} else if (attributeModifier.getId() == WeaponType.BASE_ATTACK_SPEED_UUID || attributeModifier.getId() == Item.BASE_ATTACK_SPEED_UUID) {
d += player.getAttribute(Attributes.ATTACK_SPEED).getBaseValue() - 1.5;
bl = true;
} else if (attributeModifier.getId() == WeaponType.BASE_ATTACK_REACH_UUID) {
Expand All @@ -89,7 +89,7 @@ public boolean preventOutcome(boolean original) {
e = d;
}

if (attributeModifier.getId() == WeaponType.BASE_BLOCK_REACH_UUID || attributeModifier.getId() == WeaponType.BASE_ATTACK_REACH_UUID || attributeModifier.getId() == WeaponType.BASE_ATTACK_SPEED_UUID || attributeModifier.getId() == WeaponType.BASE_ATTACK_DAMAGE_UUID || bl) {
if (attributeModifier.getId() == WeaponType.BASE_BLOCK_REACH_UUID || attributeModifier.getId() == WeaponType.BASE_ATTACK_REACH_UUID || attributeModifier.getId() == WeaponType.BASE_ATTACK_SPEED_UUID || attributeModifier.getId() == Item.BASE_ATTACK_SPEED_UUID || attributeModifier.getId() == WeaponType.BASE_ATTACK_DAMAGE_UUID || attributeModifier.getId() == Item.BASE_ATTACK_DAMAGE_UUID || bl) {
list.add(
Component.literal(" ")
.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = LivingEntity.class, priority = 800)
@Mixin(value = LivingEntity.class, priority = 1400)
public abstract class LivingEntityMixin extends Entity implements LivingEntityExtensions {

public LivingEntityMixin(EntityType<?> entityType, Level level) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ private void continueAttack(boolean bl, CallbackInfo ci) {
if (missTime <= 0 && !this.player.isUsingItem()) {
if (bl && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) {
this.retainAttack = false;
} else if (bl && ((PlayerExtensions)this.player).isAttackAvailable(-1.0F) && ((IOptions)options).autoAttack().get()) {
} else if (bl && ((PlayerExtensions)this.player).isAttackAvailable(-1.0F) && ((IOptions)options).autoAttack().get() && AtlasCombat.CONFIG.autoAttackAllowed()) {
this.startAttack();
ci.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.google.common.collect.Multimap;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.alexandra.atlas.atlas_combat.AtlasCombat;
import net.alexandra.atlas.atlas_combat.config.AtlasConfig;
import net.alexandra.atlas.atlas_combat.extensions.*;
import net.alexandra.atlas.atlas_combat.item.NewAttributes;
import net.alexandra.atlas.atlas_combat.util.UtilClass;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -46,7 +48,7 @@
import java.util.List;
import java.util.UUID;

@Mixin(value = Player.class, priority = 800)
@Mixin(value = Player.class, priority = 1400)
public abstract class PlayerMixin extends LivingEntity implements PlayerExtensions, LivingEntityExtensions {
public PlayerMixin(EntityType<? extends LivingEntity> entityType, Level level) {
super(entityType, level);
Expand Down Expand Up @@ -424,8 +426,15 @@ public void attackAir() {
@Override
public void resetAttackStrengthTicker(boolean hit) {
this.missedAttackRecovery = !hit;
if(!AtlasCombat.CONFIG.attackSpeed()) {
if(getAttribute(Attributes.ATTACK_SPEED).getValue() - 1.5 >= 10) {
return;
} else if(attackSpeedsMaxed()) {
return;
}
}
int var2 = (int) (this.getCurrentItemAttackStrengthDelay() * 2);
if (var2 > this.attackStrengthTicker && AtlasCombat.CONFIG.attackSpeed()) {
if (var2 > this.attackStrengthTicker) {
this.attackStrengthStartValue = var2;
this.attackStrengthTicker = this.attackStrengthStartValue;
}
Expand Down Expand Up @@ -550,4 +559,9 @@ public void setAttackStrengthTicker2(int value) {
this.attackStrengthStartValue = value;
player.attackStrengthTicker = this.attackStrengthStartValue;
}
public boolean attackSpeedsMaxed() {
AtlasConfig c = AtlasCombat.CONFIG;
UtilClass<Float> util = new UtilClass<>();
return util.compare(1.5F, c.swordAttackSpeed(), c.axeAttackSpeed(), c.woodenHoeAttackSpeed(), c.stoneHoeAttackSpeed(), c.ironHoeAttackSpeed(), c.goldDiaNethHoeAttackSpeed(), c.defaultAttackSpeed(), c.tridentAttackSpeed(), c.fastToolAttackSpeed(), c.fastestToolAttackSpeed(), c.slowToolAttackSpeed(), c.slowestToolAttackSpeed());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.List;

Expand Down Expand Up @@ -48,12 +50,9 @@ public ImmutableMultimap test(ImmutableMultimap.Builder instance) {
WeaponType.SWORD.addCombatAttributes(this.getTier(), var3);
return var3.build();
}
/**
* @author Mojank
*/
@Overwrite
public float getDamage() {
return WeaponType.SWORD.getDamage(this.getTier());
@Inject(method = "getDamage", at = @At(value = "RETURN"), cancellable = true)
public void getDamage(CallbackInfoReturnable<Float> cir) {
cir.setReturnValue(WeaponType.SWORD.getDamage(this.getTier()));
}

@Override
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/net/alexandra/atlas/atlas_combat/util/UtilClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.alexandra.atlas.atlas_combat.util;

public class UtilClass<T> {
public UtilClass() {

}
@SafeVarargs
public final boolean compare(T comparatee, T... comparators) {
boolean bl = true;
for(T object : comparators) {
bl &= comparatee == object;
}
return bl;
}
}
Loading

0 comments on commit 6ab1d57

Please sign in to comment.