Add colour selection for multiple block types.

This commit is contained in:
William Burns 2016-02-10 16:34:00 +00:00
parent 699a26f630
commit b3045d38e7
2 changed files with 62 additions and 60 deletions

View File

@ -68,6 +68,7 @@ public class Draw extends SoloGame
//Brush //Brush
private byte _brushColor = 15; private byte _brushColor = 15;
private Material _brushMaterial = Material.WOOL;
private Location _brushPrevious = null; private Location _brushPrevious = null;
private boolean _lockDrawer = true; private boolean _lockDrawer = true;
@ -215,8 +216,11 @@ public class Draw extends SoloGame
@Override @Override
public void ParseData() public void ParseData()
{ {
for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("LIME").get(0), WorldData.GetDataLocs("LIME").get(1), false)) for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("PINK").get(0), WorldData.GetDataLocs("PINK").get(1), false))
_canvas.add(b); {
if (b.getType() != Material.AIR)
_canvas.add(b);
}
_drawerLocation = WorldData.GetDataLocs("RED").get(0); _drawerLocation = WorldData.GetDataLocs("RED").get(0);
_textLocation = WorldData.GetDataLocs("YELLOW").get(0); _textLocation = WorldData.GetDataLocs("YELLOW").get(0);
@ -229,10 +233,6 @@ public class Draw extends SoloGame
return; return;
Reset(); Reset();
for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("PINK").get(0), WorldData.GetDataLocs("PINK").get(1), false))
if (b.getType().equals(Material.WOOL) && b.getData() == DyeColor.WHITE.getWoolData())
b.setType(Material.AIR);
} }
@EventHandler @EventHandler
@ -373,11 +373,12 @@ public class Draw extends SoloGame
drawer.setFlying(true); drawer.setFlying(true);
drawer.setFlySpeed(0.4f); drawer.setFlySpeed(0.4f);
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte) 0, 1, "Pencil"));
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte) 0, 1, "Paint Brush")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte) 0, 1, "Paint Brush"));
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD, (byte) 0, 1, "Line Tool")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD, (byte) 0, 1, "Line Tool"));
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "Square Tool")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "Square Tool"));
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, "Circle Tool")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, "Circle Tool"));
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte)0, 1, "Spray Can")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, "Spray Can"));
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_HOE, (byte)0, 1, "Paint Bucket")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_HOE, (byte)0, 1, "Paint Bucket"));
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_HOE, (byte)0, 1, "Clear Canvas")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_HOE, (byte)0, 1, "Clear Canvas"));
@ -589,10 +590,11 @@ public class Draw extends SoloGame
if (block == null || !_canvas.contains(block)) if (block == null || !_canvas.contains(block))
continue; continue;
if (block.getData() == _brushColor) if (block.getData() == _brushColor && block.getType() == _brushMaterial)
continue; continue;
//Color //Color
block.setType(_brushMaterial);
block.setData(_brushColor); block.setData(_brushColor);
//Thick Brush //Thick Brush
@ -603,21 +605,7 @@ public class Draw extends SoloGame
if (!_canvas.contains(other)) if (!_canvas.contains(other))
continue; continue;
other.setData(_brushColor); block.setType(_brushMaterial);
}
}
//Spray Can
if (UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD))
{
for (Block other : UtilBlock.getSurrounding(block, false))
{
if (!_canvas.contains(other))
continue;
if (Math.random() > 0.75)
continue;
other.setData(_brushColor); other.setData(_brushColor);
} }
} }
@ -634,6 +622,7 @@ public class Draw extends SoloGame
if (!_canvas.contains(fixBlock)) if (!_canvas.contains(fixBlock))
continue; continue;
fixBlock.setType(_brushMaterial);
fixBlock.setData(_brushColor); fixBlock.setData(_brushColor);
//Thick Brush //Thick Brush
@ -644,21 +633,7 @@ public class Draw extends SoloGame
if (!_canvas.contains(other)) if (!_canvas.contains(other))
continue; continue;
other.setData(_brushColor); other.setType(_brushMaterial);
}
}
//Spray Can
if (UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD))
{
for (Block other : UtilBlock.getSurrounding(fixBlock, false))
{
if (!_canvas.contains(other))
continue;
if (Math.random() > 0.75)
continue;
other.setData(_brushColor); other.setData(_brushColor);
} }
} }
@ -697,6 +672,7 @@ public class Draw extends SoloGame
//Restore //Restore
_brushColor = color; _brushColor = color;
_brushMaterial = Material.WOOL;
_lockDrawer = false; _lockDrawer = false;
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
@ -723,29 +699,34 @@ public class Draw extends SoloGame
//Fill //Fill
byte color = block.getData(); byte color = block.getData();
Material material = block.getType();
if (color == _brushColor) if (color == _brushColor && material == _brushMaterial)
return; return;
FillRecurse(block, color); FillRecurse(block, color, material);
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
other.playSound(other.getLocation(), Sound.SPLASH, 0.4f, 1.5f); other.playSound(other.getLocation(), Sound.SPLASH, 0.4f, 1.5f);
} }
public void FillRecurse(Block block, byte color) public void FillRecurse(Block block, byte color, Material material)
{ {
if (block.getType() != material)
return;
if (block.getData() != color) if (block.getData() != color)
return; return;
if (!_canvas.contains(block)) if (!_canvas.contains(block))
return; return;
block.setType(_brushMaterial);
block.setData(_brushColor); block.setData(_brushColor);
for (Block other : UtilBlock.getSurrounding(block, false)) for (Block other : UtilBlock.getSurrounding(block, false))
{ {
FillRecurse(other, color); FillRecurse(other, color, material);
} }
} }
@ -761,10 +742,15 @@ public class Draw extends SoloGame
return; return;
Block block = player.getTargetBlock((HashSet<Byte>) null, 200); Block block = player.getTargetBlock((HashSet<Byte>) null, 200);
if (block == null || block.getType() != Material.WOOL || _canvas.contains(block))
List<Block> possibleBlocks = UtilBlock.getInBoundingBox(WorldData.GetDataLocs("GREEN").get(0),
WorldData.GetDataLocs("GREEN").get(1));
if (block == null || !possibleBlocks.contains(block))
return; return;
_brushColor = block.getData(); _brushColor = block.getData();
_brushMaterial = block.getType();
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1f); player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1f);
} }
@ -779,6 +765,7 @@ public class Draw extends SoloGame
} }
_brushColor = 15; _brushColor = 15;
_brushMaterial = Material.WOOL;
if (_textBlocks != null) if (_textBlocks != null)
{ {
@ -961,8 +948,23 @@ public class Draw extends SoloGame
return _brushColor; return _brushColor;
} }
public Material getBrushMaterial()
{
return _brushMaterial;
}
public void setLock(boolean b) public void setLock(boolean b)
{ {
_lockDrawer = b; _lockDrawer = b;
} }
@EventHandler
public void sprayCan(UpdateEvent e)
{
if (!IsLive())
return;
//if (e.getType() != UpdateType.TICK)
//todo spray can BOW PULL BACK
}
} }

View File

@ -21,13 +21,13 @@ public class KitArtist extends Kit
super(manager, "Artist", KitAvailability.Free, super(manager, "Artist", KitAvailability.Free,
new String[] new String[]
{ {
"Show off your drawing skills!" "The world is but a canvas to our imagination."
}, },
new Perk[] new Perk[]
{ {
}, },
EntityType.ZOMBIE, new ItemStack(Material.STONE_SWORD)); EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD));
} }
@Override @Override