From 450745ac623f392b3e01adccf2935926a24136c2 Mon Sep 17 00:00:00 2001 From: Me <135455255+IcarussOne@users.noreply.github.com> Date: Wed, 28 Aug 2024 08:02:52 -0500 Subject: [PATCH] Add Kinetic Girdle of Shielding --- .../events/CRClientEvents.java | 69 ++++++++++++++++ .../crimsonrevelations/events/CREvents.java | 77 ++++++++---------- .../crimsonrevelations/init/CRItems.java | 5 +- .../assets/crimsonrevelations/lang/en_us.lang | 1 + .../models/item/runic_girdle_kinetic.json | 6 ++ .../textures/items/runic_girdle_kinetic.png | Bin 0 -> 981 bytes .../items/runic_girdle_kinetic.png.mcmeta | 5 ++ 7 files changed, 119 insertions(+), 44 deletions(-) create mode 100644 src/main/java/mod/icarus/crimsonrevelations/events/CRClientEvents.java create mode 100644 src/main/resources/assets/crimsonrevelations/models/item/runic_girdle_kinetic.json create mode 100644 src/main/resources/assets/crimsonrevelations/textures/items/runic_girdle_kinetic.png create mode 100644 src/main/resources/assets/crimsonrevelations/textures/items/runic_girdle_kinetic.png.mcmeta diff --git a/src/main/java/mod/icarus/crimsonrevelations/events/CRClientEvents.java b/src/main/java/mod/icarus/crimsonrevelations/events/CRClientEvents.java new file mode 100644 index 0000000..88337c1 --- /dev/null +++ b/src/main/java/mod/icarus/crimsonrevelations/events/CRClientEvents.java @@ -0,0 +1,69 @@ +package mod.icarus.crimsonrevelations.events; + +import mod.icarus.crimsonrevelations.NewCrimsonRevelations; +import mod.icarus.crimsonrevelations.item.CRItemBow; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraftforge.client.event.FOVUpdateEvent; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +@EventBusSubscriber(modid = NewCrimsonRevelations.MODID) +@GameRegistry.ObjectHolder(NewCrimsonRevelations.MODID) +public class CRClientEvents { + // Courtesy of NeRdTheNed + @SubscribeEvent + public void FOV(FOVUpdateEvent event) { + final EntityPlayer eventPlayer = event.getEntity(); + final Item eventItem = eventPlayer.getActiveItemStack().getItem(); + + if (eventItem instanceof CRItemBow) { + float finalFov = event.getFov(); + final float itemUseCount = ((CRItemBow) eventItem).getMaxItemUseDuration(eventPlayer.getActiveItemStack()) - eventPlayer.getItemInUseCount(); + /* + * First, we have to reverse the standard bow zoom. + * Minecraft helpfully applies the standard bow zoom + * to any item that is an instance of a ItemBow. + * However, our custom bows draw back at different speeds, + * so the standard zoom is not at the right speed. + * To compensate for this, we just calculate the standard bow zoom, + * and apply it in reverse. + */ + float realBow = itemUseCount / 20.0F; + + if (realBow > 1.0F) { + realBow = 1.0F; + } else { + realBow *= realBow; + } + + /* + * Minecraft uses finalFov *= 1.0F - (realBow * 0.15F) + * to calculate the standard bow zoom. + * To reverse this, we just divide it instead. + */ + finalFov /= 1.0F - (realBow * 0.15F); + /* + * We now calculate and apply our custom bow zoom. + * The only difference between standard bow zoom and custom bow zoom + * is that we change the hardcoded value of 20.0F to + * whatever drawTime is. + */ + float drawTime = 20 * ((CRItemBow) eventItem).drawTimeMult; + float customBow = itemUseCount / drawTime; + + if (customBow > 1.0F) { + customBow = 1.0F; + } else { + customBow *= customBow; + } + + finalFov *= 1.0F - (customBow * 0.15F); + event.setNewfov(finalFov); + } + } +} diff --git a/src/main/java/mod/icarus/crimsonrevelations/events/CREvents.java b/src/main/java/mod/icarus/crimsonrevelations/events/CREvents.java index dd5c23a..68cf04b 100644 --- a/src/main/java/mod/icarus/crimsonrevelations/events/CREvents.java +++ b/src/main/java/mod/icarus/crimsonrevelations/events/CREvents.java @@ -1,66 +1,57 @@ package mod.icarus.crimsonrevelations.events; +import java.util.List; + +import baubles.api.BaublesApi; import mod.icarus.crimsonrevelations.NewCrimsonRevelations; +import mod.icarus.crimsonrevelations.init.CRItems; import mod.icarus.crimsonrevelations.item.CRItemBow; +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.stats.StatList; +import net.minecraft.util.SoundCategory; +import net.minecraft.world.World; import net.minecraftforge.client.event.FOVUpdateEvent; +import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; +import thaumcraft.common.lib.SoundsTC; +import thaumcraft.common.lib.events.PlayerEvents; @EventBusSubscriber(modid = NewCrimsonRevelations.MODID) @GameRegistry.ObjectHolder(NewCrimsonRevelations.MODID) public class CREvents { - // Courtesy of NeRdTheNed @SubscribeEvent - public void FOV(FOVUpdateEvent event) { - final EntityPlayer eventPlayer = event.getEntity(); - final Item eventItem = eventPlayer.getActiveItemStack().getItem(); + public static void onHurtEvent(LivingHurtEvent event) { + World world = event.getEntity().world; + Entity source = event.getSource().getTrueSource(); - if (eventItem instanceof CRItemBow) { - float finalFov = event.getFov(); - final float itemUseCount = ((CRItemBow) eventItem).getMaxItemUseDuration(eventPlayer.getActiveItemStack()) - eventPlayer.getItemInUseCount(); - /* - * First, we have to reverse the standard bow zoom. - * Minecraft helpfully applies the standard bow zoom - * to any item that is an instance of a ItemBow. - * However, our custom bows draw back at different speeds, - * so the standard zoom is not at the right speed. - * To compensate for this, we just calculate the standard bow zoom, - * and apply it in reverse. - */ - float realBow = itemUseCount / 20.0F; + if (event.getEntityLiving() instanceof EntityPlayer && source instanceof EntityLivingBase && !world.isRemote) { + EntityPlayer player = (EntityPlayer) event.getEntityLiving(); + int charge = (int) player.getAbsorptionAmount(); - if (realBow > 1.0F) { - realBow = 1.0F; - } else { - realBow *= realBow; - } + if (charge > 0) { + if (BaublesApi.isBaubleEquipped(player, CRItems.runicGirdleKinetic) > 0 && !(player.getCooldownTracker().hasCooldown(CRItems.runicGirdleKinetic))) { + player.world.playSound(null, player.posX, player.posY, player.posZ, SoundsTC.poof, SoundCategory.PLAYERS, 1.0F, 1.0F + (float) player.getEntityWorld().rand.nextGaussian() * 0.05F); + player.world.createExplosion(player, player.posX, player.posY + player.height / 2.0F, player.posZ, 2.0F, false); - /* - * Minecraft uses finalFov *= 1.0F - (realBow * 0.15F) - * to calculate the standard bow zoom. - * To reverse this, we just divide it instead. - */ - finalFov /= 1.0F - (realBow * 0.15F); - /* - * We now calculate and apply our custom bow zoom. - * The only difference between standard bow zoom and custom bow zoom - * is that we change the hardcoded value of 20.0F to - * whatever drawTime is. - */ - float drawTime = 20 * ((CRItemBow) eventItem).drawTimeMult; - float customBow = itemUseCount / drawTime; + List entities = player.world.getEntitiesWithinAABBExcludingEntity(player, player.getEntityBoundingBox().grow(3.0D, 3.0D, 3.0D)); - if (customBow > 1.0F) { - customBow = 1.0F; - } else { - customBow *= customBow; - } + for (Entity entity : entities) { + if (entity instanceof EntityLivingBase) { + EntityLivingBase mob = (EntityLivingBase) entity; + mob.knockBack(player, 2.0F, player.posX - mob.posX, player.posZ - mob.posZ); + } + } - finalFov *= 1.0F - (customBow * 0.15F); - event.setNewfov(finalFov); + ((EntityPlayer) player).addStat(StatList.getObjectUseStats(CRItems.runicGirdleKinetic)); + ((EntityPlayer) player).getCooldownTracker().setCooldown(CRItems.runicGirdleKinetic, 15 * 20); + } + } } } } diff --git a/src/main/java/mod/icarus/crimsonrevelations/init/CRItems.java b/src/main/java/mod/icarus/crimsonrevelations/init/CRItems.java index ebcf923..629d62d 100644 --- a/src/main/java/mod/icarus/crimsonrevelations/init/CRItems.java +++ b/src/main/java/mod/icarus/crimsonrevelations/init/CRItems.java @@ -70,6 +70,8 @@ public class CRItems { public static Item runicAmulet; @GameRegistry.ObjectHolder("runic_girdle") public static Item runicGirdle; + @GameRegistry.ObjectHolder("runic_girdle_kinetic") + public static Item runicGirdleKinetic; @GameRegistry.ObjectHolder("runic_ring") public static Item runicRing; @@ -101,7 +103,8 @@ public static void registerItems(@Nonnull final RegistryEvent.Register eve CRRegistry.setup(new CRItemRunicBauble(BaubleType.RING, EnumRarity.UNCOMMON, 5), "runic_ring"), CRRegistry.setup(new CRItemRunicBauble(BaubleType.AMULET, EnumRarity.UNCOMMON, 8), "runic_amulet"), - CRRegistry.setup(new CRItemRunicBauble(BaubleType.BELT, EnumRarity.UNCOMMON, 10), "runic_girdle") + CRRegistry.setup(new CRItemRunicBauble(BaubleType.BELT, EnumRarity.UNCOMMON, 10), "runic_girdle"), + CRRegistry.setup(new CRItemRunicBauble(BaubleType.BELT, EnumRarity.RARE, 9), "runic_girdle_kinetic") ); // Item Blocks diff --git a/src/main/resources/assets/crimsonrevelations/lang/en_us.lang b/src/main/resources/assets/crimsonrevelations/lang/en_us.lang index 36ab987..cf9cfb3 100644 --- a/src/main/resources/assets/crimsonrevelations/lang/en_us.lang +++ b/src/main/resources/assets/crimsonrevelations/lang/en_us.lang @@ -23,6 +23,7 @@ item.crimsonrevelations.ordo_arrow.name=Ordo Arrow item.crimsonrevelations.perditio_arrow.name=Perditio Arrow item.crimsonrevelations.runic_amulet.name=Amulet of Runic Shielding item.crimsonrevelations.runic_girdle.name=Belt of Runic Shielding +item.crimsonrevelations.runic_girdle_kinetic.name=Kinetic Girdle of Shielding item.crimsonrevelations.runic_ring.name=Ring of Runic Shielding item.crimsonrevelations.terra_arrow.name=Terra Arrow diff --git a/src/main/resources/assets/crimsonrevelations/models/item/runic_girdle_kinetic.json b/src/main/resources/assets/crimsonrevelations/models/item/runic_girdle_kinetic.json new file mode 100644 index 0000000..e555ef1 --- /dev/null +++ b/src/main/resources/assets/crimsonrevelations/models/item/runic_girdle_kinetic.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "crimsonrevelations:items/runic_girdle_kinetic" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/crimsonrevelations/textures/items/runic_girdle_kinetic.png b/src/main/resources/assets/crimsonrevelations/textures/items/runic_girdle_kinetic.png new file mode 100644 index 0000000000000000000000000000000000000000..cb7e6d75504828b1217f84b3e4c1f3dd6747087d GIT binary patch literal 981 zcmV;`11kK9P)WdKcYZXh!;AWdO%ATls9G$1iFIxsRiGB_YBFfuSOA>6H300007bV*G` z2i^n+7Y7}=nFehD000SaNLh0L03N{r03N{s!)a7g00004XF*Lt006O%3;baP0009l zNkl7ip7{`C_Y-c*Nvr9inDQU}BnxF|in5vOrGz6j{qNZHD8G{nz$qQaY zJ$ZnGAt2HN1Tjrh5)ndLNopje8VG756|fcC8aD0rgKj^z?e5Ob$L{O6!8Wx^0zF_- z_BqVq&HVrGJOAg&Z(jJnOXOQLi**?=JRC^s46XGXe@^9>7)`dtU#8Ua0Qh$IvEk- z^o7d=QZA``+Ia&bsK|F--Nslf&ghs!S0sW|HB8$ftx6i6+Ct@;60*e_r&~KoB;A}= z$$hh;$-TR_`{KKd&)Hm${)J;X!ktZsxb28^!WC`T`xu;^q(lmKy|@KoD01FFgcTHF zp?DhIy(3t2nI&N*QzC16`Q1GN>bp zJf<8!11S~^0(OS}(HL{VI6F@q;lSl9gmg`+Wr|$oZ>5@s-2K86RIRV_^O>aF)X)uW zaTkKCiseT?b+UhWE4S1;H1?lm;PaEzKUs~T>NsA8_FsCa+gQ!TpSwv~nS~H@PF8@Z z`ztLaogCWq2{kgvxF4G1NG@Faoq?fIUV5&U>8WWHEs%eZ%CsW+*2QB)zKe15%yC}Z zUQ5>V_wcfeOpI|isnXpaAvv=!OiR+%RYNL@-x0eARnzhOqZ4uoSc16g<{kaVy$U>7 znLK#6BYu>1Rp2%<|15Ht!PuueHpuOupJoq7;peNc+ z>&Oj4%`A@x&s=MwJUc{J!{GuC9#s{1urhhD?`9)!w>B;Bez2qCD?Z!!iXU7b`%he9 z^!)LMyB}=m`;(TDJDiI45U!WY