Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding every possible tile data #18

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/dat/items.dat
Binary file not shown.
12 changes: 12 additions & 0 deletions src/structures/Tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ export class Tile {
return buf.data;
}

case ActionTypes.PROVIDER: {
buf = new IBuffer(13);
const date = this.block.provider?.date || 0;
const timePassed = Math.floor((Date.now() - date) / 1000);

this.serializeBlockData(buf, { lockPos, flagTile: 0x0 });

buf.writeU8(ExtraTypes.PROVIDER);
buf.writeU32(timePassed);
return buf.data;
}

default: {
buf = new IBuffer(8);
this.serializeBlockData(buf, { lockPos, flagTile: 0x0 });
Expand Down
18 changes: 18 additions & 0 deletions src/tanks/Place.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,24 @@ export class Place {
return true;
}

case ActionTypes.PROVIDER: {
p.block.provider = {
date: Date.now()
};

this.world.place({
peer: this.peer,
x: p.block.x,
y: p.block.y,
isBg: p.isBg,
id: p.id
});

this.tileUpdate(p.actionType, p.block);

return true;
}

default: {
this.base.log.debug("Unknown block placing", { actionType: p.actionType, block: p.block });
return false;
Expand Down
21 changes: 21 additions & 0 deletions src/tanks/Punch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ export class Punch {
this.tank = TankPacket.fromBuffer(diceTank);
break;
}

case ActionTypes.PROVIDER: {
// Make a if statement that check if the block ready to punch (passed time must be in seconds format)
// for example chicken is 24 hour, then its should be 86400 seconds
const date = block.provider?.date || 0;
const timePassed = Math.floor((Date.now() - date) / 1000);

// Reset date
block.provider = {
date: Date.now()
};

// Update block visual
Place.tileUpdate(this.base, this.peer, itemMeta.type, block, this.world);
break;
}
}
}

Expand Down Expand Up @@ -253,6 +269,11 @@ export class Punch {
}
break;
}

case ActionTypes.PROVIDER: {
block.provider = undefined;
break;
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/types/world.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export interface Block {
toggleable?: Toggleable;
mannequin?: Mannequin;
dice?: number;
provider?: Provider;
}

export interface Provider {
date: number;
}

export interface Mannequin {
Expand Down