From b1f4d3ebf989fe3f1ad4427bb664091b450a9b32 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 24 Oct 2018 12:42:04 +0200 Subject: [PATCH] some sounds to polish existing features up --- src/main/java/de/ellpeck/naturesaura/Helper.java | 13 ++++++++++--- .../naturesaura/blocks/BlockNatureAltar.java | 2 +- .../ellpeck/naturesaura/blocks/BlockWoodStand.java | 4 +--- .../blocks/tiles/TileEntityNatureAltar.java | 5 +++++ .../blocks/tiles/TileEntityWoodStand.java | 9 +++++++++ .../ellpeck/naturesaura/packet/PacketParticles.java | 4 ++-- .../naturesaura/models/item/color_changer.json | 2 +- .../models/item/color_changer_fill_mode.json | 2 +- .../models/item/color_changer_filled.json | 2 +- 9 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 4ee568f9..bd811ae5 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -11,10 +11,12 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; +import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; @@ -103,7 +105,7 @@ public final class Helper { GlStateManager.popMatrix(); } - public static boolean putStackOnTile(EntityPlayer player, EnumHand hand, BlockPos pos, int slot) { + public static boolean putStackOnTile(EntityPlayer player, EnumHand hand, BlockPos pos, int slot, boolean sound) { TileEntity tile = player.world.getTileEntity(pos); if (tile instanceof TileEntityImpl) { IItemHandlerModifiable handler = ((TileEntityImpl) tile).getItemHandler(null); @@ -112,14 +114,19 @@ public final class Helper { if (!handStack.isEmpty()) { ItemStack remain = handler.insertItem(slot, handStack, player.world.isRemote); if (!ItemStack.areItemStacksEqual(remain, handStack)) { - if (!player.world.isRemote) { + if (sound) + player.world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + SoundEvents.ENTITY_ITEMFRAME_ADD_ITEM, SoundCategory.PLAYERS, 0.75F, 1F); + if (!player.world.isRemote) player.setHeldItem(hand, remain); - } return true; } } if (!handler.getStackInSlot(slot).isEmpty()) { + if (sound) + player.world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + SoundEvents.ENTITY_ITEMFRAME_REMOVE_ITEM, SoundCategory.PLAYERS, 0.75F, 1F); if (!player.world.isRemote) { player.addItemStackToInventory(handler.getStackInSlot(slot)); handler.setStackInSlot(slot, ItemStack.EMPTY); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java index 975a67ca..83df1c39 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java @@ -24,7 +24,7 @@ public class BlockNatureAltar extends BlockContainerImpl { @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - return Helper.putStackOnTile(playerIn, hand, pos, 0); + return Helper.putStackOnTile(playerIn, hand, pos, 0, true); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java index cc6ee302..b0899e4c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java @@ -5,9 +5,7 @@ import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; @@ -28,7 +26,7 @@ public class BlockWoodStand extends BlockContainerImpl { @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - return Helper.putStackOnTile(playerIn, hand, pos, 0); + return Helper.putStackOnTile(playerIn, hand, pos, 0, true); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java index fd15aebd..ac018175 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java @@ -14,11 +14,13 @@ import net.minecraft.block.BlockStoneBrick; import net.minecraft.block.BlockStoneBrick.EnumType; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemStackHandler; @@ -192,6 +194,9 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { this.items.setStackInSlot(0, this.currentRecipe.output.copy()); this.currentRecipe = null; this.timer = 0; + + this.world.playSound(null, this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5, + SoundEvents.ENTITY_ARROW_HIT_PLAYER, SoundCategory.BLOCKS, 0.65F, 1F); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java index 1d214885..4c5c3104 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java @@ -9,6 +9,7 @@ import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockLog; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -16,6 +17,7 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; +import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemStackHandler; @@ -100,6 +102,8 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 3)); + this.world.playSound(null, this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5, + SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 0.65F, 1F); this.ritualPos = null; this.involvedStands = null; @@ -109,10 +113,15 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { } else if (this.timer == this.totalTime / 2) { for (BlockPos pos : this.involvedStands.keySet()) { TileEntityWoodStand stand = (TileEntityWoodStand) this.world.getTileEntity(pos); + PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(stand.pos.getX(), stand.pos.getY(), stand.pos.getZ(), 1)); + this.world.playSound(null, stand.pos.getX() + 0.5, stand.pos.getY() + 0.5, stand.pos.getZ() + 0.5, + SoundEvents.BLOCK_WOOD_STEP, SoundCategory.BLOCKS, 0.5F, 1F); + stand.items.setStackInSlot(0, ItemStack.EMPTY); stand.sendToClients(); } + } } else { diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index 66ffa864..2a672a10 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -76,8 +76,8 @@ public class PacketParticles implements IMessage { case 1: // Tree ritual: Consuming item for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) { NaturesAura.proxy.spawnMagicParticle(world, - message.posX + 0.5F, message.posY + 1.25F, message.posZ + 0.5F, - (float) world.rand.nextGaussian() * 0.05F, world.rand.nextFloat() * 0.05F, (float) world.rand.nextGaussian() * 0.05F, + message.posX + 0.5F, message.posY + 0.9F, message.posZ + 0.5F, + (float) world.rand.nextGaussian() * 0.02F, world.rand.nextFloat() * 0.02F, (float) world.rand.nextGaussian() * 0.02F, 0x89cc37, 1.5F, 50, 0F, false, true); } break; diff --git a/src/main/resources/assets/naturesaura/models/item/color_changer.json b/src/main/resources/assets/naturesaura/models/item/color_changer.json index e3ecb252..ad37c86b 100644 --- a/src/main/resources/assets/naturesaura/models/item/color_changer.json +++ b/src/main/resources/assets/naturesaura/models/item/color_changer.json @@ -1,5 +1,5 @@ { - "parent": "item/handheld", + "parent": "item/generated", "textures": { "layer0": "naturesaura:items/color_changer" }, diff --git a/src/main/resources/assets/naturesaura/models/item/color_changer_fill_mode.json b/src/main/resources/assets/naturesaura/models/item/color_changer_fill_mode.json index b5f9ddb3..06c72178 100644 --- a/src/main/resources/assets/naturesaura/models/item/color_changer_fill_mode.json +++ b/src/main/resources/assets/naturesaura/models/item/color_changer_fill_mode.json @@ -1,5 +1,5 @@ { - "parent": "item/handheld", + "parent": "item/generated", "textures": { "layer0": "naturesaura:items/color_changer_fill_mode", "layer1": "naturesaura:items/color_changer_fill_mode_overlay" diff --git a/src/main/resources/assets/naturesaura/models/item/color_changer_filled.json b/src/main/resources/assets/naturesaura/models/item/color_changer_filled.json index 8c74c5b4..daa06d4f 100644 --- a/src/main/resources/assets/naturesaura/models/item/color_changer_filled.json +++ b/src/main/resources/assets/naturesaura/models/item/color_changer_filled.json @@ -1,5 +1,5 @@ { - "parent": "item/handheld", + "parent": "item/generated", "textures": { "layer0": "naturesaura:items/color_changer", "layer1": "naturesaura:items/color_changer_overlay"