aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/multitileentity/interfaces/SyncedMultiTileEntity.java
blob: 92a147ff5325bd7de9aaaeccf676f3f4bdcf967b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package gregtech.api.multitileentity.interfaces;

import javax.annotation.Nonnull;

import net.minecraft.entity.player.EntityPlayerMP;

import gregtech.api.net.GTPacketMultiTileEntity;

public interface SyncedMultiTileEntity {

    int DEFAULT_TIMED_PACKET_PERIOD = 20;

    /**
     * Will send a packet to the client when they open the controller or access a casing.
     * Should only be sent to one player!
     */
    void sendFullPacket(@Nonnull EntityPlayerMP player);

    /**
     * Should always collect all the data that the controller or casing has and should send
     * Called by {@link #sendFullPacket()}
     *
     * @param packet The packet which will be sent
     */
    void getFullPacketData(GTPacketMultiTileEntity packet);

    /**
     * Will send a packet at a certain period of time, defined by {@link #getTimedPacketPeriod()}, to all players around
     * the controller or casing to send important information.
     * Redstone state, color, ect. It shouldn't send data about the internals like inventory and processing time
     */
    void sendTimedPacket();

    /**
     * Collects all the data that should be sent out at a certain period of time defined by
     * {@link #getTimedPacketPeriod()}
     * Called by {@link #sendTimedPacket()}
     *
     * @param packet The packet which will be sent
     */
    void getTimedPacketData(GTPacketMultiTileEntity packet);

    /**
     * Defines the period of time at which a timed packet should be sent out. Default 20 ticks
     */
    default int getTimedPacketPeriod() {
        return DEFAULT_TIMED_PACKET_PERIOD;
    }

    /**
     * Will send a packet, which should only contain data about how the TileEntity should be rendered.
     * !!! Warning !!! This is sent every single tick! Do not put a lot of data here!
     */
    void sendGraphicPacket();

    /**
     * Collects all the data that is needed to be send every single tick
     * Called by {@link #sendGraphicPacket()}
     *
     * @param packet The packet which will be sent
     */
    void getGraphicPacketData(GTPacketMultiTileEntity packet);
}