Implement cake logic

This commit is contained in:
Drew DeVault 2015-04-15 19:21:55 -06:00
parent 65deecd131
commit 06a928edbf
3 changed files with 28 additions and 0 deletions

View File

@ -2,6 +2,8 @@ using System;
using TrueCraft.API; using TrueCraft.API;
using TrueCraft.API.Logic; using TrueCraft.API.Logic;
using TrueCraft.Core.Logic.Items; using TrueCraft.Core.Logic.Items;
using TrueCraft.API.World;
using TrueCraft.API.Networking;
namespace TrueCraft.Core.Logic.Blocks namespace TrueCraft.Core.Logic.Blocks
{ {
@ -60,5 +62,14 @@ namespace TrueCraft.Core.Logic.Blocks
{ {
get { return false; } get { return false; }
} }
public override bool BlockRightClicked(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
{
if (descriptor.Metadata == 5)
world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);
else
world.SetMetadata(descriptor.Coordinates, (byte)(descriptor.Metadata + 1));
return false;
}
} }
} }

View File

@ -1,6 +1,9 @@
using System; using System;
using TrueCraft.API.Logic; using TrueCraft.API.Logic;
using TrueCraft.API; using TrueCraft.API;
using TrueCraft.API.World;
using TrueCraft.API.Networking;
using TrueCraft.Core.Logic.Blocks;
namespace TrueCraft.Core.Logic.Items namespace TrueCraft.Core.Logic.Items
{ {
@ -43,5 +46,17 @@ namespace TrueCraft.Core.Logic.Items
return false; return false;
} }
} }
public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
coordinates += MathHelper.BlockFaceToCoordinates(face);
var old = world.BlockRepository.GetBlockProvider(world.GetBlockID(coordinates));
if (old.Hardness == 0)
{
world.SetBlockID(coordinates, CakeBlock.BlockID);
item.Count--;
user.Inventory[user.SelectedSlot] = item;
}
}
} }
} }

View File

@ -139,6 +139,7 @@ namespace TrueCraft.Handlers
client.ItemStaging = held; client.ItemStaging = held;
window[packet.SlotIndex] = ItemStack.EmptyStack; window[packet.SlotIndex] = ItemStack.EmptyStack;
} }
client.QueuePacket(new WindowItemsPacket(packet.WindowID, window.GetSlots()));
return; return;
} }
if (client.ItemStaging.Empty) // Picking up something if (client.ItemStaging.Empty) // Picking up something
@ -209,6 +210,7 @@ namespace TrueCraft.Handlers
} }
} }
} }
client.QueuePacket(new WindowItemsPacket(packet.WindowID, window.GetSlots()));
} }
public static void HandleCloseWindowPacket(IPacket _packet, IRemoteClient _client, IMultiplayerServer server) public static void HandleCloseWindowPacket(IPacket _packet, IRemoteClient _client, IMultiplayerServer server)