diff --git a/src/main/java/ganymedes01/etfuturum/EtFuturum.java b/src/main/java/ganymedes01/etfuturum/EtFuturum.java index 9b419992..23407594 100644 --- a/src/main/java/ganymedes01/etfuturum/EtFuturum.java +++ b/src/main/java/ganymedes01/etfuturum/EtFuturum.java @@ -970,6 +970,27 @@ private static void getSounds(ADConfig config) { config.addSoundEvent(ver, "block.cherry_wood_pressure_plate.click_on", "block"); config.addSoundEvent(ver, "block.metal_pressure_plate.click_off", "block"); config.addSoundEvent(ver, "block.metal_pressure_plate.click_on", "block"); + + if (ConfigSounds.squidSounds) { + config.addObject(ver, "minecraft/sounds/entity/squid/ambient1.ogg"); + config.addObject(ver, "minecraft/sounds/entity/squid/ambient2.ogg"); + config.addObject(ver, "minecraft/sounds/entity/squid/ambient3.ogg"); + config.addObject(ver, "minecraft/sounds/entity/squid/ambient4.ogg"); + config.addObject(ver, "minecraft/sounds/entity/squid/ambient5.ogg"); + + config.addObject(ver, "minecraft/sounds/entity/squid/hurt1.ogg"); + config.addObject(ver, "minecraft/sounds/entity/squid/hurt2.ogg"); + config.addObject(ver, "minecraft/sounds/entity/squid/hurt3.ogg"); + config.addObject(ver, "minecraft/sounds/entity/squid/hurt4.ogg"); + + config.addObject(ver, "minecraft/sounds/entity/squid/death1.ogg"); + config.addObject(ver, "minecraft/sounds/entity/squid/death2.ogg"); + config.addObject(ver, "minecraft/sounds/entity/squid/death3.ogg"); + + config.addObject(ver, "minecraft/sounds/entity/squid/squirt1.ogg"); + config.addObject(ver, "minecraft/sounds/entity/squid/squirt2.ogg"); + config.addObject(ver, "minecraft/sounds/entity/squid/squirt3.ogg"); + } //Automatically register block sounds for AssetDirector, but only if they contain the MC version (which means it needs to be registered here) //Then we remove the mc version prefix and register that sound. diff --git a/src/main/java/ganymedes01/etfuturum/client/DynamicSoundsResourcePack.java b/src/main/java/ganymedes01/etfuturum/client/DynamicSoundsResourcePack.java index eefbee66..f7047702 100644 --- a/src/main/java/ganymedes01/etfuturum/client/DynamicSoundsResourcePack.java +++ b/src/main/java/ganymedes01/etfuturum/client/DynamicSoundsResourcePack.java @@ -130,6 +130,31 @@ public JsonObject getJson() { Reference.MCAssetVer + ":ambient/cave/cave18", Reference.MCAssetVer + ":ambient/cave/cave19"); } + + if (ConfigSounds.squidSounds) { + addSoundsToCategory("entity.squid.say", + Reference.MCAssetVer + ":entity/squid/ambient1", + Reference.MCAssetVer + ":entity/squid/ambient2", + Reference.MCAssetVer + ":entity/squid/ambient3", + Reference.MCAssetVer + ":entity/squid/ambient4", + Reference.MCAssetVer + ":entity/squid/ambient5"); + + addSoundsToCategory("entity.squid.hurt", + Reference.MCAssetVer + ":entity/squid/hurt1", + Reference.MCAssetVer + ":entity/squid/hurt2", + Reference.MCAssetVer + ":entity/squid/hurt3", + Reference.MCAssetVer + ":entity/squid/hurt4"); + + addSoundsToCategory("entity.squid.death", + Reference.MCAssetVer + ":entity/squid/death1", + Reference.MCAssetVer + ":entity/squid/death2", + Reference.MCAssetVer + ":entity/squid/death3"); + + addSoundsToCategory("entity.squid.shoot", + Reference.MCAssetVer + ":entity/squid/squirt1", + Reference.MCAssetVer + ":entity/squid/squirt2", + Reference.MCAssetVer + ":entity/squid/squirt3"); + } return rootObject; } } diff --git a/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigEntities.java b/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigEntities.java index 7ddd7fe7..9f76ecbb 100644 --- a/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigEntities.java +++ b/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigEntities.java @@ -19,6 +19,7 @@ public class ConfigEntities extends ConfigBase { public static boolean enableNetherEndermen; public static boolean enableShearableSnowGolems; public static boolean enableBees; + public static boolean enableSquidInk; static final String catHostile = "hostile"; static final String catNeutral = "neutral"; @@ -46,6 +47,7 @@ protected void syncConfigOptions() { //passive enableRabbit = getBoolean("enableRabbits", catPassive, true, ""); enableBrownMooshroom = getBoolean("enableBrownMooshroom", catPassive, true, "Brown mooshroom variant, the red mooshrooms turn into then when they are hit by lightning."); + enableSquidInk = getBoolean("enableSquidInk", catPassive, true, "Squid now produce a cloud of floating black ink particles when attacked."); //neutral enableBees = getBoolean("enableBees", catNeutral, true, ""); diff --git a/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigSounds.java b/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigSounds.java index 1e60b77b..1fe5f9bd 100644 --- a/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigSounds.java +++ b/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigSounds.java @@ -99,6 +99,7 @@ public class ConfigSounds extends ConfigBase { public static boolean furnaceCrackling; public static boolean bonemealing; public static boolean heavyWaterSplashing; + public static boolean squidSounds; public static float combatSoundStrongThreshold; @@ -150,6 +151,7 @@ protected void syncConfigOptions() { thornsSounds = getBoolean("thornsSounds", catEntity, true, "New sounds for being hurt by the Thorns enchantment."); horseEatCowMilk = getBoolean("horseEatCowMilk", catEntity, true, "Sounds for horses eating food and cows being milked."); heavyWaterSplashing = getBoolean("heavyWaterSplashing", catEntity, true, "Play a more intense splash when the player lands in water at high speeds."); + squidSounds = getBoolean("squidSounds", catEntity, true, "Add squid sounds introduced in 1.9+."); bookPageTurn = getBoolean("bookPageTurn", catMisc, true, "Changes the click in the book GUI to have a page turn sound instead of the menu click."); diff --git a/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java b/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java index 01eed04d..071c85d3 100644 --- a/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java +++ b/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java @@ -150,17 +150,33 @@ public void livingUpdate(LivingUpdateEvent event) { } } - if (ConfigMixins.stepHeightFix && event.entity.stepHeight == .5F) { - event.entity.stepHeight = .6F; + if (ConfigMixins.stepHeightFix && entity.stepHeight == .5F) { + entity.stepHeight = .6F; } if (ConfigMixins.enableElytra && entity instanceof IElytraPlayer) { ((IElytraPlayer) entity).tickElytra(); } + if (EntitySquid.class.equals(entity.getClass())) { + EntitySquid sq = (EntitySquid) entity; + + if (ConfigEntities.enableSquidInk && "Nelly".equals(sq.getCustomNameTag())) { + Vec3 a = sq.getLookVec().normalize(); + sq.fallDistance = 0.0f; + sq.addVelocity(a.xCoord * 0.08, 0.08, a.zCoord * 0.08); + sq.motionY = 0.08; + sq.velocityChanged = true; + } + + if (ConfigSounds.squidSounds && sq.livingSoundTime == 0 && sq.isInWater() && entity.worldObj.rand.nextDouble() < 0.05) { + playSoundAtEntityRng("entity.squid.say", sq); + } + } - if (ConfigSounds.armorEquip && !event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer && !(event.entity instanceof FakePlayer)) { - EntityPlayer player = (EntityPlayer) event.entity; + + if (ConfigSounds.armorEquip && !entity.worldObj.isRemote && entity instanceof EntityPlayer && !(entity instanceof FakePlayer)) { + EntityPlayer player = (EntityPlayer) entity; if (!SpectatorMode.isSpectator(player)) { if (!armorTracker.containsKey(player)) { @@ -222,6 +238,22 @@ public void livingUpdate(LivingUpdateEvent event) { } } } + + @SubscribeEvent + public void onLivingDeathEvent(LivingDeathEvent event) { + EntityLivingBase entity = event.entityLiving; + if (!entity.worldObj.isRemote && ConfigSounds.squidSounds && EntitySquid.class.equals(entity.getClass())) { + playSoundAtEntityRng("entity.squid.death", entity); + } + } + + private static void playSoundAtEntityRng(String soundName, EntityLivingBase e) { + Random r = e.worldObj.rand; + float v = e.isChild() ? 1.5F : 1.0F; + float pitch = (r.nextFloat() - r.nextFloat()) * 0.2F + v; + + e.worldObj.playSoundAtEntity(e, soundName, 0.4F, pitch); + } @SubscribeEvent public void onAttackEntityEvent(AttackEntityEvent event) { //Fires when a player presses the attack button on an entity @@ -1585,7 +1617,7 @@ public void entityStruckByLightning(EntityStruckByLightningEvent event) { @SubscribeEvent public void livingHurtEvent(LivingHurtEvent event) { - Entity targetEntity = event.entity; + EntityLivingBase targetEntity = event.entityLiving; if (targetEntity == null) return; if (ConfigFunctions.enableHayBaleFalls && targetEntity.worldObj.getBlock(MathHelper.floor_double(targetEntity.posX), MathHelper.floor_double(targetEntity.posY - 0.20000000298023224D - targetEntity.yOffset), MathHelper.floor_double(targetEntity.posZ)) == Blocks.hay_block @@ -1606,9 +1638,7 @@ public void livingHurtEvent(LivingHurtEvent event) { float attackDamage = (float) playerSource.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); float enchantmentDamage = 0.0F; - if (targetEntity instanceof EntityLivingBase) { - enchantmentDamage = EnchantmentHelper.getEnchantmentModifierLiving(playerSource, (EntityLivingBase) targetEntity); - } + enchantmentDamage = EnchantmentHelper.getEnchantmentModifierLiving(playerSource, targetEntity); if (attackDamage > 0.0F || enchantmentDamage > 0.0F) { boolean isStrongAttack = playerSource.getHeldItem() != null && event.ammount >= ConfigSounds.combatSoundStrongThreshold; @@ -1658,14 +1688,50 @@ public void livingHurtEvent(LivingHurtEvent event) { } } - - if (!(targetEntity instanceof EntityLivingBase)) { - return; + if (ConfigBlocksItems.enableTotemUndying) { + handleTotemCheck(targetEntity, event); } - EntityLivingBase livingEntity = (EntityLivingBase) targetEntity; + + if (EntitySquid.class.equals(targetEntity.getClass())) { + if (ConfigSounds.squidSounds) { + playSoundAtEntityRng("entity.squid.hurt", targetEntity); + } + World w = targetEntity.worldObj; + Random r = w.rand; + doInk: if (ConfigEntities.enableSquidInk && r.nextDouble() < 0.15 && w instanceof WorldServer serverWorld && targetEntity.isInWater()) { + AxisAlignedBB eBox = targetEntity.boundingBox; + double cx = eBox.maxX - 0.5 * (eBox.maxX - eBox.minX); + double cy = eBox.maxY - 0.5 * (eBox.maxY - eBox.minY); + double cz = eBox.maxZ - 0.5 * (eBox.maxZ - eBox.minZ); + + AxisAlignedBB box = AxisAlignedBB.getBoundingBox(-1.5, -1.5, -1.5, 1.5, 1.5, 1.5).offset(cx, cy, cz); + List around = w.getEntitiesWithinAABB(EntityLivingBase.class, box); + + if (around.isEmpty()) { + break doInk; + } - if (ConfigBlocksItems.enableTotemUndying) { - handleTotemCheck(livingEntity, event); + EntityLivingBase target = around.get(r.nextInt(around.size())); + if (target != null && target != targetEntity) { + if (w instanceof WorldServer) { + ((WorldServer) w).func_147487_a("largesmoke", cx, cy, cz, 5, 0.0, 0.0, 0.0, 0.08); + } + if (ConfigSounds.squidSounds) { + playSoundAtEntityRng("entity.squid.shoot", target); + } + if (target.isInWater()) { + PotionEffect activeEff = target.getActivePotionEffect(Potion.blindness); + int time = 20 + r.nextInt(300); + if (activeEff != null) { + if (activeEff.getAmplifier() > 0) { + break doInk; + } + time += activeEff.getDuration(); + } + target.addPotionEffect(new PotionEffect(Potion.blindness.id, time)); + } + } + } } // If the attacker is a player spawn the hearts aligned and facing it