1.0.8
SlightlyVanilla/pipeline/head This commit looks good Details

Play Throw Sound
This commit is contained in:
TheBrokenRail 2020-03-21 14:43:33 -04:00
parent 31bc26c4f8
commit 923a5936ee
5 changed files with 15 additions and 1 deletions

View File

@ -1,5 +1,8 @@
# Changelog
**1.0.8**
* Play Throw Sound
**1.0.7**
* Allow Leashing Villagers

View File

@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
fabric_loader_version = 0.7.8+build.189
# Mod Properties
mod_version = 1.0.7
mod_version = 1.0.8
maven_group = com.thebrokenrail
archives_base_name = slightlyvanilla

View File

@ -15,10 +15,13 @@ import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPointer;
@ -27,6 +30,8 @@ import net.minecraft.util.math.Position;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import java.util.Random;
public class SlightlyVanilla implements ModInitializer {
public static final String NAMESPACE = "slightlyvanilla";
@ -90,4 +95,8 @@ public class SlightlyVanilla implements ModInitializer {
});
}
}
public static void playThrowSound(PlayerEntity user) {
user.getEntityWorld().playSound(null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (new Random().nextFloat() * 0.4F + 0.8F));
}
}

View File

@ -22,6 +22,7 @@ public class MixinItem {
public void use(World world, PlayerEntity playerEntity, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> info) {
ItemStack stack = playerEntity.getStackInHand(hand);
if (stack.getItem() == Items.SLIME_BALL && SlightlyVanilla.getConfig().throwableSlimeballs.player) {
SlightlyVanilla.playThrowSound(playerEntity);
if (!world.isClient()) {
SlimeballEntity entity = new SlimeballEntity(world, playerEntity);
entity.setItem(stack);

View File

@ -21,6 +21,7 @@ public class MixinSpawnEggItem {
public void use(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> info) {
if (SlightlyVanilla.getConfig().throwableSpawnEggs.player && info.getReturnValue().getResult() == ActionResult.PASS) {
ItemStack stack = user.getStackInHand(hand);
SlightlyVanilla.playThrowSound(user);
if (!world.isClient()) {
SpawnEggEntity entity = new SpawnEggEntity(world, user);
entity.setItem(stack);