Add colour selection for multiple block types.
This commit is contained in:
parent
699a26f630
commit
b3045d38e7
@ -68,6 +68,7 @@ public class Draw extends SoloGame
|
||||
|
||||
//Brush
|
||||
private byte _brushColor = 15;
|
||||
private Material _brushMaterial = Material.WOOL;
|
||||
private Location _brushPrevious = null;
|
||||
|
||||
private boolean _lockDrawer = true;
|
||||
@ -215,8 +216,11 @@ public class Draw extends SoloGame
|
||||
@Override
|
||||
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))
|
||||
{
|
||||
if (b.getType() != Material.AIR)
|
||||
_canvas.add(b);
|
||||
}
|
||||
|
||||
_drawerLocation = WorldData.GetDataLocs("RED").get(0);
|
||||
_textLocation = WorldData.GetDataLocs("YELLOW").get(0);
|
||||
@ -229,10 +233,6 @@ public class Draw extends SoloGame
|
||||
return;
|
||||
|
||||
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
|
||||
@ -373,11 +373,12 @@ public class Draw extends SoloGame
|
||||
drawer.setFlying(true);
|
||||
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.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.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.GOLD_HOE, (byte)0, 1, "Clear Canvas"));
|
||||
@ -589,10 +590,11 @@ public class Draw extends SoloGame
|
||||
if (block == null || !_canvas.contains(block))
|
||||
continue;
|
||||
|
||||
if (block.getData() == _brushColor)
|
||||
if (block.getData() == _brushColor && block.getType() == _brushMaterial)
|
||||
continue;
|
||||
|
||||
//Color
|
||||
block.setType(_brushMaterial);
|
||||
block.setData(_brushColor);
|
||||
|
||||
//Thick Brush
|
||||
@ -603,21 +605,7 @@ public class Draw extends SoloGame
|
||||
if (!_canvas.contains(other))
|
||||
continue;
|
||||
|
||||
other.setData(_brushColor);
|
||||
}
|
||||
}
|
||||
|
||||
//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;
|
||||
|
||||
block.setType(_brushMaterial);
|
||||
other.setData(_brushColor);
|
||||
}
|
||||
}
|
||||
@ -634,6 +622,7 @@ public class Draw extends SoloGame
|
||||
if (!_canvas.contains(fixBlock))
|
||||
continue;
|
||||
|
||||
fixBlock.setType(_brushMaterial);
|
||||
fixBlock.setData(_brushColor);
|
||||
|
||||
//Thick Brush
|
||||
@ -644,21 +633,7 @@ public class Draw extends SoloGame
|
||||
if (!_canvas.contains(other))
|
||||
continue;
|
||||
|
||||
other.setData(_brushColor);
|
||||
}
|
||||
}
|
||||
|
||||
//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.setType(_brushMaterial);
|
||||
other.setData(_brushColor);
|
||||
}
|
||||
}
|
||||
@ -697,6 +672,7 @@ public class Draw extends SoloGame
|
||||
|
||||
//Restore
|
||||
_brushColor = color;
|
||||
_brushMaterial = Material.WOOL;
|
||||
_lockDrawer = false;
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
@ -723,29 +699,34 @@ public class Draw extends SoloGame
|
||||
|
||||
//Fill
|
||||
byte color = block.getData();
|
||||
Material material = block.getType();
|
||||
|
||||
if (color == _brushColor)
|
||||
if (color == _brushColor && material == _brushMaterial)
|
||||
return;
|
||||
|
||||
FillRecurse(block, color);
|
||||
FillRecurse(block, color, material);
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
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)
|
||||
return;
|
||||
|
||||
if (!_canvas.contains(block))
|
||||
return;
|
||||
|
||||
block.setType(_brushMaterial);
|
||||
block.setData(_brushColor);
|
||||
|
||||
for (Block other : UtilBlock.getSurrounding(block, false))
|
||||
{
|
||||
FillRecurse(other, color);
|
||||
FillRecurse(other, color, material);
|
||||
}
|
||||
}
|
||||
|
||||
@ -761,10 +742,15 @@ public class Draw extends SoloGame
|
||||
return;
|
||||
|
||||
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;
|
||||
|
||||
_brushColor = block.getData();
|
||||
_brushMaterial = block.getType();
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1f);
|
||||
}
|
||||
@ -779,6 +765,7 @@ public class Draw extends SoloGame
|
||||
}
|
||||
|
||||
_brushColor = 15;
|
||||
_brushMaterial = Material.WOOL;
|
||||
|
||||
if (_textBlocks != null)
|
||||
{
|
||||
@ -961,8 +948,23 @@ public class Draw extends SoloGame
|
||||
return _brushColor;
|
||||
}
|
||||
|
||||
public Material getBrushMaterial()
|
||||
{
|
||||
return _brushMaterial;
|
||||
}
|
||||
|
||||
public void setLock(boolean b)
|
||||
{
|
||||
_lockDrawer = b;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void sprayCan(UpdateEvent e)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
//if (e.getType() != UpdateType.TICK)
|
||||
//todo spray can BOW PULL BACK
|
||||
}
|
||||
}
|
||||
|
@ -21,13 +21,13 @@ public class KitArtist extends Kit
|
||||
super(manager, "Artist", KitAvailability.Free,
|
||||
new String[]
|
||||
{
|
||||
"Show off your drawing skills!"
|
||||
"The world is but a canvas to our imagination."
|
||||
},
|
||||
new Perk[]
|
||||
{
|
||||
|
||||
},
|
||||
EntityType.ZOMBIE, new ItemStack(Material.STONE_SWORD));
|
||||
EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user