aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/ServerPlayerGameMode.h
blob: 509e16763cd42abc24811727b07e8526b8c7a56b (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
#pragma once
class ServerPlayer;
class Level;
class ItemInstance;
class ServerLevel;
class GameRulesInstance;
class GameType;

class ServerPlayerGameMode
{
public:
	Level *level;
	shared_ptr<ServerPlayer> player;

private:
	GameType *gameModeForPlayer;

private:
	bool isDestroyingBlock;
    int destroyProgressStart;
    int xDestroyBlock, yDestroyBlock, zDestroyBlock;
    int gameTicks;

    bool hasDelayedDestroy;
    int delayedDestroyX, delayedDestroyY, delayedDestroyZ;
    int delayedTickStart;
	int lastSentState;

private:
	// 4J Added
	GameRulesInstance *m_gameRules;
public:
	void setGameRules(GameRulesInstance *rules);
	GameRulesInstance *getGameRules() { return m_gameRules; }

public:
	ServerPlayerGameMode(Level *level);
	~ServerPlayerGameMode();

	void setGameModeForPlayer(GameType *gameModeForPlayer);
	GameType *getGameModeForPlayer();
	bool isSurvival();
	bool isCreative();
	void updateGameMode(GameType *gameType);

    void tick();
    void startDestroyBlock(int x, int y, int z, int face);
    void stopDestroyBlock(int x, int y, int z);
    void abortDestroyBlock(int x, int y, int z);

private:
    bool superDestroyBlock(int x, int y, int z);

public:
    bool destroyBlock(int x, int y, int z);
    bool useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, bool bTestUseOnly=false);
    bool useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly=false, bool *pbUsedItem=nullptr);

	void setLevel(ServerLevel *newLevel);
};