Allow water to destroy blocks with no hardness

This commit is contained in:
Drew DeVault 2015-02-09 23:01:41 -07:00
parent e9b133a7f8
commit d8c2d4c4ce
5 changed files with 29 additions and 7 deletions

View File

@ -16,6 +16,7 @@ namespace TrueCraft.API.Logic
string DisplayName { get; } string DisplayName { get; }
BoundingBox? BoundingBox { get; } // NOTE: Will this eventually need to be metadata-aware? BoundingBox? BoundingBox { get; } // NOTE: Will this eventually need to be metadata-aware?
Tuple<int, int> GetTextureMap(byte metadata); Tuple<int, int> GetTextureMap(byte metadata);
void GenerateDropEntity(BlockDescriptor descriptor, IWorld world, IMultiplayerServer server);
bool BlockRightClicked(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user); bool BlockRightClicked(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user);
void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user); void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user);
void BlockMined(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user); void BlockMined(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user);

View File

@ -30,7 +30,7 @@ namespace TrueCraft.Core.Logic
world.SetBlockID(descriptor.Coordinates, 0); world.SetBlockID(descriptor.Coordinates, 0);
} }
protected void GenerateDropEntity(BlockDescriptor descriptor, IWorld world, IMultiplayerServer server) public void GenerateDropEntity(BlockDescriptor descriptor, IWorld world, IMultiplayerServer server)
{ {
var entityManager = server.GetEntityManagerForWorld(world); var entityManager = server.GetEntityManagerForWorld(world);
var items = GetDrop(descriptor); var items = GetDrop(descriptor);

View File

@ -1,4 +1,6 @@
using System; using System;
using TrueCraft.API;
using TrueCraft.API.Logic;
namespace TrueCraft.Core.Logic.Blocks namespace TrueCraft.Core.Logic.Blocks
{ {
@ -22,5 +24,10 @@ namespace TrueCraft.Core.Logic.Blocks
{ {
return new Tuple<int, int>(0, 0); return new Tuple<int, int>(0, 0);
} }
protected override ItemStack[] GetDrop(BlockDescriptor descriptor)
{
return new ItemStack[0];
}
} }
} }

View File

@ -1,5 +1,6 @@
using System; using System;
using TrueCraft.API.Logic; using TrueCraft.API.Logic;
using TrueCraft.API;
namespace TrueCraft.Core.Logic.Blocks namespace TrueCraft.Core.Logic.Blocks
{ {
@ -23,5 +24,10 @@ namespace TrueCraft.Core.Logic.Blocks
{ {
return new Tuple<int, int>(1, 3); return new Tuple<int, int>(1, 3);
} }
protected override ItemStack[] GetDrop(BlockDescriptor descriptor)
{
return new ItemStack[0];
}
} }
} }

View File

@ -193,8 +193,8 @@ namespace TrueCraft.Core.Logic.Blocks
if (Math.Abs(z) + Math.Abs(x) > maxDistance) if (Math.Abs(z) + Math.Abs(x) > maxDistance)
continue; continue;
var check = new Coordinates3D(x, -1, z); var check = new Coordinates3D(x, -1, z);
var c = world.GetBlockID(check + coords); var c = world.BlockRepository.GetBlockProvider(world.GetBlockID(check + coords));
if (c == 0 || c == WaterBlock.BlockID || c == StationaryWaterBlock.BlockID) if (!c.Opaque)
{ {
if (!LineOfSight(world, check + coords, coords)) if (!LineOfSight(world, check + coords, coords))
continue; continue;
@ -220,18 +220,26 @@ namespace TrueCraft.Core.Logic.Blocks
{ {
var location = extraLocations[i]; var location = extraLocations[i];
location.Clamp(1); location.Clamp(1);
var xPotential = world.GetBlockID(new Coordinates3D(location.X, 0, 0) + coords); var xPotential = world.BlockRepository.GetBlockProvider(world.GetBlockID(new Coordinates3D(location.X, 0, 0) + coords));
if (xPotential == 0) if (xPotential.Hardness == 0 && xPotential.ID != WaterBlock.BlockID && xPotential.ID != StationaryWaterBlock.BlockID)
{ {
if (PlaceWater(server, new Coordinates3D(location.X, 0, 0) + coords, world, (byte)(meta + 1))) if (PlaceWater(server, new Coordinates3D(location.X, 0, 0) + coords, world, (byte)(meta + 1)))
{
spread = true; spread = true;
xPotential.GenerateDropEntity(new BlockDescriptor
{ Coordinates = new Coordinates3D(location.X, 0, 0) + coords, ID = xPotential.ID }, world, server);
}
} }
var zPotential = world.GetBlockID(new Coordinates3D(0, 0, location.Z) + coords); var zPotential = world.BlockRepository.GetBlockProvider(world.GetBlockID(new Coordinates3D(0, 0, location.Z) + coords));
if (zPotential == 0) if (zPotential.Hardness == 0 && zPotential.ID != WaterBlock.BlockID && zPotential.ID != StationaryWaterBlock.BlockID)
{ {
if (PlaceWater(server, new Coordinates3D(0, 0, location.Z) + coords, world, (byte)(meta + 1))) if (PlaceWater(server, new Coordinates3D(0, 0, location.Z) + coords, world, (byte)(meta + 1)))
{
spread = true; spread = true;
zPotential.GenerateDropEntity(new BlockDescriptor
{ Coordinates = new Coordinates3D(0, 0, location.Z) + coords, ID = zPotential.ID }, world, server);
}
} }
} }
if (!spread) if (!spread)