Fix bucket
This commit is contained in:
parent
268536ce68
commit
4472c52432
@ -10,6 +10,7 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -99,7 +100,7 @@ public class Draw extends SoloGame
|
||||
{
|
||||
//new KitSlowAndSteady(manager),
|
||||
//new KitSelector(manager),
|
||||
//new KitTools(manager),
|
||||
// new KitTools(manager),
|
||||
new KitArtist(manager)
|
||||
},
|
||||
|
||||
@ -164,8 +165,8 @@ public class Draw extends SoloGame
|
||||
"Paint", "Guard", "Astronaut" , "Slime" , "Mansion" , "Radar" , "Thorn" , "Tears" , "Tiny" , "Candy" ,
|
||||
"Pepsi" , "Flint" , "Draw My Thing" , "Rice" , "Shout" , "Prize" , "Skirt" , "Thief" , "Syrup" ,
|
||||
"Kirby" , "Brush" , "Violin", "Car", "Sun", "Eye", "Bow", "Axe", "Face", "Mushroom", "Guitar",
|
||||
"Book", "Pickle", "Banana", "Crab", "Sugar", "Book", "Soda", "Cookie", "Burger", "Fries", "Speaker",
|
||||
"Pillow", "Rug", "Purse", "Monitor", "Bow", "Pen", "Cat", "Kitten", "Puppy", "Bed", "Bowl", "Button",
|
||||
"Pickle", "Banana", "Crab", "Sugar", "Soda", "Cookie", "Burger", "Fries", "Speaker",
|
||||
"Pillow", "Rug", "Purse", "Monitor", "Bow", "Pen", "Cat", "Kitten", "Puppy", "Bed", "Button",
|
||||
"Computer", "Key", "Spoon", "Lamp", "Bottle", "Card", "Newspaper", "Glasses", "Mountain", "Minecraft",
|
||||
"Shirt", "Truck", "Car", "Phone", "Cork", "iPod", "Paper", "Bag", "USB", "CD", "Wallet", "Cow", "Pig",
|
||||
"Sheep", "Tomato", "Painting", "Chair", "Keyboard", "Chocolate", "Duck", "Clock", "Balloon", "Remote",
|
||||
@ -179,7 +180,7 @@ public class Draw extends SoloGame
|
||||
"Piano", "Guitar", "Trumpet", "Drums", "Flute", "Helicopter", "Plane", "Football", "Tennis", "Hockey",
|
||||
"Water", "Ocean", "Microsoft", "Twitter", "Godzilla", "Building", "House", "Rainbow", "Barbie", "Girl", "Boy",
|
||||
"Children", "Bomb", "Explosion", "Gun", "Tank", "Penguin", "Eagle", "America", "Kangaroo", "Sea", "Raspberry",
|
||||
"Strawberry", "Jam", "Sandwich"
|
||||
"Strawberry", "Jam", "Sandwich", "Owl", "Watermelon", "Australia", "Canada", "United States", "Diary"
|
||||
};
|
||||
|
||||
_holidayWords = new String[]
|
||||
@ -215,14 +216,19 @@ public class Draw extends SoloGame
|
||||
@Override
|
||||
public void ParseData()
|
||||
{
|
||||
int count = 0;
|
||||
for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("PINK").get(0), WorldData.GetDataLocs("PINK").get(1), false))
|
||||
{
|
||||
if (b.getType() != Material.AIR)
|
||||
{
|
||||
_canvas.add(b);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("===");
|
||||
System.out.println("Draw loc: " + WorldData.GetDataLocs("RED").size());
|
||||
System.out.println("Canvas Count: " + count);
|
||||
System.out.println("===");
|
||||
|
||||
_drawerLocation = WorldData.GetDataLocs("RED").get(0);
|
||||
@ -236,6 +242,9 @@ public class Draw extends SoloGame
|
||||
return;
|
||||
|
||||
Reset();
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -772,67 +781,33 @@ public class Draw extends SoloGame
|
||||
return;
|
||||
}
|
||||
|
||||
// Play sound to all players.
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
Material material = target.getType();
|
||||
byte data = target.getData();
|
||||
|
||||
if (data == _brushColor && material == _brushMaterial)
|
||||
return;
|
||||
|
||||
System.out.println("Fill...");
|
||||
fillRecursive(target, material, data);
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
other.playSound(other.getLocation(), Sound.SPLASH, 0.4f, 1.5f);
|
||||
}
|
||||
|
||||
private void fillRecursive(Block block, final Material fillMaterial, final byte fillData)
|
||||
{
|
||||
if (!_canvas.contains(block) || block.getType() != fillMaterial || block.getData() != fillData)
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.SPLASH, 0.4f, 1.5f);
|
||||
return;
|
||||
}
|
||||
|
||||
// Save the current block info to check later if it's the same.
|
||||
BlockInfo originalInfo = new BlockInfo(target.getType(), target.getData());
|
||||
block.setTypeIdAndData(_brushMaterial.getId(), _brushColor, false);
|
||||
|
||||
// List of blocks needing to be changed.
|
||||
ArrayList<Block> pending = new ArrayList<>();
|
||||
List<Block> around = UtilBlock.getSurrounding(block, false);
|
||||
|
||||
// Add the current target block to pending changes.
|
||||
boolean targetBlock = true;
|
||||
pending.add(target);
|
||||
|
||||
// Cycle through all pending blocks if there are any left.
|
||||
pendingBlocks: while (!pending.isEmpty())
|
||||
for (Block next : around)
|
||||
{
|
||||
// Find the center block and remove it from the list sequentially.
|
||||
Block center = pending.get(0);
|
||||
pending.remove(0);
|
||||
|
||||
// Check if it's the original target block.
|
||||
if (!targetBlock)
|
||||
{
|
||||
// It's not: make sure that it's the same as the original block info.
|
||||
if (center.getType() != originalInfo.getType())
|
||||
{
|
||||
// Not the same block type.
|
||||
continue pendingBlocks;
|
||||
}
|
||||
|
||||
if (center.getData() != originalInfo.getData())
|
||||
{
|
||||
// Not the same block data/colour.
|
||||
continue pendingBlocks;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set so that we know the next block isn't the original target.
|
||||
targetBlock = false;
|
||||
}
|
||||
|
||||
// Set the center block type and data/colour.
|
||||
center.setType(_brushMaterial);
|
||||
center.setData(_brushColor);
|
||||
|
||||
// Cycle through the surrounding blocks and see if they need filling in.
|
||||
blocks: for (Block other : UtilBlock.getSurrounding(center, false))
|
||||
{
|
||||
if (pending.contains(other))
|
||||
{
|
||||
// Already awaiting a change. :+1:
|
||||
continue blocks;
|
||||
}
|
||||
|
||||
// Add it to the pending list for change later.
|
||||
pending.add(other);
|
||||
}
|
||||
fillRecursive(next, fillMaterial, fillData);
|
||||
}
|
||||
}
|
||||
|
||||
@ -847,7 +822,12 @@ public class Draw extends SoloGame
|
||||
if (!_drawers.HasPlayer(player))
|
||||
return;
|
||||
|
||||
Location loc = UtilPlayer.getTarget(player, UtilBlock.blockPassSet, 400).getLocation();
|
||||
Block target = UtilPlayer.getTarget(player, UtilBlock.blockPassSet, 400);
|
||||
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
Location loc = target.getLocation();
|
||||
|
||||
List<Block> possibleBlocks = UtilBlock.getInBoundingBox(WorldData.GetDataLocs("GREEN").get(0),
|
||||
WorldData.GetDataLocs("GREEN").get(1));
|
||||
|
Loading…
Reference in New Issue
Block a user