diff --git a/README.md b/README.md index e37c983a..ed01307a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java index e81e6c9f..50632ae8 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java @@ -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 @@ -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") diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/elementarystaffs/mixin/UTHealthStaffMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/elementarystaffs/mixin/UTHealthStaffMixin.java new file mode 100644 index 00000000..e9826d11 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/elementarystaffs/mixin/UTHealthStaffMixin.java @@ -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 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); + } + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.mods.elementarystaffs.json b/src/main/resources/mixins.mods.elementarystaffs.json index a6301f15..54d3b264 100644 --- a/src/main/resources/mixins.mods.elementarystaffs.json +++ b/src/main/resources/mixins.mods.elementarystaffs.json @@ -3,5 +3,5 @@ "refmap": "universaltweaks.refmap.json", "minVersion": "0.8", "compatibilityLevel": "JAVA_8", - "mixins": ["UTElectricStaffMixin"] + "mixins": ["UTElectricStaffMixin", "UTHealthStaffMixin"] } \ No newline at end of file