Skip to content

Commit

Permalink
mana blaster draw speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Partonetrain committed Aug 30, 2024
1 parent ff11b23 commit 0506107
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public static class RangedItemConfig{
public float skadiDamage = 10f;
@Comment("Pull time in ticks of Skadi Bow")
public int skadiPullTime = 30;
@Comment("Add ranged attributes to Elementium and Manaweave armor")
public boolean addRangedAttributes = false;
}

@ConfigEntry.Gui.CollapsibleObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@

@Mixin(TerrasteelArmorItem.class)
public class TerrasteelArmorItemMixin {




@Inject(
method = "getDefaultAttributeModifiers(Lnet/minecraft/world/entity/EquipmentSlot;)Lcom/google/common/collect/Multimap;",
at = @At("TAIL"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
package info.partonetrain.botaniacombat.mixin.ranged;

import com.llamalad7.mixinextras.sugar.Local;
import info.partonetrain.botaniacombat.BotaniaCombat;
import info.partonetrain.botaniacombat.BotaniaNerfConfiguredValues;
import net.fabric_extras.ranged_weapon.api.EntityAttributes_RangedWeapon;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import vazkii.botania.common.item.BotaniaItems;
import vazkii.botania.common.item.ManaBlasterItem;

Expand All @@ -23,6 +32,8 @@ public abstract class ManaBlasterMixin extends Item {
@Unique
float damage;
@Unique
int modifiedCooldown = 30;
@Unique
AttributeModifier mod1, mod2;

public ManaBlasterMixin(Properties properties) {
Expand All @@ -33,8 +44,8 @@ public ManaBlasterMixin(Properties properties) {
public void botaniacombat$setDamageLensNBT(ItemStack stack, Level world, Entity entity, int slot, boolean selected, CallbackInfo ci){
if(ManaBlasterItem.getLens(stack).is(BotaniaItems.lensDamage)){
damage = BotaniaNerfConfiguredValues.dmgLensDamage;
mod1 = new AttributeModifier(UUID.fromString("60dfc4ff-de55-4f4f-8b4b-a7748c26ec4d"), "Blaster mainhand modifier", damage, AttributeModifier.Operation.ADDITION);
mod2 = new AttributeModifier(UUID.fromString("2c9b7180-d04f-4b1f-9574-174969759856"), "Blaster offhand modifier", damage, AttributeModifier.Operation.ADDITION);
mod1 = new AttributeModifier(UUID.fromString("60dfc4ff-de55-4f4f-8b4b-a7748c26ec4d"), "Blaster mainhand damage", damage, AttributeModifier.Operation.ADDITION);
mod2 = new AttributeModifier(UUID.fromString("2c9b7180-d04f-4b1f-9574-174969759856"), "Blaster offhand damage", damage, AttributeModifier.Operation.ADDITION);
if(!stack.getAttributeModifiers(EquipmentSlot.MAINHAND).containsKey(EntityAttributes_RangedWeapon.DAMAGE.attribute)){
stack.addAttributeModifier(EntityAttributes_RangedWeapon.DAMAGE.attribute, mod1, EquipmentSlot.MAINHAND);
stack.addAttributeModifier(EntityAttributes_RangedWeapon.DAMAGE.attribute, mod2, EquipmentSlot.OFFHAND);
Expand All @@ -46,4 +57,34 @@ public ManaBlasterMixin(Properties properties) {
}
}

//haste disabler - use player ranged speed attribute instead
@Inject(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;isSecondaryUseActive()Z"))
public void botaniacombat$useRangedWeaponHaste(Level world, Player player, @NotNull InteractionHand hand, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir){
ItemStack stack = player.getItemInHand(hand);
if(ManaBlasterItem.getLens(stack).is(BotaniaItems.lensDamage) && !player.level().isClientSide()) { //only relevant to damaging lens
modifiedCooldown = 30; //default cooldown
double attributeValue = player.getAttributeValue(EntityAttributes_RangedWeapon.HASTE.attribute); //defaults to 100, increases with bonuses.
double cooldownMultiplier = (100 - attributeValue) / 100;
modifiedCooldown = (int) (modifiedCooldown + (modifiedCooldown * cooldownMultiplier)); //int is a primitive type, so we can't use effCd local var, because it wouldn't be propgated
}
}

@ModifyArg(method = "use", at= @At(value = "INVOKE", target = "Lvazkii/botania/common/item/ManaBlasterItem;setCooldown(Lnet/minecraft/world/item/ItemStack;I)V"), index = 1)
public int botaniacombat$useModifiedCooldown(int cooldown){
BotaniaCombat.LOGGER.info(String.valueOf(modifiedCooldown));
return modifiedCooldown;
}

@Inject(method = "getBarColor", at=@At(value = "HEAD"), cancellable = true)
public void dontCrash(ItemStack stack, CallbackInfoReturnable<Integer> cir){
int cd = stack.getOrCreateTag().getInt("cooldown");
try{
cir.setReturnValue(Mth.hsvToRgb((1 - cd / (float) 30) / 3.0F, 1.0F, 1.0F));
}
catch (RuntimeException e){
BotaniaCombat.LOGGER.error(e.getMessage());
cir.setReturnValue(Mth.hsvToRgb(1, 1, 1));
}
}

}
2 changes: 1 addition & 1 deletion src/main/resources/assets/botaniacombat/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"botaniacombat.page.angry_bozu1": "haha. just a glimpse into my dark reality.",

"botaniacombat.entry.damageLens": "Damaging Lens Bonus",
"botaniacombat.page.damageLens": "A $(l:botania:tools/mana_blaster)Mana Blaster$() with a Damage Lens attached is affected by Ranged Damage bonuses. Unlike other ranged weapons, a Blaster with such a lens seems to deal magic damage, bypassing armor.",
"botaniacombat.page.damageLens": "A $(l:botania:tools/mana_blaster)Mana Blaster$() with a Damage Lens attached is affected by Ranged Damage and Draw Speed bonuses. On the downside, it won't recieve the cooldown reduction from Haste effect. Unlike other ranged weapons, a Blaster with such a lens seems to deal magic damage, bypassing armor.",

"text.autoconfig.botaniacombat.title": "BotaniaCombat config (Requires Restart)",
"text.autoconfig.botaniacombat.option.daggerDamageModifier": "Dagger Damage Modifier",
Expand Down

0 comments on commit 0506107

Please sign in to comment.