This repository has been archived on 2024-06-13. You can view files and clone it, but cannot push or open issues or pull requests.
TrueCraft/TrueCraft.Core/Logic/Blocks/UprightSignBlock.cs
Drew DeVault a361703746 Implement walking sounds
These sounds change depending on what kind of block you're walking in.

Still to come: sound effects for mining and placing blocks
2015-10-05 22:06:59 -04:00

89 lines
2.8 KiB
C#

using System;
using TrueCraft.API.Logic;
using TrueCraft.API;
using TrueCraft.API.World;
using TrueCraft.API.Networking;
using TrueCraft.Core.Logic.Items;
using fNbt;
using TrueCraft.Core.Networking.Packets;
namespace TrueCraft.Core.Logic.Blocks
{
public class UprightSignBlock : BlockProvider
{
public static readonly byte BlockID = 0x3F;
public override byte ID { get { return 0x3F; } }
public override double BlastResistance { get { return 5; } }
public override double Hardness { get { return 1; } }
public override byte Luminance { get { return 0; } }
public override bool Opaque { get { return true; } } // This is weird. You can stack signs on signs in Minecraft.
public override string DisplayName { get { return "Sign"; } }
public override SoundEffectClass SoundEffect
{
get
{
return SoundEffectClass.Wood;
}
}
public override BoundingBox? BoundingBox { get { return null; } }
public override BoundingBox? InteractiveBoundingBox
{
get
{
return new BoundingBox(new Vector3(6 / 16.0, 0, 6 / 16.0), new Vector3(10 / 16.0, 10 / 16.0, 10 / 16.0));
}
}
public override Tuple<int, int> GetTextureMap(byte metadata)
{
return new Tuple<int, int>(4, 0);
}
public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
{
double rotation = user.Entity.Yaw + 180 % 360;
if (rotation < 0)
rotation += 360;
world.SetMetadata(descriptor.Coordinates, (byte)(rotation / 22.5));
}
protected override ItemStack[] GetDrop(BlockDescriptor descriptor, ItemStack item)
{
return new[] { new ItemStack(SignItem.ItemID) };
}
public override void BlockMined(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
{
world.SetTileEntity(descriptor.Coordinates, null);
base.BlockMined(descriptor, face, world, user);
}
public override void TileEntityLoadedForClient(BlockDescriptor descriptor, IWorld world, NbtCompound entity, IRemoteClient client)
{
client.QueuePacket(new UpdateSignPacket
{
X = descriptor.Coordinates.X,
Y = (short)descriptor.Coordinates.Y,
Z = descriptor.Coordinates.Z,
Text = new[]
{
entity["Text1"].StringValue,
entity["Text2"].StringValue,
entity["Text3"].StringValue,
entity["Text4"].StringValue
}
});
}
}
}