Implement special cases for block drops
This does not include things that require certain tools, such as cobblestone.
This commit is contained in:
parent
12dea4d037
commit
e3051a673c
@ -39,7 +39,7 @@ SharpDevelop or something equally idiot-proof.
|
||||
## Get Involved
|
||||
|
||||
If you want to keep up with development or contribute, join #truecraft on
|
||||
irc.esper.net. Pull request will be rejected from authors who have read any
|
||||
irc.esper.net. Pull requests will be rejected from authors who have read any
|
||||
decompiled official Minecraft code.
|
||||
|
||||
## Roadmap
|
||||
|
@ -12,6 +12,8 @@ namespace TrueCraft.API.Entities
|
||||
Vector3 Position { get; set; }
|
||||
float Yaw { get; set; }
|
||||
float Pitch { get; set; }
|
||||
bool Despawned { get; set; }
|
||||
DateTime SpawnTime { get; set; }
|
||||
MetadataDictionary Metadata { get; }
|
||||
Size Size { get; }
|
||||
bool SendMetadataToClients { get; }
|
||||
|
@ -19,7 +19,7 @@ namespace TrueCraft.Core.Entities
|
||||
SpawnTime = DateTime.Now;
|
||||
}
|
||||
|
||||
protected DateTime SpawnTime { get; set; }
|
||||
public DateTime SpawnTime { get; set; }
|
||||
|
||||
public int EntityID { get; set; }
|
||||
|
||||
@ -67,6 +67,8 @@ namespace TrueCraft.Core.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public bool Despawned { get; set; }
|
||||
|
||||
public abstract Size Size { get; }
|
||||
|
||||
public abstract IPacket SpawnPacket { get; }
|
||||
|
@ -19,13 +19,10 @@ namespace TrueCraft.Core.Entities
|
||||
{
|
||||
Position = position;
|
||||
Item = item;
|
||||
SpawnTime = DateTime.Now;
|
||||
}
|
||||
|
||||
public ItemStack Item { get; set; }
|
||||
|
||||
private DateTime SpawnTime { get; set; }
|
||||
|
||||
public override IPacket SpawnPacket
|
||||
{
|
||||
get
|
||||
@ -109,6 +106,7 @@ namespace TrueCraft.Core.Entities
|
||||
playerEntity.OnPickUpItem(this);
|
||||
entityManager.DespawnEntity(this);
|
||||
}
|
||||
/* TODO: Merging item entities (this code behaves strangely
|
||||
var item = nearbyEntities.FirstOrDefault(e => e is ItemEntity
|
||||
&& e != this
|
||||
&& (DateTime.Now - (e as ItemEntity).SpawnTime).TotalSeconds > 1
|
||||
@ -123,7 +121,7 @@ namespace TrueCraft.Core.Entities
|
||||
newItem.Count += (item as ItemEntity).Item.Count;
|
||||
Item = newItem;
|
||||
OnPropertyChanged("Metadata");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,11 @@ namespace TrueCraft.Core.Logic
|
||||
public virtual void BlockMined(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
|
||||
{
|
||||
var entityManager = user.Server.GetEntityManagerForWorld(world);
|
||||
entityManager.SpawnEntity(new ItemEntity(new Vector3(descriptor.Coordinates) + new Vector3(0.5),
|
||||
new ItemStack(descriptor.ID, 1, descriptor.Metadata)));
|
||||
var items = GetDrop(descriptor);
|
||||
foreach (var item in items)
|
||||
{
|
||||
entityManager.SpawnEntity(new ItemEntity(new Vector3(descriptor.Coordinates) + new Vector3(0.5), item));
|
||||
}
|
||||
world.SetBlockID(descriptor.Coordinates, 0);
|
||||
}
|
||||
|
||||
@ -40,6 +43,11 @@ namespace TrueCraft.Core.Logic
|
||||
// This space intentionally left blank
|
||||
}
|
||||
|
||||
protected virtual ItemStack[] GetDrop(BlockDescriptor descriptor) // TODO: Include tools
|
||||
{
|
||||
return new[] { new ItemStack(descriptor.ID, 1, descriptor.Metadata) };
|
||||
}
|
||||
|
||||
short IItemProvider.ID
|
||||
{
|
||||
get
|
||||
|
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using TrueCraft.API.Logic;
|
||||
using TrueCraft.API;
|
||||
using TrueCraft.API.World;
|
||||
|
||||
namespace TrueCraft.Core.Logic.Blocks
|
||||
{
|
||||
@ -23,5 +25,10 @@ namespace TrueCraft.Core.Logic.Blocks
|
||||
{
|
||||
return new Tuple<int, int>(3, 0);
|
||||
}
|
||||
|
||||
protected override ItemStack[] GetDrop(BlockDescriptor descriptor)
|
||||
{
|
||||
return new[] { new ItemStack(DirtBlock.BlockID, 1) };
|
||||
}
|
||||
}
|
||||
}
|
@ -145,7 +145,7 @@ namespace TrueCraft
|
||||
|
||||
public void SpawnEntity(IEntity entity)
|
||||
{
|
||||
|
||||
entity.SpawnTime = DateTime.Now;
|
||||
entity.EntityID = NextEntityID++;
|
||||
entity.PropertyChanged -= HandlePropertyChanged;
|
||||
entity.PropertyChanged += HandlePropertyChanged;
|
||||
@ -168,6 +168,7 @@ namespace TrueCraft
|
||||
public void DespawnEntity(IEntity entity)
|
||||
{
|
||||
PendingDespawns.Add(entity);
|
||||
entity.Despawned = true;
|
||||
}
|
||||
|
||||
public IEntity GetEntityByID(int id)
|
||||
@ -184,6 +185,7 @@ namespace TrueCraft
|
||||
{
|
||||
foreach (var e in Entities)
|
||||
{
|
||||
if (!e.Despawned)
|
||||
e.Update(this);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user