Skip to content

Commit

Permalink
Implement Elementary Staffs health staff tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Oct 22, 2024
1 parent 9abd329 commit dbf089f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ All changes are toggleable via config files.
* **Block Transmutation Fix:** Fixes Effortless Building ignoring Metadata when checking for items in inventory
* **Elementary Staffs**
* **Electric Staff Port:** Reintroduces the 1.5 electric staff behavior along with some subtle particles
* **Health Staff Player Healing:** Lets the health staff also heal other players (and potentially more living entities)
* **Elenai Dodge 2**
* **Extinguishing Dodges:** Chance per dodge to extinguish the player when burning
* **Feathers Helper API Fix:** Fixes server-sided crashes when the Feathers Helper API is utilized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ public static class ElementaryStaffsCategory
@Config.Name("Electric Staff Port")
@Config.Comment("Reintroduces the 1.5 electric staff behavior along with some subtle particles")
public boolean utESElectricStaffToggle = true;

@Config.RequiresMcRestart
@Config.Name("Health Staff Player Healing")
@Config.Comment("Lets the health staff also heal other players (and potentially more living entities)")
public boolean utESHealthStaffToggle = true;
}

public static class ElenaiDodge2Category
Expand Down Expand Up @@ -1009,7 +1014,7 @@ public static class FocusEffectsCategory
@Config.Name("[12] Rift: Impact Sound")
@Config.Comment("Adds an impact sound to the rift focus effect")
public boolean utTCRiftFocusImpactSoundToggle = true;

@Config.RequiresMcRestart
@Config.Name("[13] Exchange: Cast Sound Revamp")
@Config.Comment("Overhauls the exchange focus effect cast sound")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package mod.acgaming.universaltweaks.mods.elementarystaffs.mixin;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;

import de.krokoyt.element.items.HealthStaff;
import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import mod.acgaming.universaltweaks.config.UTConfigMods;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(HealthStaff.class)
public abstract class UTHealthStaffMixin extends Item
{
@Inject(method = "onLeftClickEntity", at = @At("HEAD"), cancellable = true, remap = false)
public void utHealthStaff(ItemStack stack, EntityPlayer player, Entity entity, CallbackInfoReturnable<Boolean> cir)
{
if (!UTConfigMods.ELEMENTARY_STAFFS.utESHealthStaffToggle) return;
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTHealthStaff ::: On left click entity");
if (!(entity instanceof EntityLivingBase))
{
cir.setReturnValue(false);
}
else
{
((EntityLivingBase) entity).heal(2.0F);
player.getHeldItem(EnumHand.MAIN_HAND).damageItem(1, player);

for (int i = 0; i < 5; ++i)
{
entity.world.spawnParticle(EnumParticleTypes.HEART, entity.posX + (double) itemRand.nextFloat() - 0.5, entity.posY + 1.0 + (double) itemRand.nextFloat(), entity.posZ + (double) itemRand.nextFloat() - 0.5, (double) (itemRand.nextFloat() - 0.5F), (double) (itemRand.nextFloat() - 0.5F), (double) (itemRand.nextFloat() - 0.5F), new int[0]);
}

BlockPos bp = new BlockPos(entity.posX, entity.posY, entity.posZ);
ResourceLocation location = new ResourceLocation("element", "magic");
SoundEvent event = new SoundEvent(location);
player.world.playSound(player, bp, event, SoundCategory.MASTER, 4.0F, 0.0F);
cir.setReturnValue(true);
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/mixins.mods.elementarystaffs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTElectricStaffMixin"]
"mixins": ["UTElectricStaffMixin", "UTHealthStaffMixin"]
}

2 comments on commit dbf089f

@ACGaming
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xJon
Copy link

@xJon xJon commented on dbf089f Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Please sign in to comment.