Fix tools for block type/colour selections.

This commit is contained in:
William Burns 2016-02-11 08:11:40 +00:00
parent b3045d38e7
commit 790ed4f993
5 changed files with 56 additions and 20 deletions

View File

@ -958,13 +958,10 @@ public class Draw extends SoloGame
_lockDrawer = b; _lockDrawer = b;
} }
@EventHandler //fdmsdmfsdfpmsd
public void sprayCan(UpdateEvent e) /**
{ * TODO:
if (!IsLive()) * - Spray Can
return; * - Undo/Redo
*/
//if (e.getType() != UpdateType.TICK)
//todo spray can BOW PULL BACK
}
} }

View File

@ -18,6 +18,28 @@ import org.bukkit.event.player.PlayerInteractEvent;
public abstract class Tool 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 Draw Host;
protected Player _drawer; protected Player _drawer;
@ -25,8 +47,8 @@ public abstract class Tool
protected Material _material; protected Material _material;
protected HashMap<Block, Byte> _past = new HashMap<Block, Byte>(); protected HashMap<Block, BlockInfo> _past = new HashMap<Block, BlockInfo>();
protected HashMap<Block, Byte> _new = new HashMap<Block, Byte>(); protected HashMap<Block, BlockInfo> _new = new HashMap<Block, BlockInfo>();
public Tool(Draw host, Material mat) public Tool(Draw host, Material mat)
{ {
@ -68,7 +90,7 @@ public abstract class Tool
return; return;
} }
_new = new HashMap<Block, Byte>(); _new = new HashMap<Block, BlockInfo>();
//Calculate New //Calculate New
Block end = _drawer.getTargetBlock((HashSet<Byte>) null, 64); Block end = _drawer.getTargetBlock((HashSet<Byte>) null, 64);
@ -81,7 +103,10 @@ public abstract class Tool
for (Block block : _past.keySet()) for (Block block : _past.keySet())
{ {
if (!_new.containsKey(block)) if (!_new.containsKey(block))
block.setData(_past.get(block)); {
block.setType(_past.get(block).getType());
block.setData(_past.get(block).getData());
}
} }
_past = _new; _past = _new;

View File

@ -48,10 +48,15 @@ public class ToolCircle extends Tool
return; return;
byte color = block.getData(); byte color = block.getData();
Material type = block.getType();
if (_past.containsKey(block)) 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.setData(Host.getColor());
block.setType(Host.getBrushMaterial());
} }
} }

View File

@ -32,10 +32,15 @@ public class ToolLine extends Tool
continue; continue;
byte color = lineBlock.getData(); byte color = lineBlock.getData();
Material type = lineBlock.getType();
if (_past.containsKey(lineBlock)) 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()); lineBlock.setData(Host.getColor());
} }
} }

View File

@ -71,12 +71,16 @@ public class ToolSquare extends Tool
if (!Host.getCanvas().contains(block)) if (!Host.getCanvas().contains(block))
return; return;
Material type = block.getType();
byte color = block.getData(); byte color = block.getData();
if (_past.containsKey(block)) 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.setData(Host.getColor());
} }
} }