This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
Added some Blocks+Block functionality #223
Open
SonOfTheStars
wants to merge
1
commit into
ddevault:master
Choose a base branch
from
SonOfTheStars:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,10 @@ public abstract class Block : Item | |
private static Dictionary<short, IsSolidOnFaceHandler> IsSolidOnFaceHandlers { get; set; } | ||
private static Dictionary<short, BlockMinedHandler> BlockMinedHandlers { get; set; } | ||
private static Dictionary<short, BlockRightClickedHandler> BlockRightClickedHandlers { get; set; } | ||
//HarvestLevesl: 0=Hand, 1=Wooden Tool, 2= Stone Tool, 3= Iron Tool, 4= Diamond Tool | ||
private int ToolQuality = 0; | ||
//Item Damagevalue, used for blocks to determine subtypes | ||
private int MetaData = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Metadata" is better than "MetaData". |
||
|
||
static Block() | ||
{ | ||
|
@@ -73,7 +77,27 @@ protected void SetPlacementSoundEffect(string soundEffect) | |
{ | ||
BlockPlacementSoundEffects[BlockId] = soundEffect; | ||
} | ||
|
||
|
||
protected void SetToolQuality(int level) | ||
{ | ||
ToolQuality = level; | ||
} | ||
|
||
public int GetToolQuality() | ||
{ | ||
return ToolQuality; | ||
} | ||
|
||
protected void SetMetaData(int meta) | ||
{ | ||
MetaData = meta; | ||
} | ||
|
||
public int GetMetaData() | ||
{ | ||
return MetaData; | ||
} | ||
|
||
protected void SetBoundingBoxHandler(BoundingBoxHandler handler) | ||
{ | ||
BoundingBoxHandlers[BlockId] = handler; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Craft.Net.Common; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Craft.Net.Logic.Blocks | ||
{ | ||
public class BlockCobble : Block | ||
{ | ||
public static readonly short ID = 4; | ||
public override short BlockId { get {return ID;}} | ||
|
||
public BlockCobble() | ||
: base("minecraft:cobblestone", hardness: 0.8) | ||
{ | ||
base.SetToolQuality(1); | ||
base.SetPlacementSoundEffect(SoundEffect.DigStone); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Craft.Net.Logic; | ||
using Craft.Net.Common; | ||
|
||
namespace Craft.Net.Logic.Blocks | ||
{ | ||
public class BlockStone : Block | ||
{ | ||
public static readonly short ID = 1; | ||
public override short BlockId { get { return ID; } } | ||
|
||
public BlockStone() : base("minecraft:stone", hardness : 1.0) | ||
{ | ||
base.SetToolQuality(1); | ||
base.SetPlacementSoundEffect(SoundEffect.DigStone); | ||
base.SetDropHandler((world, coordinates, info) => new[] { new ItemStack(BlockCobble.ID) }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ public class DecorativeGrassBlock : Block | |
|
||
public DecorativeGrassBlock() : base("minecraft:tallgrass") | ||
{ | ||
base.SetToolQuality(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A good default value is better than explicitly mentioning it for every block. |
||
base.SetBoundingBoxHandler(BoundingBox); | ||
//TODO: Once items are implemented, we need to drop seeds here | ||
//SetDropHandler(Id, (world, coordinates, info) => new[] { new ItemStack(ItemSeeds.Id) }); | ||
|
@@ -28,6 +29,7 @@ public class TallGrassBlock : Block | |
|
||
public TallGrassBlock() : base("minecraft:tallgrass") | ||
{ | ||
base.SetToolQuality(0); | ||
base.SetBoundingBoxHandler(BoundingBox); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use an enum please.