Skip to content

Commit

Permalink
fixed wool coloration
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisj42 committed May 24, 2017
1 parent 9e23262 commit 43599df
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions Bugs and things to do.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

-continue commeting code and renovating code
-display current player score in score mode
-reorder tools a bit in ToolType.java b/c I'm picky. Hoes should be first, at least. ;)

Note to self: for more little bugs/ideas/concerns, search code for "TODO"
-----------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/minicraft/entity/Mob.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public boolean move(int xa, int ya) { // Move the mob, overrides from Entity
if(level == null) return true;

if(tickTime % 2 == 0/* && !(this instanceof Player && ((Player)this).staminaRechargeDelay % 2 == 0)*/) {
if(isSwimming() || isWooling()) return true;
if(isSwimming() || isWooling() && !(this instanceof Player)) return true;
}
if (tickTime % walkTime == 0 && walkTime > 1) return true;

Expand Down
12 changes: 6 additions & 6 deletions src/minicraft/item/TileItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ protected static ArrayList<Item> getAllInstances() {

// TODO make a method in Item.java; calls clone(), but then changes color, and returns itself. Call it cloneAsColor, or changeColor, or maybe *asColor()*.
items.add(new TileItem("Wool", (new Sprite(2, 4, Color.get(-1, 555))), "wool", "hole", "water"));
items.add(new TileItem("Red Wool", (new Sprite(2, 4, Color.get(-1, 100, 300, 500))), "Wool_"+WoolTile.WoolColor.RED.ordinal(), "hole", "water"));
items.add(new TileItem("Blue Wool", (new Sprite(2, 4, Color.get(-1, 005, 115, 115))), "Wool_"+WoolTile.WoolColor.BLUE.ordinal(), "hole", "water"));
items.add(new TileItem("Green Wool", (new Sprite(2, 4, Color.get(-1, 10, 40, 50))), "Wool_"+WoolTile.WoolColor.GREEN.ordinal(), "hole", "water"));
items.add(new TileItem("Yellow Wool", (new Sprite(2, 4, Color.get(-1, 110, 440, 552))), "Wool_"+WoolTile.WoolColor.YELLOW.ordinal(), "hole", "water"));
items.add(new TileItem("Black Wool", (new Sprite(2, 4, Color.get(-1, 000, 111, 111))), "Wool_"+WoolTile.WoolColor.BLACK.ordinal(), "hole", "water"));

items.add(new TileItem("Red Wool", (new Sprite(2, 4, Color.get(-1, 100, 300, 500))), "Wool_RED", "hole", "water"));
items.add(new TileItem("Blue Wool", (new Sprite(2, 4, Color.get(-1, 005, 115, 115))), "Wool_BLUE", "hole", "water"));
items.add(new TileItem("Green Wool", (new Sprite(2, 4, Color.get(-1, 10, 40, 50))), "Wool_GREEN", "hole", "water"));
items.add(new TileItem("Yellow Wool", (new Sprite(2, 4, Color.get(-1, 110, 440, 552))), "Wool_YELLOW", "hole", "water"));
items.add(new TileItem("Black Wool", (new Sprite(2, 4, Color.get(-1, 000, 111, 111))), "Wool_BLACK", "hole", "water"));
items.add(new TileItem("Sand", (new Sprite(2, 4, Color.get(-1, 110, 440, 550))), "sand", "dirt"));
items.add(new TileItem("Cactus", (new Sprite(4, 4, Color.get(-1, 10, 40, 50))), "cactus Sapling", "sand"));
items.add(new TileItem("Seeds", (new Sprite(5, 4, Color.get(-1, 10, 40, 50))), "wheat", "farmland"));
Expand Down
4 changes: 2 additions & 2 deletions src/minicraft/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,9 @@ public void setTile(int x, int y, String tilewithdata) {
setTile(x, y, Tiles.get(tilewithdata));
return;
}
int data = Integer.parseInt(tilewithdata.substring(tilewithdata.indexOf("_")+1));
String name = tilewithdata.substring(0, tilewithdata.indexOf("_"));
setTile(x, y, Tiles.get(name));
int data = Tiles.get(name).getData(tilewithdata.substring(name.length()+1));
setTile(x, y, Tiles.get(name), data);
}
public void setTile(int x, int y, Tile t) {
setTile(x, y, t, t.getDefaultData());
Expand Down
8 changes: 8 additions & 0 deletions src/minicraft/level/tile/Tile.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ public boolean connectsToLiquid() {
return connectsToWater || connectsToLava;
}

public int getData(String data) {
try {
return Integer.parseInt(data);
} catch(NumberFormatException ex) {
return 0;
}
}

public boolean matches(Tile other) {
return name == other.name;
}
Expand Down
6 changes: 5 additions & 1 deletion src/minicraft/level/tile/WoolTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ public boolean mayPass(Level level, int x, int y, Entity e) {
return e.canWool();
}

public int getData(String data) {
return Enum.valueOf(WoolColor.class, data.toUpperCase()).ordinal();
}

public boolean matches(String woolColor, String otherTile) {
return matches(Enum.valueOf(WoolColor.class, woolColor.toUpperCase()).ordinal(), otherTile);
return matches(getData(woolColor), otherTile);
}
public boolean matches(int thisData, String otherTile) {
if(!otherTile.contains("_"))
Expand Down

0 comments on commit 43599df

Please sign in to comment.