Skip to content

Commit

Permalink
Item classes, see #147
Browse files Browse the repository at this point in the history
Rename Spade to Shovel
Add tools classes
Remove Player.GetWeaponDamage(), use ItemClass.GetDamage() instead
  • Loading branch information
taugit committed Sep 23, 2012
1 parent 19bcb66 commit e3fd02e
Show file tree
Hide file tree
Showing 47 changed files with 647 additions and 132 deletions.
1 change: 0 additions & 1 deletion Chraft.PluginSystem/Entity/IPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public interface IPlayer : ILivingEntity
void StartSprinting();
void StopSprinting();

short GetWeaponDamage();
void DamageArmor(short damage);

void SynchronizeEntities();
Expand Down
1 change: 1 addition & 0 deletions Chraft.PluginSystem/Item/IItemInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public interface IItemInventory
void DestroyBlock(IStructBlock block);
void DamageItem(IStructBlock block);
void DamageItem(short value);
short GetDamage();
}
}
20 changes: 10 additions & 10 deletions Chraft.Utilities/Blocks/BlockData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ public enum Blocks : byte

public enum Items : short
{
Iron_Spade = 256,
Iron_Shovel = 256,
Iron_Pick = 257,
Iron_Pickaxe = 257,
Iron_Axe = 258,
Expand All @@ -544,19 +544,19 @@ public enum Items : short
Iron_Sword = 267,

Wooden_Sword = 268,
Wooden_Spade = 269,
Wooden_Shovel = 269,
Wooden_Pick = 270,
Wooden_Pickaxe = 270,
Wooden_Axe = 271,

Stone_Sword = 272,
Stone_Spade = 273,
Stone_Shovel = 273,
Stone_Pick = 274,
Stone_Pickaxe = 274,
Stone_Axe = 275,

Diamond_Sword = 276,
Diamond_Spade = 277,
Diamond_Shovel = 277,
Diamond_Pick = 278,
Diamond_Pickaxe = 278,
Diamond_Axe = 279,
Expand All @@ -566,7 +566,7 @@ public enum Items : short
Mushroom_Soup = 282,

Gold_Sword = 283,
Gold_Spade = 284,
Gold_Shovel = 284,
Gold_Pick = 285,
Gold_Pickaxe = 285,
Gold_Axe = 286,
Expand Down Expand Up @@ -711,7 +711,7 @@ public enum Items : short
{Items.Diamond_Hoe, 1562},
{Items.Diamond_Pants, 368},
{Items.Diamond_Pick, 1562},
{Items.Diamond_Spade, 1562},
{Items.Diamond_Shovel, 1562},
{Items.Diamond_Sword, 1562},
{Items.Fishing_Rod, 33},
{Items.Flint_And_Steel, 65},
Expand All @@ -722,7 +722,7 @@ public enum Items : short
{Items.Gold_Hoe, 33},
{Items.Gold_Pants, 92},
{Items.Gold_Pickaxe, 33},
{Items.Gold_Spade, 33},
{Items.Gold_Shovel, 33},
{Items.Gold_Sword, 33},
{Items.Iron_Axe, 251},
{Items.Iron_Boots, 160},
Expand All @@ -731,7 +731,7 @@ public enum Items : short
{Items.Iron_Hoe, 251},
{Items.Iron_Pants, 184},
{Items.Iron_Pick, 251},
{Items.Iron_Spade, 251},
{Items.Iron_Shovel, 251},
{Items.Iron_Sword, 251},
{Items.Leather_Boots, 40},
{Items.Leather_Chestplate, 49},
Expand All @@ -741,12 +741,12 @@ public enum Items : short
{Items.Stone_Axe, 132},
{Items.Stone_Hoe, 132},
{Items.Stone_Pick, 132},
{Items.Stone_Spade, 132},
{Items.Stone_Shovel, 132},
{Items.Stone_Sword, 132},
{Items.Wooden_Axe, 60},
{Items.Wooden_Hoe, 60},
{Items.Wooden_Pick, 60},
{Items.Wooden_Spade, 60},
{Items.Wooden_Shovel, 60},
{Items.Wooden_Sword, 60}
};
}
Expand Down
17 changes: 17 additions & 0 deletions Chraft/Chraft.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,23 @@
<Compile Include="Entity\Items\ItemIronDoor.cs" />
<Compile Include="Entity\Items\ItemWoodenDoor.cs" />
<Compile Include="Entity\Items\ItemShears.cs" />
<Compile Include="Entity\Items\ItemWoodenShovel.cs" />
<Compile Include="Entity\Items\ItemGoldShovel.cs" />
<Compile Include="Entity\Items\ItemWoodenPickaxe.cs" />
<Compile Include="Entity\Items\ItemGoldPickaxe.cs" />
<Compile Include="Entity\Items\ItemStoneShovel.cs" />
<Compile Include="Entity\Items\ItemWoodenAxe.cs" />
<Compile Include="Entity\Items\ItemGoldAxe.cs" />
<Compile Include="Entity\Items\ItemStonePickaxe.cs" />
<Compile Include="Entity\Items\ItemWoodenSword.cs" />
<Compile Include="Entity\Items\ItemDiamondSword.cs" />
<Compile Include="Entity\Items\ItemDiamondAxe.cs" />
<Compile Include="Entity\Items\ItemIronSword.cs" />
<Compile Include="Entity\Items\ItemGoldSword.cs" />
<Compile Include="Entity\Items\ItemStoneAxe.cs" />
<Compile Include="Entity\Items\ItemDiamondShovel.cs" />
<Compile Include="Entity\Items\ItemStoneSword.cs" />
<Compile Include="Entity\Items\ItemIronAxe.cs" />
<Compile Include="Entity\Monster.cs" />
<Compile Include="Interfaces\Containers\ContainerFactory.cs" />
<Compile Include="Interfaces\Containers\DispenserContainer.cs" />
Expand Down
5 changes: 5 additions & 0 deletions Chraft/Entity/Items/Base/ItemInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public abstract class ItemInventory : ItemBase, IItemInventory
return false;
}*/

public ItemInventory()
{
Damage = 1;
}

internal override void Write(Net.BigEndianStream stream)
{
base.Write(stream);
Expand Down
5 changes: 2 additions & 3 deletions Chraft/Entity/Items/Base/ItemPlaceable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ protected virtual bool CanBePlacedOn(IStructBlock baseBlock, BlockFace face)

protected virtual byte GetBlockToPlace(IStructBlock baseBlock, BlockFace face)
{
var player = Owner.GetPlayer() as Player;
return (byte)player.Inventory.ActiveItem.Type;
return (byte)Type;
}

public virtual void Place(IStructBlock baseBlock, BlockFace face)
Expand All @@ -53,7 +52,7 @@ public virtual void Place(IStructBlock baseBlock, BlockFace face)

var player = Owner.GetPlayer() as Player;
byte bType = GetBlockToPlace(baseBlock, face);
byte bMetaData = (byte)player.Inventory.ActiveItem.Durability;
byte bMetaData = (byte)Durability;

var coordsFromFace = UniversalCoords.FromFace(baseBlock.Coords, face);
var bBlock = new StructBlock(coordsFromFace, bType, bMetaData, player.World);
Expand Down
5 changes: 1 addition & 4 deletions Chraft/Entity/Items/ItemChest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ public ItemChest()
{
Type = (short)BlockData.Blocks.Chest;
Name = "Chest";
Durability = 0;
Damage = 1;
Count = 1;
IsStackable = false;
IsStackable = true;
MaxStackSize = 64;
}
}
Expand Down
5 changes: 1 addition & 4 deletions Chraft/Entity/Items/ItemCobblestone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ public ItemCobblestone()
{
Type = (short)BlockData.Blocks.Cobblestone;
Name = "CobbleStone";
Durability = 0;
Damage = 1;
Count = 1;
IsStackable = false;
IsStackable = true;
MaxStackSize = 64;
}
}
Expand Down
35 changes: 35 additions & 0 deletions Chraft/Entity/Items/ItemDiamondAxe.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#region C#raft License
// This file is part of C#raft. Copyright C#raft Team
//
// C#raft is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion

using Chraft.Entity.Items.Base;
using Chraft.Utilities.Blocks;

namespace Chraft.Entity.Items
{
class ItemDiamondAxe : ItemInventory
{
public ItemDiamondAxe()
{
Type = (short)BlockData.Items.Diamond_Axe;
Name = "DiamondAxe";
Durability = 1562;
Damage = 6;
IsStackable = false;
MaxStackSize = 1;
}
}
}
3 changes: 1 addition & 2 deletions Chraft/Entity/Items/ItemDiamondPickaxe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public ItemDiamondPickaxe()
Type = (short)BlockData.Items.Diamond_Pickaxe;
Name = "DiamondPickaxe";
Durability = 1562;
Damage = 1;
Count = 1;
Damage = 5;
IsStackable = false;
MaxStackSize = 1;
}
Expand Down
35 changes: 35 additions & 0 deletions Chraft/Entity/Items/ItemDiamondShovel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#region C#raft License
// This file is part of C#raft. Copyright C#raft Team
//
// C#raft is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion

using Chraft.Entity.Items.Base;
using Chraft.Utilities.Blocks;

namespace Chraft.Entity.Items
{
class ItemDiamondShovel : ItemInventory
{
public ItemDiamondShovel()
{
Type = (short)BlockData.Items.Diamond_Shovel;
Name = "DiamondShovel";
Durability = 1562;
Damage = 4;
IsStackable = false;
MaxStackSize = 1;
}
}
}
35 changes: 35 additions & 0 deletions Chraft/Entity/Items/ItemDiamondSword.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#region C#raft License
// This file is part of C#raft. Copyright C#raft Team
//
// C#raft is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion

using Chraft.Entity.Items.Base;
using Chraft.Utilities.Blocks;

namespace Chraft.Entity.Items
{
class ItemDiamondSword : ItemInventory
{
public ItemDiamondSword()
{
Type = (short)BlockData.Items.Diamond_Sword;
Name = "DiamondSword";
Durability = 1562;
Damage = 7;
IsStackable = false;
MaxStackSize = 1;
}
}
}
3 changes: 0 additions & 3 deletions Chraft/Entity/Items/ItemDirt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public ItemDirt()
{
Type = (short)BlockData.Blocks.Dirt;
Name = "Dirt";
Durability = 0;
Damage = 1;
Count = 1;
IsStackable = true;
MaxStackSize = 64;
}
Expand Down
35 changes: 35 additions & 0 deletions Chraft/Entity/Items/ItemGoldAxe.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#region C#raft License
// This file is part of C#raft. Copyright C#raft Team
//
// C#raft is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion

using Chraft.Entity.Items.Base;
using Chraft.Utilities.Blocks;

namespace Chraft.Entity.Items
{
class ItemGoldAxe : ItemInventory
{
public ItemGoldAxe()
{
Type = (short)BlockData.Items.Gold_Axe;
Name = "GoldAxe";
Durability = 33;
Damage = 3;
IsStackable = false;
MaxStackSize = 1;
}
}
}
35 changes: 35 additions & 0 deletions Chraft/Entity/Items/ItemGoldPickaxe.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#region C#raft License
// This file is part of C#raft. Copyright C#raft Team
//
// C#raft is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion

using Chraft.Entity.Items.Base;
using Chraft.Utilities.Blocks;

namespace Chraft.Entity.Items
{
class ItemGoldPickaxe : ItemInventory
{
public ItemGoldPickaxe()
{
Type = (short)BlockData.Items.Gold_Pickaxe;
Name = "GoldPickaxe";
Durability = 33;
Damage = 2;
IsStackable = false;
MaxStackSize = 1;
}
}
}
Loading

0 comments on commit e3fd02e

Please sign in to comment.