Fix tools for block type/colour selections.
This commit is contained in:
parent
b3045d38e7
commit
790ed4f993
|
@ -958,13 +958,10 @@ public class Draw extends SoloGame
|
|||
_lockDrawer = b;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void sprayCan(UpdateEvent e)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
//if (e.getType() != UpdateType.TICK)
|
||||
//todo spray can BOW PULL BACK
|
||||
}
|
||||
//fdmsdmfsdfpmsd
|
||||
/**
|
||||
* TODO:
|
||||
* - Spray Can
|
||||
* - Undo/Redo
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -18,6 +18,28 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||
|
||||
public abstract class Tool
|
||||
{
|
||||
public class BlockInfo
|
||||
{
|
||||
private Material _type;
|
||||
private byte _data;
|
||||
|
||||
public BlockInfo(Material type, byte data)
|
||||
{
|
||||
_type = type;
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public Material getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public byte getData()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
}
|
||||
|
||||
protected Draw Host;
|
||||
|
||||
protected Player _drawer;
|
||||
|
@ -25,8 +47,8 @@ public abstract class Tool
|
|||
|
||||
protected Material _material;
|
||||
|
||||
protected HashMap<Block, Byte> _past = new HashMap<Block, Byte>();
|
||||
protected HashMap<Block, Byte> _new = new HashMap<Block, Byte>();
|
||||
protected HashMap<Block, BlockInfo> _past = new HashMap<Block, BlockInfo>();
|
||||
protected HashMap<Block, BlockInfo> _new = new HashMap<Block, BlockInfo>();
|
||||
|
||||
public Tool(Draw host, Material mat)
|
||||
{
|
||||
|
@ -68,7 +90,7 @@ public abstract class Tool
|
|||
return;
|
||||
}
|
||||
|
||||
_new = new HashMap<Block, Byte>();
|
||||
_new = new HashMap<Block, BlockInfo>();
|
||||
|
||||
//Calculate New
|
||||
Block end = _drawer.getTargetBlock((HashSet<Byte>) null, 64);
|
||||
|
@ -81,7 +103,10 @@ public abstract class Tool
|
|||
for (Block block : _past.keySet())
|
||||
{
|
||||
if (!_new.containsKey(block))
|
||||
block.setData(_past.get(block));
|
||||
{
|
||||
block.setType(_past.get(block).getType());
|
||||
block.setData(_past.get(block).getData());
|
||||
}
|
||||
}
|
||||
|
||||
_past = _new;
|
||||
|
|
|
@ -48,10 +48,15 @@ public class ToolCircle extends Tool
|
|||
return;
|
||||
|
||||
byte color = block.getData();
|
||||
Material type = block.getType();
|
||||
if (_past.containsKey(block))
|
||||
color = _past.get(block);
|
||||
{
|
||||
type = _past.get(block).getType();
|
||||
color = _past.get(block).getData();
|
||||
}
|
||||
|
||||
_new.put(block, color);
|
||||
_new.put(block, new BlockInfo(type, color));
|
||||
block.setData(Host.getColor());
|
||||
block.setType(Host.getBrushMaterial());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,10 +32,15 @@ public class ToolLine extends Tool
|
|||
continue;
|
||||
|
||||
byte color = lineBlock.getData();
|
||||
Material type = lineBlock.getType();
|
||||
if (_past.containsKey(lineBlock))
|
||||
color = _past.get(lineBlock);
|
||||
{
|
||||
type = _past.get(lineBlock).getType();
|
||||
color = _past.get(lineBlock).getData();
|
||||
}
|
||||
|
||||
_new.put(lineBlock, color);
|
||||
_new.put(lineBlock, new BlockInfo(type, color));
|
||||
lineBlock.setType(Host.getBrushMaterial());
|
||||
lineBlock.setData(Host.getColor());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,12 +71,16 @@ public class ToolSquare extends Tool
|
|||
|
||||
if (!Host.getCanvas().contains(block))
|
||||
return;
|
||||
|
||||
|
||||
Material type = block.getType();
|
||||
byte color = block.getData();
|
||||
if (_past.containsKey(block))
|
||||
color = _past.get(block);
|
||||
{
|
||||
type = _past.get(block).getType();
|
||||
color = _past.get(block).getData();
|
||||
}
|
||||
|
||||
_new.put(block, color);
|
||||
_new.put(block, new BlockInfo(type, color));
|
||||
block.setData(Host.getColor());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue