Skip to content

Commit

Permalink
kinda reversed some impl that moved interactions to the server; it wa…
Browse files Browse the repository at this point in the history
…s too slow. didn't reverse it entirely though
  • Loading branch information
chrisj42 committed Jun 12, 2018
1 parent 4cd6bec commit f46f104
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/minicraft/entity/Arrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import minicraft.gfx.Rectangle;
import minicraft.gfx.Screen;

public class Arrow extends Entity {
public class Arrow extends Entity implements ClientTickable {
private Direction dir;
private int damage;
public Mob owner;
Expand Down
6 changes: 4 additions & 2 deletions src/minicraft/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public boolean move(int xa, int ya) {
protected boolean move2(int xa, int ya) {
if(xa == 0 && ya == 0) return true; // was not stopped

boolean interact = true;//!Game.isValidClient() || this instanceof ClientTickable;

// gets the tile coordinate of each direction from the sprite...
int xto0 = ((x) - xr) >> 4; // to the left
int yto0 = ((y) - yr) >> 4; // above
Expand All @@ -125,7 +127,7 @@ protected boolean move2(int xa, int ya) {
for (int xt = xt0; xt <= xt1; xt++) { // cycles through x's of tile after movement
if (xt >= xto0 && xt <= xto1 && yt >= yto0 && yt <= yto1) continue; // skip this position if this entity's sprite is touching it
// tile positions that make it here are the ones that the entity will be in, but are not in now.
if(!Game.isValidClient())
if(interact)
level.getTile(xt, yt).bumpedInto(level, xt, yt, this); // Used in tiles like cactus
if (!level.getTile(xt, yt).mayPass(level, xt, yt, this)) { // if the entity can't pass this tile...
//blocked = true; // then the entity is blocked
Expand All @@ -143,7 +145,7 @@ protected boolean move2(int xa, int ya) {
yr++;
}
List<Entity> isInside = level.getEntitiesInRect(new Rectangle(x+xa, y+ya, xr*2, yr*2, Rectangle.CENTER_DIMS)); // gets the entities that this entity will touch once moved.
for (int i = 0; !Game.isValidClient() && i < isInside.size(); i++) {
for (int i = 0; interact && i < isInside.size(); i++) {
/// cycles through entities about to be touched, and calls touchedBy(this) for each of them.
Entity e = isInside.get(i);
if (e == this) continue; // touching yourself doesn't count.
Expand Down

0 comments on commit f46f104

Please sign in to comment.