StileDevs / GrowServer

A Growtopia private server using NodeJS
MIT License
50 stars 28 forks source link

feat: adding every possible tile data #18

Open JadlionHD opened 2 months ago

JadlionHD commented 2 months ago

Every commit from this PR should be containing atleast 1 tile data that growtopia had.

If you have more information about specific growtopia tile data, leave a comment :D

JadlionHD commented 2 months ago

Also note, this PR didnt has a functional checking for every tile that been added here. Try make a seperate PR for it.

HTPDeveloper commented 2 months ago

Magplant, Gaia etc

case ActionTypes.ITEM_SUCKER: {
        const flag = 0x0;
        buf = new IBuffer(23);

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

        buf.writeU8(ExtraTypes.MAGPLANT);
        buf.writeU32(this.block.magplant?.itemID || 0); 
        buf.writeI32(this.block.magplant?.itemCount || 0); 
        buf.writeU16(this.block.magplant?.flags || 0x0); 
        buf.writeI32(this.block.magplant?.capacity || 5000); 

        return buf.data;
      }
HTPDeveloper commented 2 months ago
  Vend:
      case ActionTypes.VENDING_MACHINE: {
        const flag = 0x0;
        buf = new IBuffer(17);

        this.serializeBlockData(buf, { lockPos, flagTile: Flags.FLAGS_TILEEXTRA });

        buf.writeU8(ExtraTypes.VENDING_MACHINE);
        buf.writeU32(this.block.vendingMachine?.itemID || 0);

        let price = this.block.vendingMachine?.price|| 0;

        // Check if the price should be negative for "ITEM per WORLD LOCK"
        if (price < 0) {
            price = (price >>> 0); 
        }

        buf.writeI32(price); 
        return buf.data;
      }
JadlionHD commented 2 months ago

Magplant, Gaia etc

case ActionTypes.ITEM_SUCKER: {
        const flag = 0x0;
        buf = new IBuffer(23);

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

        buf.writeU8(ExtraTypes.MAGPLANT);
        buf.writeU32(this.block.magplant?.itemID || 0); 
        buf.writeI32(this.block.magplant?.itemCount || 0); 
        buf.writeU16(this.block.magplant?.flags || 0x0); 
        buf.writeI32(this.block.magplant?.capacity || 5000); 

        return buf.data;
      }
  Vend:
      case ActionTypes.VENDING_MACHINE: {
        const flag = 0x0;
        buf = new IBuffer(17);

        this.serializeBlockData(buf, { lockPos, flagTile: Flags.FLAGS_TILEEXTRA });

        buf.writeU8(ExtraTypes.VENDING_MACHINE);
        buf.writeU32(this.block.vendingMachine?.itemID || 0);

        let price = this.block.vendingMachine?.price|| 0;

        // Check if the price should be negative for "ITEM per WORLD LOCK"
        if (price < 0) {
            price = (price >>> 0); 
        }

        buf.writeI32(price); 
        return buf.data;
      }

Thank you 👍 Appreciate it

Shulej commented 2 months ago

You forgot to render if provider tiles are turned left :P

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

        if (this.block.rotatedLeft) flag |= Flags.FLAGS_ROTATED_LEFT;

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

        buf.writeU8(ExtraTypes.PROVIDER);
        buf.writeU32(timePassed);
        return buf.data;
      }
JadlionHD commented 2 months ago

You forgot to render if provider tiles are turned left :P

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

        if (this.block.rotatedLeft) flag |= Flags.FLAGS_ROTATED_LEFT;

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

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

Oh yeah didn't realize that