diff --git a/assets/dat/items.dat b/assets/dat/items.dat index e81c510..521b773 100644 Binary files a/assets/dat/items.dat and b/assets/dat/items.dat differ diff --git a/src/structures/Tile.ts b/src/structures/Tile.ts index cc7e454..add4256 100644 --- a/src/structures/Tile.ts +++ b/src/structures/Tile.ts @@ -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 }); diff --git a/src/tanks/Place.ts b/src/tanks/Place.ts index a2bc37a..e2def65 100644 --- a/src/tanks/Place.ts +++ b/src/tanks/Place.ts @@ -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; diff --git a/src/tanks/Punch.ts b/src/tanks/Punch.ts index c6bbc4f..86f0eb5 100644 --- a/src/tanks/Punch.ts +++ b/src/tanks/Punch.ts @@ -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; + } } } @@ -253,6 +269,11 @@ export class Punch { } break; } + + case ActionTypes.PROVIDER: { + block.provider = undefined; + break; + } } } } diff --git a/src/types/world.d.ts b/src/types/world.d.ts index 224157a..7db896c 100644 --- a/src/types/world.d.ts +++ b/src/types/world.d.ts @@ -41,6 +41,11 @@ export interface Block { toggleable?: Toggleable; mannequin?: Mannequin; dice?: number; + provider?: Provider; +} + +export interface Provider { + date: number; } export interface Mannequin {