Confirmedusers, editor, Administrators
886
edits
CreativeMD (talk | contribs) No edit summary |
CreativeMD (talk | contribs) |
||
Line 86: | Line 86: | ||
Now we can implement <code>OnBlockBroken</code> rather easily, by taken care of every possible axis the player could face: | Now we can implement <code>OnBlockBroken</code> rather easily, by taken care of every possible axis the player could face: | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
public override | public override bool OnBlockBrokenWith(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, BlockSelection blockSel) | ||
{ | { | ||
base. | if (base.OnBlockBrokenWith(world, byEntity, itemslot, blockSel)) | ||
{ | { | ||
if (byEntity is EntityPlayer) | |||
{ | { | ||
case EnumAxis.X: | IPlayer player = world.PlayerByUid((byEntity as EntityPlayer).PlayerUID); | ||
switch (blockSel.Face.Axis) | |||
{ | |||
case EnumAxis.X: | |||
destroyBlocks(world, blockSel.Position.AddCopy(0, -1, -1), blockSel.Position.AddCopy(0, 1, 1), player); | |||
break; | |||
case EnumAxis.Y: | |||
destroyBlocks(world, blockSel.Position.AddCopy(-1, 0, -1), blockSel.Position.AddCopy(1, 0, 1), player); | |||
break; | |||
case EnumAxis.Z: | |||
destroyBlocks(world, blockSel.Position.AddCopy(-1, -1, 0), blockSel.Position.AddCopy(1, 1, 0), player); | |||
break; | |||
} | |||
} | } | ||
} | return true; | ||
} | |||
return false; | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 152: | Line 156: | ||
} | } | ||
public override | public override bool OnBlockBrokenWith(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, BlockSelection blockSel) | ||
{ | { | ||
base. | if (base.OnBlockBrokenWith(world, byEntity, itemslot, blockSel)) | ||
{ | { | ||
if (byEntity is EntityPlayer) | |||
{ | { | ||
case EnumAxis.X: | IPlayer player = world.PlayerByUid((byEntity as EntityPlayer).PlayerUID); | ||
switch (blockSel.Face.Axis) | |||
{ | |||
case EnumAxis.X: | |||
destroyBlocks(world, blockSel.Position.AddCopy(0, -1, -1), blockSel.Position.AddCopy(0, 1, 1), player); | |||
break; | |||
case EnumAxis.Y: | |||
destroyBlocks(world, blockSel.Position.AddCopy(-1, 0, -1), blockSel.Position.AddCopy(1, 0, 1), player); | |||
break; | |||
case EnumAxis.Z: | |||
destroyBlocks(world, blockSel.Position.AddCopy(-1, -1, 0), blockSel.Position.AddCopy(1, 1, 0), player); | |||
break; | |||
} | |||
} | } | ||
} | return true; | ||
} | |||
return false; | |||
} | } | ||