pragma once everywhere

This commit is contained in:
Kolyah35
2026-03-28 00:00:19 +03:00
parent a45c01d013
commit 7d3257669a
575 changed files with 37222 additions and 38345 deletions

View File

@@ -1,5 +1,4 @@
#ifndef EGLCONFIGPRINTER_H__
#define EGLCONFIGPRINTER_H__
#pragma once
#include <cstdio>
#include <string>
@@ -122,4 +121,3 @@ public:
}
};
#endif /*EGLCONFIGPRINTER_H__*/

View File

@@ -1,40 +1,39 @@
#ifndef LICENSECODES_H__
#define LICENSECODES_H__
class LicenseCodes
{
public:
// Something's not ready, call again later
static const int WAIT_PLATFORM_NOT_READY = -2;
static const int WAIT_SERVER_NOT_READY = -1;
// License is ok
static const int LICENSE_OK = 0;
static const int LICENSE_TRIAL_OK = 1;
// License is not working in one way or another
static const int LICENSE_VALIDATION_FAILED = 50;
static const int ITEM_NOT_FOUND = 51;
static const int LICENSE_NOT_FOUND = 52;
static const int ERROR_CONTENT_HANDLER = 100;
static const int ERROR_ILLEGAL_ARGUMENT = 101;
static const int ERROR_SECURITY = 102;
static const int ERROR_INPUT_OUTPUT = 103;
static const int ERROR_ILLEGAL_STATE = 104;
static const int ERROR_NULL_POINTER = 105;
static const int ERROR_GENERAL = 106;
static const int ERROR_UNABLE_TO_CONNECT_TO_CDS = 107;
// The call went wrong so we didn't get a license value at all
static const int ERROR_EXCEPTION = 200;
static bool isOk(int i) {
return (i == 0) || (i == 1);
}
static bool isReady(int i) {
return (i >= 0);
}
};
#endif /*LICENSECODES_H__ */
#pragma once
class LicenseCodes
{
public:
// Something's not ready, call again later
static const int WAIT_PLATFORM_NOT_READY = -2;
static const int WAIT_SERVER_NOT_READY = -1;
// License is ok
static const int LICENSE_OK = 0;
static const int LICENSE_TRIAL_OK = 1;
// License is not working in one way or another
static const int LICENSE_VALIDATION_FAILED = 50;
static const int ITEM_NOT_FOUND = 51;
static const int LICENSE_NOT_FOUND = 52;
static const int ERROR_CONTENT_HANDLER = 100;
static const int ERROR_ILLEGAL_ARGUMENT = 101;
static const int ERROR_SECURITY = 102;
static const int ERROR_INPUT_OUTPUT = 103;
static const int ERROR_ILLEGAL_STATE = 104;
static const int ERROR_NULL_POINTER = 105;
static const int ERROR_GENERAL = 106;
static const int ERROR_UNABLE_TO_CONNECT_TO_CDS = 107;
// The call went wrong so we didn't get a license value at all
static const int ERROR_EXCEPTION = 200;
static bool isOk(int i) {
return (i == 0) || (i == 1);
}
static bool isReady(int i) {
return (i >= 0);
}
};
#endif /*LICENSECODES_H__ */

View File

@@ -1,140 +1,138 @@
#ifndef NET_MINECRAFT_CLIENT__Minecraft_H__
#define NET_MINECRAFT_CLIENT__Minecraft_H__
#include "client/Options.h"
#include "client/Timer.h"
//#include "../network/RakNetInstance.h"
#include "world/phys/HitResult.h"
#include "App.h"
#include <cstddef>
class Level;
class LocalPlayer;
class IInputHolder;
class Mob;
class Player;
class Entity;
class ICreator;
class GameMode;
class CThread;
class LevelStorageSource;
class BuildActionIntention;
class PerfRenderer;
class LevelSettings;
class IRakNetInstance;
class NetEventCallback;
class CommandServer;
struct PingedCompatibleServer;
class Minecraft: public App {
public:
using App::App;
virtual ~Minecraft();
virtual void init();
virtual void update();
virtual void restartServer();
virtual void tick(int nTick, int maxTick);
virtual bool isOnlineClient();
virtual bool isOnline();
virtual void setIsCreativeMode(bool isCreative);
virtual void optionUpdated(OptionId option, bool value);
virtual void optionUpdated(OptionId option, float value);
virtual void optionUpdated(OptionId option, int value);
/**
* @brief Get public name that will be listed in JoinGame menu
*/
virtual std::string getServerName() { return "Unknown"; }
void toggleDimension() {}
bool isCreativeMode();
virtual void selectLevel(const std::string& levelId, const std::string& levelName, const LevelSettings& settings);
virtual void setLevel(Level* level, const std::string& message = "", Player* forceInsertPlayer = NULL);
virtual void onBlockDestroyed(Player* player, int x, int y, int z, int face) {}
void generateLevel( const std::string& message, Level* level );
LevelStorageSource* getLevelSource();
virtual void hostMultiplayer(int port=19132);
Player* respawnPlayer(int playerId);
void respawnPlayer();
void resetPlayer(Player* player);
void doActuallyRespawnPlayer();
void prepareLevel(const std::string& message);
int getProgressStatusId();
const char* getProgressMessage();
ICreator* getCreator();
bool isLevelGenerated();
#ifdef __APPLE__
bool _isSuperFast = false;
bool isSuperFast() { return _isSuperFast; }
#endif
protected:
virtual void _levelGenerated();
private:
static void* prepareLevel_tspawn(void *p_param);
public:
Level* level = nullptr;
CommandServer* _commandServer = nullptr;
GameMode* gameMode = nullptr;
IRakNetInstance* raknetInstance = nullptr;
NetEventCallback* netCallback = nullptr;
int commandPort = 4711;
int lastTime = 0;
int lastTickTime = -1;
int missTime = 0;
int ticks = 0;
CThread* generateLevelThread = nullptr;
// static int customDebugId;
HitResult hitResult;
volatile int progressStagePercentage = 0;
// This field is initialized in main()
// It sets the base path to where worlds can be written (sdcard on android)
std::string externalStoragePath;
std::string externalCacheStoragePath;
protected:
Timer timer{20};
// @note @attn @warn: this is dangerous as fuck!
volatile bool isGeneratingLevel = false;
bool _hasSignaledGeneratingLevelFinished = true;
LevelStorageSource* storageSource;
bool _running;
protected:
volatile int progressStageStatusId = 0;
static const char* progressMessages[];
int _licenseId;
bool _isCreativeMode;
Player* _pendingRemovePlayer; // @attn @todo @fix: remove this shait and fix the respawn behaviour
// from NinecraftApp
bool _verbose = true;
int _lastTickMs = 0;
static bool _hasInitedStatics;
};
#endif /*NET_MINECRAFT_CLIENT__Minecraft_H__*/
#pragma once
#include "client/Options.h"
#include "client/Timer.h"
//#include "../network/RakNetInstance.h"
#include "world/phys/HitResult.h"
#include "App.h"
#include <cstddef>
class Level;
class LocalPlayer;
class IInputHolder;
class Mob;
class Player;
class Entity;
class ICreator;
class GameMode;
class CThread;
class LevelStorageSource;
class BuildActionIntention;
class PerfRenderer;
class LevelSettings;
class IRakNetInstance;
class NetEventCallback;
class CommandServer;
struct PingedCompatibleServer;
class Minecraft: public App {
public:
using App::App;
virtual ~Minecraft();
virtual void init();
virtual void update();
virtual void restartServer();
virtual void tick(int nTick, int maxTick);
virtual bool isOnlineClient();
virtual bool isOnline();
virtual void setIsCreativeMode(bool isCreative);
virtual void optionUpdated(OptionId option, bool value);
virtual void optionUpdated(OptionId option, float value);
virtual void optionUpdated(OptionId option, int value);
/**
* @brief Get public name that will be listed in JoinGame menu
*/
virtual std::string getServerName() { return "Unknown"; }
void toggleDimension() {}
bool isCreativeMode();
virtual void selectLevel(const std::string& levelId, const std::string& levelName, const LevelSettings& settings);
virtual void setLevel(Level* level, const std::string& message = "", Player* forceInsertPlayer = NULL);
virtual void onBlockDestroyed(Player* player, int x, int y, int z, int face) {}
void generateLevel( const std::string& message, Level* level );
LevelStorageSource* getLevelSource();
virtual void hostMultiplayer(int port=19132);
Player* respawnPlayer(int playerId);
void respawnPlayer();
void resetPlayer(Player* player);
void doActuallyRespawnPlayer();
void prepareLevel(const std::string& message);
int getProgressStatusId();
const char* getProgressMessage();
ICreator* getCreator();
bool isLevelGenerated();
#ifdef __APPLE__
bool _isSuperFast = false;
bool isSuperFast() { return _isSuperFast; }
#endif
protected:
virtual void _levelGenerated();
private:
static void* prepareLevel_tspawn(void *p_param);
public:
Level* level = nullptr;
CommandServer* _commandServer = nullptr;
GameMode* gameMode = nullptr;
IRakNetInstance* raknetInstance = nullptr;
NetEventCallback* netCallback = nullptr;
int commandPort = 4711;
int lastTime = 0;
int lastTickTime = -1;
int missTime = 0;
int ticks = 0;
CThread* generateLevelThread = nullptr;
// static int customDebugId;
HitResult hitResult;
volatile int progressStagePercentage = 0;
// This field is initialized in main()
// It sets the base path to where worlds can be written (sdcard on android)
std::string externalStoragePath;
std::string externalCacheStoragePath;
protected:
Timer timer{20};
// @note @attn @warn: this is dangerous as fuck!
volatile bool isGeneratingLevel = false;
bool _hasSignaledGeneratingLevelFinished = true;
LevelStorageSource* storageSource;
bool _running;
protected:
volatile int progressStageStatusId = 0;
static const char* progressMessages[];
int _licenseId;
bool _isCreativeMode;
Player* _pendingRemovePlayer; // @attn @todo @fix: remove this shait and fix the respawn behaviour
// from NinecraftApp
bool _verbose = true;
int _lastTickMs = 0;
static bool _hasInitedStatics;
};

View File

@@ -1,12 +1,10 @@
#ifndef PERFORMANCE_H__
#define PERFORMANCE_H__
#include "platform/time.h"
class Performance
{
public:
static StopwatchHandler watches;
};
#endif /*PERFORMANCE_H__*/
#pragma once
#include "platform/time.h"
class Performance
{
public:
static StopwatchHandler watches;
};

View File

@@ -1,34 +1,32 @@
#ifndef NET_MINECRAFT_SharedConstants_H__
#define NET_MINECRAFT_SharedConstants_H__
#include <string>
enum LevelGeneratorVersion
{
LGV_ORIGINAL = 0,
};
namespace Common {
std::string getGameVersionString(const std::string& versionSuffix = "");
}
namespace SharedConstants
{
// 0.5.0 uses NPv8
// 0.6.0 uses NPv9
const int NetworkProtocolVersion = 9;
const int NetworkProtocolLowestSupportedVersion = 9;
const int GameProtocolVersion = 1;
const int GameProtocolLowestSupportedVersion = 1;
const int StorageVersion = 3;
const int MaxChatLength = 100;
const int TicksPerSecond = 20;
const int GeneratorVersion = (int)LGV_ORIGINAL;
//int FULLBRIGHT_LIGHTVALUE = 15 << 20 | 15 << 4;
}
#endif /*NET_MINECRAFT_SharedConstants_H__*/
#pragma once
#include <string>
enum LevelGeneratorVersion
{
LGV_ORIGINAL = 0,
};
namespace Common {
std::string getGameVersionString(const std::string& versionSuffix = "");
}
namespace SharedConstants
{
// 0.5.0 uses NPv8
// 0.6.0 uses NPv9
const int NetworkProtocolVersion = 9;
const int NetworkProtocolLowestSupportedVersion = 9;
const int GameProtocolVersion = 1;
const int GameProtocolLowestSupportedVersion = 1;
const int StorageVersion = 3;
const int MaxChatLength = 100;
const int TicksPerSecond = 20;
const int GeneratorVersion = (int)LGV_ORIGINAL;
//int FULLBRIGHT_LIGHTVALUE = 15 << 20 | 15 << 4;
}

View File

@@ -1,48 +1,46 @@
#ifndef CONFIGLISTENER_H__
#define CONFIGLISTENER_H__
#include "PixelCalc.h"
class Minecraft;
class Options;
class Config {
public:
// Screen dimensions and world-to-screen conversion
void setScreenSize(int width, int height, float scale) {
this->width = width;
this->height = height;
this->guiScale = scale;
this->invGuiScale = 1.0f / scale;
this->guiWidth = (int)(width * invGuiScale);
this->guiHeight = (int)(height * invGuiScale);
}
int width;
int height;
float guiScale;
float invGuiScale;
int guiWidth;
int guiHeight;
PixelCalc pixelCalc;
PixelCalc pixelCalcUi;
Minecraft* minecraft;
Options* options;
};
Config createConfig(Minecraft* mc);
// Interface for Configuration-Changed listener
// This can mean (for instance);
// - Screen has changed dimensions, or rotation if rotations are enabled
// - New input device or control mechanism
class IConfigListener
{
public:
virtual ~IConfigListener() {}
virtual void onConfigChanged(const Config& config) = 0;
};
#endif /*CONFIGLISTENER_H__*/
#pragma once
#include "PixelCalc.h"
class Minecraft;
class Options;
class Config {
public:
// Screen dimensions and world-to-screen conversion
void setScreenSize(int width, int height, float scale) {
this->width = width;
this->height = height;
this->guiScale = scale;
this->invGuiScale = 1.0f / scale;
this->guiWidth = (int)(width * invGuiScale);
this->guiHeight = (int)(height * invGuiScale);
}
int width;
int height;
float guiScale;
float invGuiScale;
int guiWidth;
int guiHeight;
PixelCalc pixelCalc;
PixelCalc pixelCalcUi;
Minecraft* minecraft;
Options* options;
};
Config createConfig(Minecraft* mc);
// Interface for Configuration-Changed listener
// This can mean (for instance);
// - Screen has changed dimensions, or rotation if rotations are enabled
// - New input device or control mechanism
class IConfigListener
{
public:
virtual ~IConfigListener() {}
virtual void onConfigChanged(const Config& config) = 0;
};

View File

@@ -1,28 +1,26 @@
#ifndef NET_MINECRAFT_CLIENT__MouseHandler_H__
#define NET_MINECRAFT_CLIENT__MouseHandler_H__
//package net.minecraft.client;
class ITurnInput;
class MouseHandler
{
public:
MouseHandler(ITurnInput* turnInput);
MouseHandler();
~MouseHandler();
void setTurnInput(ITurnInput* turnInput);
void grab();
void release();
void poll();
float xd, yd;
private:
int toSkip;
ITurnInput* _turnInput;
};
#endif /*NET_MINECRAFT_CLIENT__MouseHandler_H__*/
#pragma once
//package net.minecraft.client;
class ITurnInput;
class MouseHandler
{
public:
MouseHandler(ITurnInput* turnInput);
MouseHandler();
~MouseHandler();
void setTurnInput(ITurnInput* turnInput);
void grab();
void release();
void poll();
float xd, yd;
private:
int toSkip;
ITurnInput* _turnInput;
};

View File

@@ -1,5 +1,4 @@
#ifndef NET_MINECRAFT_CLIENT__OptionStrings_H__
#define NET_MINECRAFT_CLIENT__OptionStrings_H__
#pragma once
class OptionStrings {
public:
@@ -33,4 +32,3 @@ public:
};
#endif /*NET_MINECRAFT_CLIENT__OptionsStrings_H__*/

View File

@@ -1,166 +1,164 @@
#ifndef NET_MINECRAFT_CLIENT__Options_H__
#define NET_MINECRAFT_CLIENT__Options_H__
#define SOUND_MIN_VALUE 0.0f
#define SOUND_MAX_VALUE 1.0f
#define MUSIC_MIN_VALUE 0.0f
#define MUSIC_MAX_VALUE 1.0f
#define SENSITIVITY_MIN_VALUE 0.0f
#define SENSITIVITY_MAX_VALUE 1.0f
#define PIXELS_PER_MILLIMETER_MIN_VALUE 3.0f
#define PIXELS_PER_MILLIMETER_MAX_VALUE 4.0f
//package net.minecraft.client;
//#include "locale/Language.h"
#include <string>
#include <platform/input/Keyboard.h>
#include <util/StringUtils.h>
#include "OptionsFile.h"
#include "Option.h"
#include <array>
enum OptionId {
// General
OPTIONS_DIFFICULTY,
OPTIONS_HIDEGUI,
OPTIONS_THIRD_PERSON_VIEW,
OPTIONS_GUI_SCALE,
OPTIONS_DESTROY_VIBRATION,
OPTIONS_MUSIC_VOLUME,
OPTIONS_SOUND_VOLUME,
OPTIONS_SKIN,
OPTIONS_USERNAME,
OPTIONS_SERVER_VISIBLE,
OPTIONS_BAR_ON_TOP,
OPTIONS_ALLOW_SPRINT,
OPTIONS_AUTOJUMP,
// Graphics
OPTIONS_RENDER_DEBUG,
OPTIONS_SMOOTH_CAMERA,
OPTIONS_FIXED_CAMERA,
OPTIONS_VIEW_DISTANCE,
OPTIONS_VIEW_BOBBING,
OPTIONS_AMBIENT_OCCLUSION,
OPTIONS_ANAGLYPH_3D,
OPTIONS_LIMIT_FRAMERATE,
OPTIONS_VSYNC,
OPTIONS_FANCY_GRAPHICS,
// Cheats / debug
OPTIONS_FLY_SPEED,
OPTIONS_CAMERA_SPEED,
OPTIONS_IS_FLYING,
// Control
OPTIONS_USE_MOUSE_FOR_DIGGING,
OPTIONS_IS_LEFT_HANDED,
OPTIONS_IS_JOY_TOUCH_AREA,
OPTIONS_SENSITIVITY,
OPTIONS_INVERT_Y_MOUSE,
OPTIONS_USE_TOUCHSCREEN,
OPTIONS_KEY_FORWARD,
OPTIONS_KEY_LEFT,
OPTIONS_KEY_BACK,
OPTIONS_KEY_RIGHT,
OPTIONS_KEY_JUMP,
OPTIONS_KEY_INVENTORY,
OPTIONS_KEY_SNEAK,
OPTIONS_KEY_DROP,
OPTIONS_KEY_CHAT,
OPTIONS_KEY_FOG,
OPTIONS_KEY_USE,
OPTIONS_KEY_MENU_NEXT,
OPTIONS_KEY_MENU_PREV,
OPTIONS_KEY_MENU_OK,
OPTIONS_KEY_MENU_CANCEL,
OPTIONS_FIRST_LAUNCH,
OPTIONS_LAST_IP,
OPTIONS_RPI_CURSOR,
// Should be last!
OPTIONS_COUNT
};
class MinecraftClient;
typedef std::vector<std::string> StringVector;
class Options
{
public:
static bool debugGl;
Options(MinecraftClient& minecraft, const std::string& workingDirectory = "")
: minecraft(minecraft) {
// elements werent initialized so i was getting a garbage pointer and a crash
m_options.fill(nullptr);
initTable();
// load() is deferred to init() where path is configured correctly
}
void initTable();
int getIntValue(OptionId key) {
auto option = opt<OptionInt>(key);
return (option)? option->get() : 0;
}
std::string getStringValue(OptionId key) {
auto option = opt<OptionString>(key);
return (option)? option->get() : "";
}
float getProgressValue(OptionId key) {
auto option = opt<OptionFloat>(key);
return (option)? option->get() : 0.f;
}
bool getBooleanValue(OptionId key) {
auto option = opt<OptionBool>(key);
return (option)? option->get() : false;
}
float getProgrssMin(OptionId key) {
auto option = opt<OptionFloat>(key);
return (option)? option->getMin() : 0.f;
}
float getProgrssMax(OptionId key) {
auto option = opt<OptionFloat>(key);
return (option)? option->getMax() : 0.f;
}
Option* getOpt(OptionId id) { return m_options[id]; }
void load();
void save();
void set(OptionId key, int value);
void set(OptionId key, float value);
void set(OptionId key, const std::string& value);
void setOptionsFilePath(const std::string& path);
void toggle(OptionId key);
void notifyOptionUpdate(OptionId key, bool value);
void notifyOptionUpdate(OptionId key, float value);
void notifyOptionUpdate(OptionId key, int value);
void notifyOptionUpdate(OptionId key, const std::string& value) {}
private:
template<typename T>
T* opt(OptionId key) {
if (m_options[key] == nullptr) return nullptr;
return dynamic_cast<T*>(m_options[key]);
}
std::array<Option*, OPTIONS_COUNT> m_options;
OptionsFile optionsFile;
MinecraftClient& minecraft;
};
#endif /*NET_MINECRAFT_CLIENT__Options_H__*/
#pragma once
#define SOUND_MIN_VALUE 0.0f
#define SOUND_MAX_VALUE 1.0f
#define MUSIC_MIN_VALUE 0.0f
#define MUSIC_MAX_VALUE 1.0f
#define SENSITIVITY_MIN_VALUE 0.0f
#define SENSITIVITY_MAX_VALUE 1.0f
#define PIXELS_PER_MILLIMETER_MIN_VALUE 3.0f
#define PIXELS_PER_MILLIMETER_MAX_VALUE 4.0f
//package net.minecraft.client;
//#include "locale/Language.h"
#include <string>
#include <platform/input/Keyboard.h>
#include <util/StringUtils.h>
#include "OptionsFile.h"
#include "Option.h"
#include <array>
enum OptionId {
// General
OPTIONS_DIFFICULTY,
OPTIONS_HIDEGUI,
OPTIONS_THIRD_PERSON_VIEW,
OPTIONS_GUI_SCALE,
OPTIONS_DESTROY_VIBRATION,
OPTIONS_MUSIC_VOLUME,
OPTIONS_SOUND_VOLUME,
OPTIONS_SKIN,
OPTIONS_USERNAME,
OPTIONS_SERVER_VISIBLE,
OPTIONS_BAR_ON_TOP,
OPTIONS_ALLOW_SPRINT,
OPTIONS_AUTOJUMP,
// Graphics
OPTIONS_RENDER_DEBUG,
OPTIONS_SMOOTH_CAMERA,
OPTIONS_FIXED_CAMERA,
OPTIONS_VIEW_DISTANCE,
OPTIONS_VIEW_BOBBING,
OPTIONS_AMBIENT_OCCLUSION,
OPTIONS_ANAGLYPH_3D,
OPTIONS_LIMIT_FRAMERATE,
OPTIONS_VSYNC,
OPTIONS_FANCY_GRAPHICS,
// Cheats / debug
OPTIONS_FLY_SPEED,
OPTIONS_CAMERA_SPEED,
OPTIONS_IS_FLYING,
// Control
OPTIONS_USE_MOUSE_FOR_DIGGING,
OPTIONS_IS_LEFT_HANDED,
OPTIONS_IS_JOY_TOUCH_AREA,
OPTIONS_SENSITIVITY,
OPTIONS_INVERT_Y_MOUSE,
OPTIONS_USE_TOUCHSCREEN,
OPTIONS_KEY_FORWARD,
OPTIONS_KEY_LEFT,
OPTIONS_KEY_BACK,
OPTIONS_KEY_RIGHT,
OPTIONS_KEY_JUMP,
OPTIONS_KEY_INVENTORY,
OPTIONS_KEY_SNEAK,
OPTIONS_KEY_DROP,
OPTIONS_KEY_CHAT,
OPTIONS_KEY_FOG,
OPTIONS_KEY_USE,
OPTIONS_KEY_MENU_NEXT,
OPTIONS_KEY_MENU_PREV,
OPTIONS_KEY_MENU_OK,
OPTIONS_KEY_MENU_CANCEL,
OPTIONS_FIRST_LAUNCH,
OPTIONS_LAST_IP,
OPTIONS_RPI_CURSOR,
// Should be last!
OPTIONS_COUNT
};
class MinecraftClient;
typedef std::vector<std::string> StringVector;
class Options
{
public:
static bool debugGl;
Options(MinecraftClient& minecraft, const std::string& workingDirectory = "")
: minecraft(minecraft) {
// elements werent initialized so i was getting a garbage pointer and a crash
m_options.fill(nullptr);
initTable();
// load() is deferred to init() where path is configured correctly
}
void initTable();
int getIntValue(OptionId key) {
auto option = opt<OptionInt>(key);
return (option)? option->get() : 0;
}
std::string getStringValue(OptionId key) {
auto option = opt<OptionString>(key);
return (option)? option->get() : "";
}
float getProgressValue(OptionId key) {
auto option = opt<OptionFloat>(key);
return (option)? option->get() : 0.f;
}
bool getBooleanValue(OptionId key) {
auto option = opt<OptionBool>(key);
return (option)? option->get() : false;
}
float getProgrssMin(OptionId key) {
auto option = opt<OptionFloat>(key);
return (option)? option->getMin() : 0.f;
}
float getProgrssMax(OptionId key) {
auto option = opt<OptionFloat>(key);
return (option)? option->getMax() : 0.f;
}
Option* getOpt(OptionId id) { return m_options[id]; }
void load();
void save();
void set(OptionId key, int value);
void set(OptionId key, float value);
void set(OptionId key, const std::string& value);
void setOptionsFilePath(const std::string& path);
void toggle(OptionId key);
void notifyOptionUpdate(OptionId key, bool value);
void notifyOptionUpdate(OptionId key, float value);
void notifyOptionUpdate(OptionId key, int value);
void notifyOptionUpdate(OptionId key, const std::string& value) {}
private:
template<typename T>
T* opt(OptionId key) {
if (m_options[key] == nullptr) return nullptr;
return dynamic_cast<T*>(m_options[key]);
}
std::array<Option*, OPTIONS_COUNT> m_options;
OptionsFile optionsFile;
MinecraftClient& minecraft;
};

View File

@@ -1,21 +1,19 @@
#ifndef NET_MINECRAFT_CLIENT__OptionsFile_H__
#define NET_MINECRAFT_CLIENT__OptionsFile_H__
//package net.minecraft.client;
#include <string>
#include <vector>
typedef std::vector<std::string> StringVector;
class OptionsFile
{
public:
OptionsFile();
void save(const StringVector& settings);
StringVector getOptionStrings();
void setOptionsPath(const std::string& path);
std::string getOptionsPath() const;
private:
std::string settingsPath;
};
#endif /* NET_MINECRAFT_CLIENT__OptionsFile_H__ */
#pragma once
//package net.minecraft.client;
#include <string>
#include <vector>
typedef std::vector<std::string> StringVector;
class OptionsFile
{
public:
OptionsFile();
void save(const StringVector& settings);
StringVector getOptionStrings();
void setOptionsPath(const std::string& path);
std::string getOptionsPath() const;
private:
std::string settingsPath;
};

View File

@@ -1,124 +1,122 @@
#ifndef NET_MINECRAFT_CLIENT__Timer_H__
#define NET_MINECRAFT_CLIENT__Timer_H__
//package net.minecraft.client;
#include "../platform/time.h"
class Timer
{
public:
Timer(float ticksPerSecond)
: ticksPerSecond(ticksPerSecond),
adjustTime(1.0f),
timeScale(1.0f),
passedTime(0)
{
lastMs = getTimeMs();
lastMsSysTime = lastMs;
lastTime = lastMs / 1000.0f;
}
void advanceTime() {
long nowMs = getTimeMs();
long passedMs = nowMs - lastMs;
long msSysTime = nowMs;//System.nanoTime() / 1000000;
if (passedMs > 1000) {
long passedMsSysTime = msSysTime - lastMsSysTime;
if (passedMsSysTime == 0)
passedMs = passedMsSysTime = 1;
float adjustTimeT = passedMs / (float) passedMsSysTime;
adjustTime += (adjustTimeT - adjustTime) * 0.2f;
lastMs = nowMs;
lastMsSysTime = msSysTime;
}
if (passedMs < 0) {
lastMs = nowMs;
lastMsSysTime = msSysTime;
}
float now = msSysTime / 1000.0f;
float passedSeconds = (now - lastTime) * adjustTime;
lastTime = now;
if (passedSeconds < 0) passedSeconds = 0;
if (passedSeconds > 1) passedSeconds = 1;
//LOGI("passed s: %f\n", passedSeconds);
passedTime += passedSeconds * timeScale * ticksPerSecond;
ticks = (int) passedTime;
passedTime -= ticks;
if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE;
a = passedTime;
}
/**
* Advances time the max number of ticks per second.
*/
void advanceTimeQuickly() {
float passedSeconds = (float) MAX_TICKS_PER_UPDATE / (float) ticksPerSecond;
passedTime += passedSeconds * timeScale * ticksPerSecond;
ticks = (int) passedTime;
passedTime -= ticks;
a = passedTime;
lastMs = getTimeMs();//System.currentTimeMillis();
lastMsSysTime = lastMs;
}
void skipTime() {
long nowMs = getTimeMs();//System.currentTimeMillis();
long passedMs = nowMs - lastMs;
long msSysTime = nowMs;//System.nanoTime() / 1000000;
if (passedMs > 1000) {
long passedMsSysTime = msSysTime - lastMsSysTime;
if (passedMsSysTime == 0)
passedMs = passedMsSysTime = 1;
float adjustTimeT = passedMs / (float) passedMsSysTime;
adjustTime += (adjustTimeT - adjustTime) * 0.2f;
lastMs = nowMs;
lastMsSysTime = msSysTime;
}
if (passedMs < 0) {
lastMs = nowMs;
lastMsSysTime = msSysTime;
}
float now = msSysTime / 1000.0f;
float passedSeconds = (now - lastTime) * adjustTime;
lastTime = now;
if (passedSeconds < 0) passedSeconds = 0;
if (passedSeconds > 1) passedSeconds = 1;
passedTime += passedSeconds * timeScale * ticksPerSecond;
ticks = (int) 0;
if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE;
passedTime -= ticks;
}
public:
float ticksPerSecond;
int ticks;
float a;
float timeScale;
float passedTime;
private:
static const int MAX_TICKS_PER_UPDATE = 10;
float lastTime;
long lastMs;
long lastMsSysTime;
float adjustTime;
};
#endif /*NET_MINECRAFT_CLIENT__Timer_H__*/
#pragma once
//package net.minecraft.client;
#include "../platform/time.h"
class Timer
{
public:
Timer(float ticksPerSecond)
: ticksPerSecond(ticksPerSecond),
adjustTime(1.0f),
timeScale(1.0f),
passedTime(0)
{
lastMs = getTimeMs();
lastMsSysTime = lastMs;
lastTime = lastMs / 1000.0f;
}
void advanceTime() {
long nowMs = getTimeMs();
long passedMs = nowMs - lastMs;
long msSysTime = nowMs;//System.nanoTime() / 1000000;
if (passedMs > 1000) {
long passedMsSysTime = msSysTime - lastMsSysTime;
if (passedMsSysTime == 0)
passedMs = passedMsSysTime = 1;
float adjustTimeT = passedMs / (float) passedMsSysTime;
adjustTime += (adjustTimeT - adjustTime) * 0.2f;
lastMs = nowMs;
lastMsSysTime = msSysTime;
}
if (passedMs < 0) {
lastMs = nowMs;
lastMsSysTime = msSysTime;
}
float now = msSysTime / 1000.0f;
float passedSeconds = (now - lastTime) * adjustTime;
lastTime = now;
if (passedSeconds < 0) passedSeconds = 0;
if (passedSeconds > 1) passedSeconds = 1;
//LOGI("passed s: %f\n", passedSeconds);
passedTime += passedSeconds * timeScale * ticksPerSecond;
ticks = (int) passedTime;
passedTime -= ticks;
if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE;
a = passedTime;
}
/**
* Advances time the max number of ticks per second.
*/
void advanceTimeQuickly() {
float passedSeconds = (float) MAX_TICKS_PER_UPDATE / (float) ticksPerSecond;
passedTime += passedSeconds * timeScale * ticksPerSecond;
ticks = (int) passedTime;
passedTime -= ticks;
a = passedTime;
lastMs = getTimeMs();//System.currentTimeMillis();
lastMsSysTime = lastMs;
}
void skipTime() {
long nowMs = getTimeMs();//System.currentTimeMillis();
long passedMs = nowMs - lastMs;
long msSysTime = nowMs;//System.nanoTime() / 1000000;
if (passedMs > 1000) {
long passedMsSysTime = msSysTime - lastMsSysTime;
if (passedMsSysTime == 0)
passedMs = passedMsSysTime = 1;
float adjustTimeT = passedMs / (float) passedMsSysTime;
adjustTime += (adjustTimeT - adjustTime) * 0.2f;
lastMs = nowMs;
lastMsSysTime = msSysTime;
}
if (passedMs < 0) {
lastMs = nowMs;
lastMsSysTime = msSysTime;
}
float now = msSysTime / 1000.0f;
float passedSeconds = (now - lastTime) * adjustTime;
lastTime = now;
if (passedSeconds < 0) passedSeconds = 0;
if (passedSeconds > 1) passedSeconds = 1;
passedTime += passedSeconds * timeScale * ticksPerSecond;
ticks = (int) 0;
if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE;
passedTime -= ticks;
}
public:
float ticksPerSecond;
int ticks;
float a;
float timeScale;
float passedTime;
private:
static const int MAX_TICKS_PER_UPDATE = 10;
float lastTime;
long lastMs;
long lastMsSysTime;
float adjustTime;
};

View File

@@ -1,63 +1,61 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__Font_H__
#define NET_MINECRAFT_CLIENT_GUI__Font_H__
//package net.minecraft.client.gui;
#include <string>
#include <cctype>
#include "../renderer/gles.h"
class Textures;
class Options;
class Font
{
public:
Font(Options* options, const std::string& name, Textures* textures);
//Font(Options* options, const std::string& name, Textures* textures, int imgW, int imgH, int x, int y, int cols, int rows, unsigned char charOffset);
void init(Options* options);
void onGraphicsReset();
void draw(const char* str, float x, float y, int color);
void draw(const std::string& str, float x, float y, int color);
void draw(const char* str, float x, float y, int color, bool darken);
void draw(const std::string& str, float x, float y, int color, bool darken);
void drawShadow(const std::string& str, float x, float y, int color);
void drawShadow(const char* str, float x, float y, int color);
void drawWordWrap(const std::string& str, float x, float y, float w, int col);
int width(const std::string& str);
int height(const std::string& str);
static std::string sanitize(const std::string& str);
private:
void buildChar(unsigned char i, float x = 0, float y = 0);
void drawSlow(const std::string& str, float x, float y, int color, bool darken = false);
void drawSlow(const char* str, float x, float y, int color, bool darken = false);
public:
int fontTexture;
int lineHeight;
static const int DefaultLineHeight = 10;
private:
int charWidths[256];
float fcharWidths[256];
int listPos;
int index;
int count;
GLuint lists[1024];
std::string fontName;
Textures* _textures;
Options* options;
int _x, _y;
int _cols;
int _rows;
unsigned char _charOffset;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__Font_H__*/
#pragma once
//package net.minecraft.client.gui;
#include <string>
#include <cctype>
#include "../renderer/gles.h"
class Textures;
class Options;
class Font
{
public:
Font(Options* options, const std::string& name, Textures* textures);
//Font(Options* options, const std::string& name, Textures* textures, int imgW, int imgH, int x, int y, int cols, int rows, unsigned char charOffset);
void init(Options* options);
void onGraphicsReset();
void draw(const char* str, float x, float y, int color);
void draw(const std::string& str, float x, float y, int color);
void draw(const char* str, float x, float y, int color, bool darken);
void draw(const std::string& str, float x, float y, int color, bool darken);
void drawShadow(const std::string& str, float x, float y, int color);
void drawShadow(const char* str, float x, float y, int color);
void drawWordWrap(const std::string& str, float x, float y, float w, int col);
int width(const std::string& str);
int height(const std::string& str);
static std::string sanitize(const std::string& str);
private:
void buildChar(unsigned char i, float x = 0, float y = 0);
void drawSlow(const std::string& str, float x, float y, int color, bool darken = false);
void drawSlow(const char* str, float x, float y, int color, bool darken = false);
public:
int fontTexture;
int lineHeight;
static const int DefaultLineHeight = 10;
private:
int charWidths[256];
float fcharWidths[256];
int listPos;
int index;
int count;
GLuint lists[1024];
std::string fontName;
Textures* _textures;
Options* options;
int _x, _y;
int _cols;
int _rows;
unsigned char _charOffset;
};

View File

@@ -1,133 +1,131 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__Gui_H__
#define NET_MINECRAFT_CLIENT_GUI__Gui_H__
//package net.minecraft.client.gui;
#include "GuiComponent.h"
#include "Font.h"
#include "../player/input/touchscreen/TouchAreaModel.h"
#include "../renderer/RenderChunk.h"
#include "../../util/Random.h"
#include "../IConfigListener.h"
class MinecraftClient;
class ItemInstance;
class Textures;
class Tesselator;
struct IntRectangle;
struct GuiMessage
{
std::string message;
int ticks;
};
typedef std::vector<GuiMessage> GuiMessageList;
class Gui: public GuiComponent, IConfigListener
{
public:
Gui(MinecraftClient& minecraft);
~Gui();
int getSlotIdAt(int x, int y);
void flashSlot(int slotId);
bool isInside(int x, int y);
RectangleArea getRectangleArea(int extendSide);
void getSlotPos(int slot, int& posX, int& posY);
int getNumSlots();
void handleClick(int button, int x, int y);
void handleKeyPressed( int key );
void scrollChat(int delta);
void tick();
void render(float a, bool mouseFree, int xMouse, int yMouse);
void renderToolBar( float a, int ySlot, const int screenWidth );
void renderChatMessages( const int screenHeight, unsigned int max, bool isChatting, Font* font );
// draw a string containing simple [color]...[/color] tags; color names are matched
// case-insensitively and default to white. alpha is applied to each segment.
// draw tagged string (ignores simple [color]…[/color] tags)
static void drawColoredString(Font* font, const std::string& text, float x, float y, int alpha);
static float getColoredWidth(Font* font, const std::string& text);
void renderOnSelectItemNameText( const int screenWidth, Font* font, int ySlot );
void renderSleepAnimation( const int screenWidth, const int screenHeight );
void renderBubbles();
void renderHearts();
void renderDebugInfo();
void renderPlayerList(Font* font, int screenWidth, int screenHeight);
void renderProgressIndicator( const bool isTouchInterface, const int screenWidth, const int screenHeight, float a );
void addMessage(const std::string& string);
void clearMessages();
void postError(int errCode);
void onGraphicsReset();
void inventoryUpdated();
void setNowPlaying(const std::string& string);
void displayClientMessage(const std::string& messageId);
void renderSlotText(const ItemInstance* item, float x, float y, bool hasFinite, bool shadow);
void texturesLoaded( Textures* textures );
void onConfigChanged(const Config& config);
void onLevelGenerated();
void setScissorRect(const IntRectangle& rect);
static float floorAlignToScreenPixel(float);
static int itemCountItoa(char* buf, int count);
private:
void renderVignette(float br, int w, int h);
void renderSlot(int slot, int x, int y, float a);
void tickItemDrop();
float cubeSmoothStep(float percentage, float min, float max);
public:
float progress = 0.f;
std::string selectedName;
static float InvGuiScale;
static float GuiScale;
private:
//ItemRenderer itemRenderer;
GuiMessageList guiMessages;
int chatScrollOffset = 0;
Random random;
MinecraftClient& minecraft;
int tickCount = 0;
float itemNameOverlayTime = 2;
std::string overlayMessageString;
int overlayMessageTime = 0;
bool animateOverlayMessageColor = false;
float tbr = 1.f;
RenderChunk _inventoryRc;
bool _inventoryNeedsUpdate = true;
int _flashSlotId = -1;
float _flashSlotStartTime = -1;
Font* _slotFont = nullptr;
int _numSlots = 4;
RenderChunk rcFeedbackOuter;
RenderChunk rcFeedbackInner;
// For dropping
static const float DropTicks;
float _currentDropTicks = -1;
int _currentDropSlot = -1;
bool _openInventorySlot;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__Gui_H__*/
#pragma once
//package net.minecraft.client.gui;
#include "GuiComponent.h"
#include "Font.h"
#include "../player/input/touchscreen/TouchAreaModel.h"
#include "../renderer/RenderChunk.h"
#include "../../util/Random.h"
#include "../IConfigListener.h"
class MinecraftClient;
class ItemInstance;
class Textures;
class Tesselator;
struct IntRectangle;
struct GuiMessage
{
std::string message;
int ticks;
};
typedef std::vector<GuiMessage> GuiMessageList;
class Gui: public GuiComponent, IConfigListener
{
public:
Gui(MinecraftClient& minecraft);
~Gui();
int getSlotIdAt(int x, int y);
void flashSlot(int slotId);
bool isInside(int x, int y);
RectangleArea getRectangleArea(int extendSide);
void getSlotPos(int slot, int& posX, int& posY);
int getNumSlots();
void handleClick(int button, int x, int y);
void handleKeyPressed( int key );
void scrollChat(int delta);
void tick();
void render(float a, bool mouseFree, int xMouse, int yMouse);
void renderToolBar( float a, int ySlot, const int screenWidth );
void renderChatMessages( const int screenHeight, unsigned int max, bool isChatting, Font* font );
// draw a string containing simple [color]...[/color] tags; color names are matched
// case-insensitively and default to white. alpha is applied to each segment.
// draw tagged string (ignores simple [color]…[/color] tags)
static void drawColoredString(Font* font, const std::string& text, float x, float y, int alpha);
static float getColoredWidth(Font* font, const std::string& text);
void renderOnSelectItemNameText( const int screenWidth, Font* font, int ySlot );
void renderSleepAnimation( const int screenWidth, const int screenHeight );
void renderBubbles();
void renderHearts();
void renderDebugInfo();
void renderPlayerList(Font* font, int screenWidth, int screenHeight);
void renderProgressIndicator( const bool isTouchInterface, const int screenWidth, const int screenHeight, float a );
void addMessage(const std::string& string);
void clearMessages();
void postError(int errCode);
void onGraphicsReset();
void inventoryUpdated();
void setNowPlaying(const std::string& string);
void displayClientMessage(const std::string& messageId);
void renderSlotText(const ItemInstance* item, float x, float y, bool hasFinite, bool shadow);
void texturesLoaded( Textures* textures );
void onConfigChanged(const Config& config);
void onLevelGenerated();
void setScissorRect(const IntRectangle& rect);
static float floorAlignToScreenPixel(float);
static int itemCountItoa(char* buf, int count);
private:
void renderVignette(float br, int w, int h);
void renderSlot(int slot, int x, int y, float a);
void tickItemDrop();
float cubeSmoothStep(float percentage, float min, float max);
public:
float progress = 0.f;
std::string selectedName;
static float InvGuiScale;
static float GuiScale;
private:
//ItemRenderer itemRenderer;
GuiMessageList guiMessages;
int chatScrollOffset = 0;
Random random;
MinecraftClient& minecraft;
int tickCount = 0;
float itemNameOverlayTime = 2;
std::string overlayMessageString;
int overlayMessageTime = 0;
bool animateOverlayMessageColor = false;
float tbr = 1.f;
RenderChunk _inventoryRc;
bool _inventoryNeedsUpdate = true;
int _flashSlotId = -1;
float _flashSlotStartTime = -1;
Font* _slotFont = nullptr;
int _numSlots = 4;
RenderChunk rcFeedbackOuter;
RenderChunk rcFeedbackInner;
// For dropping
static const float DropTicks;
float _currentDropTicks = -1;
int _currentDropSlot = -1;
bool _openInventorySlot;
};

View File

@@ -1,34 +1,32 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__GuiComponent_H__
#define NET_MINECRAFT_CLIENT_GUI__GuiComponent_H__
//package net.minecraft.client.gui;
#include <string>
class Font;
class Minecraft;
class GuiComponent
{
public:
GuiComponent();
virtual ~GuiComponent();
void drawString(Font* font, const std::string& str, int x, int y, int color);
void drawCenteredString(Font* font, const std::string& str, int x, int y, int color);
void blit(int x, int y, int sx, int sy, int w, int h, int sw=0, int sh=0);
void blit(float x, float y, int sx, int sy, float w, float h, int sw=0, int sh=0);
protected:
void fill(int x0, int y0, int x1, int y1, int col);
void fill(float x0, float y0, float x1, float y1, int col);
void fillGradient(int x0, int y0, int x1, int y1, int col1, int col2);
void fillGradient(float x0, float y0, float x1, float y1, int col1, int col2);
void fillHorizontalGradient(int x0, int y0, int x1, int y1, int col1, int col2);
void fillHorizontalGradient(float x0, float y0, float x1, float y1, int col1, int col2);
float blitOffset;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__GuiComponent_H__*/
#pragma once
//package net.minecraft.client.gui;
#include <string>
class Font;
class Minecraft;
class GuiComponent
{
public:
GuiComponent();
virtual ~GuiComponent();
void drawString(Font* font, const std::string& str, int x, int y, int color);
void drawCenteredString(Font* font, const std::string& str, int x, int y, int color);
void blit(int x, int y, int sx, int sy, int w, int h, int sw=0, int sh=0);
void blit(float x, float y, int sx, int sy, float w, float h, int sw=0, int sh=0);
protected:
void fill(int x0, int y0, int x1, int y1, int col);
void fill(float x0, float y0, float x1, float y1, int col);
void fillGradient(int x0, int y0, int x1, int y1, int col1, int col2);
void fillGradient(float x0, float y0, float x1, float y1, int col1, int col2);
void fillHorizontalGradient(int x0, int y0, int x1, int y1, int col1, int col2);
void fillHorizontalGradient(float x0, float y0, float x1, float y1, int col1, int col2);
float blitOffset;
};

View File

@@ -1,83 +1,81 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__Screen_H__
#define NET_MINECRAFT_CLIENT_GUI__Screen_H__
//package net.minecraft.client.gui;
#include <vector>
#include "GuiComponent.h"
class Font;
class Minecraft;
class Button;
class TextBox;
struct IntRectangle;
class Screen: public GuiComponent
{
public:
Screen();
virtual void render(int xm, int ym, float a);
void init(Minecraft* minecraft, int width, int height);
virtual void init();
void setSize(int width, int height);
virtual void setupPositions() {};
virtual void updateEvents();
virtual void mouseEvent();
virtual void keyboardEvent();
virtual void keyboardTextEvent();
virtual bool handleBackEvent(bool isDown);
virtual void tick() {}
virtual void removed() {}
virtual void renderBackground();
virtual void renderBackground(int vo);
virtual void renderDirtBackground(int vo);
// query
virtual bool renderGameBehind();
virtual bool hasClippingArea(IntRectangle& out);
virtual bool isPauseScreen();
virtual bool isErrorScreen();
virtual bool isInGameScreen();
virtual bool closeOnPlayerHurt();
virtual void confirmResult(bool result, int id) {}
virtual void lostFocus();
virtual void toGUICoordinate(int& x, int& y);
protected:
void updateTabButtonSelection();
virtual void buttonClicked(Button* button) {}
virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseReleased(int x, int y, int buttonNum);
// mouse wheel movement (dx/dy are wheel deltas, xm/ym are GUI coords)
virtual void mouseWheel(int dx, int dy, int xm, int ym) {}
virtual void keyPressed(int eventKey);
virtual void charPressed(char inputChar);
public:
int width;
int height;
bool passEvents;
//GuiParticles* particles;
protected:
Minecraft* minecraft;
std::vector<Button*> buttons;
std::vector<TextBox*> textBoxes;
std::vector<Button*> tabButtons;
int tabButtonIndex;
Font* font;
private:
Button* clickedButton;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__Screen_H__*/
#pragma once
//package net.minecraft.client.gui;
#include <vector>
#include "GuiComponent.h"
class Font;
class Minecraft;
class Button;
class TextBox;
struct IntRectangle;
class Screen: public GuiComponent
{
public:
Screen();
virtual void render(int xm, int ym, float a);
void init(Minecraft* minecraft, int width, int height);
virtual void init();
void setSize(int width, int height);
virtual void setupPositions() {};
virtual void updateEvents();
virtual void mouseEvent();
virtual void keyboardEvent();
virtual void keyboardTextEvent();
virtual bool handleBackEvent(bool isDown);
virtual void tick() {}
virtual void removed() {}
virtual void renderBackground();
virtual void renderBackground(int vo);
virtual void renderDirtBackground(int vo);
// query
virtual bool renderGameBehind();
virtual bool hasClippingArea(IntRectangle& out);
virtual bool isPauseScreen();
virtual bool isErrorScreen();
virtual bool isInGameScreen();
virtual bool closeOnPlayerHurt();
virtual void confirmResult(bool result, int id) {}
virtual void lostFocus();
virtual void toGUICoordinate(int& x, int& y);
protected:
void updateTabButtonSelection();
virtual void buttonClicked(Button* button) {}
virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseReleased(int x, int y, int buttonNum);
// mouse wheel movement (dx/dy are wheel deltas, xm/ym are GUI coords)
virtual void mouseWheel(int dx, int dy, int xm, int ym) {}
virtual void keyPressed(int eventKey);
virtual void charPressed(char inputChar);
public:
int width;
int height;
bool passEvents;
//GuiParticles* particles;
protected:
Minecraft* minecraft;
std::vector<Button*> buttons;
std::vector<TextBox*> textBoxes;
std::vector<Button*> tabButtons;
int tabButtonIndex;
Font* font;
private:
Button* clickedButton;
};

View File

@@ -1,11 +1,9 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__TweenData_H__
#define NET_MINECRAFT_CLIENT_GUI__TweenData_H__
typedef struct TweenData {
float cur;
float dur;
float start;
float stop;
} TweenData;
#endif /*NET_MINECRAFT_CLIENT_GUI__TweenData_H__*/
#pragma once
typedef struct TweenData {
float cur;
float dur;
float start;
float stop;
} TweenData;

View File

@@ -1,80 +1,78 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Button_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Button_H__
//package net.minecraft.client.gui;
#include <string>
#include "GuiElement.h"
#include "../../Options.h"
class Font;
class Minecraft;
class Button: public GuiElement
{
public:
Button(int id, const std::string& msg);
Button(int id, int x, int y, const std::string& msg);
Button(int id, int x, int y, int w, int h, const std::string& msg);
virtual ~Button() {}
virtual void render(Minecraft* minecraft, int xm, int ym);
virtual bool clicked(Minecraft* minecraft, int mx, int my);
virtual void released(int mx, int my);
virtual void setPressed();
bool isInside(int xm, int ym);
protected:
virtual int getYImage(bool hovered);
virtual void renderBg(Minecraft* minecraft, int xm, int ym);
virtual void renderFace(Minecraft* minecraft, int xm, int ym);
bool hovered(Minecraft* minecraft, int xm, int ym);
public:
std::string msg;
int id;
bool selected;
protected:
bool _currentlyDown;
};
// @note: A bit backwards, but this is a button that
// only reacts to clicks, but isn't rendered.
class BlankButton: public Button
{
typedef Button super;
public:
BlankButton(int id);
BlankButton(int id, int x, int y, int w, int h);
};
namespace Touch {
class TButton: public Button
{
typedef Button super;
public:
TButton(int id, const std::string& msg);
TButton(int id, int x, int y, const std::string& msg);
TButton(int id, int x, int y, int w, int h, const std::string& msg);
protected:
virtual void renderBg(Minecraft* minecraft, int xm, int ym);
};
// "Header" in Touchscreen mode
class THeader: public Button {
typedef Button super;
public:
THeader(int id, const std::string& msg);
THeader(int id, int x, int y, const std::string& msg);
THeader(int id, int x, int y, int w, int h, const std::string& msg);
protected:
virtual void renderBg(Minecraft* minecraft, int xm, int ym);
void render( Minecraft* minecraft, int xm, int ym );
public:
int xText;
};
}
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Button_H__*/
#pragma once
//package net.minecraft.client.gui;
#include <string>
#include "GuiElement.h"
#include "../../Options.h"
class Font;
class Minecraft;
class Button: public GuiElement
{
public:
Button(int id, const std::string& msg);
Button(int id, int x, int y, const std::string& msg);
Button(int id, int x, int y, int w, int h, const std::string& msg);
virtual ~Button() {}
virtual void render(Minecraft* minecraft, int xm, int ym);
virtual bool clicked(Minecraft* minecraft, int mx, int my);
virtual void released(int mx, int my);
virtual void setPressed();
bool isInside(int xm, int ym);
protected:
virtual int getYImage(bool hovered);
virtual void renderBg(Minecraft* minecraft, int xm, int ym);
virtual void renderFace(Minecraft* minecraft, int xm, int ym);
bool hovered(Minecraft* minecraft, int xm, int ym);
public:
std::string msg;
int id;
bool selected;
protected:
bool _currentlyDown;
};
// @note: A bit backwards, but this is a button that
// only reacts to clicks, but isn't rendered.
class BlankButton: public Button
{
typedef Button super;
public:
BlankButton(int id);
BlankButton(int id, int x, int y, int w, int h);
};
namespace Touch {
class TButton: public Button
{
typedef Button super;
public:
TButton(int id, const std::string& msg);
TButton(int id, int x, int y, const std::string& msg);
TButton(int id, int x, int y, int w, int h, const std::string& msg);
protected:
virtual void renderBg(Minecraft* minecraft, int xm, int ym);
};
// "Header" in Touchscreen mode
class THeader: public Button {
typedef Button super;
public:
THeader(int id, const std::string& msg);
THeader(int id, int x, int y, const std::string& msg);
THeader(int id, int x, int y, int w, int h, const std::string& msg);
protected:
virtual void renderBg(Minecraft* minecraft, int xm, int ym);
void render( Minecraft* minecraft, int xm, int ym );
public:
int xText;
};
}

View File

@@ -1,55 +1,53 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__GButton_H__
#define NET_MINECRAFT_CLIENT_GUI__GButton_H__
#include "Button.h"
class GButton: public Button {
typedef Button super;
public:
static const int LayerDefault = 1;
static const int LayerSelected = 2;
static const int LayerMax = 4;
GButton(int id)
: super(id, "")
{}
~GButton() {
for (unsigned int i = 0; i < layers.size(); ++i) {
delete layers[i].first;
}
}
void addElement(int layerId, GuiElement* e) {
if (!e || layerId < 0 || layerId >= LayerMax) {
LOGE("Error @ GButton::element : Trying to add element %p at layer: %d\n", e, layerId);
return;
}
layers.push_back(std::make_pair(e, layerId));
}
void render( Minecraft* minecraft, int xm, int ym )
{
if (!visible) return;
bool isHovered = minecraft->isTouchscreen()?
(_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height): false;
int layer = isHovered? LayerSelected : LayerDefault;
if (layer < 0) return;
Tesselator& t = Tesselator::instance;
t.addOffset((float)x, (float)y, 0);
for (unsigned int i = 0; i < layers.size(); ++i) {
if ((layers[i].second & layer) != 0)
layers[i].first->render(minecraft, 0, 0);
}
t.addOffset((float)-x, (float)-y, 0);
}
private:
std::vector<std::pair<GuiElement*, int> > layers;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__GButton_H__*/
#pragma once
#include "Button.h"
class GButton: public Button {
typedef Button super;
public:
static const int LayerDefault = 1;
static const int LayerSelected = 2;
static const int LayerMax = 4;
GButton(int id)
: super(id, "")
{}
~GButton() {
for (unsigned int i = 0; i < layers.size(); ++i) {
delete layers[i].first;
}
}
void addElement(int layerId, GuiElement* e) {
if (!e || layerId < 0 || layerId >= LayerMax) {
LOGE("Error @ GButton::element : Trying to add element %p at layer: %d\n", e, layerId);
return;
}
layers.push_back(std::make_pair(e, layerId));
}
void render( Minecraft* minecraft, int xm, int ym )
{
if (!visible) return;
bool isHovered = minecraft->isTouchscreen()?
(_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height): false;
int layer = isHovered? LayerSelected : LayerDefault;
if (layer < 0) return;
Tesselator& t = Tesselator::instance;
t.addOffset((float)x, (float)y, 0);
for (unsigned int i = 0; i < layers.size(); ++i) {
if ((layers[i].second & layer) != 0)
layers[i].first->render(minecraft, 0, 0);
}
t.addOffset((float)-x, (float)-y, 0);
}
private:
std::vector<std::pair<GuiElement*, int> > layers;
};

View File

@@ -1,34 +1,32 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__GuiElement_H__
#define NET_MINECRAFT_CLIENT_GUI__GuiElement_H__
#include "../GuiComponent.h"
class Tesselator;
class Minecraft;
class GuiElement : public GuiComponent {
public:
GuiElement(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
virtual ~GuiElement() {}
virtual void tick(Minecraft* minecraft) {}
virtual void render(Minecraft* minecraft, int xm, int ym) { }
virtual void setupPositions() {}
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {}
virtual void mouseReleased(Minecraft* minecraft, int x, int y, int buttonNum) {}
virtual void keyPressed(Minecraft* minecraft, int key) {}
virtual void charPressed(Minecraft* minecraft, char key) {}
virtual bool pointInside(int x, int y);
void setVisible(bool visible);
bool active;
bool visible;
int x;
int y;
int width;
int height;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__GuiElement_H__*/
#pragma once
#include "../GuiComponent.h"
class Tesselator;
class Minecraft;
class GuiElement : public GuiComponent {
public:
GuiElement(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
virtual ~GuiElement() {}
virtual void tick(Minecraft* minecraft) {}
virtual void render(Minecraft* minecraft, int xm, int ym) { }
virtual void setupPositions() {}
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {}
virtual void mouseReleased(Minecraft* minecraft, int x, int y, int buttonNum) {}
virtual void keyPressed(Minecraft* minecraft, int key) {}
virtual void charPressed(Minecraft* minecraft, char key) {}
virtual bool pointInside(int x, int y);
void setVisible(bool visible);
bool active;
bool visible;
int x;
int y;
int width;
int height;
};

View File

@@ -1,28 +1,26 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__GuiElementContainer_H__
#define NET_MINECRAFT_CLIENT_GUI__GuiElementContainer_H__
#include "GuiElement.h"
#include <vector>
class Tesselator;
class Minecraft;
class GuiElementContainer : public GuiElement {
public:
GuiElementContainer(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
virtual ~GuiElementContainer();
virtual void render(Minecraft* minecraft, int xm, int ym);
virtual void setupPositions();
virtual void addChild(GuiElement* element);
virtual void removeChild(GuiElement* element);
virtual void tick( Minecraft* minecraft );
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void keyPressed(Minecraft* minecraft, int key);
virtual void charPressed(Minecraft* minecraft, char key);
protected:
std::vector<GuiElement*> children;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__GuiElementContainer_H__*/
#pragma once
#include "GuiElement.h"
#include <vector>
class Tesselator;
class Minecraft;
class GuiElementContainer : public GuiElement {
public:
GuiElementContainer(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
virtual ~GuiElementContainer();
virtual void render(Minecraft* minecraft, int xm, int ym);
virtual void setupPositions();
virtual void addChild(GuiElement* element);
virtual void removeChild(GuiElement* element);
virtual void tick( Minecraft* minecraft );
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void keyPressed(Minecraft* minecraft, int key);
virtual void charPressed(Minecraft* minecraft, char key);
protected:
std::vector<GuiElement*> children;
};

View File

@@ -1,97 +1,95 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ImageButton_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ImageButton_H__
#include "Button.h"
typedef struct IntRectangle {
IntRectangle()
: x(0),
y(0),
w(1),
h(1)
{}
IntRectangle(int x, int y, int w, int h)
: x(x),
y(y),
w(w),
h(h)
{}
int x, y;
int w, h;
} IntRectangle;
typedef struct ImageDef {
ImageDef()
: hasSrc(false),
x(0),
y(0),
width(16),
height(16)
{}
std::string name;
int x;
int y;
float width;
float height;
ImageDef& setSrc(const IntRectangle& srcRect) {
hasSrc = true;
src = srcRect;
return *this;
}
IntRectangle* getSrc() {
return hasSrc? &src : NULL;
}
protected:
IntRectangle src;
bool hasSrc;
} ImageDef;
class ImageButton: public Button
{
typedef Button super;
public:
ImageButton(int id, const std::string& msg);
ImageButton(int id, const std::string& msg, const ImageDef& imageDef);
void setImageDef(const ImageDef& imageDef, bool setButtonSize);
void render(Minecraft* minecraft, int xm, int ym);
void renderBg(Minecraft* minecraft, int xm, int ym) {}
protected:
virtual void setupDefault();
virtual bool isSecondImage(bool hovered) { return hovered; }
ImageDef _imageDef;
public:
bool scaleWhenPressed;
};
//
// A toggleable Button
//
class OptionButton: public ImageButton
{
typedef ImageButton super;
public:
OptionButton(OptionId optId);
void toggle(Options* options);
void updateImage(Options* options);
static const int ButtonId = 9999999;
protected:
bool isSecondImage(bool hovered) { return _secondImage; }
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
private:
OptionId m_optId;
bool _secondImage;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ImageButton_H__*/
#pragma once
#include "Button.h"
typedef struct IntRectangle {
IntRectangle()
: x(0),
y(0),
w(1),
h(1)
{}
IntRectangle(int x, int y, int w, int h)
: x(x),
y(y),
w(w),
h(h)
{}
int x, y;
int w, h;
} IntRectangle;
typedef struct ImageDef {
ImageDef()
: hasSrc(false),
x(0),
y(0),
width(16),
height(16)
{}
std::string name;
int x;
int y;
float width;
float height;
ImageDef& setSrc(const IntRectangle& srcRect) {
hasSrc = true;
src = srcRect;
return *this;
}
IntRectangle* getSrc() {
return hasSrc? &src : NULL;
}
protected:
IntRectangle src;
bool hasSrc;
} ImageDef;
class ImageButton: public Button
{
typedef Button super;
public:
ImageButton(int id, const std::string& msg);
ImageButton(int id, const std::string& msg, const ImageDef& imageDef);
void setImageDef(const ImageDef& imageDef, bool setButtonSize);
void render(Minecraft* minecraft, int xm, int ym);
void renderBg(Minecraft* minecraft, int xm, int ym) {}
protected:
virtual void setupDefault();
virtual bool isSecondImage(bool hovered) { return hovered; }
ImageDef _imageDef;
public:
bool scaleWhenPressed;
};
//
// A toggleable Button
//
class OptionButton: public ImageButton
{
typedef ImageButton super;
public:
OptionButton(OptionId optId);
void toggle(Options* options);
void updateImage(Options* options);
static const int ButtonId = 9999999;
protected:
bool isSecondImage(bool hovered) { return _secondImage; }
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
private:
OptionId m_optId;
bool _secondImage;
};

View File

@@ -1,62 +1,60 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__InventoryPane_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__InventoryPane_H__
#include "ScrollingPane.h"
#include "ImageButton.h"
class Minecraft;
class ItemInstance;
class Font;
class IArea;
namespace Touch {
class IInventoryPaneCallback;
class InventoryPane: public ScrollingPane
{
typedef ScrollingPane super;
public:
InventoryPane(IInventoryPaneCallback* screen, Minecraft* mc, const IntRectangle& rect, int paneWidth, float clickMarginH, int numItems, int itemSize, int itemBorderSize);
~InventoryPane();
void tick();
void renderBatch( std::vector<GridItem>& item, float alpha );
bool onSelect( int gridId, bool selected );
void drawScrollBar( ScrollBar& hScroll );
void setRenderDecorations(bool value);
IntRectangle rect;
int paneWidth;
IArea* _clickArea;
IInventoryPaneCallback* screen;
Minecraft* mc;
int fillMarginX;
int fillMarginY;
int markerType;
int markerIndex;
float markerShare;
private:
int lastItemIndex;
int lastItemTicks;
int BorderPixels;
bool renderDecorations;
IntRectangle bg;
};
class IInventoryPaneCallback
{
public:
virtual ~IInventoryPaneCallback() {}
virtual bool addItem(const InventoryPane* forPane, int index) = 0;
virtual bool isAllowed( int slot ) = 0;
virtual std::vector<const ItemInstance*> getItems(const InventoryPane* forPane) = 0;
};
}
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__InventoryPane_H__*/
#pragma once
#include "ScrollingPane.h"
#include "ImageButton.h"
class Minecraft;
class ItemInstance;
class Font;
class IArea;
namespace Touch {
class IInventoryPaneCallback;
class InventoryPane: public ScrollingPane
{
typedef ScrollingPane super;
public:
InventoryPane(IInventoryPaneCallback* screen, Minecraft* mc, const IntRectangle& rect, int paneWidth, float clickMarginH, int numItems, int itemSize, int itemBorderSize);
~InventoryPane();
void tick();
void renderBatch( std::vector<GridItem>& item, float alpha );
bool onSelect( int gridId, bool selected );
void drawScrollBar( ScrollBar& hScroll );
void setRenderDecorations(bool value);
IntRectangle rect;
int paneWidth;
IArea* _clickArea;
IInventoryPaneCallback* screen;
Minecraft* mc;
int fillMarginX;
int fillMarginY;
int markerType;
int markerIndex;
float markerShare;
private:
int lastItemIndex;
int lastItemTicks;
int BorderPixels;
bool renderDecorations;
IntRectangle bg;
};
class IInventoryPaneCallback
{
public:
virtual ~IInventoryPaneCallback() {}
virtual bool addItem(const InventoryPane* forPane, int index) = 0;
virtual bool isAllowed( int slot ) = 0;
virtual std::vector<const ItemInstance*> getItems(const InventoryPane* forPane) = 0;
};
}

View File

@@ -1,95 +1,93 @@
#ifndef ITEMPANE_H__
#define ITEMPANE_H__
#include <string>
#include <vector>
#include "ScrollingPane.h"
#include "../../../world/item/ItemInstance.h"
class Font;
class Textures;
class NinePatchLayer;
class Recipe;
class ItemPane;
class CItem
{
public:
CItem(const ItemInstance& ins, Recipe* recipe, const std::string& text)
: item(ins),
recipe(recipe),
text(text),
sortText(text),
//maxBuildCount(0),
numBuilt(0),
inventoryCount(0),
_canCraft(false)
{
}
typedef struct ReqItem {
ReqItem() {}
ReqItem(const ItemInstance& needItem, int has)
: item(needItem), has(has) {}
ItemInstance item;
int has;
bool enough() { return has >= item.count; }
} ReqItem;
bool canCraft() {
return _canCraft;// || maxBuildCount > 0;
}
void setCanCraft(bool status) {
_canCraft = status;
}
ItemInstance item;
Recipe* recipe;
std::string text;
std::string sortText;
//int maxBuildCount;
int numBuilt;
int inventoryCount;
std::vector<ReqItem> neededItems;
private:
bool _canCraft;
};
class IItemPaneCallback
{
public:
virtual ~IItemPaneCallback() {}
virtual void onItemSelected(const ItemPane* forPane, int index) = 0;
virtual const std::vector<CItem*>& getItems(const ItemPane* forPane) = 0;
};
class ItemPane: public ScrollingPane
{
typedef ScrollingPane super;
public:
ItemPane( IItemPaneCallback* screen,
Textures* textures,
const IntRectangle& rect,
int numItems,
int guiHeight,
int physicalScreenHeight,
bool isVertical = true);
~ItemPane();
void renderBatch( std::vector<GridItem>& item, float alpha );
bool onSelect( int gridId, bool selected );
void drawScrollBar( ScrollBar& hScroll );
//void setSize()
Font* f;
Textures* textures;
IItemPaneCallback* screen;
int physicalScreenHeight; // Needed for glScissor
bool isVertical;
NinePatchLayer* guiSlotItem;
NinePatchLayer* guiSlotItemSelected;
};
#endif /*ITEMPANE_H__*/
#pragma once
#include <string>
#include <vector>
#include "ScrollingPane.h"
#include "../../../world/item/ItemInstance.h"
class Font;
class Textures;
class NinePatchLayer;
class Recipe;
class ItemPane;
class CItem
{
public:
CItem(const ItemInstance& ins, Recipe* recipe, const std::string& text)
: item(ins),
recipe(recipe),
text(text),
sortText(text),
//maxBuildCount(0),
numBuilt(0),
inventoryCount(0),
_canCraft(false)
{
}
typedef struct ReqItem {
ReqItem() {}
ReqItem(const ItemInstance& needItem, int has)
: item(needItem), has(has) {}
ItemInstance item;
int has;
bool enough() { return has >= item.count; }
} ReqItem;
bool canCraft() {
return _canCraft;// || maxBuildCount > 0;
}
void setCanCraft(bool status) {
_canCraft = status;
}
ItemInstance item;
Recipe* recipe;
std::string text;
std::string sortText;
//int maxBuildCount;
int numBuilt;
int inventoryCount;
std::vector<ReqItem> neededItems;
private:
bool _canCraft;
};
class IItemPaneCallback
{
public:
virtual ~IItemPaneCallback() {}
virtual void onItemSelected(const ItemPane* forPane, int index) = 0;
virtual const std::vector<CItem*>& getItems(const ItemPane* forPane) = 0;
};
class ItemPane: public ScrollingPane
{
typedef ScrollingPane super;
public:
ItemPane( IItemPaneCallback* screen,
Textures* textures,
const IntRectangle& rect,
int numItems,
int guiHeight,
int physicalScreenHeight,
bool isVertical = true);
~ItemPane();
void renderBatch( std::vector<GridItem>& item, float alpha );
bool onSelect( int gridId, bool selected );
void drawScrollBar( ScrollBar& hScroll );
//void setSize()
Font* f;
Textures* textures;
IItemPaneCallback* screen;
int physicalScreenHeight; // Needed for glScissor
bool isVertical;
NinePatchLayer* guiSlotItem;
NinePatchLayer* guiSlotItemSelected;
};

View File

@@ -1,21 +1,19 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__LargeImageButton_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__LargeImageButton_H__
#include "ImageButton.h"
class LargeImageButton: public ImageButton
{
typedef ImageButton super;
public:
LargeImageButton(int id, const std::string& msg);
LargeImageButton(int id, const std::string& msg, ImageDef& imageDef);
void render(Minecraft* minecraft, int xm, int ym);
private:
void setupDefault();
float _buttonScale;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__LargeImageButton_H__*/
#pragma once
#include "ImageButton.h"
class LargeImageButton: public ImageButton
{
typedef ImageButton super;
public:
LargeImageButton(int id, const std::string& msg);
LargeImageButton(int id, const std::string& msg, ImageDef& imageDef);
void render(Minecraft* minecraft, int xm, int ym);
private:
void setupDefault();
float _buttonScale;
};

View File

@@ -1,78 +1,76 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__NinePatch_H__
#define NET_MINECRAFT_CLIENT_GUI__NinePatch_H__
#include "ImageButton.h"
#include "../../renderer/TextureData.h"
#include "../../renderer/Textures.h"
#include "../../renderer/Tesselator.h"
#include "../../Minecraft.h"
class Tesselator;
class NinePatchDescription {
public:
NinePatchDescription& transformUVForImage(const TextureData& d);
NinePatchDescription& transformUVForImageSize(int w, int h);
float u0, u1, u2, u3;
float v0, v1, v2, v3;
float w, e, n, s;
static NinePatchDescription createSymmetrical(int texWidth, int texHeight, const IntRectangle& src, int xCutAt, int yCutAt);
private:
NinePatchDescription( float x, float y, float x1, float x2, float x3, float y1, float y2, float y3,
float w, float e, float n, float s);
int imgW;
int imgH;
};
class NinePatchLayer: public GuiElement
{
struct CachedQuad;
public:
NinePatchLayer(const NinePatchDescription& desc, const std::string& imageName, Textures* textures, float w = 32, float h = 32);
virtual ~NinePatchLayer() {};
void setSize(float w, float h);
void draw(Tesselator& t, float x, float y);
NinePatchLayer* exclude(int excludeId);
NinePatchLayer* setExcluded(int exludeBits);
float getWidth() { return w; }
float getHeight() { return h; }
private:
void buildQuad(int qid);
void getPatchInfo(int xc, int yc, float& x0, float& x1, float& y0, float& y1);
void d(Tesselator& t, const CachedQuad& q);
float w, h;
NinePatchDescription desc;
std::string imageName;
Textures* textures;
int excluded;
typedef struct CachedQuad {
float x0, x1, y0, y1, z;
float u0, u1, v0, v1;
} CachedQuad;
CachedQuad quads[9];
};
class NinePatchFactory {
public:
NinePatchFactory(Textures* textures, const std::string& imageName );
NinePatchLayer* createSymmetrical(const IntRectangle& src, int xCutAt, int yCutAt, float w = 32.0f, float h = 32.0f);
private:
Textures* textures;
std::string imageName;
int width;
int height;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__NinePatch_H__*/
#pragma once
#include "ImageButton.h"
#include "../../renderer/TextureData.h"
#include "../../renderer/Textures.h"
#include "../../renderer/Tesselator.h"
#include "../../Minecraft.h"
class Tesselator;
class NinePatchDescription {
public:
NinePatchDescription& transformUVForImage(const TextureData& d);
NinePatchDescription& transformUVForImageSize(int w, int h);
float u0, u1, u2, u3;
float v0, v1, v2, v3;
float w, e, n, s;
static NinePatchDescription createSymmetrical(int texWidth, int texHeight, const IntRectangle& src, int xCutAt, int yCutAt);
private:
NinePatchDescription( float x, float y, float x1, float x2, float x3, float y1, float y2, float y3,
float w, float e, float n, float s);
int imgW;
int imgH;
};
class NinePatchLayer: public GuiElement
{
struct CachedQuad;
public:
NinePatchLayer(const NinePatchDescription& desc, const std::string& imageName, Textures* textures, float w = 32, float h = 32);
virtual ~NinePatchLayer() {};
void setSize(float w, float h);
void draw(Tesselator& t, float x, float y);
NinePatchLayer* exclude(int excludeId);
NinePatchLayer* setExcluded(int exludeBits);
float getWidth() { return w; }
float getHeight() { return h; }
private:
void buildQuad(int qid);
void getPatchInfo(int xc, int yc, float& x0, float& x1, float& y0, float& y1);
void d(Tesselator& t, const CachedQuad& q);
float w, h;
NinePatchDescription desc;
std::string imageName;
Textures* textures;
int excluded;
typedef struct CachedQuad {
float x0, x1, y0, y1, z;
float u0, u1, v0, v1;
} CachedQuad;
CachedQuad quads[9];
};
class NinePatchFactory {
public:
NinePatchFactory(Textures* textures, const std::string& imageName );
NinePatchLayer* createSymmetrical(const IntRectangle& src, int xCutAt, int yCutAt, float w = 32.0f, float h = 32.0f);
private:
Textures* textures;
std::string imageName;
int width;
int height;
};

View File

@@ -1,32 +1,30 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__
//package net.minecraft.client.gui;
#include <string>
#include "GuiElementContainer.h"
#include "ScrollingPane.h"
#include "../../Options.h"
class Font;
class Minecraft;
class OptionsGroup: public GuiElementContainer {
typedef GuiElementContainer super;
public:
OptionsGroup(std::string labelID);
virtual void setupPositions();
virtual void render(Minecraft* minecraft, int xm, int ym);
OptionsGroup& addOptionItem(OptionId optId, Minecraft* minecraft);
protected:
void createToggle(OptionId optId, Minecraft* minecraft);
void createProgressSlider(OptionId optId, Minecraft* minecraft);
void createStepSlider(OptionId optId, Minecraft* minecraft);
void createTextbox(OptionId optId, Minecraft* minecraft);
void createKey(OptionId optId, Minecraft* minecraft);
std::string label;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__*/
#pragma once
//package net.minecraft.client.gui;
#include <string>
#include "GuiElementContainer.h"
#include "ScrollingPane.h"
#include "../../Options.h"
class Font;
class Minecraft;
class OptionsGroup: public GuiElementContainer {
typedef GuiElementContainer super;
public:
OptionsGroup(std::string labelID);
virtual void setupPositions();
virtual void render(Minecraft* minecraft, int xm, int ym);
OptionsGroup& addOptionItem(OptionId optId, Minecraft* minecraft);
protected:
void createToggle(OptionId optId, Minecraft* minecraft);
void createProgressSlider(OptionId optId, Minecraft* minecraft);
void createStepSlider(OptionId optId, Minecraft* minecraft);
void createTextbox(OptionId optId, Minecraft* minecraft);
void createKey(OptionId optId, Minecraft* minecraft);
std::string label;
};

View File

@@ -1,27 +1,25 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsItem_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsItem_H__
#include <string>
#include <vector>
#include "GuiElementContainer.h"
#include "../../../world/item/ItemInstance.h"
#include "../../../client/Options.h"
class Font;
class Textures;
class NinePatchLayer;
class ItemPane;
class OptionsItem: public GuiElementContainer
{
typedef GuiElementContainer super;
public:
OptionsItem(OptionId optionId, std::string label, GuiElement* element);
virtual void render(Minecraft* minecraft, int xm, int ym);
void setupPositions();
private:
OptionId m_optionId;
std::string m_label;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsItem_H__*/
#pragma once
#include <string>
#include <vector>
#include "GuiElementContainer.h"
#include "../../../world/item/ItemInstance.h"
#include "../../../client/Options.h"
class Font;
class Textures;
class NinePatchLayer;
class ItemPane;
class OptionsItem: public GuiElementContainer
{
typedef GuiElementContainer super;
public:
OptionsItem(OptionId optionId, std::string label, GuiElement* element);
virtual void render(Minecraft* minecraft, int xm, int ym);
void setupPositions();
private:
OptionId m_optionId;
std::string m_label;
};

View File

@@ -1,82 +1,80 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListH_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListH_H__
#include "../GuiComponent.h"
class MinecraftClient;
class Tesselator;
class RolledSelectionListH : public GuiComponent
{
static const int NO_DRAG = -1;
static const int DRAG_OUTSIDE = -2;
static const int DRAG_NORMAL = 0;
public:
RolledSelectionListH(MinecraftClient& minecraft, int width, int height, int x0, int x1, int y0, int y1, int itemWidth);
virtual int getItemAtPosition(int x, int y);
virtual bool capXPosition();
virtual void tick();
virtual void render(int xm, int ym, float a);
virtual void renderHoleBackground(/*float x0, float x1,*/ float y0, float y1, int a0, int a1);
virtual void setRenderSelection(bool _renderSelection);
virtual void setComponentSelected(bool selected);
protected:
void setRenderHeader(bool _renderHeader, int _headerHeight);
virtual int getNumberOfItems() = 0;
virtual void selectStart(int item, int localX, int localY) {}
virtual void selectCancel() {}
virtual void selectItem(int item, bool doubleClick) = 0;
virtual bool isSelectedItem(int item) = 0;
virtual int getMaxPosition();
virtual float getPos(float alpha);
virtual void touched();
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) = 0;
virtual void renderHeader(int x, int y, Tesselator& t) {}
virtual void renderBackground() = 0;
virtual void renderDecorations(int mouseX, int mouseY) {}
virtual void clickedHeader(int headerMouseX, int headerMouseY) {}
int getItemAtXPositionRaw(int x);
protected:
MinecraftClient& minecraft;
float x0;
float x1;
int itemWidth;
int width;
int height;
//private:
float y0;
float y1;
int dragState;
float xDrag;
float xo;
float xoo;
float xInertia;
float _xinertia;
int selectionX;
bool renderSelection;
bool _componentSelected;
bool _renderTopBorder;
bool _renderBottomBorder;
private:
int headerWidth;
bool doRenderHeader;
long lastSelectionTime;
int lastSelection;
float _lastxoo;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListH_H__*/
#pragma once
#include "../GuiComponent.h"
class MinecraftClient;
class Tesselator;
class RolledSelectionListH : public GuiComponent
{
static const int NO_DRAG = -1;
static const int DRAG_OUTSIDE = -2;
static const int DRAG_NORMAL = 0;
public:
RolledSelectionListH(MinecraftClient& minecraft, int width, int height, int x0, int x1, int y0, int y1, int itemWidth);
virtual int getItemAtPosition(int x, int y);
virtual bool capXPosition();
virtual void tick();
virtual void render(int xm, int ym, float a);
virtual void renderHoleBackground(/*float x0, float x1,*/ float y0, float y1, int a0, int a1);
virtual void setRenderSelection(bool _renderSelection);
virtual void setComponentSelected(bool selected);
protected:
void setRenderHeader(bool _renderHeader, int _headerHeight);
virtual int getNumberOfItems() = 0;
virtual void selectStart(int item, int localX, int localY) {}
virtual void selectCancel() {}
virtual void selectItem(int item, bool doubleClick) = 0;
virtual bool isSelectedItem(int item) = 0;
virtual int getMaxPosition();
virtual float getPos(float alpha);
virtual void touched();
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) = 0;
virtual void renderHeader(int x, int y, Tesselator& t) {}
virtual void renderBackground() = 0;
virtual void renderDecorations(int mouseX, int mouseY) {}
virtual void clickedHeader(int headerMouseX, int headerMouseY) {}
int getItemAtXPositionRaw(int x);
protected:
MinecraftClient& minecraft;
float x0;
float x1;
int itemWidth;
int width;
int height;
//private:
float y0;
float y1;
int dragState;
float xDrag;
float xo;
float xoo;
float xInertia;
float _xinertia;
int selectionX;
bool renderSelection;
bool _componentSelected;
bool _renderTopBorder;
bool _renderBottomBorder;
private:
int headerWidth;
bool doRenderHeader;
long lastSelectionTime;
int lastSelection;
float _lastxoo;
};

View File

@@ -1,94 +1,92 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListV_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListV_H__
#include "../GuiComponent.h"
class Minecraft;
class Tesselator;
class RolledSelectionListV : public GuiComponent
{
static const int NO_DRAG = -1;
static const int DRAG_OUTSIDE = -2;
static const int DRAG_NORMAL = 0;
public:
RolledSelectionListV(Minecraft* minecraft, int width, int height, int x0, int x1, int y0, int y1, int itemHeight);
virtual int getItemAtPosition(int x, int y);
virtual bool capYPosition();
virtual void tick();
virtual void render(int xm, int ym, float a);
virtual void renderHoleBackground(/*float x0, float x1,*/ float y0, float y1, int a0, int a1);
virtual void setRenderSelection(bool _renderSelection);
virtual void setComponentSelected(bool selected);
protected:
void setRenderHeader(bool _renderHeader, int _headerHeight);
virtual int getNumberOfItems() = 0;
virtual void selectStart(int item) {}
virtual void selectCancel() {}
virtual void selectItem(int item, bool doubleClick) = 0;
virtual bool isSelectedItem(int item) = 0;
virtual int getMaxPosition();
virtual float getPos(float alpha);
virtual void touched();
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) = 0;
virtual void renderHeader(int x, int y, Tesselator& t) {}
virtual void renderBackground() = 0;
virtual void renderForeground() {}
virtual void renderDecorations(int mouseX, int mouseY) {}
virtual void clickedHeader(int headerMouseX, int headerMouseY) {}
virtual int convertSelection(int item, int xm, int ym) { return item; }
int getItemAtYPositionRaw(int y);
void evaluate(int xm, int ym);
virtual void onPreRender();
virtual void onPostRender();
void renderDirtBackground();
protected:
Minecraft* minecraft;
float x0;
float x1;
int itemHeight;
int width;
int height;
//private:
float y0;
float y1;
int dragState;
float yDrag;
float yo;
float yoo;
float yInertia;
float _yinertia;
int selectionY;
bool renderSelection;
bool _componentSelected;
bool _renderDirtBackground;
bool _renderTopBorder;
bool _renderBottomBorder;
int _lastxm;
int _lastym;
private:
int headerHeight;
bool doRenderHeader;
long lastSelectionTime;
int lastSelection;
float _lastyoo;
float _stickPixels;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListV_H__*/
#pragma once
#include "../GuiComponent.h"
class Minecraft;
class Tesselator;
class RolledSelectionListV : public GuiComponent
{
static const int NO_DRAG = -1;
static const int DRAG_OUTSIDE = -2;
static const int DRAG_NORMAL = 0;
public:
RolledSelectionListV(Minecraft* minecraft, int width, int height, int x0, int x1, int y0, int y1, int itemHeight);
virtual int getItemAtPosition(int x, int y);
virtual bool capYPosition();
virtual void tick();
virtual void render(int xm, int ym, float a);
virtual void renderHoleBackground(/*float x0, float x1,*/ float y0, float y1, int a0, int a1);
virtual void setRenderSelection(bool _renderSelection);
virtual void setComponentSelected(bool selected);
protected:
void setRenderHeader(bool _renderHeader, int _headerHeight);
virtual int getNumberOfItems() = 0;
virtual void selectStart(int item) {}
virtual void selectCancel() {}
virtual void selectItem(int item, bool doubleClick) = 0;
virtual bool isSelectedItem(int item) = 0;
virtual int getMaxPosition();
virtual float getPos(float alpha);
virtual void touched();
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) = 0;
virtual void renderHeader(int x, int y, Tesselator& t) {}
virtual void renderBackground() = 0;
virtual void renderForeground() {}
virtual void renderDecorations(int mouseX, int mouseY) {}
virtual void clickedHeader(int headerMouseX, int headerMouseY) {}
virtual int convertSelection(int item, int xm, int ym) { return item; }
int getItemAtYPositionRaw(int y);
void evaluate(int xm, int ym);
virtual void onPreRender();
virtual void onPostRender();
void renderDirtBackground();
protected:
Minecraft* minecraft;
float x0;
float x1;
int itemHeight;
int width;
int height;
//private:
float y0;
float y1;
int dragState;
float yDrag;
float yo;
float yoo;
float yInertia;
float _yinertia;
int selectionY;
bool renderSelection;
bool _componentSelected;
bool _renderDirtBackground;
bool _renderTopBorder;
bool _renderBottomBorder;
int _lastxm;
int _lastym;
private:
int headerHeight;
bool doRenderHeader;
long lastSelectionTime;
int lastSelection;
float _lastyoo;
float _stickPixels;
};

View File

@@ -1,69 +1,67 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ScrolledSelectionList_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ScrolledSelectionList_H__
#include "../GuiComponent.h"
class Minecraft;
class Tesselator;
class ScrolledSelectionList : public GuiComponent
{
static const int NO_DRAG = -1;
static const int DRAG_OUTSIDE = -2;
static const int DRAG_NORMAL = 0;
static const int DRAG_SKIP = 1; // special case to fix android jump bug
public:
ScrolledSelectionList(Minecraft* _minecraft, int _width, int _height, int _y0, int _y1, int _itemHeight);
virtual void setRenderSelection(bool _renderSelection);
protected:
void setRenderHeader(bool _renderHeader, int _headerHeight);
virtual int getNumberOfItems() = 0;
virtual void selectItem(int item, bool doubleClick) = 0;
virtual bool isSelectedItem(int item) = 0;
virtual int getMaxPosition();
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) = 0;
virtual void renderHeader(int x, int y, Tesselator& t) {}
virtual void renderBackground() = 0;
virtual void renderDecorations(int mouseX, int mouseY) {}
virtual void clickedHeader(int headerMouseX, int headerMouseY) {}
public:
virtual int getItemAtPosition(int x, int y);
virtual void capYPosition();
virtual void render(int xm, int ym, float a);
virtual void renderHoleBackground(float y0, float y1, int a0, int a1);
void renderDirtBackground();
protected:
Minecraft* minecraft;
float y0;
float y1;
int itemHeight;
private:
int width;
int height;
float x1;
float x0;
int ignoreY; // new attempt to fix android jump bug
int dragState;
float yDrag;
float yo;
float yInertia;
int selectionY;
long lastSelectionTime;
bool renderSelection;
bool doRenderHeader;
int headerHeight;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ScrolledSelectionList_H__*/
#pragma once
#include "../GuiComponent.h"
class Minecraft;
class Tesselator;
class ScrolledSelectionList : public GuiComponent
{
static const int NO_DRAG = -1;
static const int DRAG_OUTSIDE = -2;
static const int DRAG_NORMAL = 0;
static const int DRAG_SKIP = 1; // special case to fix android jump bug
public:
ScrolledSelectionList(Minecraft* _minecraft, int _width, int _height, int _y0, int _y1, int _itemHeight);
virtual void setRenderSelection(bool _renderSelection);
protected:
void setRenderHeader(bool _renderHeader, int _headerHeight);
virtual int getNumberOfItems() = 0;
virtual void selectItem(int item, bool doubleClick) = 0;
virtual bool isSelectedItem(int item) = 0;
virtual int getMaxPosition();
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) = 0;
virtual void renderHeader(int x, int y, Tesselator& t) {}
virtual void renderBackground() = 0;
virtual void renderDecorations(int mouseX, int mouseY) {}
virtual void clickedHeader(int headerMouseX, int headerMouseY) {}
public:
virtual int getItemAtPosition(int x, int y);
virtual void capYPosition();
virtual void render(int xm, int ym, float a);
virtual void renderHoleBackground(float y0, float y1, int a0, int a1);
void renderDirtBackground();
protected:
Minecraft* minecraft;
float y0;
float y1;
int itemHeight;
private:
int width;
int height;
float x1;
float x0;
int ignoreY; // new attempt to fix android jump bug
int dragState;
float yDrag;
float yo;
float yInertia;
int selectionY;
long lastSelectionTime;
bool renderSelection;
bool doRenderHeader;
int headerHeight;
};

View File

@@ -1,203 +1,201 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ScrollingPane_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ScrollingPane_H__
#include "../GuiComponent.h"
#include "ImageButton.h"
#include "../../player/input/touchscreen/TouchAreaModel.h"
#include "../../../world/phys/Vec3.h"
#include "../../Timer.h"
enum ScrollingPaneFlags {
SF_LockX = 1 << 0,
SF_LockY = 1 << 1,
SF_WrapX = 1 << 2,
SF_WrapY = 1 << 3,
SF_HardLimits = 1 << 4,
SF_MultiSelect = 1 << 5,
//SF_Snap = 1 << 6,
//SF_CustomSnap = 1 << 7,
//SF_Scissor = 1 << 8,
SF_ShowScrollbar= 1 << 9,
SF_NoHoldSelect = 1 << 10
};
typedef struct ScrollBar {
ScrollBar()
: alpha(0),
fading(-1)
{}
float x;
float y;
float w;
float h;
//bool visible;
float alpha;
int fading;
} ScrollBar;
class ScrollingPane: public GuiComponent {
public:
typedef struct GridItem {
int id;
int x, y;
// The GUI coordinates comes in (xf, yf)
float xf, yf;
bool selected;
} GridItem;
ScrollingPane(int flags, const IntRectangle& boundingBox, const IntRectangle& itemRect, int columns, int numItems, float screenScale = 1.0f, const IntRectangle& itemBoundingRect = IntRectangle(0,0,0,0));
~ScrollingPane();
//void init(Minecraft*, int width, int height);
void tick();
void render(int xm, int ym, float alpha);
// scroll the content by the given amount (dx horizontal, dy vertical)
// positive values move content downward/rightward
void scrollBy(float dx, float dy);
bool getGridItemFor_slow(int itemIndex, GridItem& out);
void setSelected(int id, bool selected);
// This function is called with all visible GridItems. The base
// implementation just dispatches each item to renderItem in y,x order
virtual void renderBatch(std::vector<GridItem>& items, float alpha);
virtual void renderItem(GridItem& item, float alpha);
//void render(int xx, int yy);
bool queryHoldTime(int* gridId, int* heldMs);
protected:
GridItem getItemForPos(float x, float y, bool isScreenPos);
void handleUserInput();
void addDeltaPos(float x, float y, float dt, int z);
void translate(float xo, float yo);
int flags;
int columns;
int rows;
int numItems;
int px, py;
float fpx, fpy;
float screenScale;
float invScreenScale;
//bool hasItemBounding;
IntRectangle bbox;
IntRectangle itemRect;
IntRectangle itemBbox;
RectangleArea area;
RectangleArea bboxArea;
// Dragging info
std::vector<float> dragDeltas;
int dragState;
Vec3 dragBeginPos;
Vec3 dragBeginScreenPos;
int dragTicks;
float dragLastDeltaTimeStamp;
Vec3 dragLastPos;
float dx, dy;
float friction;
float dstx, dsty;
// Rewrite
bool dragging; //!
bool decelerating;
bool tracking; //!
bool pagingEnabled; //!
Vec3 _contentOffset; //!
Vec3 _contentOffsetBeforeDeceleration; //*
int lastEventTime; //<
Vec3 decelerationVelocity; //*
Vec3 minDecelerationPoint; //*
Vec3 maxDecelerationPoint; //*
float penetrationDeceleration; //<
float penetrationAcceleration; //<
Vec3 minPoint; //*
Vec3 startPosition; //*
Vec3 startTouchPosition; //*
Vec3 startTimePosition; //*
bool wasDeceleratingWhenTouchesBegan; //*
bool firstDrag; //<
float startTime; //<
//float startTime
IntRectangle size;
int lastFrame;
bool _scrollEnabled; //!
bool touchesHaveMoved; //*
virtual void didEndDragging() {}
virtual void didEndDecelerating() {}
virtual void willBeginDecelerating() {}
virtual void willBeginDragging() {}
int te_moved,
te_ended,
te_highlight;
int highlightTimer;
int highlightStarted;
GridItem highlightItem;
bool* selected;
int selectedId;
ScrollBar vScroll, hScroll;
IntRectangle adjustedContentSize;
void touchesBegan(float x, float y, int t);
void touchesMoved(float x, float y, int t);
void touchesEnded(float x, float y, int t);
void touchesCancelled(float x, float y, int t);
void beginTracking(float x, float y, int t);
void onHoldItem();
void _onSelect( int id );
virtual bool onSelect(int gridId, bool selected);
Vec3& contentOffset();
void startDecelerationAnimation(bool force);
void stopDecelerationAnimation();
void stepThroughDecelerationAnimation(bool f);
void setContentOffset(float x, float y);
void setContentOffset(Vec3 a);
void setContentOffsetWithAnimation(Vec3 b, bool doScroll);
void snapContentOffsetToBounds(bool snap); //*
void adjustContentSize();
//TouchAreaModel _areaModel;
bool isAllSet(int flag) { return (flags & flag) == flag; }
bool isSet(int flag) { return (flags & flag) != 0; }
bool isNotSet(int flag) { return !isSet(flag); }
void updateHorizontalScrollIndicator();
void updateVerticalScrollIndicator();
void hideScrollIndicators(); //*
void updateScrollFade( ScrollBar& vScroll );
private:
Timer _timer;
bool _doStepTimer;
bool _wasDown;
float _lx;
float _ly;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ScrollingPane_H__*/
#pragma once
#include "../GuiComponent.h"
#include "ImageButton.h"
#include "../../player/input/touchscreen/TouchAreaModel.h"
#include "../../../world/phys/Vec3.h"
#include "../../Timer.h"
enum ScrollingPaneFlags {
SF_LockX = 1 << 0,
SF_LockY = 1 << 1,
SF_WrapX = 1 << 2,
SF_WrapY = 1 << 3,
SF_HardLimits = 1 << 4,
SF_MultiSelect = 1 << 5,
//SF_Snap = 1 << 6,
//SF_CustomSnap = 1 << 7,
//SF_Scissor = 1 << 8,
SF_ShowScrollbar= 1 << 9,
SF_NoHoldSelect = 1 << 10
};
typedef struct ScrollBar {
ScrollBar()
: alpha(0),
fading(-1)
{}
float x;
float y;
float w;
float h;
//bool visible;
float alpha;
int fading;
} ScrollBar;
class ScrollingPane: public GuiComponent {
public:
typedef struct GridItem {
int id;
int x, y;
// The GUI coordinates comes in (xf, yf)
float xf, yf;
bool selected;
} GridItem;
ScrollingPane(int flags, const IntRectangle& boundingBox, const IntRectangle& itemRect, int columns, int numItems, float screenScale = 1.0f, const IntRectangle& itemBoundingRect = IntRectangle(0,0,0,0));
~ScrollingPane();
//void init(Minecraft*, int width, int height);
void tick();
void render(int xm, int ym, float alpha);
// scroll the content by the given amount (dx horizontal, dy vertical)
// positive values move content downward/rightward
void scrollBy(float dx, float dy);
bool getGridItemFor_slow(int itemIndex, GridItem& out);
void setSelected(int id, bool selected);
// This function is called with all visible GridItems. The base
// implementation just dispatches each item to renderItem in y,x order
virtual void renderBatch(std::vector<GridItem>& items, float alpha);
virtual void renderItem(GridItem& item, float alpha);
//void render(int xx, int yy);
bool queryHoldTime(int* gridId, int* heldMs);
protected:
GridItem getItemForPos(float x, float y, bool isScreenPos);
void handleUserInput();
void addDeltaPos(float x, float y, float dt, int z);
void translate(float xo, float yo);
int flags;
int columns;
int rows;
int numItems;
int px, py;
float fpx, fpy;
float screenScale;
float invScreenScale;
//bool hasItemBounding;
IntRectangle bbox;
IntRectangle itemRect;
IntRectangle itemBbox;
RectangleArea area;
RectangleArea bboxArea;
// Dragging info
std::vector<float> dragDeltas;
int dragState;
Vec3 dragBeginPos;
Vec3 dragBeginScreenPos;
int dragTicks;
float dragLastDeltaTimeStamp;
Vec3 dragLastPos;
float dx, dy;
float friction;
float dstx, dsty;
// Rewrite
bool dragging; //!
bool decelerating;
bool tracking; //!
bool pagingEnabled; //!
Vec3 _contentOffset; //!
Vec3 _contentOffsetBeforeDeceleration; //*
int lastEventTime; //<
Vec3 decelerationVelocity; //*
Vec3 minDecelerationPoint; //*
Vec3 maxDecelerationPoint; //*
float penetrationDeceleration; //<
float penetrationAcceleration; //<
Vec3 minPoint; //*
Vec3 startPosition; //*
Vec3 startTouchPosition; //*
Vec3 startTimePosition; //*
bool wasDeceleratingWhenTouchesBegan; //*
bool firstDrag; //<
float startTime; //<
//float startTime
IntRectangle size;
int lastFrame;
bool _scrollEnabled; //!
bool touchesHaveMoved; //*
virtual void didEndDragging() {}
virtual void didEndDecelerating() {}
virtual void willBeginDecelerating() {}
virtual void willBeginDragging() {}
int te_moved,
te_ended,
te_highlight;
int highlightTimer;
int highlightStarted;
GridItem highlightItem;
bool* selected;
int selectedId;
ScrollBar vScroll, hScroll;
IntRectangle adjustedContentSize;
void touchesBegan(float x, float y, int t);
void touchesMoved(float x, float y, int t);
void touchesEnded(float x, float y, int t);
void touchesCancelled(float x, float y, int t);
void beginTracking(float x, float y, int t);
void onHoldItem();
void _onSelect( int id );
virtual bool onSelect(int gridId, bool selected);
Vec3& contentOffset();
void startDecelerationAnimation(bool force);
void stopDecelerationAnimation();
void stepThroughDecelerationAnimation(bool f);
void setContentOffset(float x, float y);
void setContentOffset(Vec3 a);
void setContentOffsetWithAnimation(Vec3 b, bool doScroll);
void snapContentOffsetToBounds(bool snap); //*
void adjustContentSize();
//TouchAreaModel _areaModel;
bool isAllSet(int flag) { return (flags & flag) == flag; }
bool isSet(int flag) { return (flags & flag) != 0; }
bool isNotSet(int flag) { return !isSet(flag); }
void updateHorizontalScrollIndicator();
void updateVerticalScrollIndicator();
void hideScrollIndicators(); //*
void updateScrollFade( ScrollBar& vScroll );
private:
Timer _timer;
bool _doStepTimer;
bool _wasDown;
float _lx;
float _ly;
};

View File

@@ -1,48 +1,46 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Slider_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Slider_H__
#include "GuiElement.h"
#include "../../../client/Options.h"
#include <client/Option.h>
class Slider : public GuiElement {
typedef GuiElement super;
public:
virtual void render( Minecraft* minecraft, int xm, int ym );
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void tick(Minecraft* minecraft);
protected:
Slider(OptionId optId);
OptionId m_optId;
bool m_mouseDownOnElement;
float m_percentage;
int m_numSteps;
};
class SliderFloat : public Slider {
public:
SliderFloat(Minecraft* minecraft, OptionId option);
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
protected:
OptionFloat* m_option;
};
class SliderInt : public Slider {
public:
SliderInt(Minecraft* minecraft, OptionId option);
virtual void render( Minecraft* minecraft, int xm, int ym ) override;
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
protected:
OptionInt* m_option;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Slider_H__*/
#pragma once
#include "GuiElement.h"
#include "../../../client/Options.h"
#include <client/Option.h>
class Slider : public GuiElement {
typedef GuiElement super;
public:
virtual void render( Minecraft* minecraft, int xm, int ym );
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void tick(Minecraft* minecraft);
protected:
Slider(OptionId optId);
OptionId m_optId;
bool m_mouseDownOnElement;
float m_percentage;
int m_numSteps;
};
class SliderFloat : public Slider {
public:
SliderFloat(Minecraft* minecraft, OptionId option);
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
protected:
OptionFloat* m_option;
};
class SliderInt : public Slider {
public:
SliderInt(Minecraft* minecraft, OptionId option);
virtual void render( Minecraft* minecraft, int xm, int ym ) override;
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
protected:
OptionInt* m_option;
};

View File

@@ -1,44 +1,42 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__TextBox_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__TextBox_H__
//package net.minecraft.client.gui;
#include <string>
#include "GuiElement.h"
#include "../../Options.h"
#include "../../../platform/input/Mouse.h"
#include "../../../platform/input/Keyboard.h"
class Font;
class Minecraft;
class TextBox: public GuiElement
{
public:
TextBox(int id, const std::string& msg);
TextBox(int id, int x, int y, const std::string& msg);
TextBox(int id, int x, int y, int w, int h, const std::string& msg);
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum);
virtual void setFocus(Minecraft* minecraft);
virtual bool loseFocus(Minecraft* minecraft);
virtual void render(Minecraft* minecraft, int xm, int ym);
virtual void keyPressed(Minecraft* minecraft, int key);
virtual void charPressed(Minecraft* minecraft, char c);
virtual void tick(Minecraft* minecraft);
public:
std::string hint;
std::string text;
int id;
int blinkTicks;
bool focused;
bool blink;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__TextBox_H__*/
#pragma once
//package net.minecraft.client.gui;
#include <string>
#include "GuiElement.h"
#include "../../Options.h"
#include "../../../platform/input/Mouse.h"
#include "../../../platform/input/Keyboard.h"
class Font;
class Minecraft;
class TextBox: public GuiElement
{
public:
TextBox(int id, const std::string& msg);
TextBox(int id, int x, int y, const std::string& msg);
TextBox(int id, int x, int y, int w, int h, const std::string& msg);
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum);
virtual void setFocus(Minecraft* minecraft);
virtual bool loseFocus(Minecraft* minecraft);
virtual void render(Minecraft* minecraft, int xm, int ym);
virtual void keyPressed(Minecraft* minecraft, int key);
virtual void charPressed(Minecraft* minecraft, char c);
virtual void tick(Minecraft* minecraft);
public:
std::string hint;
std::string text;
int id;
int blinkTicks;
bool focused;
bool blink;
};

View File

@@ -1,79 +1,77 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ArmorScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ArmorScreen_H__
#include "BaseContainerScreen.h"
#include "../components/InventoryPane.h"
#include "../components/Button.h"
class Font;
class CItem;
class Textures;
class NinePatchLayer;
class Tesselator;
class ArmorScreen: public Screen,
public Touch::IInventoryPaneCallback
{
typedef Screen super;
typedef std::vector<CItem*> ItemList;
static const int NUM_ARMORBUTTONS = 4;
public:
ArmorScreen();
~ArmorScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
bool renderGameBehind();
void buttonClicked(Button* button);
// IInventoryPaneCallback
bool addItem(const Touch::InventoryPane* pane, int itemId);
bool isAllowed( int slot );
std::vector<const ItemInstance*> getItems( const Touch::InventoryPane* forPane );
private:
void renderPlayer(float xo, float yo);
void setupInventoryPane();
void updateItems();
void drawSlotItemAt(Tesselator& t, int slot, const ItemInstance* item, int x, int y);
ItemInstance moveOver(const ItemInstance* item, int maxCount);
void takeAndClearSlot( int slot );
void handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, int xm, int ym, float a);
bool canMoveToSlot(int slot, const ItemInstance* item);
ItemList _items;
std::string currentItemDesc;
ItemInstance burnResult;
float descWidth;
ImageButton btnClose;
BlankButton btnArmor0;
BlankButton btnArmor1;
BlankButton btnArmor2;
BlankButton btnArmor3;
BlankButton* armorButtons[4];
Touch::THeader bHeader;
Touch::InventoryPane* inventoryPane;
IntRectangle inventoryPaneRect;
IntRectangle guiPlayerBgRect;
std::vector<const ItemInstance*> armorItems;
bool doRecreatePane;
// GUI elements such as 9-Patches
NinePatchLayer* guiBackground;
NinePatchLayer* guiSlot;
NinePatchLayer* guiPaneFrame;
NinePatchLayer* guiPlayerBg;
Player* player;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ArmorScreen_H__*/
#pragma once
#include "BaseContainerScreen.h"
#include "../components/InventoryPane.h"
#include "../components/Button.h"
class Font;
class CItem;
class Textures;
class NinePatchLayer;
class Tesselator;
class ArmorScreen: public Screen,
public Touch::IInventoryPaneCallback
{
typedef Screen super;
typedef std::vector<CItem*> ItemList;
static const int NUM_ARMORBUTTONS = 4;
public:
ArmorScreen();
~ArmorScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
bool renderGameBehind();
void buttonClicked(Button* button);
// IInventoryPaneCallback
bool addItem(const Touch::InventoryPane* pane, int itemId);
bool isAllowed( int slot );
std::vector<const ItemInstance*> getItems( const Touch::InventoryPane* forPane );
private:
void renderPlayer(float xo, float yo);
void setupInventoryPane();
void updateItems();
void drawSlotItemAt(Tesselator& t, int slot, const ItemInstance* item, int x, int y);
ItemInstance moveOver(const ItemInstance* item, int maxCount);
void takeAndClearSlot( int slot );
void handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, int xm, int ym, float a);
bool canMoveToSlot(int slot, const ItemInstance* item);
ItemList _items;
std::string currentItemDesc;
ItemInstance burnResult;
float descWidth;
ImageButton btnClose;
BlankButton btnArmor0;
BlankButton btnArmor1;
BlankButton btnArmor2;
BlankButton btnArmor3;
BlankButton* armorButtons[4];
Touch::THeader bHeader;
Touch::InventoryPane* inventoryPane;
IntRectangle inventoryPaneRect;
IntRectangle guiPlayerBgRect;
std::vector<const ItemInstance*> armorItems;
bool doRecreatePane;
// GUI elements such as 9-Patches
NinePatchLayer* guiBackground;
NinePatchLayer* guiSlot;
NinePatchLayer* guiPaneFrame;
NinePatchLayer* guiPlayerBg;
Player* player;
};

View File

@@ -1,50 +1,48 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__BaseContainerScreen_H__
#define NET_MINECRAFT_CLIENT_GUI__BaseContainerScreen_H__
//package net.minecraft.client.gui.screens;
#include <vector>
#include "../Screen.h"
#include "../../Minecraft.h"
#include "../../player/LocalPlayer.h"
class BaseContainerMenu;
class BaseContainerScreen: public Screen
{
typedef Screen super;
public:
BaseContainerScreen(BaseContainerMenu* menu)
: menu(menu)
{
}
virtual void init() {
super::init();
minecraft->player->containerMenu = menu;
}
virtual void tick() {
super::tick();
if (!minecraft->player->isAlive() || minecraft->player->removed)
minecraft->player->closeContainer();
}
virtual void keyPressed( int eventKey )
{
if (eventKey == Keyboard::KEY_ESCAPE) {
minecraft->player->closeContainer();
} else {
super::keyPressed(eventKey);
}
}
virtual bool closeOnPlayerHurt() {
return true;
}
protected:
BaseContainerMenu* menu;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__BaseContainerScreen_H__*/
#pragma once
//package net.minecraft.client.gui.screens;
#include <vector>
#include "../Screen.h"
#include "../../Minecraft.h"
#include "../../player/LocalPlayer.h"
class BaseContainerMenu;
class BaseContainerScreen: public Screen
{
typedef Screen super;
public:
BaseContainerScreen(BaseContainerMenu* menu)
: menu(menu)
{
}
virtual void init() {
super::init();
minecraft->player->containerMenu = menu;
}
virtual void tick() {
super::tick();
if (!minecraft->player->isAlive() || minecraft->player->removed)
minecraft->player->closeContainer();
}
virtual void keyPressed( int eventKey )
{
if (eventKey == Keyboard::KEY_ESCAPE) {
minecraft->player->closeContainer();
} else {
super::keyPressed(eventKey);
}
}
virtual bool closeOnPlayerHurt() {
return true;
}
protected:
BaseContainerMenu* menu;
};

View File

@@ -1,21 +1,19 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ChatScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ChatScreen_H__
#include "../Screen.h"
class ChatScreen: public Screen
{
public:
ChatScreen() {}
virtual ~ChatScreen() {}
void init();
void render(int xm, int ym, float a);
void buttonClicked(Button* button) {};
private:
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ChatScreen_H__*/
#pragma once
#include "../Screen.h"
class ChatScreen: public Screen
{
public:
ChatScreen() {}
virtual ~ChatScreen() {}
void init();
void render(int xm, int ym, float a);
void buttonClicked(Button* button) {};
private:
};

View File

@@ -1,72 +1,70 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ChestScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ChestScreen_H__
#include "BaseContainerScreen.h"
#include "../components/InventoryPane.h"
#include "../components/Button.h"
class Font;
class CItem;
class Textures;
class NinePatchLayer;
class FillingContainer;
class ChestTileEntity;
class Tesselator;
class ChestScreen: public BaseContainerScreen,
public Touch::IInventoryPaneCallback
{
typedef BaseContainerScreen super;
typedef std::vector<CItem*> ItemList;
friend class ItemPane;
public:
ChestScreen(Player* player, ChestTileEntity* chest);
~ChestScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
bool renderGameBehind();
void buttonClicked(Button* button);
// IInventoryPaneCallback
bool addItem(const Touch::InventoryPane* pane, int itemId);
bool isAllowed( int slot );
std::vector<const ItemInstance*> getItems( const Touch::InventoryPane* forPane );
//const ItemList& getItems(const ItemPane* forPane);
private:
void setupPane();
void drawSlotItemAt(Tesselator& t, const ItemInstance* item, int x, int y, bool selected);
bool handleAddItem(FillingContainer* from, FillingContainer* to, int itemIndex);
void handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, int xm, int ym, float a);
std::string currentItemDesc;
ImageButton btnClose;
Touch::THeader bHeader;
Touch::THeader bHeaderChest;
Touch::InventoryPane* inventoryPane;
Touch::InventoryPane* chestPane;
IntRectangle panesBbox;
std::vector<const ItemInstance*> inventoryItems;
std::vector<const ItemInstance*> chestItems;
bool doRecreatePane;
int selectedSlot;
// GUI elements such as 9-Patches
NinePatchLayer* guiBackground;
NinePatchLayer* guiSlot;
NinePatchLayer* guiSlotMarked;
NinePatchLayer* guiSlotMarker;
NinePatchLayer* guiPaneFrame;
Player* player;
ChestTileEntity* chest;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ChestScreen_H__*/
#pragma once
#include "BaseContainerScreen.h"
#include "../components/InventoryPane.h"
#include "../components/Button.h"
class Font;
class CItem;
class Textures;
class NinePatchLayer;
class FillingContainer;
class ChestTileEntity;
class Tesselator;
class ChestScreen: public BaseContainerScreen,
public Touch::IInventoryPaneCallback
{
typedef BaseContainerScreen super;
typedef std::vector<CItem*> ItemList;
friend class ItemPane;
public:
ChestScreen(Player* player, ChestTileEntity* chest);
~ChestScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
bool renderGameBehind();
void buttonClicked(Button* button);
// IInventoryPaneCallback
bool addItem(const Touch::InventoryPane* pane, int itemId);
bool isAllowed( int slot );
std::vector<const ItemInstance*> getItems( const Touch::InventoryPane* forPane );
//const ItemList& getItems(const ItemPane* forPane);
private:
void setupPane();
void drawSlotItemAt(Tesselator& t, const ItemInstance* item, int x, int y, bool selected);
bool handleAddItem(FillingContainer* from, FillingContainer* to, int itemIndex);
void handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, int xm, int ym, float a);
std::string currentItemDesc;
ImageButton btnClose;
Touch::THeader bHeader;
Touch::THeader bHeaderChest;
Touch::InventoryPane* inventoryPane;
Touch::InventoryPane* chestPane;
IntRectangle panesBbox;
std::vector<const ItemInstance*> inventoryItems;
std::vector<const ItemInstance*> chestItems;
bool doRecreatePane;
int selectedSlot;
// GUI elements such as 9-Patches
NinePatchLayer* guiBackground;
NinePatchLayer* guiSlot;
NinePatchLayer* guiSlotMarked;
NinePatchLayer* guiSlotMarker;
NinePatchLayer* guiPaneFrame;
Player* player;
ChestTileEntity* chest;
};

View File

@@ -1,21 +1,19 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ChooseLevelScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ChooseLevelScreen_H__
#include "../Screen.h"
#include "../../../world/level/storage/LevelStorageSource.h"
class ChooseLevelScreen: public Screen
{
public:
void init();
protected:
std::string getUniqueLevelName(const std::string& level);
private:
void loadLevelSource();
LevelSummaryList levels;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ChooseLevelScreen_H__*/
#pragma once
#include "../Screen.h"
#include "../../../world/level/storage/LevelStorageSource.h"
class ChooseLevelScreen: public Screen
{
public:
void init();
protected:
std::string getUniqueLevelName(const std::string& level);
private:
void loadLevelSource();
LevelSummaryList levels;
};

View File

@@ -1,40 +1,38 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ConfirmScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ConfirmScreen_H__
//package net.minecraft.client.gui;
#include "../Screen.h"
#include <string>
class ConfirmScreen: public Screen
{
typedef Screen super;
public:
ConfirmScreen(Screen* parent_, const std::string& title1_, const std::string& title2_, int id_);
ConfirmScreen(Screen* parent_, const std::string& title1_, const std::string& title2_, const std::string& yesButton, const std::string& noButton, int id_);
~ConfirmScreen();
void init();
void setupPositions();
bool handleBackEvent(bool isDown);
void render(int xm, int ym, float a);
protected:
void buttonClicked(Button* button);
virtual void postResult(bool isOk);
Screen* parent;
int id;
private:
std::string title1;
std::string title2;
std::string yesButtonText;
std::string noButtonText;
Button* yesButton; // 0
Button* noButton; // 1
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ConfirmScreen_H__*/
#pragma once
//package net.minecraft.client.gui;
#include "../Screen.h"
#include <string>
class ConfirmScreen: public Screen
{
typedef Screen super;
public:
ConfirmScreen(Screen* parent_, const std::string& title1_, const std::string& title2_, int id_);
ConfirmScreen(Screen* parent_, const std::string& title1_, const std::string& title2_, const std::string& yesButton, const std::string& noButton, int id_);
~ConfirmScreen();
void init();
void setupPositions();
bool handleBackEvent(bool isDown);
void render(int xm, int ym, float a);
protected:
void buttonClicked(Button* button);
virtual void postResult(bool isOk);
Screen* parent;
int id;
private:
std::string title1;
std::string title2;
std::string yesButtonText;
std::string noButtonText;
Button* yesButton; // 0
Button* noButton; // 1
};

View File

@@ -1,5 +1,4 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ConsoleScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ConsoleScreen_H__
#pragma once
#include "../Screen.h"
#include <string>
@@ -31,4 +30,3 @@ private:
int _cursorBlink; // tick counter for cursor blink
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ConsoleScreen_H__*/

View File

@@ -1,5 +1,4 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__CreditsScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__CreditsScreen_H__
#pragma once
#include "../Screen.h"
#include "../components/Button.h"
@@ -29,4 +28,3 @@ private:
float _scrollSpeed;
};
#endif /* NET_MINECRAFT_CLIENT_GUI_SCREENS__CreditsScreen_H__ */

View File

@@ -1,30 +1,28 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__DeathScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__DeathScreen_H__
#include "../Screen.h"
class Button;
class DeathScreen: public Screen
{
public:
DeathScreen();
virtual ~DeathScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
private:
Button* bRespawn;
Button* bTitle;
bool _hasChosen;
int _tick;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__DeathScreen_H__*/
#pragma once
#include "../Screen.h"
class Button;
class DeathScreen: public Screen
{
public:
DeathScreen();
virtual ~DeathScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
private:
Button* bRespawn;
Button* bTitle;
bool _hasChosen;
int _tick;
};

View File

@@ -1,13 +1,11 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__DialogDefinitions_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__DialogDefinitions_H__
class DialogDefinitions {
public:
static const int DIALOG_CREATE_NEW_WORLD = 1;
static const int DIALOG_NEW_CHAT_MESSAGE = 2;
static const int DIALOG_MAINMENU_OPTIONS = 3;
static const int DIALOG_RENAME_MP_WORLD = 4;
static const int DIALOG_DEMO_FEATURE_DISABLED = 98;
};
#endif /*#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__DialogDefinitions_H__*/
#pragma once
class DialogDefinitions {
public:
static const int DIALOG_CREATE_NEW_WORLD = 1;
static const int DIALOG_NEW_CHAT_MESSAGE = 2;
static const int DIALOG_MAINMENU_OPTIONS = 3;
static const int DIALOG_RENAME_MP_WORLD = 4;
static const int DIALOG_DEMO_FEATURE_DISABLED = 98;
};

View File

@@ -1,57 +1,55 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__DisconnectionScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__DisconnectionScreen_H__
#include "../Screen.h"
#include "../Font.h"
#include "../components/Button.h"
#include "../../Minecraft.h"
#include <string>
class DisconnectionScreen: public Screen
{
typedef Screen super;
public:
DisconnectionScreen(const std::string& msg)
: _msg(msg),
_back(NULL)
{}
~DisconnectionScreen() {
delete _back;
}
void init() {
if (/* minecraft->useTouchscreen() */ true)
_back = new Touch::TButton(1, "Ok");
else
_back = new Button(1, "Ok");
buttons.push_back(_back);
tabButtons.push_back(_back);
_back->width = 128;
_back->x = (width - _back->width) / 2;
_back->y = height / 2;
}
void render( int xm, int ym, float a ) {
renderBackground();
super::render(xm, ym, a);
int center = (width - minecraft->font->width(_msg)) / 2;
minecraft->font->drawShadow(_msg, (float)center, (float)(height / 2 - 32), 0xffffffff);
}
void buttonClicked(Button* button) {
if (button->id == _back->id) {
minecraft->leaveGame();
}
}
bool isInGameScreen() { return false; }
private:
std::string _msg;
Button* _back;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__DisconnectionScreen_H__*/
#pragma once
#include "../Screen.h"
#include "../Font.h"
#include "../components/Button.h"
#include "../../Minecraft.h"
#include <string>
class DisconnectionScreen: public Screen
{
typedef Screen super;
public:
DisconnectionScreen(const std::string& msg)
: _msg(msg),
_back(NULL)
{}
~DisconnectionScreen() {
delete _back;
}
void init() {
if (/* minecraft->useTouchscreen() */ true)
_back = new Touch::TButton(1, "Ok");
else
_back = new Button(1, "Ok");
buttons.push_back(_back);
tabButtons.push_back(_back);
_back->width = 128;
_back->x = (width - _back->width) / 2;
_back->y = height / 2;
}
void render( int xm, int ym, float a ) {
renderBackground();
super::render(xm, ym, a);
int center = (width - minecraft->font->width(_msg)) / 2;
minecraft->font->drawShadow(_msg, (float)center, (float)(height / 2 - 32), 0xffffffff);
}
void buttonClicked(Button* button) {
if (button->id == _back->id) {
minecraft->leaveGame();
}
}
bool isInGameScreen() { return false; }
private:
std::string _msg;
Button* _back;
};

View File

@@ -1,84 +1,82 @@
#ifndef _FURNACESCREEN_H__
#define _FURNACESCREEN_H__
#include "BaseContainerScreen.h"
#include "../components/InventoryPane.h"
#include "../components/Button.h"
class Font;
class CItem;
class Textures;
class NinePatchLayer;
class Tesselator;
class FurnaceScreen: public BaseContainerScreen,
public Touch::IInventoryPaneCallback
{
typedef BaseContainerScreen super;
typedef std::vector<CItem*> ItemList;
public:
FurnaceScreen(Player* player, FurnaceTileEntity* furnace);
~FurnaceScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
bool renderGameBehind();
void buttonClicked(Button* button);
// IInventoryPaneCallback
bool addItem(const Touch::InventoryPane* pane, int itemId);
bool isAllowed( int slot );
std::vector<const ItemInstance*> getItems( const Touch::InventoryPane* forPane );
private:
//void addItem(Recipe* recipe);
void recheckRecipes();
void clearItems();
void updateResult(const ItemInstance* item);
void setupInventoryPane();
void updateItems();
void drawSlotItemAt(Tesselator& t, const ItemInstance* item, int x, int y, bool selected);
ItemInstance moveOver(const ItemInstance* item, int maxCount);
void takeAndClearSlot( int slot );
bool handleAddItem( int slot, const ItemInstance* item );
void handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, int xm, int ym, float a);
bool canMoveToFurnace(int inventorySlot, const ItemInstance* item);
ItemList _items;
std::string currentItemDesc;
ItemInstance burnResult;
float descWidth;
ImageButton btnClose;
BlankButton btnIngredient;
BlankButton btnFuel;
BlankButton btnResult;
Touch::THeader bHeader;
Touch::InventoryPane* inventoryPane;
IntRectangle inventoryPaneRect;
ItemList listFuel;
ItemList listIngredient;
std::vector<int> inventorySlots;
std::vector<const ItemInstance*> inventoryItems;
bool doRecreatePane;
int selectedSlot;
int lastBurnTypeId;
// GUI elements such as 9-Patches
NinePatchLayer* guiBackground;
NinePatchLayer* guiSlot;
NinePatchLayer* guiSlotMarked;
NinePatchLayer* guiSlotMarker;
NinePatchLayer* guiPaneFrame;
Player* player;
FurnaceTileEntity* furnace;
};
#endif /*_FURNACESCREEN_H__*/
#pragma once
#include "BaseContainerScreen.h"
#include "../components/InventoryPane.h"
#include "../components/Button.h"
class Font;
class CItem;
class Textures;
class NinePatchLayer;
class Tesselator;
class FurnaceScreen: public BaseContainerScreen,
public Touch::IInventoryPaneCallback
{
typedef BaseContainerScreen super;
typedef std::vector<CItem*> ItemList;
public:
FurnaceScreen(Player* player, FurnaceTileEntity* furnace);
~FurnaceScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
bool renderGameBehind();
void buttonClicked(Button* button);
// IInventoryPaneCallback
bool addItem(const Touch::InventoryPane* pane, int itemId);
bool isAllowed( int slot );
std::vector<const ItemInstance*> getItems( const Touch::InventoryPane* forPane );
private:
//void addItem(Recipe* recipe);
void recheckRecipes();
void clearItems();
void updateResult(const ItemInstance* item);
void setupInventoryPane();
void updateItems();
void drawSlotItemAt(Tesselator& t, const ItemInstance* item, int x, int y, bool selected);
ItemInstance moveOver(const ItemInstance* item, int maxCount);
void takeAndClearSlot( int slot );
bool handleAddItem( int slot, const ItemInstance* item );
void handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, int xm, int ym, float a);
bool canMoveToFurnace(int inventorySlot, const ItemInstance* item);
ItemList _items;
std::string currentItemDesc;
ItemInstance burnResult;
float descWidth;
ImageButton btnClose;
BlankButton btnIngredient;
BlankButton btnFuel;
BlankButton btnResult;
Touch::THeader bHeader;
Touch::InventoryPane* inventoryPane;
IntRectangle inventoryPaneRect;
ItemList listFuel;
ItemList listIngredient;
std::vector<int> inventorySlots;
std::vector<const ItemInstance*> inventoryItems;
bool doRecreatePane;
int selectedSlot;
int lastBurnTypeId;
// GUI elements such as 9-Patches
NinePatchLayer* guiBackground;
NinePatchLayer* guiSlot;
NinePatchLayer* guiSlotMarked;
NinePatchLayer* guiSlotMarker;
NinePatchLayer* guiPaneFrame;
Player* player;
FurnaceTileEntity* furnace;
};

View File

@@ -1,26 +1,24 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__InBedScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__InBedScreen_H__
#include "../Screen.h"
class Button;
class InBedScreen: public Screen
{
public:
InBedScreen();
virtual ~InBedScreen();
void init();
void setupPositions();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
private:
Button* bWakeUp;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__InBedScreen_H__*/
#pragma once
#include "../Screen.h"
class Button;
class InBedScreen: public Screen
{
public:
InBedScreen();
virtual ~InBedScreen();
void init();
void setupPositions();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
private:
Button* bWakeUp;
};

View File

@@ -1,59 +1,57 @@
#ifndef _MINECRAFT_INGAMEBLOCKSELECTIONSCREEN_H_
#define _MINECRAFT_INGAMEBLOCKSELECTIONSCREEN_H_
#include "../Screen.h"
#include "../../player/input/touchscreen/TouchAreaModel.h"
#include "../components/Button.h"
class IngameBlockSelectionScreen : public Screen
{
typedef Screen super;
public:
IngameBlockSelectionScreen();
virtual ~IngameBlockSelectionScreen() {}
virtual void init() override;
virtual void removed() override;
void render(int xm, int ym, float a) override;
protected:
virtual void mouseClicked(int x, int y, int buttonNum) override;
virtual void mouseReleased(int x, int y, int buttonNum) override;
virtual void buttonClicked(Button* button) override;
// wheel input for creative inventory scrolling
virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
virtual void keyPressed(int eventKey) override;
private:
void renderSlots();
void renderSlot(int slot, int x, int y, float a);
void renderDemoOverlay();
int getSelectedSlot(int x, int y);
void selectSlotAndClose();
//int getLinearSlotId(int x, int y);
int getSlotPosX(int slotX);
int getSlotPosY(int slotY);
int getSlotHeight();
bool isAllowed(int slot);
private:
int InventoryCols;
int InventoryRows;
int InventorySize;
int selectedItem;
bool _pendingQuit;
Button bArmor;
RectangleArea _area;
};
#endif
#pragma once
#include "../Screen.h"
#include "../../player/input/touchscreen/TouchAreaModel.h"
#include "../components/Button.h"
class IngameBlockSelectionScreen : public Screen
{
typedef Screen super;
public:
IngameBlockSelectionScreen();
virtual ~IngameBlockSelectionScreen() {}
virtual void init() override;
virtual void removed() override;
void render(int xm, int ym, float a) override;
protected:
virtual void mouseClicked(int x, int y, int buttonNum) override;
virtual void mouseReleased(int x, int y, int buttonNum) override;
virtual void buttonClicked(Button* button) override;
// wheel input for creative inventory scrolling
virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
virtual void keyPressed(int eventKey) override;
private:
void renderSlots();
void renderSlot(int slot, int x, int y, float a);
void renderDemoOverlay();
int getSelectedSlot(int x, int y);
void selectSlotAndClose();
//int getLinearSlotId(int x, int y);
int getSlotPosX(int slotX);
int getSlotPosY(int slotY);
int getSlotHeight();
bool isAllowed(int slot);
private:
int InventoryCols;
int InventoryRows;
int InventorySize;
int selectedItem;
bool _pendingQuit;
Button bArmor;
RectangleArea _area;
};

View File

@@ -1,70 +1,68 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__JoinGameScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__JoinGameScreen_H__
#include "../Screen.h"
#include "../components/Button.h"
#include "../components/ScrolledSelectionList.h"
#include "../../Minecraft.h"
#include "../../../network/RakNetInstance.h"
class JoinGameScreen;
class AvailableGamesList : public ScrolledSelectionList
{
int selectedItem;
ServerList copiedServerList;
friend class JoinGameScreen;
public:
AvailableGamesList(Minecraft* _minecraft, int _width, int _height)
: ScrolledSelectionList(_minecraft, _width, _height, 24, _height - 30, 28)
{
}
protected:
virtual int getNumberOfItems() { return (int)copiedServerList.size(); }
virtual void selectItem(int item, bool doubleClick) { selectedItem = item; }
virtual bool isSelectedItem(int item) { return item == selectedItem; }
virtual void renderBackground() {}
virtual void renderItem(int i, int x, int y, int h, Tesselator& t)
{
const PingedCompatibleServer& s = copiedServerList[i];
unsigned int color = s.isSpecial? 0xff00b0 : 0xffffa0;
drawString(minecraft->font, s.name.C_String(), x, y + 2, color);
drawString(minecraft->font, s.address.ToString(false), x, y + 16, 0xffffa0);
}
};
class JoinGameScreen: public Screen
{
public:
JoinGameScreen();
virtual ~JoinGameScreen();
void init();
void setupPositions();
virtual bool handleBackEvent(bool isDown);
virtual bool isIndexValid(int index);
virtual void tick();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
bool isInGameScreen();
private:
Button bJoin;
Button bBack;
AvailableGamesList* gamesList;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__JoinGameScreen_H__*/
#pragma once
#include "../Screen.h"
#include "../components/Button.h"
#include "../components/ScrolledSelectionList.h"
#include "../../Minecraft.h"
#include "../../../network/RakNetInstance.h"
class JoinGameScreen;
class AvailableGamesList : public ScrolledSelectionList
{
int selectedItem;
ServerList copiedServerList;
friend class JoinGameScreen;
public:
AvailableGamesList(Minecraft* _minecraft, int _width, int _height)
: ScrolledSelectionList(_minecraft, _width, _height, 24, _height - 30, 28)
{
}
protected:
virtual int getNumberOfItems() { return (int)copiedServerList.size(); }
virtual void selectItem(int item, bool doubleClick) { selectedItem = item; }
virtual bool isSelectedItem(int item) { return item == selectedItem; }
virtual void renderBackground() {}
virtual void renderItem(int i, int x, int y, int h, Tesselator& t)
{
const PingedCompatibleServer& s = copiedServerList[i];
unsigned int color = s.isSpecial? 0xff00b0 : 0xffffa0;
drawString(minecraft->font, s.name.C_String(), x, y + 2, color);
drawString(minecraft->font, s.address.ToString(false), x, y + 16, 0xffffa0);
}
};
class JoinGameScreen: public Screen
{
public:
JoinGameScreen();
virtual ~JoinGameScreen();
void init();
void setupPositions();
virtual bool handleBackEvent(bool isDown);
virtual bool isIndexValid(int index);
virtual void tick();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
bool isInGameScreen();
private:
Button bJoin;
Button bBack;
AvailableGamesList* gamesList;
};

View File

@@ -1,49 +1,47 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__OptionsScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__OptionsScreen_H__
#include "../Screen.h"
#include "../components/Button.h"
#include "../components/OptionsGroup.h"
class ImageButton;
class OptionsPane;
class OptionsScreen: public Screen
{
typedef Screen super;
void init();
void generateOptionScreens();
public:
OptionsScreen();
~OptionsScreen();
void setupPositions();
void buttonClicked(Button* button);
void render(int xm, int ym, float a);
void removed();
void selectCategory(int index);
virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseReleased(int x, int y, int buttonNum);
virtual void keyPressed(int eventKey);
virtual void charPressed(char inputChar);
virtual void tick();
private:
Touch::THeader* bHeader;
ImageButton* btnClose;
Button* btnCredits; // <-- ADD THIS
std::vector<Touch::TButton*> categoryButtons;
std::vector<OptionsGroup*> optionPanes;
OptionsGroup* currentOptionsGroup;
int selectedCategory;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__OptionsScreen_H__*/
#pragma once
#include "../Screen.h"
#include "../components/Button.h"
#include "../components/OptionsGroup.h"
class ImageButton;
class OptionsPane;
class OptionsScreen: public Screen
{
typedef Screen super;
void init();
void generateOptionScreens();
public:
OptionsScreen();
~OptionsScreen();
void setupPositions();
void buttonClicked(Button* button);
void render(int xm, int ym, float a);
void removed();
void selectCategory(int index);
virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseReleased(int x, int y, int buttonNum);
virtual void keyPressed(int eventKey);
virtual void charPressed(char inputChar);
virtual void tick();
private:
Touch::THeader* bHeader;
ImageButton* btnClose;
Button* btnCredits; // <-- ADD THIS
std::vector<Touch::TButton*> categoryButtons;
std::vector<OptionsGroup*> optionPanes;
OptionsGroup* currentOptionsGroup;
int selectedCategory;
};

View File

@@ -1,45 +1,43 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__PauseScreen_H__
#define NET_MINECRAFT_CLIENT_GUI__PauseScreen_H__
//package net.minecraft.client.gui;
#include "../Screen.h"
#include "../components/ImageButton.h"
class Button;
class PauseScreen: public Screen
{
typedef Screen super;
public:
PauseScreen(bool wasBackPaused);
~PauseScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
protected:
void buttonClicked(Button* button);
private:
void updateServerVisibilityText();
int saveStep;
int visibleTime;
bool wasBackPaused;
Button* bContinue;
Button* bQuit;
Button* bQuitAndSaveLocally;
Button* bServerVisibility;
Button* bOptions;
// Button* bThirdPerson;
// OptionButton bSound;
OptionButton bThirdPerson;
OptionButton bHideGui;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__PauseScreen_H__*/
#pragma once
//package net.minecraft.client.gui;
#include "../Screen.h"
#include "../components/ImageButton.h"
class Button;
class PauseScreen: public Screen
{
typedef Screen super;
public:
PauseScreen(bool wasBackPaused);
~PauseScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
protected:
void buttonClicked(Button* button);
private:
void updateServerVisibilityText();
int saveStep;
int visibleTime;
bool wasBackPaused;
Button* bContinue;
Button* bQuit;
Button* bQuitAndSaveLocally;
Button* bServerVisibility;
Button* bOptions;
// Button* bThirdPerson;
// OptionButton bSound;
OptionButton bThirdPerson;
OptionButton bHideGui;
};

View File

@@ -1,162 +1,160 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__PrerenderTilesScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__PrerenderTilesScreen_H__
#include "../Screen.h"
#include "../../renderer/GameRenderer.h"
#include "../../renderer/entity/ItemRenderer.h"
#include "../../../world/item/ItemInstance.h"
#include "../../../world/level/tile/Tile.h"
#include "../../../world/entity/player/Inventory.h"
#include "../../renderer/Tesselator.h"
#include "../../../world/item/crafting/Recipes.h"
#include "../../../world/item/crafting/FurnaceRecipes.h"
#include "../../../world/level/tile/LeafTile.h"
#include "../../renderer/TileRenderer.h"
class PrerenderTilesScreen: public Screen
{
public:
void init() {
Player p(minecraft->level, true);
Inventory _inventory(&p, true);
Inventory* inventory = &_inventory;
// Copy over the inventory items
for (int i = Inventory::MAX_SELECTION_SIZE; i < inventory->getContainerSize(); ++i)
addItem(inventory->getItem(i));
// Fill the inventory with all the recipe items we don't already have: furnace
const FurnaceRecipes::Map& furnaceRecipes = FurnaceRecipes::getInstance()->getRecipes();
for (FurnaceRecipes::Map::const_iterator cit = furnaceRecipes.begin(); cit != furnaceRecipes.end(); ++cit) {
ItemInstance ingredient(cit->first, 1, 0);
addItem(&ingredient);
ItemInstance result = cit->second;
addItem(&result);
}
// Fill the inventory with all the recipe items we don't already have: crafting
const RecipeList& recipes = Recipes::getInstance()->getRecipes();
for (unsigned int i = 0; i < recipes.size(); ++i) {
std::vector<ItemInstance> items;
std::vector<ItemInstance> required = recipes[i]->getItemPack().getItemInstances();
items.push_back(recipes[i]->getResultItem());
items.insert(items.end(), required.begin(), required.end());
for (unsigned int i = 0; i < items.size(); ++i) {
ItemInstance& item = items[i];
addItem(&item);
}
}
// Manually added stuff
// Example: the one that's spawned from tiles when destroyed
int items[] = {
Tile::sapling->id, LeafTile::BIRCH_LEAF,
Tile::sapling->id, LeafTile::EVERGREEN_LEAF,
Tile::sapling->id, LeafTile::NORMAL_LEAF,
Tile::dirt->id, 0,
Tile::reeds->id, 0,
Tile::gravel->id, 0,
Item::apple->id, 0,
Tile::grass_carried->id, 0,
Tile::web->id, 0,
Item::sign->id, 0,
};
for (int i = 0; i < sizeof(items)/sizeof(int); i += 2) {
ItemInstance item(items[i], 1, items[i+1]);
addItem(&item);
}
}
void render( int xm, int ym, float a ) {
static Stopwatch w;
w.start();
glDisable2(GL_DEPTH_TEST);
fill(0, 0, width, height, 0xffff00ff);
//fill(0, 0, width, height, 0xff333333);
glColor4f2(1, 1, 1, 1);
glEnable2(GL_BLEND);
LOGI("--------------------\n");
/*int j = 0;
for (int i = Inventory::MAX_SELECTION_SIZE; i < inventory->getContainerSize(); ++i) {
ItemInstance* item = inventory->getItem(i);
if (!item) continue;
//LOGI("desc: %d - %s. %d\n", i, item->toString().c_str());
int x = j%16 * 16;
int y = j/16 * 16;
//Tesselator::instance.color(0xffffffff);
//minecraft->textures->loadAndBindTexture("gui/gui2.png");
//glColor4f2(0.2f, 0.5f, 0.2f, 1);
//blit(x, y, 4 + 20 * (i%9), 4, 16, 16, 15, 15);
//glColor4f2(1, 1, 1, 1);
if (item->id < 256 && TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape())) {
LOGI("0, %d, %d, %d, 0\n", j, item->id, item->getAuxValue());
ItemRenderer::renderGuiItemCorrect(minecraft->font, minecraft->textures, item, x, y);
} else if (item->getIcon() >= 0) {
LOGI("1, %d, %d, %d, %d\n", j, item->id, item->getAuxValue(), item->getIcon());
}
++j;
}*/
int j = 0;
for(std::vector<ItemInstance>::iterator i = mItems.begin(); i != mItems.end(); ++i) {
ItemInstance* item = &(*i);
//LOGI("desc: %d - %s. %d\n", i, item->toString().c_str());
int x = j%16 * 16;
int y = j/16 * 16;
if (item->id < 256 && TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape())) {
LOGI("0, %d, %d, %d, 0\n", j, item->id, item->getAuxValue());
ItemRenderer::renderGuiItemCorrect(minecraft->font, minecraft->textures, item, x, y);
} else if (item->getIcon() >= 0) {
LOGI("1, %d, %d, %d, %d\n", j, item->id, item->getAuxValue(), item->getIcon());
}
j++;
}
//@todo: blit out something famous here
//glRotatef2(-180, 1, 0, 0);
glEnable2(GL_DEPTH_TEST);
glDisable2(GL_BLEND);
w.stop();
w.printEvery(100, "render-blocksel");
}
void removed(){}
void addItem(ItemInstance* item) {
if(item == NULL)
return;
if (item->getAuxValue() < 0) return;
bool found = false;
for(std::vector<ItemInstance>::iterator i = mItems.begin(); i != mItems.end(); ++i) {
ItemInstance *jitem = &*i;
if(jitem->id != item->id) continue;
if(jitem->isStackedByData() && jitem->getAuxValue() != item->getAuxValue()) continue;
found = true;
break;
}
if (!found) {
LOGI("Adding item: %s\n", item->getDescriptionId().c_str());
mItems.push_back(*item);
}
}
private:
std::vector<ItemInstance> mItems;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__PrerenderTilesScreen_H__*/
#pragma once
#include "../Screen.h"
#include "../../renderer/GameRenderer.h"
#include "../../renderer/entity/ItemRenderer.h"
#include "../../../world/item/ItemInstance.h"
#include "../../../world/level/tile/Tile.h"
#include "../../../world/entity/player/Inventory.h"
#include "../../renderer/Tesselator.h"
#include "../../../world/item/crafting/Recipes.h"
#include "../../../world/item/crafting/FurnaceRecipes.h"
#include "../../../world/level/tile/LeafTile.h"
#include "../../renderer/TileRenderer.h"
class PrerenderTilesScreen: public Screen
{
public:
void init() {
Player p(minecraft->level, true);
Inventory _inventory(&p, true);
Inventory* inventory = &_inventory;
// Copy over the inventory items
for (int i = Inventory::MAX_SELECTION_SIZE; i < inventory->getContainerSize(); ++i)
addItem(inventory->getItem(i));
// Fill the inventory with all the recipe items we don't already have: furnace
const FurnaceRecipes::Map& furnaceRecipes = FurnaceRecipes::getInstance()->getRecipes();
for (FurnaceRecipes::Map::const_iterator cit = furnaceRecipes.begin(); cit != furnaceRecipes.end(); ++cit) {
ItemInstance ingredient(cit->first, 1, 0);
addItem(&ingredient);
ItemInstance result = cit->second;
addItem(&result);
}
// Fill the inventory with all the recipe items we don't already have: crafting
const RecipeList& recipes = Recipes::getInstance()->getRecipes();
for (unsigned int i = 0; i < recipes.size(); ++i) {
std::vector<ItemInstance> items;
std::vector<ItemInstance> required = recipes[i]->getItemPack().getItemInstances();
items.push_back(recipes[i]->getResultItem());
items.insert(items.end(), required.begin(), required.end());
for (unsigned int i = 0; i < items.size(); ++i) {
ItemInstance& item = items[i];
addItem(&item);
}
}
// Manually added stuff
// Example: the one that's spawned from tiles when destroyed
int items[] = {
Tile::sapling->id, LeafTile::BIRCH_LEAF,
Tile::sapling->id, LeafTile::EVERGREEN_LEAF,
Tile::sapling->id, LeafTile::NORMAL_LEAF,
Tile::dirt->id, 0,
Tile::reeds->id, 0,
Tile::gravel->id, 0,
Item::apple->id, 0,
Tile::grass_carried->id, 0,
Tile::web->id, 0,
Item::sign->id, 0,
};
for (int i = 0; i < sizeof(items)/sizeof(int); i += 2) {
ItemInstance item(items[i], 1, items[i+1]);
addItem(&item);
}
}
void render( int xm, int ym, float a ) {
static Stopwatch w;
w.start();
glDisable2(GL_DEPTH_TEST);
fill(0, 0, width, height, 0xffff00ff);
//fill(0, 0, width, height, 0xff333333);
glColor4f2(1, 1, 1, 1);
glEnable2(GL_BLEND);
LOGI("--------------------\n");
/*int j = 0;
for (int i = Inventory::MAX_SELECTION_SIZE; i < inventory->getContainerSize(); ++i) {
ItemInstance* item = inventory->getItem(i);
if (!item) continue;
//LOGI("desc: %d - %s. %d\n", i, item->toString().c_str());
int x = j%16 * 16;
int y = j/16 * 16;
//Tesselator::instance.color(0xffffffff);
//minecraft->textures->loadAndBindTexture("gui/gui2.png");
//glColor4f2(0.2f, 0.5f, 0.2f, 1);
//blit(x, y, 4 + 20 * (i%9), 4, 16, 16, 15, 15);
//glColor4f2(1, 1, 1, 1);
if (item->id < 256 && TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape())) {
LOGI("0, %d, %d, %d, 0\n", j, item->id, item->getAuxValue());
ItemRenderer::renderGuiItemCorrect(minecraft->font, minecraft->textures, item, x, y);
} else if (item->getIcon() >= 0) {
LOGI("1, %d, %d, %d, %d\n", j, item->id, item->getAuxValue(), item->getIcon());
}
++j;
}*/
int j = 0;
for(std::vector<ItemInstance>::iterator i = mItems.begin(); i != mItems.end(); ++i) {
ItemInstance* item = &(*i);
//LOGI("desc: %d - %s. %d\n", i, item->toString().c_str());
int x = j%16 * 16;
int y = j/16 * 16;
if (item->id < 256 && TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape())) {
LOGI("0, %d, %d, %d, 0\n", j, item->id, item->getAuxValue());
ItemRenderer::renderGuiItemCorrect(minecraft->font, minecraft->textures, item, x, y);
} else if (item->getIcon() >= 0) {
LOGI("1, %d, %d, %d, %d\n", j, item->id, item->getAuxValue(), item->getIcon());
}
j++;
}
//@todo: blit out something famous here
//glRotatef2(-180, 1, 0, 0);
glEnable2(GL_DEPTH_TEST);
glDisable2(GL_BLEND);
w.stop();
w.printEvery(100, "render-blocksel");
}
void removed(){}
void addItem(ItemInstance* item) {
if(item == NULL)
return;
if (item->getAuxValue() < 0) return;
bool found = false;
for(std::vector<ItemInstance>::iterator i = mItems.begin(); i != mItems.end(); ++i) {
ItemInstance *jitem = &*i;
if(jitem->id != item->id) continue;
if(jitem->isStackedByData() && jitem->getAuxValue() != item->getAuxValue()) continue;
found = true;
break;
}
if (!found) {
LOGI("Adding item: %s\n", item->getDescriptionId().c_str());
mItems.push_back(*item);
}
}
private:
std::vector<ItemInstance> mItems;
};

View File

@@ -1,21 +1,19 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ProgressScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ProgressScreen_H__
#include "../Screen.h"
class ProgressScreen: public Screen
{
public:
ProgressScreen();
void render(int xm, int ym, float a);
bool isInGameScreen();
virtual void keyPressed(int eventKey) {}
void tick();
private:
int ticks;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ProgressScreen_H__*/
#pragma once
#include "../Screen.h"
class ProgressScreen: public Screen
{
public:
ProgressScreen();
void render(int xm, int ym, float a);
bool isInGameScreen();
virtual void keyPressed(int eventKey) {}
void tick();
private:
int ticks;
};

View File

@@ -1,30 +1,28 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ScreenChooser_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ScreenChooser_H__
enum ScreenId {
SCREEN_NONE,
SCREEN_STARTMENU,
SCREEN_JOINGAME,
SCREEN_PAUSE,
SCREEN_PAUSEPREV,
SCREEN_SELECTWORLD,
SCREEN_BLOCKSELECTION,
SCREEN_JOINBYIP,
SCREEN_CONSOLE
};
class Screen;
class MinecraftClient;
class ScreenChooser
{
public:
ScreenChooser(MinecraftClient& mc) : _mc(mc) {}
Screen* createScreen(ScreenId id);
Screen* setScreen(ScreenId id);
private:
MinecraftClient& _mc;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ScreenChooser_H__*/
#pragma once
enum ScreenId {
SCREEN_NONE,
SCREEN_STARTMENU,
SCREEN_JOINGAME,
SCREEN_PAUSE,
SCREEN_PAUSEPREV,
SCREEN_SELECTWORLD,
SCREEN_BLOCKSELECTION,
SCREEN_JOINBYIP,
SCREEN_CONSOLE
};
class Screen;
class MinecraftClient;
class ScreenChooser
{
public:
ScreenChooser(MinecraftClient& mc) : _mc(mc) {}
Screen* createScreen(ScreenId id);
Screen* setScreen(ScreenId id);
private:
MinecraftClient& _mc;
};

View File

@@ -1,112 +1,110 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__SelectWorldScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__SelectWorldScreen_H__
#include "../Screen.h"
#include "../TweenData.h"
#include "../components/Button.h"
#include "../components/RolledSelectionListH.h"
#include "../../../world/level/storage/LevelStorageSource.h"
class SelectWorldScreen;
class MinecraftClient;
//
// Scrolling World selection list
//
class WorldSelectionList : public RolledSelectionListH
{
public:
WorldSelectionList(MinecraftClient& _minecraft, int _width, int _height);
virtual void tick();
void stepLeft();
void stepRight();
void commit();
protected:
virtual int getNumberOfItems();
virtual void selectItem(int item, bool doubleClick);
virtual bool isSelectedItem(int item);
virtual void renderBackground() {}
virtual void renderItem(int i, int x, int y, int h, Tesselator& t);
virtual float getPos(float alpha);
virtual void touched() { mode = 0; }
virtual bool capXPosition();
private:
TweenData td;
void tweenInited();
int selectedItem;
int _height;
LevelSummaryList levels;
std::vector<StringVector> _descriptions;
StringVector _imageNames;
bool hasPickedLevel;
LevelSummary pickedLevel;
int stoppedTick;
int currentTick;
float accRatio;
int mode;
friend class SelectWorldScreen;
};
//
// Delete World screen
//
#include "ConfirmScreen.h"
class DeleteWorldScreen: public ConfirmScreen
{
public:
DeleteWorldScreen(const LevelSummary& levelId);
protected:
virtual void postResult(bool isOk);
private:
LevelSummary _level;
};
//
// Select world screen
//
class SelectWorldScreen: public Screen
{
public:
SelectWorldScreen();
virtual ~SelectWorldScreen();
virtual void init();
virtual void setupPositions();
virtual void tick();
virtual bool isIndexValid(int index);
virtual bool handleBackEvent(bool isDown);
virtual void buttonClicked(Button* button);
virtual void keyPressed(int eventKey);
void render(int xm, int ym, float a);
// mouse wheel scroll (new in desktop implementation)
virtual void mouseWheel(int dx, int dy, int xm, int ym);
bool isInGameScreen();
private:
void loadLevelSource();
std::string getUniqueLevelName(const std::string& level);
Button bDelete;
Button bCreate;
Button bBack;
Button bWorldView;
WorldSelectionList* worldsList;
LevelSummaryList levels;
bool _mouseHasBeenUp;
bool _hasStartedLevel;
//LevelStorageSource* levels;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__SelectWorldScreen_H__*/
#pragma once
#include "../Screen.h"
#include "../TweenData.h"
#include "../components/Button.h"
#include "../components/RolledSelectionListH.h"
#include "../../../world/level/storage/LevelStorageSource.h"
class SelectWorldScreen;
class MinecraftClient;
//
// Scrolling World selection list
//
class WorldSelectionList : public RolledSelectionListH
{
public:
WorldSelectionList(MinecraftClient& _minecraft, int _width, int _height);
virtual void tick();
void stepLeft();
void stepRight();
void commit();
protected:
virtual int getNumberOfItems();
virtual void selectItem(int item, bool doubleClick);
virtual bool isSelectedItem(int item);
virtual void renderBackground() {}
virtual void renderItem(int i, int x, int y, int h, Tesselator& t);
virtual float getPos(float alpha);
virtual void touched() { mode = 0; }
virtual bool capXPosition();
private:
TweenData td;
void tweenInited();
int selectedItem;
int _height;
LevelSummaryList levels;
std::vector<StringVector> _descriptions;
StringVector _imageNames;
bool hasPickedLevel;
LevelSummary pickedLevel;
int stoppedTick;
int currentTick;
float accRatio;
int mode;
friend class SelectWorldScreen;
};
//
// Delete World screen
//
#include "ConfirmScreen.h"
class DeleteWorldScreen: public ConfirmScreen
{
public:
DeleteWorldScreen(const LevelSummary& levelId);
protected:
virtual void postResult(bool isOk);
private:
LevelSummary _level;
};
//
// Select world screen
//
class SelectWorldScreen: public Screen
{
public:
SelectWorldScreen();
virtual ~SelectWorldScreen();
virtual void init();
virtual void setupPositions();
virtual void tick();
virtual bool isIndexValid(int index);
virtual bool handleBackEvent(bool isDown);
virtual void buttonClicked(Button* button);
virtual void keyPressed(int eventKey);
void render(int xm, int ym, float a);
// mouse wheel scroll (new in desktop implementation)
virtual void mouseWheel(int dx, int dy, int xm, int ym);
bool isInGameScreen();
private:
void loadLevelSource();
std::string getUniqueLevelName(const std::string& level);
Button bDelete;
Button bCreate;
Button bBack;
Button bWorldView;
WorldSelectionList* worldsList;
LevelSummaryList levels;
bool _mouseHasBeenUp;
bool _hasStartedLevel;
//LevelStorageSource* levels;
};

View File

@@ -1,44 +1,42 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__
#include "ChooseLevelScreen.h"
#include "../components/TextBox.h"
#include "../components/Button.h" // for Touch::THeader
class Button;
class ImageButton;
class SimpleChooseLevelScreen: public ChooseLevelScreen
{
public:
SimpleChooseLevelScreen(const std::string& levelName);
virtual ~SimpleChooseLevelScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
bool handleBackEvent(bool isDown);
virtual void keyPressed(int eventKey);
virtual void mouseClicked(int x, int y, int buttonNum);
private:
Touch::THeader* bHeader;
Button* bGamemode;
Button* bCheats;
ImageButton* bBack;
Button* bCreate;
bool hasChosen;
std::string levelName;
int gamemode;
bool cheatsEnabled;
TextBox tLevelName;
TextBox tSeed;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__*/
#pragma once
#include "ChooseLevelScreen.h"
#include "../components/TextBox.h"
#include "../components/Button.h" // for Touch::THeader
class Button;
class ImageButton;
class SimpleChooseLevelScreen: public ChooseLevelScreen
{
public:
SimpleChooseLevelScreen(const std::string& levelName);
virtual ~SimpleChooseLevelScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
bool handleBackEvent(bool isDown);
virtual void keyPressed(int eventKey);
virtual void mouseClicked(int x, int y, int buttonNum);
private:
Touch::THeader* bHeader;
Button* bGamemode;
Button* bCheats;
ImageButton* bBack;
Button* bCreate;
bool hasChosen;
std::string levelName;
int gamemode;
bool cheatsEnabled;
TextBox tLevelName;
TextBox tSeed;
};

View File

@@ -1,40 +1,38 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__StartMenuScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__StartMenuScreen_H__
#include "../Screen.h"
#include "../components/Button.h"
#include "../components/ImageButton.h"
class StartMenuScreen: public Screen
{
public:
StartMenuScreen();
virtual ~StartMenuScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
virtual void mouseClicked(int x, int y, int buttonNum);
bool handleBackEvent(bool isDown);
bool isInGameScreen();
private:
Button bHost;
Button bJoin;
Button bOptions;
ImageButton bQuit; // X button in top-right corner
std::string copyright;
int copyrightPosX;
std::string version;
int versionPosX;
std::string username;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__StartMenuScreen_H__*/
#pragma once
#include "../Screen.h"
#include "../components/Button.h"
#include "../components/ImageButton.h"
class StartMenuScreen: public Screen
{
public:
StartMenuScreen();
virtual ~StartMenuScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
virtual void mouseClicked(int x, int y, int buttonNum);
bool handleBackEvent(bool isDown);
bool isInGameScreen();
private:
Button bHost;
Button bJoin;
Button bOptions;
ImageButton bQuit; // X button in top-right corner
std::string copyright;
int copyrightPosX;
std::string version;
int versionPosX;
std::string username;
};

View File

@@ -1,35 +1,33 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__TextEditScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__TextEditScreen_H__
//package net.minecraft.client.gui;
#include "../Screen.h"
#include <string>
#include "../components/ImageButton.h"
class SignTileEntity;
class Button;
class TextEditScreen: public Screen
{
typedef Screen super;
public:
TextEditScreen(SignTileEntity* signEntity);
~TextEditScreen();
void init();
void tick();
bool handleBackEvent(bool isDown);
void render(int xm, int ym, float a);
virtual void lostFocus();
virtual void keyPressed(int eventKey);
virtual void charPressed(char inputChar);
void setupPositions();
void buttonClicked(Button* button);
protected:
bool isShowingKeyboard;
SignTileEntity* sign;
int frame;
int line;
private:
ImageButton btnClose;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__TextEditScreen_H__*/
#pragma once
//package net.minecraft.client.gui;
#include "../Screen.h"
#include <string>
#include "../components/ImageButton.h"
class SignTileEntity;
class Button;
class TextEditScreen: public Screen
{
typedef Screen super;
public:
TextEditScreen(SignTileEntity* signEntity);
~TextEditScreen();
void init();
void tick();
bool handleBackEvent(bool isDown);
void render(int xm, int ym, float a);
virtual void lostFocus();
virtual void keyPressed(int eventKey);
virtual void charPressed(char inputChar);
void setupPositions();
void buttonClicked(Button* button);
protected:
bool isShowingKeyboard;
SignTileEntity* sign;
int frame;
int line;
private:
ImageButton btnClose;
};

View File

@@ -1,36 +1,34 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__UploadPhotoScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__UploadPhotoScreen_H__
#include "Screen.h"
class UploadPhotoScreen : public Screen
{
public:
UploadPhotoScreen();
virtual ~UploadPhotoScreen() {}
virtual void init();
void render(int xm, int ym, float a) {
Screen::render(xm, ym, a);
}
protected:
virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseReleased(int x, int y, int buttonNum);
virtual void keyPressed(int eventKey);
private:
int selectedItem;
void renderSlots();
void renderSlot(int slot, int x, int y, float a);
int getSelectedSlot(int x, int y);
void selectSlotAndClose();
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__UploadPhotoScreen_H__*/
#pragma once
#include "Screen.h"
class UploadPhotoScreen : public Screen
{
public:
UploadPhotoScreen();
virtual ~UploadPhotoScreen() {}
virtual void init();
void render(int xm, int ym, float a) {
Screen::render(xm, ym, a);
}
protected:
virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseReleased(int x, int y, int buttonNum);
virtual void keyPressed(int eventKey);
private:
int selectedItem;
void renderSlots();
void renderSlot(int slot, int x, int y, float a);
int getSelectedSlot(int x, int y);
void selectSlotAndClose();
};

View File

@@ -1,5 +1,4 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__UsernameScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__UsernameScreen_H__
#pragma once
#include "../Screen.h"
#include "../components/Button.h"
@@ -34,4 +33,3 @@ private:
int _cursorBlink;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__UsernameScreen_H__*/

View File

@@ -1,10 +1,8 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_CraftingFilters_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_CraftingFilters_H__
class ItemInstance;
namespace CraftingFilters {
bool isStonecutterItem(const ItemInstance& item);
}
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_CraftingFilters_H__*/
#pragma once
class ItemInstance;
namespace CraftingFilters {
bool isStonecutterItem(const ItemInstance& item);
}

View File

@@ -1,106 +1,104 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_PaneCraftingScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_PaneCraftingScreen_H__
#include "../../Screen.h"
#include "../../../../world/item/crafting/Recipes.h"
#include "../../../../world/item/ItemInstance.h"
#include "../../components/ScrollingPane.h"
#include "../../components/ImageButton.h"
#include "../../components/ItemPane.h"
class Font;
class CItem;
class Textures;
class NinePatchLayer;
class CraftButton: public ImageButton
{
typedef ImageButton super;
public:
CraftButton(int id);
~CraftButton();
void init(Textures*);
void setSize(float w, float h);
void setNumItems(int i) { numItems = i; }
IntRectangle getItemPos(int i);
void renderBg(Minecraft* minecraft, int xm, int ym);
private:
NinePatchLayer* bg;
NinePatchLayer* bgSelected;
int numItems;
};
class PaneCraftingScreen: public Screen,
public IItemPaneCallback
{
typedef Screen super;
typedef std::vector<CItem*> ItemList;
public:
PaneCraftingScreen(int craftingSize);
~PaneCraftingScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
bool renderGameBehind();
bool closeOnPlayerHurt();
void buttonClicked(Button* button);
void keyPressed( int eventKey );
// IItemPaneCallback
void onItemSelected(const ItemPane* forPane, int itemIndexInCurrentCategory);
const std::vector<CItem*>& getItems(const ItemPane* forPane);
protected:
void setSingleCategoryAndIcon(int categoryBitmask, int categoryIcon);
private:
/// Filter out non craftable recipes.
/// The default implementation calls bool filterRecipe(r) for every
/// Recipe r and keeps the ones that returned true.
/// A crafting size filter has already been applied.
virtual void filterRecipes(RecipeList& recipes);
virtual bool filterRecipe(const Recipe& recipe) = 0;
void initCategories();
void addItem(Recipe* recipe);
void recheckRecipes();
void onItemSelected(int buttonIndex, CItem* item);
void clearCategoryItems();
void craftSelectedItem();
std::vector<ImageButton*> _categoryButtons;
ItemList _items;
std::vector<ItemList> _categories;
int currentCategory;
CItem* currentItem;
std::string currentItemDesc;
std::vector<Button*> currentCategoryButtons;
ImageButton btnClose;
CraftButton btnCraft;
int craftingSize;
ItemPane* pane;
IntRectangle paneRect;
//int paneX;
//int paneW;
int numCategories;
std::vector<int> categoryBitmasks;
std::vector<int> categoryIcons;
ImageButton* selectedCategoryButton;
// GUI elements such as 9-Patches
NinePatchLayer* guiBackground;
NinePatchLayer* guiSlotCategory;
NinePatchLayer* guiSlotCategorySelected;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_PaneCraftingScreen_H__*/
#pragma once
#include "../../Screen.h"
#include "../../../../world/item/crafting/Recipes.h"
#include "../../../../world/item/ItemInstance.h"
#include "../../components/ScrollingPane.h"
#include "../../components/ImageButton.h"
#include "../../components/ItemPane.h"
class Font;
class CItem;
class Textures;
class NinePatchLayer;
class CraftButton: public ImageButton
{
typedef ImageButton super;
public:
CraftButton(int id);
~CraftButton();
void init(Textures*);
void setSize(float w, float h);
void setNumItems(int i) { numItems = i; }
IntRectangle getItemPos(int i);
void renderBg(Minecraft* minecraft, int xm, int ym);
private:
NinePatchLayer* bg;
NinePatchLayer* bgSelected;
int numItems;
};
class PaneCraftingScreen: public Screen,
public IItemPaneCallback
{
typedef Screen super;
typedef std::vector<CItem*> ItemList;
public:
PaneCraftingScreen(int craftingSize);
~PaneCraftingScreen();
void init();
void setupPositions();
void tick();
void render(int xm, int ym, float a);
bool renderGameBehind();
bool closeOnPlayerHurt();
void buttonClicked(Button* button);
void keyPressed( int eventKey );
// IItemPaneCallback
void onItemSelected(const ItemPane* forPane, int itemIndexInCurrentCategory);
const std::vector<CItem*>& getItems(const ItemPane* forPane);
protected:
void setSingleCategoryAndIcon(int categoryBitmask, int categoryIcon);
private:
/// Filter out non craftable recipes.
/// The default implementation calls bool filterRecipe(r) for every
/// Recipe r and keeps the ones that returned true.
/// A crafting size filter has already been applied.
virtual void filterRecipes(RecipeList& recipes);
virtual bool filterRecipe(const Recipe& recipe) = 0;
void initCategories();
void addItem(Recipe* recipe);
void recheckRecipes();
void onItemSelected(int buttonIndex, CItem* item);
void clearCategoryItems();
void craftSelectedItem();
std::vector<ImageButton*> _categoryButtons;
ItemList _items;
std::vector<ItemList> _categories;
int currentCategory;
CItem* currentItem;
std::string currentItemDesc;
std::vector<Button*> currentCategoryButtons;
ImageButton btnClose;
CraftButton btnCraft;
int craftingSize;
ItemPane* pane;
IntRectangle paneRect;
//int paneX;
//int paneW;
int numCategories;
std::vector<int> categoryBitmasks;
std::vector<int> categoryIcons;
ImageButton* selectedCategoryButton;
// GUI elements such as 9-Patches
NinePatchLayer* guiBackground;
NinePatchLayer* guiSlotCategory;
NinePatchLayer* guiSlotCategorySelected;
};

View File

@@ -1,17 +1,15 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_StonecutterScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_StonecutterScreen_H__
#include "PaneCraftingScreen.h"
class StonecutterScreen: public PaneCraftingScreen
{
typedef PaneCraftingScreen super;
public:
StonecutterScreen();
~StonecutterScreen();
private:
bool filterRecipe(const Recipe& r);
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_StonecutterScreen_H__*/
#pragma once
#include "PaneCraftingScreen.h"
class StonecutterScreen: public PaneCraftingScreen
{
typedef PaneCraftingScreen super;
public:
StonecutterScreen();
~StonecutterScreen();
private:
bool filterRecipe(const Recipe& r);
};

View File

@@ -1,17 +1,15 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_WorkbenchScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_WorkbenchScreen_H__
#include "PaneCraftingScreen.h"
class WorkbenchScreen: public PaneCraftingScreen
{
typedef PaneCraftingScreen super;
public:
WorkbenchScreen(int craftingSize);
~WorkbenchScreen();
private:
bool filterRecipe(const Recipe& r);
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_WorkbenchScreen_H__*/
#pragma once
#include "PaneCraftingScreen.h"
class WorkbenchScreen: public PaneCraftingScreen
{
typedef PaneCraftingScreen super;
public:
WorkbenchScreen(int craftingSize);
~WorkbenchScreen();
private:
bool filterRecipe(const Recipe& r);
};

View File

@@ -1,73 +1,71 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchIngameBlockSelectionScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchIngameBlockSelectionScreen_H__
#include "../../Screen.h"
#include "../../components/InventoryPane.h"
#include "../../components/Button.h"
#include "../../components/ScrollingPane.h"
#include "../../components/ItemPane.h"
#include "../../TweenData.h"
#include "../../../player/input/touchscreen/TouchAreaModel.h"
#include "../../../../AppPlatform.h"
namespace Touch {
class IngameBlockSelectionScreen : public Screen,
public IInventoryPaneCallback
{
typedef Screen super;
public:
IngameBlockSelectionScreen();
virtual ~IngameBlockSelectionScreen();
virtual void init() override;
virtual void setupPositions() override;
virtual void removed() override;
void tick() override;
void render(int xm, int ym, float a) override;
bool hasClippingArea(IntRectangle& out) override;
// IInventoryPaneCallback
bool addItem(const InventoryPane* pane, int itemId) override;
bool isAllowed(int slot) override;
std::vector<const ItemInstance*> getItems(const InventoryPane* forPane) override;
void buttonClicked(Button* button) override;
protected:
virtual void mouseClicked(int x, int y, int buttonNum) override;
virtual void mouseReleased(int x, int y, int buttonNum) override;
// also support wheel scrolling
virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
private:
void renderDemoOverlay();
//int getLinearSlotId(int x, int y);
int getSlotPosX(int slotX);
int getSlotPosY(int slotY);
int getSlotHeight();
private:
int selectedItem;
bool _pendingClose;
InventoryPane* _blockList;
THeader bHeader;
ImageButton bDone;
TButton bCraft;
TButton bArmor;
TButton bMenu;
IntRectangle clippingArea;
int InventoryRows;
int InventorySize;
int InventoryColumns;
};
}
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchIngameBlockSelectionScreen_H__*/
#pragma once
#include "../../Screen.h"
#include "../../components/InventoryPane.h"
#include "../../components/Button.h"
#include "../../components/ScrollingPane.h"
#include "../../components/ItemPane.h"
#include "../../TweenData.h"
#include "../../../player/input/touchscreen/TouchAreaModel.h"
#include "../../../../AppPlatform.h"
namespace Touch {
class IngameBlockSelectionScreen : public Screen,
public IInventoryPaneCallback
{
typedef Screen super;
public:
IngameBlockSelectionScreen();
virtual ~IngameBlockSelectionScreen();
virtual void init() override;
virtual void setupPositions() override;
virtual void removed() override;
void tick() override;
void render(int xm, int ym, float a) override;
bool hasClippingArea(IntRectangle& out) override;
// IInventoryPaneCallback
bool addItem(const InventoryPane* pane, int itemId) override;
bool isAllowed(int slot) override;
std::vector<const ItemInstance*> getItems(const InventoryPane* forPane) override;
void buttonClicked(Button* button) override;
protected:
virtual void mouseClicked(int x, int y, int buttonNum) override;
virtual void mouseReleased(int x, int y, int buttonNum) override;
// also support wheel scrolling
virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
private:
void renderDemoOverlay();
//int getLinearSlotId(int x, int y);
int getSlotPosX(int slotX);
int getSlotPosY(int slotY);
int getSlotHeight();
private:
int selectedItem;
bool _pendingClose;
InventoryPane* _blockList;
THeader bHeader;
ImageButton bDone;
TButton bCraft;
TButton bArmor;
TButton bMenu;
IntRectangle clippingArea;
int InventoryRows;
int InventorySize;
int InventoryColumns;
};
}

View File

@@ -1,74 +1,72 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchJoinGameScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchJoinGameScreen_H__
#include "../../Screen.h"
#include "../../components/Button.h"
#include "../../components/RolledSelectionListV.h"
#include "../../../Minecraft.h"
#include "../../../../platform/input/Multitouch.h"
#include "../../../../network/RakNetInstance.h"
namespace Touch {
class JoinGameScreen;
class AvailableGamesList : public RolledSelectionListV
{
int startSelected;
int selectedItem;
ServerList copiedServerList;
friend class JoinGameScreen;
public:
AvailableGamesList(Minecraft* _minecraft, int _width, int _height)
: RolledSelectionListV(_minecraft, _width, _height, 0, _width, 24, _height, 34),
selectedItem(-1),
startSelected(-1)
{
}
protected:
virtual int getNumberOfItems() { return (int)copiedServerList.size(); }
virtual void selectCancel();
virtual void selectStart(int item);
virtual void selectItem(int item, bool doubleClick);
virtual bool isSelectedItem(int item) { return item == selectedItem; }
virtual void renderBackground() {}
virtual void renderItem(int i, int x, int y, int h, Tesselator& t);
};
class JoinGameScreen: public Screen
{
public:
JoinGameScreen();
virtual ~JoinGameScreen();
void init();
void setupPositions();
virtual bool handleBackEvent(bool isDown);
virtual bool isIndexValid(int index);
virtual void tick();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
bool isInGameScreen();
private:
Button bJoin;
TButton bBack;
TButton bJoinByIp;
THeader bHeader;
AvailableGamesList* gamesList;
};
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchJoinGameScreen_H__*/
#pragma once
#include "../../Screen.h"
#include "../../components/Button.h"
#include "../../components/RolledSelectionListV.h"
#include "../../../Minecraft.h"
#include "../../../../platform/input/Multitouch.h"
#include "../../../../network/RakNetInstance.h"
namespace Touch {
class JoinGameScreen;
class AvailableGamesList : public RolledSelectionListV
{
int startSelected;
int selectedItem;
ServerList copiedServerList;
friend class JoinGameScreen;
public:
AvailableGamesList(Minecraft* _minecraft, int _width, int _height)
: RolledSelectionListV(_minecraft, _width, _height, 0, _width, 24, _height, 34),
selectedItem(-1),
startSelected(-1)
{
}
protected:
virtual int getNumberOfItems() { return (int)copiedServerList.size(); }
virtual void selectCancel();
virtual void selectStart(int item);
virtual void selectItem(int item, bool doubleClick);
virtual bool isSelectedItem(int item) { return item == selectedItem; }
virtual void renderBackground() {}
virtual void renderItem(int i, int x, int y, int h, Tesselator& t);
};
class JoinGameScreen: public Screen
{
public:
JoinGameScreen();
virtual ~JoinGameScreen();
void init();
void setupPositions();
virtual bool handleBackEvent(bool isDown);
virtual bool isIndexValid(int index);
virtual void tick();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
bool isInGameScreen();
private:
Button bJoin;
TButton bBack;
TButton bJoinByIp;
THeader bHeader;
AvailableGamesList* gamesList;
};
};

View File

@@ -1,122 +1,120 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchSelectWorldScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchSelectWorldScreen_H__
#include "../ConfirmScreen.h"
#include "../../Screen.h"
#include "../../TweenData.h"
#include "../../components/ImageButton.h"
#include "../../components/Button.h"
#include "../../components/RolledSelectionListH.h"
#include "../../../Minecraft.h"
#include "../../../../world/level/storage/LevelStorageSource.h"
namespace Touch {
class SelectWorldScreen;
//
// Scrolling World selection list
//
class TouchWorldSelectionList : public RolledSelectionListH
{
public:
TouchWorldSelectionList(Minecraft* _minecraft, int _width, int _height);
virtual void tick();
void stepLeft();
void stepRight();
void commit();
protected:
virtual int getNumberOfItems();
virtual void selectItem(int item, bool doubleClick);
virtual bool isSelectedItem(int item);
virtual void renderBackground() {}
virtual void renderItem(int i, int x, int y, int h, Tesselator& t);
virtual float getPos(float alpha);
virtual void touched() { mode = 0; }
virtual bool capXPosition();
virtual void selectStart(int item, int localX, int localY);
virtual void selectCancel();
private:
TweenData td;
void tweenInited();
int selectedItem;
bool _newWorldSelected; // Is the PLUS button pressed?
int _height;
LevelSummaryList levels;
std::vector<StringVector> _descriptions;
StringVector _imageNames;
bool hasPickedLevel;
LevelSummary pickedLevel;
int pickedIndex;
int stoppedTick;
int currentTick;
float accRatio;
int mode;
friend class SelectWorldScreen;
};
//
// Delete World screen
//
class TouchDeleteWorldScreen: public ConfirmScreen
{
public:
TouchDeleteWorldScreen(const LevelSummary& levelId);
protected:
virtual void postResult(bool isOk);
private:
LevelSummary _level;
};
//
// Select world screen
//
class SelectWorldScreen: public Screen
{
public:
SelectWorldScreen();
virtual ~SelectWorldScreen();
virtual void init() override;
virtual void setupPositions() override;
virtual void tick() override;
virtual void render(int xm, int ym, float a) override;
virtual bool isIndexValid(int index);
virtual bool handleBackEvent(bool isDown) override;
virtual void buttonClicked(Button* button) override;
virtual void keyPressed(int eventKey) override;
// support for mouse wheel when desktop code uses touch variant
virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
bool isInGameScreen() override;
private:
void loadLevelSource();
std::string getUniqueLevelName(const std::string& level);
ImageButton bDelete;
TButton bCreate;
THeader bHeader;
TButton bBack;
Button bWorldView;
TouchWorldSelectionList* worldsList;
LevelSummaryList levels;
bool _mouseHasBeenUp;
bool _hasStartedLevel;
//LevelStorageSource* levels;
};
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchSelectWorldScreen_H__*/
#pragma once
#include "../ConfirmScreen.h"
#include "../../Screen.h"
#include "../../TweenData.h"
#include "../../components/ImageButton.h"
#include "../../components/Button.h"
#include "../../components/RolledSelectionListH.h"
#include "../../../Minecraft.h"
#include "../../../../world/level/storage/LevelStorageSource.h"
namespace Touch {
class SelectWorldScreen;
//
// Scrolling World selection list
//
class TouchWorldSelectionList : public RolledSelectionListH
{
public:
TouchWorldSelectionList(Minecraft* _minecraft, int _width, int _height);
virtual void tick();
void stepLeft();
void stepRight();
void commit();
protected:
virtual int getNumberOfItems();
virtual void selectItem(int item, bool doubleClick);
virtual bool isSelectedItem(int item);
virtual void renderBackground() {}
virtual void renderItem(int i, int x, int y, int h, Tesselator& t);
virtual float getPos(float alpha);
virtual void touched() { mode = 0; }
virtual bool capXPosition();
virtual void selectStart(int item, int localX, int localY);
virtual void selectCancel();
private:
TweenData td;
void tweenInited();
int selectedItem;
bool _newWorldSelected; // Is the PLUS button pressed?
int _height;
LevelSummaryList levels;
std::vector<StringVector> _descriptions;
StringVector _imageNames;
bool hasPickedLevel;
LevelSummary pickedLevel;
int pickedIndex;
int stoppedTick;
int currentTick;
float accRatio;
int mode;
friend class SelectWorldScreen;
};
//
// Delete World screen
//
class TouchDeleteWorldScreen: public ConfirmScreen
{
public:
TouchDeleteWorldScreen(const LevelSummary& levelId);
protected:
virtual void postResult(bool isOk);
private:
LevelSummary _level;
};
//
// Select world screen
//
class SelectWorldScreen: public Screen
{
public:
SelectWorldScreen();
virtual ~SelectWorldScreen();
virtual void init() override;
virtual void setupPositions() override;
virtual void tick() override;
virtual void render(int xm, int ym, float a) override;
virtual bool isIndexValid(int index);
virtual bool handleBackEvent(bool isDown) override;
virtual void buttonClicked(Button* button) override;
virtual void keyPressed(int eventKey) override;
// support for mouse wheel when desktop code uses touch variant
virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
bool isInGameScreen() override;
private:
void loadLevelSource();
std::string getUniqueLevelName(const std::string& level);
ImageButton bDelete;
TButton bCreate;
THeader bHeader;
TButton bBack;
Button bWorldView;
TouchWorldSelectionList* worldsList;
LevelSummaryList levels;
bool _mouseHasBeenUp;
bool _hasStartedLevel;
//LevelStorageSource* levels;
};
};

View File

@@ -1,43 +1,41 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchStartMenuScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchStartMenuScreen_H__
#include "../../Screen.h"
#include "../../components/LargeImageButton.h"
#include "../../components/ImageButton.h"
#include "../../components/TextBox.h"
namespace Touch {
class StartMenuScreen: public Screen
{
public:
StartMenuScreen();
virtual ~StartMenuScreen();
void init();
void setupPositions();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
virtual void mouseClicked(int x, int y, int buttonNum);
bool handleBackEvent(bool isDown);
bool isInGameScreen();
private:
LargeImageButton bHost;
LargeImageButton bJoin;
LargeImageButton bOptions;
ImageButton bQuit; // X close icon
std::string copyright;
int copyrightPosX;
std::string version;
int versionPosX;
std::string username;
};
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchStartMenuScreen_H__*/
#pragma once
#include "../../Screen.h"
#include "../../components/LargeImageButton.h"
#include "../../components/ImageButton.h"
#include "../../components/TextBox.h"
namespace Touch {
class StartMenuScreen: public Screen
{
public:
StartMenuScreen();
virtual ~StartMenuScreen();
void init();
void setupPositions();
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
virtual void mouseClicked(int x, int y, int buttonNum);
bool handleBackEvent(bool isDown);
bool isInGameScreen();
private:
LargeImageButton bHost;
LargeImageButton bJoin;
LargeImageButton bOptions;
ImageButton bQuit; // X close icon
std::string copyright;
int copyrightPosX;
std::string version;
int versionPosX;
std::string username;
};
};

View File

@@ -1,52 +1,50 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__ChestModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__ChestModel_H__
//package net.minecraft.client.model;
#include "Model.h"
#include "geom/ModelPart.h"
class ChestModel: public Model
{
public:
ChestModel()
: lid(0, 0),
lock(0, 0),
bottom(0, 0)
{
lid.setModel(this);
lid.setTexSize(64, 64);
lid.addBox(0.0f, -5, -14, 14, 5, 14, 0);
lid.x = 1;
lid.y = 7;
lid.z = 15;
lock.setModel(this);
lock.setTexSize(64, 64);
lock.addBox(-1, -2, -15, 2, 4, 1, 0);
lock.x = 8;
lock.y = 7;
lock.z = 15;
bottom.setModel(this);
bottom.setTexSize(64, 64);
bottom.addBox(0.0f, 0, 0, 14, 10, 14, 0);
bottom.x = 1;
bottom.y = 6;
bottom.z = 1;
}
void render() {
lock.xRot = lid.xRot;
lid.render(1 / 16.0f);
lock.render(1 / 16.0f);
bottom.render(1 / 16.0f);
}
ModelPart lid;
ModelPart bottom;
ModelPart lock;
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__ChestModel_H__*/
#pragma once
//package net.minecraft.client.model;
#include "Model.h"
#include "geom/ModelPart.h"
class ChestModel: public Model
{
public:
ChestModel()
: lid(0, 0),
lock(0, 0),
bottom(0, 0)
{
lid.setModel(this);
lid.setTexSize(64, 64);
lid.addBox(0.0f, -5, -14, 14, 5, 14, 0);
lid.x = 1;
lid.y = 7;
lid.z = 15;
lock.setModel(this);
lock.setTexSize(64, 64);
lock.addBox(-1, -2, -15, 2, 4, 1, 0);
lock.x = 8;
lock.y = 7;
lock.z = 15;
bottom.setModel(this);
bottom.setTexSize(64, 64);
bottom.addBox(0.0f, 0, 0, 14, 10, 14, 0);
bottom.x = 1;
bottom.y = 6;
bottom.z = 1;
}
void render() {
lock.xRot = lid.xRot;
lid.render(1 / 16.0f);
lock.render(1 / 16.0f);
bottom.render(1 / 16.0f);
}
ModelPart lid;
ModelPart bottom;
ModelPart lock;
};

View File

@@ -1,23 +1,21 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__ChickenModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__ChickenModel_H__
#include "Model.h"
#include "geom/ModelPart.h"
class Entity;
class ChickenModel: public Model
{
typedef Model super;
public:
ModelPart head, hair, body, leg0, leg1, wing0, wing1, beak, redThing;
ChickenModel();
/*@Override*/
void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__ChickenModel_H__*/
#pragma once
#include "Model.h"
#include "geom/ModelPart.h"
class Entity;
class ChickenModel: public Model
{
typedef Model super;
public:
ModelPart head, hair, body, leg0, leg1, wing0, wing1, beak, redThing;
ChickenModel();
/*@Override*/
void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
};

View File

@@ -1,15 +1,13 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__CowModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__CowModel_H__
//package net.minecraft.client.model;
#include "QuadrupedModel.h"
class CowModel: public QuadrupedModel
{
typedef QuadrupedModel super;
public:
CowModel();
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__CowModel_H__*/
#pragma once
//package net.minecraft.client.model;
#include "QuadrupedModel.h"
class CowModel: public QuadrupedModel
{
typedef QuadrupedModel super;
public:
CowModel();
};

View File

@@ -1,82 +1,80 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__CreeperModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__CreeperModel_H__
//package net.minecraft.client.model;
#include "Model.h"
#include "geom/ModelPart.h"
#include "../../world/entity/Entity.h"
class CreeperModel: public Model
{
typedef Model super;
public:
ModelPart head, /*hair,*/ body, leg0, leg1, leg2, leg3;
CreeperModel(float g = 0)
: head(0, 0),
//hair(32, 0),
body(16, 16),
leg0(0, 16),
leg1(0, 16),
leg2(0, 16),
leg3(0, 16)
{
float yo = 4;
head.setModel(this);
//hair.setModel(this);
body.setModel(this);
leg0.setModel(this);
leg1.setModel(this);
leg2.setModel(this);
leg3.setModel(this);
head.addBox(-4, -8, -4, 8, 8, 8, g); // Head
head.setPos(0, yo, 0);
// hair.addBox(-4, -8, -4, 8, 8, 8, g + 0.5f); // Head
// hair.setPos(0, yo, 0);
body.addBox(-4, 0, -2, 8, 12, 4, g); // Body
body.setPos(0, yo, 0);
leg0.addBox(-2, 0, -2, 4, 6, 4, g); // Leg0
leg0.setPos(-2, 12 + yo, 4);
leg1.addBox(-2, 0, -2, 4, 6, 4, g); // Leg1
leg1.setPos(2, 12 + yo, 4);
leg2.addBox(-2, 0, -2, 4, 6, 4, g); // Leg2
leg2.setPos(-2, 12 + yo, -4);
leg3.addBox(-2, 0, -2, 4, 6, 4, g); // Leg3
leg3.setPos(2, 12 + yo, -4);
}
/*@Override*/
void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale) {
setupAnim(time, r, bob, yRot, xRot, scale);
head.render(scale);
body.render(scale);
leg0.render(scale);
leg1.render(scale);
leg2.render(scale);
leg3.render(scale);
}
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {
head.yRot = yRot / (float) (180 / Mth::PI);
head.xRot = xRot / (float) (180 / Mth::PI);
const float pend = (Mth::cos(time * 0.6662f) * 1.4f) * r;
leg0.xRot = pend;
leg1.xRot = -pend;
leg2.xRot = -pend;
leg3.xRot = pend;
}
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__CreeperModel_H__*/
#pragma once
//package net.minecraft.client.model;
#include "Model.h"
#include "geom/ModelPart.h"
#include "../../world/entity/Entity.h"
class CreeperModel: public Model
{
typedef Model super;
public:
ModelPart head, /*hair,*/ body, leg0, leg1, leg2, leg3;
CreeperModel(float g = 0)
: head(0, 0),
//hair(32, 0),
body(16, 16),
leg0(0, 16),
leg1(0, 16),
leg2(0, 16),
leg3(0, 16)
{
float yo = 4;
head.setModel(this);
//hair.setModel(this);
body.setModel(this);
leg0.setModel(this);
leg1.setModel(this);
leg2.setModel(this);
leg3.setModel(this);
head.addBox(-4, -8, -4, 8, 8, 8, g); // Head
head.setPos(0, yo, 0);
// hair.addBox(-4, -8, -4, 8, 8, 8, g + 0.5f); // Head
// hair.setPos(0, yo, 0);
body.addBox(-4, 0, -2, 8, 12, 4, g); // Body
body.setPos(0, yo, 0);
leg0.addBox(-2, 0, -2, 4, 6, 4, g); // Leg0
leg0.setPos(-2, 12 + yo, 4);
leg1.addBox(-2, 0, -2, 4, 6, 4, g); // Leg1
leg1.setPos(2, 12 + yo, 4);
leg2.addBox(-2, 0, -2, 4, 6, 4, g); // Leg2
leg2.setPos(-2, 12 + yo, -4);
leg3.addBox(-2, 0, -2, 4, 6, 4, g); // Leg3
leg3.setPos(2, 12 + yo, -4);
}
/*@Override*/
void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale) {
setupAnim(time, r, bob, yRot, xRot, scale);
head.render(scale);
body.render(scale);
leg0.render(scale);
leg1.render(scale);
leg2.render(scale);
leg3.render(scale);
}
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {
head.yRot = yRot / (float) (180 / Mth::PI);
head.xRot = xRot / (float) (180 / Mth::PI);
const float pend = (Mth::cos(time * 0.6662f) * 1.4f) * r;
leg0.xRot = pend;
leg1.xRot = -pend;
leg2.xRot = -pend;
leg3.xRot = pend;
}
};

View File

@@ -1,28 +1,26 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__HumanoidModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__HumanoidModel_H__
//package net.minecraft.client.model;
#include "Model.h"
#include "geom/ModelPart.h"
class ItemInstance;
class HumanoidModel: public Model
{
public:
HumanoidModel(float g = 0, float yOffset = 0, int texW = 64, int texH = 32);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
void render(HumanoidModel* model, float scale);
void render(Entity* e, float time, float r, float bob, float yRot, float xRot, float scale);
void renderHorrible(float time, float r, float bob, float yRot, float xRot, float scale);
void onGraphicsReset();
ModelPart head, hair, body, arm0, arm1, leg0, leg1;//, ear;
bool holdingLeftHand;
bool holdingRightHand;
bool sneaking;
bool bowAndArrow;
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__HumanoidModel_H__*/
#pragma once
//package net.minecraft.client.model;
#include "Model.h"
#include "geom/ModelPart.h"
class ItemInstance;
class HumanoidModel: public Model
{
public:
HumanoidModel(float g = 0, float yOffset = 0, int texW = 64, int texH = 32);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
void render(HumanoidModel* model, float scale);
void render(Entity* e, float time, float r, float bob, float yRot, float xRot, float scale);
void renderHorrible(float time, float r, float bob, float yRot, float xRot, float scale);
void onGraphicsReset();
ModelPart head, hair, body, arm0, arm1, leg0, leg1;//, ear;
bool holdingLeftHand;
bool holdingRightHand;
bool sneaking;
bool bowAndArrow;
};

View File

@@ -1,48 +1,46 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__Model_H__
#define NET_MINECRAFT_CLIENT_MODEL__Model_H__
//package net.minecraft.client.model;
#include <vector>
#include "geom/ModelPart.h"
class Mob;
class Entity;
class Model
{
protected:
Model()
: riding(false),
attackTime(0),
texWidth(64),
texHeight(32),
young(true)
{}
public:
virtual ~Model() {}
virtual void onGraphicsReset() {
for (unsigned int i = 0; i < cubes.size(); ++i)
cubes[i]->onGraphicsReset();
}
virtual void render(Entity* e, float time, float r, float bob, float yRot, float xRot, float scale) {}
virtual void renderHorrible(float time, float r, float bob, float yRot, float xRot, float scale) {}
virtual void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {}
virtual void prepareMobModel(Mob* mob, float time, float r, float a) {}
float attackTime;
bool riding;
int texWidth;
int texHeight;
std::vector<ModelPart*> cubes;
bool young;
private:
//Map<String, TexOffs> mappedTexOffs = new HashMap<String, TexOffs>();
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__Model_H__*/
#pragma once
//package net.minecraft.client.model;
#include <vector>
#include "geom/ModelPart.h"
class Mob;
class Entity;
class Model
{
protected:
Model()
: riding(false),
attackTime(0),
texWidth(64),
texHeight(32),
young(true)
{}
public:
virtual ~Model() {}
virtual void onGraphicsReset() {
for (unsigned int i = 0; i < cubes.size(); ++i)
cubes[i]->onGraphicsReset();
}
virtual void render(Entity* e, float time, float r, float bob, float yRot, float xRot, float scale) {}
virtual void renderHorrible(float time, float r, float bob, float yRot, float xRot, float scale) {}
virtual void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {}
virtual void prepareMobModel(Mob* mob, float time, float r, float a) {}
float attackTime;
bool riding;
int texWidth;
int texHeight;
std::vector<ModelPart*> cubes;
bool young;
private:
//Map<String, TexOffs> mappedTexOffs = new HashMap<String, TexOffs>();
};

View File

@@ -1,17 +1,15 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__ModelInclude_H__
#define NET_MINECRAFT_CLIENT_MODEL__ModelInclude_H__
#include "HumanoidModel.h"
#include "ChickenModel.h"
#include "CowModel.h"
#include "PigModel.h"
#include "SheepModel.h"
#include "SheepFurModel.h"
#include "ZombieModel.h"
#include "SkeletonModel.h"
#include "SignModel.h"
#endif /*NET_MINECRAFT_CLIENT_MODEL__ModelInclude_H__*/
#pragma once
#include "HumanoidModel.h"
#include "ChickenModel.h"
#include "CowModel.h"
#include "PigModel.h"
#include "SheepModel.h"
#include "SheepFurModel.h"
#include "ZombieModel.h"
#include "SkeletonModel.h"
#include "SignModel.h"

View File

@@ -1,15 +1,13 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__PigModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__PigModel_H__
//package net.minecraft.client.model;
#include "QuadrupedModel.h"
class PigModel: public QuadrupedModel
{
typedef QuadrupedModel super;
public:
PigModel(float g = 0);
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__PigModel_H__*/
#pragma once
//package net.minecraft.client.model;
#include "QuadrupedModel.h"
class PigModel: public QuadrupedModel
{
typedef QuadrupedModel super;
public:
PigModel(float g = 0);
};

View File

@@ -1,28 +1,26 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__QuadrupedModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__QuadrupedModel_H__
//package net.minecraft.client.model;
#include "Model.h"
#include "geom/ModelPart.h"
class Entity;
class QuadrupedModel: public Model
{
public:
QuadrupedModel(int legSize, float g);
//@Override
void render(QuadrupedModel* model, float scale);
void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
ModelPart head, hair, body, leg0, leg1, leg2, leg3;
protected:
float yHeadOffs;
float zHeadOffs;
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__QuadrupedModel_H__*/
#pragma once
//package net.minecraft.client.model;
#include "Model.h"
#include "geom/ModelPart.h"
class Entity;
class QuadrupedModel: public Model
{
public:
QuadrupedModel(int legSize, float g);
//@Override
void render(QuadrupedModel* model, float scale);
void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
ModelPart head, hair, body, leg0, leg1, leg2, leg3;
protected:
float yHeadOffs;
float zHeadOffs;
};

View File

@@ -1,24 +1,22 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__SheepFurModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__SheepFurModel_H__
//package net.minecraft.client.model;
#include "QuadrupedModel.h"
class SheepFurModel: public QuadrupedModel
{
typedef QuadrupedModel super;
public:
SheepFurModel();
/*@Override*/
void prepareMobModel(Mob* mob, float time, float r, float a);
/*@Override*/
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
private:
float headXRot;
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__SheepFurModel_H__*/
#pragma once
//package net.minecraft.client.model;
#include "QuadrupedModel.h"
class SheepFurModel: public QuadrupedModel
{
typedef QuadrupedModel super;
public:
SheepFurModel();
/*@Override*/
void prepareMobModel(Mob* mob, float time, float r, float a);
/*@Override*/
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
private:
float headXRot;
};

View File

@@ -1,23 +1,21 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__SheepModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__SheepModel_H__
//package net.minecraft.client.model;
#include "QuadrupedModel.h"
class SheepModel: public QuadrupedModel
{
typedef QuadrupedModel super;
public:
SheepModel();
/*@Override*/
void prepareMobModel(Mob* mob, float time, float r, float a);
/*@Override*/
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
private:
float headXRot;
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__SheepModel_H__*/
#pragma once
//package net.minecraft.client.model;
#include "QuadrupedModel.h"
class SheepModel: public QuadrupedModel
{
typedef QuadrupedModel super;
public:
SheepModel();
/*@Override*/
void prepareMobModel(Mob* mob, float time, float r, float a);
/*@Override*/
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
private:
float headXRot;
};

View File

@@ -1,32 +1,30 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__SignModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__SignModel_H__
//package net.minecraft.client.model;
#include "Model.h"
#include "geom/ModelPart.h"
class SignModel: public Model
{
public:
SignModel()
: cube(0, 0),
cube2(0, 14)
{
cube.addBox(-12, -14, -1, 24, 12, 2, 0);
cube2.addBox(-1, -2, -1, 2, 14, 2, 0);
cube.setModel(this);
cube2.setModel(this);
}
void render() {
cube.render(1 / 16.0f);
cube2.render(1 / 16.0f);
}
ModelPart cube;
ModelPart cube2;
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__SignModel_H__*/
#pragma once
//package net.minecraft.client.model;
#include "Model.h"
#include "geom/ModelPart.h"
class SignModel: public Model
{
public:
SignModel()
: cube(0, 0),
cube2(0, 14)
{
cube.addBox(-12, -14, -1, 24, 12, 2, 0);
cube2.addBox(-1, -2, -1, 2, 14, 2, 0);
cube.setModel(this);
cube2.setModel(this);
}
void render() {
cube.render(1 / 16.0f);
cube2.render(1 / 16.0f);
}
ModelPart cube;
ModelPart cube2;
};

View File

@@ -1,46 +1,44 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__SkeletonModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__SkeletonModel_H__
//package net.minecraft.client.model;
#include "ZombieModel.h"
#include "geom/ModelPart.h"
class SkeletonModel: public ZombieModel
{
typedef ZombieModel super;
public:
SkeletonModel()
{
float g = 0;
arm0 = ModelPart(24 + 16, 16);
arm0.setModel(this);
arm0.addBox(-1, -2, -1, 2, 12, 2, g); // Arm0
arm0.setPos(-5, 2, 0);
arm1 = ModelPart(24 + 16, 16);
arm1.setModel(this);
arm1.mirror = true;
arm1.addBox(-1, -2, -1, 2, 12, 2, g); // Arm1
arm1.setPos(5, 2, 0);
leg0 = ModelPart(0, 16);
leg0.setModel(this);
leg0.addBox(-1, 0, -1, 2, 12, 2, g); // Leg0
leg0.setPos(-2, 12, 0);
leg1 = ModelPart(0, 16);
leg1.setModel(this);
leg1.mirror = true;
leg1.addBox(-1, 0, -1, 2, 12, 2, g); // Leg1
leg1.setPos(2, 12, 0);
}
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {
bowAndArrow = true;
super::setupAnim(time, r, bob, yRot, xRot, scale);
}
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__SkeletonModel_H__*/
#pragma once
//package net.minecraft.client.model;
#include "ZombieModel.h"
#include "geom/ModelPart.h"
class SkeletonModel: public ZombieModel
{
typedef ZombieModel super;
public:
SkeletonModel()
{
float g = 0;
arm0 = ModelPart(24 + 16, 16);
arm0.setModel(this);
arm0.addBox(-1, -2, -1, 2, 12, 2, g); // Arm0
arm0.setPos(-5, 2, 0);
arm1 = ModelPart(24 + 16, 16);
arm1.setModel(this);
arm1.mirror = true;
arm1.addBox(-1, -2, -1, 2, 12, 2, g); // Arm1
arm1.setPos(5, 2, 0);
leg0 = ModelPart(0, 16);
leg0.setModel(this);
leg0.addBox(-1, 0, -1, 2, 12, 2, g); // Leg0
leg0.setPos(-2, 12, 0);
leg1 = ModelPart(0, 16);
leg1.setModel(this);
leg1.mirror = true;
leg1.addBox(-1, 0, -1, 2, 12, 2, g); // Leg1
leg1.setPos(2, 12, 0);
}
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {
bowAndArrow = true;
super::setupAnim(time, r, bob, yRot, xRot, scale);
}
};

View File

@@ -1,168 +1,166 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__SpiderModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__SpiderModel_H__
//package net.minecraft.client.model;
#include "Model.h"
#include "geom/ModelPart.h"
#include "../../world/entity/Entity.h"
#include "../../util/Mth.h"
class SpiderModel: public Model
{
typedef Model super;
public:
ModelPart head, body0, body1, leg0, leg1, leg2, leg3, leg4, leg5, leg6, leg7;
SpiderModel()
: head(32, 4),
body0(0, 0),
body1(0, 12),
leg0(18, 0),
leg1(18, 0),
leg2(18, 0),
leg3(18, 0),
leg4(18, 0),
leg5(18, 0),
leg6(18, 0),
leg7(18, 0)
{
float g = 0;
head.setModel(this);
body0.setModel(this);
body0.setModel(this);
leg0.setModel(this);
leg1.setModel(this);
leg2.setModel(this);
leg3.setModel(this);
leg4.setModel(this);
leg5.setModel(this);
leg6.setModel(this);
leg7.setModel(this);
float yo = 18 + 6 - 9;
head.addBox(-4, -4, -8, 8, 8, 8, g); // Head
head.setPos(0, 0 + yo, -3);
body0.addBox(-3, -3, -3, 6, 6, 6, g); // Body
body0.setPos(0, yo, 0);
body1.addBox(-5, -4, -6, 10, 8, 12, g); // Body
body1.setPos(0, 0 + yo, 3 + 6);
leg0.addBox(-15, -1, -1, 16, 2, 2, g); // Leg0
leg0.setPos(-4, 0 + yo, 2);
leg1.addBox(-1, -1, -1, 16, 2, 2, g); // Leg1
leg1.setPos(4, 0 + yo, 2);
leg2.addBox(-15, -1, -1, 16, 2, 2, g); // Leg2
leg2.setPos(-4, 0 + yo, 1);
leg3.addBox(-1, -1, -1, 16, 2, 2, g); // Leg3
leg3.setPos(4, 0 + yo, 1);
leg4.addBox(-15, -1, -1, 16, 2, 2, g); // Leg0
leg4.setPos(-4, 0 + yo, 0);
leg5.addBox(-1, -1, -1, 16, 2, 2, g); // Leg1
leg5.setPos(4, 0 + yo, 0);
leg6.addBox(-15, -1, -1, 16, 2, 2, g); // Leg2
leg6.setPos(-4, 0 + yo, -1);
leg7.addBox(-1, -1, -1, 16, 2, 2, g); // Leg3
leg7.setPos(4, 0 + yo, -1);
}
/*@Override*/
void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale) {
setupAnim(time, r, bob, yRot, xRot, scale);
head.render(scale);
body0.render(scale);
body1.render(scale);
leg0.render(scale);
leg1.render(scale);
leg2.render(scale);
leg3.render(scale);
leg4.render(scale);
leg5.render(scale);
leg6.render(scale);
leg7.render(scale);
}
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {
head.yRot = yRot / (float) (180 / Mth::PI);
head.xRot = xRot / (float) (180 / Mth::PI);
const float sr = (float) Mth::PI / 4.0f;
leg0.zRot = -sr;
leg1.zRot = sr;
leg2.zRot = -sr * 0.74f;
leg3.zRot = sr * 0.74f;
leg4.zRot = -sr * 0.74f;
leg5.zRot = sr * 0.74f;
leg6.zRot = -sr;
leg7.zRot = sr;
//float ro = -(float) Mth::PI / 2.0f * 0;
const float ur = (float) Mth::PI / 8.0f;
const float ur2 = sr;
leg0.yRot = ur2;
leg1.yRot = -ur2;
leg2.yRot = ur;
leg3.yRot = -ur;
leg4.yRot = -ur;
leg5.yRot = +ur;
leg6.yRot = -ur2;
leg7.yRot = +ur2;
//static Stopwatch w;
//w.start();
float c0 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 0 / 4.0f) * 0.4f) * r;
float c1 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 2 / 4.0f) * 0.4f) * r;
float c2 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 1 / 4.0f) * 0.4f) * r;
float c3 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 3 / 4.0f) * 0.4f) * r;
//LOGI("spider: %f, %f, %f, %f\n", c0, c1, c2, c3);
float s0 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 0 / 4.0f) * 0.4f) * r;
float s1 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 2 / 4.0f) * 0.4f) * r;
float s2 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 1 / 4.0f) * 0.4f) * r;
float s3 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 3 / 4.0f) * 0.4f) * r;
//w.stop();
//w.printEvery(100);
//LOGI("spiddy: %f, %f, %f, %f\n", s0, s1, s2, s3);
leg0.yRot += c0;
leg1.yRot -= c0;
leg2.yRot += c1;
leg3.yRot -= c1;
leg4.yRot += c2;
leg5.yRot -= c2;
leg6.yRot += c3;
leg7.yRot -= c3;
leg0.zRot += s0;
leg1.zRot -= s0;
leg2.zRot += s1;
leg3.zRot -= s1;
leg4.zRot += s2;
leg5.zRot -= s2;
leg6.zRot += s3;
leg7.zRot -= s3;
}
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__SpiderModel_H__*/
#pragma once
//package net.minecraft.client.model;
#include "Model.h"
#include "geom/ModelPart.h"
#include "../../world/entity/Entity.h"
#include "../../util/Mth.h"
class SpiderModel: public Model
{
typedef Model super;
public:
ModelPart head, body0, body1, leg0, leg1, leg2, leg3, leg4, leg5, leg6, leg7;
SpiderModel()
: head(32, 4),
body0(0, 0),
body1(0, 12),
leg0(18, 0),
leg1(18, 0),
leg2(18, 0),
leg3(18, 0),
leg4(18, 0),
leg5(18, 0),
leg6(18, 0),
leg7(18, 0)
{
float g = 0;
head.setModel(this);
body0.setModel(this);
body0.setModel(this);
leg0.setModel(this);
leg1.setModel(this);
leg2.setModel(this);
leg3.setModel(this);
leg4.setModel(this);
leg5.setModel(this);
leg6.setModel(this);
leg7.setModel(this);
float yo = 18 + 6 - 9;
head.addBox(-4, -4, -8, 8, 8, 8, g); // Head
head.setPos(0, 0 + yo, -3);
body0.addBox(-3, -3, -3, 6, 6, 6, g); // Body
body0.setPos(0, yo, 0);
body1.addBox(-5, -4, -6, 10, 8, 12, g); // Body
body1.setPos(0, 0 + yo, 3 + 6);
leg0.addBox(-15, -1, -1, 16, 2, 2, g); // Leg0
leg0.setPos(-4, 0 + yo, 2);
leg1.addBox(-1, -1, -1, 16, 2, 2, g); // Leg1
leg1.setPos(4, 0 + yo, 2);
leg2.addBox(-15, -1, -1, 16, 2, 2, g); // Leg2
leg2.setPos(-4, 0 + yo, 1);
leg3.addBox(-1, -1, -1, 16, 2, 2, g); // Leg3
leg3.setPos(4, 0 + yo, 1);
leg4.addBox(-15, -1, -1, 16, 2, 2, g); // Leg0
leg4.setPos(-4, 0 + yo, 0);
leg5.addBox(-1, -1, -1, 16, 2, 2, g); // Leg1
leg5.setPos(4, 0 + yo, 0);
leg6.addBox(-15, -1, -1, 16, 2, 2, g); // Leg2
leg6.setPos(-4, 0 + yo, -1);
leg7.addBox(-1, -1, -1, 16, 2, 2, g); // Leg3
leg7.setPos(4, 0 + yo, -1);
}
/*@Override*/
void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale) {
setupAnim(time, r, bob, yRot, xRot, scale);
head.render(scale);
body0.render(scale);
body1.render(scale);
leg0.render(scale);
leg1.render(scale);
leg2.render(scale);
leg3.render(scale);
leg4.render(scale);
leg5.render(scale);
leg6.render(scale);
leg7.render(scale);
}
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {
head.yRot = yRot / (float) (180 / Mth::PI);
head.xRot = xRot / (float) (180 / Mth::PI);
const float sr = (float) Mth::PI / 4.0f;
leg0.zRot = -sr;
leg1.zRot = sr;
leg2.zRot = -sr * 0.74f;
leg3.zRot = sr * 0.74f;
leg4.zRot = -sr * 0.74f;
leg5.zRot = sr * 0.74f;
leg6.zRot = -sr;
leg7.zRot = sr;
//float ro = -(float) Mth::PI / 2.0f * 0;
const float ur = (float) Mth::PI / 8.0f;
const float ur2 = sr;
leg0.yRot = ur2;
leg1.yRot = -ur2;
leg2.yRot = ur;
leg3.yRot = -ur;
leg4.yRot = -ur;
leg5.yRot = +ur;
leg6.yRot = -ur2;
leg7.yRot = +ur2;
//static Stopwatch w;
//w.start();
float c0 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 0 / 4.0f) * 0.4f) * r;
float c1 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 2 / 4.0f) * 0.4f) * r;
float c2 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 1 / 4.0f) * 0.4f) * r;
float c3 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 3 / 4.0f) * 0.4f) * r;
//LOGI("spider: %f, %f, %f, %f\n", c0, c1, c2, c3);
float s0 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 0 / 4.0f) * 0.4f) * r;
float s1 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 2 / 4.0f) * 0.4f) * r;
float s2 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 1 / 4.0f) * 0.4f) * r;
float s3 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 3 / 4.0f) * 0.4f) * r;
//w.stop();
//w.printEvery(100);
//LOGI("spiddy: %f, %f, %f, %f\n", s0, s1, s2, s3);
leg0.yRot += c0;
leg1.yRot -= c0;
leg2.yRot += c1;
leg3.yRot -= c1;
leg4.yRot += c2;
leg5.yRot -= c2;
leg6.yRot += c3;
leg7.yRot -= c3;
leg0.zRot += s0;
leg1.zRot -= s0;
leg2.zRot += s1;
leg3.zRot -= s1;
leg4.zRot += s2;
leg5.zRot -= s2;
leg6.zRot += s3;
leg7.zRot -= s3;
}
};

View File

@@ -1,37 +1,35 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__ZombieModel_H__
#define NET_MINECRAFT_CLIENT_MODEL__ZombieModel_H__
//package net.minecraft.client.model;
#include "HumanoidModel.h"
class ZombieModel: public HumanoidModel
{
typedef HumanoidModel super;
public:
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {
super::setupAnim(time, r, bob, yRot, xRot, scale);
if(!holdingLeftHand && !holdingRightHand) {
float attack2 = (float) Mth::sin(attackTime * Mth::PI);
float attack = (float) Mth::sin((1 - (1 - attackTime) * (1 - attackTime)) * Mth::PI);
arm0.zRot = 0;// -attack;
arm1.zRot = 0;// +attack;
arm0.yRot = -(0.1f - attack2 * 0.6f);
arm1.yRot = +(0.1f - attack2 * 0.6f);
arm0.xRot = -Mth::PI / 2.0f;
arm1.xRot = -Mth::PI / 2.0f;
arm0.xRot -= attack2 * 1.2f - attack * 0.4f;
arm1.xRot -= attack2 * 1.2f - attack * 0.4f;
// body.yRot = attack;
const float zBob = Mth::cos(bob * 0.09f) * 0.05f + 0.05f;
const float xBob = Mth::sin(bob * 0.067f) * 0.05f;
arm0.zRot += zBob;
arm1.zRot -= zBob;
arm0.xRot += xBob;
arm1.xRot -= xBob;
}
}
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__ZombieModel_H__*/
#pragma once
//package net.minecraft.client.model;
#include "HumanoidModel.h"
class ZombieModel: public HumanoidModel
{
typedef HumanoidModel super;
public:
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {
super::setupAnim(time, r, bob, yRot, xRot, scale);
if(!holdingLeftHand && !holdingRightHand) {
float attack2 = (float) Mth::sin(attackTime * Mth::PI);
float attack = (float) Mth::sin((1 - (1 - attackTime) * (1 - attackTime)) * Mth::PI);
arm0.zRot = 0;// -attack;
arm1.zRot = 0;// +attack;
arm0.yRot = -(0.1f - attack2 * 0.6f);
arm1.yRot = +(0.1f - attack2 * 0.6f);
arm0.xRot = -Mth::PI / 2.0f;
arm1.xRot = -Mth::PI / 2.0f;
arm0.xRot -= attack2 * 1.2f - attack * 0.4f;
arm1.xRot -= attack2 * 1.2f - attack * 0.4f;
// body.yRot = attack;
const float zBob = Mth::cos(bob * 0.09f) * 0.05f + 0.05f;
const float xBob = Mth::sin(bob * 0.067f) * 0.05f;
arm0.zRot += zBob;
arm1.zRot -= zBob;
arm0.xRot += xBob;
arm1.xRot -= xBob;
}
}
};

View File

@@ -1,29 +1,27 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL_GEOM__Cube_H__
#define NET_MINECRAFT_CLIENT_MODEL_GEOM__Cube_H__
//package net.minecraft.client.model;
#include <string>
#include "Polygon.h"
class Tesselator;
class ModelPart;
class Cube
{
public:
Cube(ModelPart* modelPart, int xTexOffs, int yTexOffs, float x0, float y0, float z0, int w, int h, int d, float g);
void compile(Tesselator& t, float scale);
Cube* setId(const std::string& id);
private:
VertexPT vertices[8];
PolygonQuad polygons[6];
std::string id;
const float x0, y0, z0, x1, y1, z1;
friend class ModelPart;
};
#endif /*NET_MINECRAFT_CLIENT_MODEL_GEOM__Cube_H__*/
#pragma once
//package net.minecraft.client.model;
#include <string>
#include "Polygon.h"
class Tesselator;
class ModelPart;
class Cube
{
public:
Cube(ModelPart* modelPart, int xTexOffs, int yTexOffs, float x0, float y0, float z0, int w, int h, int d, float g);
void compile(Tesselator& t, float scale);
Cube* setId(const std::string& id);
private:
VertexPT vertices[8];
PolygonQuad polygons[6];
std::string id;
const float x0, y0, z0, x1, y1, z1;
friend class ModelPart;
};

View File

@@ -1,74 +1,72 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL_GEOM__ModelPart_H__
#define NET_MINECRAFT_CLIENT_MODEL_GEOM__ModelPart_H__
#include "../../renderer/gles.h"
class Model;
class Cube;
class ModelPart
{
public:
ModelPart(const std::string& id);
ModelPart(int xTexOffs = 0, int yTexOffs = 0);
ModelPart(Model* model, int xTexOffs = 0, int yTexOffs = 0);
~ModelPart();
void _init();
void clear();//const ModelPart& rhs);
ModelPart& operator=(const ModelPart& rhs);
void setModel(Model* model);
void setPos( float x, float y, float z );
void translateTo( float scale );
ModelPart& setTexSize(int xs, int ys);
ModelPart& texOffs(int xTexOffs, int yTexOffs);
void mimic(const ModelPart* o);
// Render normally
void render( float scale );
void renderRollable( float scale );
void draw();
// Bad, immediate version... //@fix @todo: remove this
void renderHorrible(float scale);
void drawSlow( float scale );
void onGraphicsReset() { compiled = false; }
void compile( float scale );
void addChild(ModelPart* child);
ModelPart& addBox(const std::string& id, float x0, float y0, float z0, int w, int h, int d);
ModelPart& addBox(float x0, float y0, float z0, int w, int h, int d);
void addBox(float x0, float y0, float z0, int w, int h, int d, float g);
void addTexBox(float x0, float y0, float z0, int w, int h, int d, int tex);
float x, y, z;
float xRot, yRot, zRot;
bool mirror;
bool visible;
std::vector<Cube*> cubes;
std::vector<ModelPart*> children;
std::string id;
float xTexSize;
float yTexSize;
private:
int xTexOffs, yTexOffs;
bool neverRender;
bool compiled;
int list;
GLuint vboId;
Model* model;
};
#endif /*NET_MINECRAFT_CLIENT_MODEL_GEOM__ModelPart_H__*/
#pragma once
#include "../../renderer/gles.h"
class Model;
class Cube;
class ModelPart
{
public:
ModelPart(const std::string& id);
ModelPart(int xTexOffs = 0, int yTexOffs = 0);
ModelPart(Model* model, int xTexOffs = 0, int yTexOffs = 0);
~ModelPart();
void _init();
void clear();//const ModelPart& rhs);
ModelPart& operator=(const ModelPart& rhs);
void setModel(Model* model);
void setPos( float x, float y, float z );
void translateTo( float scale );
ModelPart& setTexSize(int xs, int ys);
ModelPart& texOffs(int xTexOffs, int yTexOffs);
void mimic(const ModelPart* o);
// Render normally
void render( float scale );
void renderRollable( float scale );
void draw();
// Bad, immediate version... //@fix @todo: remove this
void renderHorrible(float scale);
void drawSlow( float scale );
void onGraphicsReset() { compiled = false; }
void compile( float scale );
void addChild(ModelPart* child);
ModelPart& addBox(const std::string& id, float x0, float y0, float z0, int w, int h, int d);
ModelPart& addBox(float x0, float y0, float z0, int w, int h, int d);
void addBox(float x0, float y0, float z0, int w, int h, int d, float g);
void addTexBox(float x0, float y0, float z0, int w, int h, int d, int tex);
float x, y, z;
float xRot, yRot, zRot;
bool mirror;
bool visible;
std::vector<Cube*> cubes;
std::vector<ModelPart*> children;
std::string id;
float xTexSize;
float yTexSize;
private:
int xTexOffs, yTexOffs;
bool neverRender;
bool compiled;
int list;
GLuint vboId;
Model* model;
};

View File

@@ -1,29 +1,27 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__Polygon_H__
#define NET_MINECRAFT_CLIENT_MODEL__Polygon_H__
//package net.minecraft.client.model;
#include "Vertex.h"
class Tesselator;
class PolygonQuad
{
public:
PolygonQuad() {}
PolygonQuad(VertexPT*,VertexPT*,VertexPT*,VertexPT*);
PolygonQuad(VertexPT*,VertexPT*,VertexPT*,VertexPT*, int u0, int v0, int u1, int v1, float texW = 64.0f, float texH = 32.0f);
PolygonQuad(VertexPT*,VertexPT*,VertexPT*,VertexPT*, float u0, float v0, float u1, float v1);
void mirror();
void render(Tesselator& t, float scale, int vboId = -1);
PolygonQuad* flipNormal();
VertexPT vertices[4];
//int vertexCount;
private:
static const int VERTEX_COUNT = 4;
bool _flipNormal;
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__Polygon_H__*/
#pragma once
//package net.minecraft.client.model;
#include "Vertex.h"
class Tesselator;
class PolygonQuad
{
public:
PolygonQuad() {}
PolygonQuad(VertexPT*,VertexPT*,VertexPT*,VertexPT*);
PolygonQuad(VertexPT*,VertexPT*,VertexPT*,VertexPT*, int u0, int v0, int u1, int v1, float texW = 64.0f, float texH = 32.0f);
PolygonQuad(VertexPT*,VertexPT*,VertexPT*,VertexPT*, float u0, float v0, float u1, float v1);
void mirror();
void render(Tesselator& t, float scale, int vboId = -1);
PolygonQuad* flipNormal();
VertexPT vertices[4];
//int vertexCount;
private:
static const int VERTEX_COUNT = 4;
bool _flipNormal;
};

View File

@@ -1,40 +1,38 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__Vertex_H__
#define NET_MINECRAFT_CLIENT_MODEL__Vertex_H__
//package net.minecraft.client.model;
#include "../../../world/phys/Vec3.h"
class VertexPT
{
public:
Vec3 pos;
float u, v;
VertexPT() {}
VertexPT(float x, float y, float z, float u_, float v_)
: pos(x, y, z),
u(u_),
v(v_)
{}
VertexPT remap(float u, float v) {
return VertexPT(*this, u, v);
}
VertexPT(const VertexPT& vertex, float u_, float v_) {
pos = vertex.pos;
u = u_;
v = v_;
}
VertexPT(const Vec3& pos_, float u_, float v_) {
pos = pos_;
u = u_;
v = v_;
}
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__Vertex_H__*/
#pragma once
//package net.minecraft.client.model;
#include "../../../world/phys/Vec3.h"
class VertexPT
{
public:
Vec3 pos;
float u, v;
VertexPT() {}
VertexPT(float x, float y, float z, float u_, float v_)
: pos(x, y, z),
u(u_),
v(v_)
{}
VertexPT remap(float u, float v) {
return VertexPT(*this, u, v);
}
VertexPT(const VertexPT& vertex, float u_, float v_) {
pos = vertex.pos;
u = u_;
v = v_;
}
VertexPT(const Vec3& pos_, float u_, float v_) {
pos = pos_;
u = u_;
v = v_;
}
};

View File

@@ -1,265 +1,263 @@
#ifndef NET_MINECRAFT_CLIENT_MULTIPLAYER__MultiPlayerLevel_H__
#define NET_MINECRAFT_CLIENT_MULTIPLAYER__MultiPlayerLevel_H__
#include "../../world/Pos.h"
#include "../../world/level/Level.h"
//#include "../../network/packet/DisconnectPacket.h"
#include "../../world/entity/Entity.h"
#include "../../world/level/chunk/ChunkSource.h"
#include "../../world/level/dimension/Dimension.h"
//#include "../../world/level/storage/MockedLevelStorage.h"
#include <set>
#include <map>
#include <list>
class MultiPlayerLevel: public Level
{
typedef Level super;
typedef std::map<int, Entity*> EntityIdMap;
typedef std::set<Entity*> EntitySet;
static const int TICKS_BEFORE_RESET = SharedConstants::TicksPerSecond * 4;
class ResetInfo {
public:
int x, y, z, ticks, tile, data;
ResetInfo(int x, int y, int z, int tile, int data)
: x(x),
y(y),
z(z),
ticks(TICKS_BEFORE_RESET),
tile(tile),
data(data)
{}
};
typedef std::list<ResetInfo> ResetInfoList;
public:
MultiPlayerLevel(LevelStorage* levelStorage, const std::string& levelName, const LevelSettings& settings, int levelVersion)
: super(levelStorage, levelName, settings, levelVersion)
{
//super(new MockedLevelStorage(), "MpServer", Dimension.getNew(dimension), levelSettings);
//this->difficulty = difficulty;
//setSpawnPos(new Pos(8, 64, 8));
//this.savedDataStorage = connection.savedDataStorage;
}
//@todo: destructor (to <delete> Entities)
void tick() {
if (adventureSettings.doTickTime) {
setTime(getTime() + 1);
}
updateSkyDarken();
for (int i = 0; i < 10 && !reEntries.empty(); i++) {
EntitySet::iterator it = reEntries.begin();
Entity* e = *it;//reEntries.iterator().next();
reEntries.erase(it);
//if (!entities.contains(e)) addEntity(e);
EntityList::iterator jt = std::find(entities.begin(), entities.end(), e);
if (jt == entities.end())
addEntity(e);
}
for (ResetInfoList::iterator it = updatesToReset.begin(); it != updatesToReset.end();) {
ResetInfo& r = *it;
if (--r.ticks == 0) {
super::setTileAndDataNoUpdate(r.x, r.y, r.z, r.tile, r.data);
super::sendTileUpdated(r.x, r.y, r.z);
it = updatesToReset.erase(it);
} else
++it;
}
}
void clearResetRegion(int x0, int y0, int z0, int x1, int y1, int z1) {
for (ResetInfoList::iterator it = updatesToReset.begin(); it != updatesToReset.end();) {
ResetInfo& r = *it;
if (r.x >= x0 && r.y >= y0 && r.z >= z0 && r.x <= x1 && r.y <= y1 && r.z <= z1) {
it = updatesToReset.erase(it);
} else
++it;
}
}
void validateSpawn() {
setSpawnPos(Pos(8, 64, 8));
}
void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay) {
}
bool tickPendingTicks(bool force) {
return false;
}
//@todo
//void setChunkVisible(int x, int z, bool visible) {
// if (visible) chunkCache.create(x, z);
// else chunkCache.drop(x, z);
// if (!visible) {
// this->setTilesDirty(x * 16, 0, z * 16, x * 16 + 15, depth, z * 16 + 15);
// }
//}
bool addEntity(Entity* e) {
bool ok = super::addEntity(e);
forced.insert(e);
if (!ok) {
reEntries.insert(e);
}
return ok;
}
void removeEntity(Entity* e) {
super::removeEntity(e);
forced.erase(e);
}
void putEntity(int id, Entity* e) {
Entity* old = getEntity(id);
if (old != NULL) {
removeEntity(old);
}
forced.insert(e);
e->entityId = id;
if (!addEntity(e)) {
reEntries.insert(e);
}
entitiesById.insert(std::make_pair(id, e));
}
Entity* getEntity(int id) {
EntityIdMap::const_iterator cit = entitiesById.find(id);
return cit != entitiesById.end()? cit->second : NULL;
}
Entity* removeEntity(int id) {
EntityIdMap::iterator it = entitiesById.find(id);
if (it != entitiesById.end()) {
Entity* e = it->second;
entitiesById.erase(it);
removeEntity(e);
return it->second;
}
return NULL;
}
bool setDataNoUpdate(int x, int y, int z, int data) {
int t = getTile(x, y, z);
int d = getData(x, y, z);
if (super::setDataNoUpdate(x, y, z, data)) {
updatesToReset.push_back(/*new*/ ResetInfo(x, y, z, t, d));
return true;
}
return false;
}
bool setTileAndDataNoUpdate(int x, int y, int z, int tile, int data) {
int t = getTile(x, y, z);
int d = getData(x, y, z);
if (super::setTileAndDataNoUpdate(x, y, z, tile, data)) {
updatesToReset.push_back(/*new*/ ResetInfo(x, y, z, t, d));
return true;
}
return false;
}
bool setTileNoUpdate(int x, int y, int z, int tile) {
int t = getTile(x, y, z);
int d = getData(x, y, z);
if (super::setTileNoUpdate(x, y, z, tile)) {
updatesToReset.push_back(/*new*/ ResetInfo(x, y, z, t, d));
return true;
}
return false;
}
bool doSetTileAndData(int x, int y, int z, int tile, int data) {
clearResetRegion(x, y, z, x, y, z);
if (super::setTileAndDataNoUpdate(x, y, z, tile, data)) {
// if (setTile(x, y, z, tile)) {
// setData(x, y, z, data);
tileUpdated(x, y, z, tile);
return true;
}
return false;
}
void disconnect() {
//connection.sendAndDisconnect(/*new*/ DisconnectPacket("Quitting"));
}
protected:
void tickTiles() {
}
/*@Override*/
ChunkSource* createChunkSource() {
//chunkCache = /*new*/ MultiPlayerChunkCache(this);
//return chunkCache;
return NULL;
}
void entityAdded(Entity* e) {
super::entityAdded(e);
EntitySet::iterator it = reEntries.find(e);
if (it != reEntries.end()) {
reEntries.erase(it);
}
}
void entityRemoved(Entity* e) {
super::entityRemoved(e);
EntitySet::iterator it = forced.find(e);
if (it != forced.end()) {
if (e->isAlive()) {
reEntries.insert(e);
} else {
forced.erase(it);
}
}
}
// void tickWeather() {
// if (dimension.hasCeiling) return;
//
// if (lightningTime > 0) {
// lightningTime--;
// }
//
// oRainLevel = rainLevel;
// if (levelData.isRaining()) {
// rainLevel += 0.01;
// } else {
// rainLevel -= 0.01;
// }
// if (rainLevel < 0) rainLevel = 0;
// if (rainLevel > 1) rainLevel = 1;
//
// oThunderLevel = thunderLevel;
// if (levelData.isThundering()) {
// thunderLevel += 0.01;
// } else {
// thunderLevel -= 0.01;
// }
// if (thunderLevel < 0) thunderLevel = 0;
// if (thunderLevel > 1) thunderLevel = 1;
// }
private:
ResetInfoList updatesToReset;
//ClientConnection connection;
//MultiPlayerChunkCache chunkCache;
EntityIdMap entitiesById;
EntitySet forced;
EntitySet reEntries;
};
#endif /*NET_MINECRAFT_CLIENT_MULTIPLAYER__MultiPlayerLevel_H__*/
#pragma once
#include "../../world/Pos.h"
#include "../../world/level/Level.h"
//#include "../../network/packet/DisconnectPacket.h"
#include "../../world/entity/Entity.h"
#include "../../world/level/chunk/ChunkSource.h"
#include "../../world/level/dimension/Dimension.h"
//#include "../../world/level/storage/MockedLevelStorage.h"
#include <set>
#include <map>
#include <list>
class MultiPlayerLevel: public Level
{
typedef Level super;
typedef std::map<int, Entity*> EntityIdMap;
typedef std::set<Entity*> EntitySet;
static const int TICKS_BEFORE_RESET = SharedConstants::TicksPerSecond * 4;
class ResetInfo {
public:
int x, y, z, ticks, tile, data;
ResetInfo(int x, int y, int z, int tile, int data)
: x(x),
y(y),
z(z),
ticks(TICKS_BEFORE_RESET),
tile(tile),
data(data)
{}
};
typedef std::list<ResetInfo> ResetInfoList;
public:
MultiPlayerLevel(LevelStorage* levelStorage, const std::string& levelName, const LevelSettings& settings, int levelVersion)
: super(levelStorage, levelName, settings, levelVersion)
{
//super(new MockedLevelStorage(), "MpServer", Dimension.getNew(dimension), levelSettings);
//this->difficulty = difficulty;
//setSpawnPos(new Pos(8, 64, 8));
//this.savedDataStorage = connection.savedDataStorage;
}
//@todo: destructor (to <delete> Entities)
void tick() {
if (adventureSettings.doTickTime) {
setTime(getTime() + 1);
}
updateSkyDarken();
for (int i = 0; i < 10 && !reEntries.empty(); i++) {
EntitySet::iterator it = reEntries.begin();
Entity* e = *it;//reEntries.iterator().next();
reEntries.erase(it);
//if (!entities.contains(e)) addEntity(e);
EntityList::iterator jt = std::find(entities.begin(), entities.end(), e);
if (jt == entities.end())
addEntity(e);
}
for (ResetInfoList::iterator it = updatesToReset.begin(); it != updatesToReset.end();) {
ResetInfo& r = *it;
if (--r.ticks == 0) {
super::setTileAndDataNoUpdate(r.x, r.y, r.z, r.tile, r.data);
super::sendTileUpdated(r.x, r.y, r.z);
it = updatesToReset.erase(it);
} else
++it;
}
}
void clearResetRegion(int x0, int y0, int z0, int x1, int y1, int z1) {
for (ResetInfoList::iterator it = updatesToReset.begin(); it != updatesToReset.end();) {
ResetInfo& r = *it;
if (r.x >= x0 && r.y >= y0 && r.z >= z0 && r.x <= x1 && r.y <= y1 && r.z <= z1) {
it = updatesToReset.erase(it);
} else
++it;
}
}
void validateSpawn() {
setSpawnPos(Pos(8, 64, 8));
}
void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay) {
}
bool tickPendingTicks(bool force) {
return false;
}
//@todo
//void setChunkVisible(int x, int z, bool visible) {
// if (visible) chunkCache.create(x, z);
// else chunkCache.drop(x, z);
// if (!visible) {
// this->setTilesDirty(x * 16, 0, z * 16, x * 16 + 15, depth, z * 16 + 15);
// }
//}
bool addEntity(Entity* e) {
bool ok = super::addEntity(e);
forced.insert(e);
if (!ok) {
reEntries.insert(e);
}
return ok;
}
void removeEntity(Entity* e) {
super::removeEntity(e);
forced.erase(e);
}
void putEntity(int id, Entity* e) {
Entity* old = getEntity(id);
if (old != NULL) {
removeEntity(old);
}
forced.insert(e);
e->entityId = id;
if (!addEntity(e)) {
reEntries.insert(e);
}
entitiesById.insert(std::make_pair(id, e));
}
Entity* getEntity(int id) {
EntityIdMap::const_iterator cit = entitiesById.find(id);
return cit != entitiesById.end()? cit->second : NULL;
}
Entity* removeEntity(int id) {
EntityIdMap::iterator it = entitiesById.find(id);
if (it != entitiesById.end()) {
Entity* e = it->second;
entitiesById.erase(it);
removeEntity(e);
return it->second;
}
return NULL;
}
bool setDataNoUpdate(int x, int y, int z, int data) {
int t = getTile(x, y, z);
int d = getData(x, y, z);
if (super::setDataNoUpdate(x, y, z, data)) {
updatesToReset.push_back(/*new*/ ResetInfo(x, y, z, t, d));
return true;
}
return false;
}
bool setTileAndDataNoUpdate(int x, int y, int z, int tile, int data) {
int t = getTile(x, y, z);
int d = getData(x, y, z);
if (super::setTileAndDataNoUpdate(x, y, z, tile, data)) {
updatesToReset.push_back(/*new*/ ResetInfo(x, y, z, t, d));
return true;
}
return false;
}
bool setTileNoUpdate(int x, int y, int z, int tile) {
int t = getTile(x, y, z);
int d = getData(x, y, z);
if (super::setTileNoUpdate(x, y, z, tile)) {
updatesToReset.push_back(/*new*/ ResetInfo(x, y, z, t, d));
return true;
}
return false;
}
bool doSetTileAndData(int x, int y, int z, int tile, int data) {
clearResetRegion(x, y, z, x, y, z);
if (super::setTileAndDataNoUpdate(x, y, z, tile, data)) {
// if (setTile(x, y, z, tile)) {
// setData(x, y, z, data);
tileUpdated(x, y, z, tile);
return true;
}
return false;
}
void disconnect() {
//connection.sendAndDisconnect(/*new*/ DisconnectPacket("Quitting"));
}
protected:
void tickTiles() {
}
/*@Override*/
ChunkSource* createChunkSource() {
//chunkCache = /*new*/ MultiPlayerChunkCache(this);
//return chunkCache;
return NULL;
}
void entityAdded(Entity* e) {
super::entityAdded(e);
EntitySet::iterator it = reEntries.find(e);
if (it != reEntries.end()) {
reEntries.erase(it);
}
}
void entityRemoved(Entity* e) {
super::entityRemoved(e);
EntitySet::iterator it = forced.find(e);
if (it != forced.end()) {
if (e->isAlive()) {
reEntries.insert(e);
} else {
forced.erase(it);
}
}
}
// void tickWeather() {
// if (dimension.hasCeiling) return;
//
// if (lightningTime > 0) {
// lightningTime--;
// }
//
// oRainLevel = rainLevel;
// if (levelData.isRaining()) {
// rainLevel += 0.01;
// } else {
// rainLevel -= 0.01;
// }
// if (rainLevel < 0) rainLevel = 0;
// if (rainLevel > 1) rainLevel = 1;
//
// oThunderLevel = thunderLevel;
// if (levelData.isThundering()) {
// thunderLevel += 0.01;
// } else {
// thunderLevel -= 0.01;
// }
// if (thunderLevel < 0) thunderLevel = 0;
// if (thunderLevel > 1) thunderLevel = 1;
// }
private:
ResetInfoList updatesToReset;
//ClientConnection connection;
//MultiPlayerChunkCache chunkCache;
EntityIdMap entitiesById;
EntitySet forced;
EntitySet reEntries;
};

View File

@@ -1,66 +1,64 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__BreakingItemParticle_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__BreakingItemParticle_H__
//package net.minecraft.client.particle;
#include "Particle.h"
#include "../renderer/Tesselator.h"
#include "../../world/item/Item.h"
#include "../../world/level/Level.h"
#include "../../world/level/tile/Tile.h"
class BreakingItemParticle: public Particle
{
typedef Particle super;
public:
BreakingItemParticle(Level* level, float x, float y, float z, Item* item)
: super(level, x, y, z, 0, 0, 0)
{
_init(item);
}
BreakingItemParticle(Level* level, float x, float y, float z, float xa, float ya, float za, Item* item)
: super(level, x, y, z, 0, 0, 0)
{
_init(item);
xd *= 0.1f;
yd *= 0.1f;
zd *= 0.1f;
xd += xa;
yd += ya;
zd += za;
}
void _init(Item* item) {
tex = item->getIcon(0);
rCol = gCol = bCol = 1.0f;
gravity = Tile::snow->gravity;
size /= 2;
}
int getParticleTexture() {
return ParticleEngine::ITEM_TEXTURE;
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
float u0 = (tex % 16 + uo / 4.0f) / 16.0f;
float u1 = u0 + 0.999f / 16.0f / 4;
float v0 = (tex / 16 + vo / 4.0f) / 16.0f;
float v1 = v0 + 0.999f / 16.0f / 4;
float r = 0.1f * size;
float x = (float) (xo + (this->x - xo) * a - xOff);
float y = (float) (yo + (this->y - yo) * a - yOff);
float z = (float) (zo + (this->z - zo) * a - zOff);
float br = getBrightness(a);
t.color(br * rCol, br * gCol, br * bCol);
t.vertexUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u0, v1);
t.vertexUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u0, v0);
t.vertexUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u1, v0);
t.vertexUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u1, v1);
}
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__BreakingItemParticle_H__*/
#pragma once
//package net.minecraft.client.particle;
#include "Particle.h"
#include "../renderer/Tesselator.h"
#include "../../world/item/Item.h"
#include "../../world/level/Level.h"
#include "../../world/level/tile/Tile.h"
class BreakingItemParticle: public Particle
{
typedef Particle super;
public:
BreakingItemParticle(Level* level, float x, float y, float z, Item* item)
: super(level, x, y, z, 0, 0, 0)
{
_init(item);
}
BreakingItemParticle(Level* level, float x, float y, float z, float xa, float ya, float za, Item* item)
: super(level, x, y, z, 0, 0, 0)
{
_init(item);
xd *= 0.1f;
yd *= 0.1f;
zd *= 0.1f;
xd += xa;
yd += ya;
zd += za;
}
void _init(Item* item) {
tex = item->getIcon(0);
rCol = gCol = bCol = 1.0f;
gravity = Tile::snow->gravity;
size /= 2;
}
int getParticleTexture() {
return ParticleEngine::ITEM_TEXTURE;
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
float u0 = (tex % 16 + uo / 4.0f) / 16.0f;
float u1 = u0 + 0.999f / 16.0f / 4;
float v0 = (tex / 16 + vo / 4.0f) / 16.0f;
float v1 = v0 + 0.999f / 16.0f / 4;
float r = 0.1f * size;
float x = (float) (xo + (this->x - xo) * a - xOff);
float y = (float) (yo + (this->y - yo) * a - yOff);
float z = (float) (zo + (this->z - zo) * a - zOff);
float br = getBrightness(a);
t.color(br * rCol, br * gCol, br * bCol);
t.vertexUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u0, v1);
t.vertexUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u0, v0);
t.vertexUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u1, v0);
t.vertexUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u1, v1);
}
};

View File

@@ -1,51 +1,49 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__BubbleParticle_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__BubbleParticle_H__
//package net.minecraft.client.particle;
#include "../../util/Mth.h"
#include "../../world/level/Level.h"
#include "../../world/level/material/Material.h"
#include "Particle.h"
class BubbleParticle: public Particle
{
typedef Particle super;
public:
BubbleParticle(Level* level, float x, float y, float z, float xa, float ya, float za)
: super(level, x, y, z, xa, ya, za)
{
rCol = 1.0f;
gCol = 1.0f;
bCol = 1.0f;
tex = 32;
this->setSize(0.02f, 0.02f);
size = size*(sharedRandom.nextFloat()*0.6f+0.2f);
xd = xa*0.2f+(float)(Mth::random()*2-1)*0.02f;
yd = ya*0.2f+(float)(Mth::random()*2-1)*0.02f;
zd = za*0.2f+(float)(Mth::random()*2-1)*0.02f;
lifetime = (int) (8 / (Mth::random() * 0.8 + 0.2));
}
void tick() {
xo = x;
yo = y;
zo = z;
yd += 0.002f;
move(xd, yd, zd);
xd *= 0.85f;
yd *= 0.85f;
zd *= 0.85f;
if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) != Material::water) remove();
if (lifetime-- <= 0) remove();
}
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__BubbleParticle_H__*/
#pragma once
//package net.minecraft.client.particle;
#include "../../util/Mth.h"
#include "../../world/level/Level.h"
#include "../../world/level/material/Material.h"
#include "Particle.h"
class BubbleParticle: public Particle
{
typedef Particle super;
public:
BubbleParticle(Level* level, float x, float y, float z, float xa, float ya, float za)
: super(level, x, y, z, xa, ya, za)
{
rCol = 1.0f;
gCol = 1.0f;
bCol = 1.0f;
tex = 32;
this->setSize(0.02f, 0.02f);
size = size*(sharedRandom.nextFloat()*0.6f+0.2f);
xd = xa*0.2f+(float)(Mth::random()*2-1)*0.02f;
yd = ya*0.2f+(float)(Mth::random()*2-1)*0.02f;
zd = za*0.2f+(float)(Mth::random()*2-1)*0.02f;
lifetime = (int) (8 / (Mth::random() * 0.8 + 0.2));
}
void tick() {
xo = x;
yo = y;
zo = z;
yd += 0.002f;
move(xd, yd, zd);
xd *= 0.85f;
yd *= 0.85f;
zd *= 0.85f;
if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) != Material::water) remove();
if (lifetime-- <= 0) remove();
}
};

View File

@@ -1,74 +1,72 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__CritParticle2_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__CritParticle2_H__
//package net.minecraft.client.particle;
#include "Particle.h"
#include "../../util/Mth.h"
#include "../../world/level/Level.h"
#include "../../world/level/material/Material.h"
class CritParticle2: public Particle
{
typedef Particle super;
public:
CritParticle2(Level* level, float x, float y, float z, float xa, float ya, float za, float scale = 1.0f)
: super(level, x, y, z, 0, 0, 0),
visible(true)
{
xd *= 0.1f;
yd *= 0.1f;
zd *= 0.1f;
xd += xa * 0.4f;
yd += ya * 0.4f;
zd += za * 0.4f;
rCol = gCol = bCol = (float) (Mth::random() * 0.3f + 0.6f);
size *= 0.75f;
size *= scale;
oSize = size;
lifetime = (int)(6 / (Mth::random() * 0.8f + 0.6f) * scale);
noPhysics = false;
tex = 16 * 4 + 1;
tick();
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
if (!visible) return;
float l = ((age + a) / lifetime) * 32;
if (l < 0) l = 0;
if (l > 1) l = 1;
size = oSize * l;
super::render(t, a, xa, ya, za, xa2, za2);
}
void tick() {
xo = x;
yo = y;
zo = z;
if (age++ >= lifetime) remove();
move(xd, yd, zd);
gCol *= 0.96f;
bCol *= 0.9f;
xd *= 0.70f;
yd *= 0.70f;
zd *= 0.70f;
yd -= 0.02f;
if (onGround) {
xd *= 0.7f;
zd *= 0.7f;
}
}
protected:
bool visible;
float oSize;
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__CritParticle2_H__*/
#pragma once
//package net.minecraft.client.particle;
#include "Particle.h"
#include "../../util/Mth.h"
#include "../../world/level/Level.h"
#include "../../world/level/material/Material.h"
class CritParticle2: public Particle
{
typedef Particle super;
public:
CritParticle2(Level* level, float x, float y, float z, float xa, float ya, float za, float scale = 1.0f)
: super(level, x, y, z, 0, 0, 0),
visible(true)
{
xd *= 0.1f;
yd *= 0.1f;
zd *= 0.1f;
xd += xa * 0.4f;
yd += ya * 0.4f;
zd += za * 0.4f;
rCol = gCol = bCol = (float) (Mth::random() * 0.3f + 0.6f);
size *= 0.75f;
size *= scale;
oSize = size;
lifetime = (int)(6 / (Mth::random() * 0.8f + 0.6f) * scale);
noPhysics = false;
tex = 16 * 4 + 1;
tick();
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
if (!visible) return;
float l = ((age + a) / lifetime) * 32;
if (l < 0) l = 0;
if (l > 1) l = 1;
size = oSize * l;
super::render(t, a, xa, ya, za, xa2, za2);
}
void tick() {
xo = x;
yo = y;
zo = z;
if (age++ >= lifetime) remove();
move(xd, yd, zd);
gCol *= 0.96f;
bCol *= 0.9f;
xd *= 0.70f;
yd *= 0.70f;
zd *= 0.70f;
yd -= 0.02f;
if (onGround) {
xd *= 0.7f;
zd *= 0.7f;
}
}
protected:
bool visible;
float oSize;
};

View File

@@ -1,51 +1,49 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__ExplodeParticle_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__ExplodeParticle_H__
//package net.minecraft.client.particle;
#include "Particle.h"
#include "../renderer/Tesselator.h"
#include "../../world/level/Level.h"
class ExplodeParticle: public Particle
{
typedef Particle super;
public:
ExplodeParticle(Level* level, float x, float y, float z, float xa, float ya, float za)
: super(level, x, y, z, xa, ya, za)
{
xd = xa + (Mth::random()*2.0f-1.0f) * 0.05f;
yd = ya + (Mth::random()*2.0f-1.0f) * 0.05f;
zd = za + (Mth::random()*2.0f-1.0f) * 0.05f;
rCol = gCol = bCol = sharedRandom.nextFloat() * 0.3f + 0.7f;
size = sharedRandom.nextFloat() * sharedRandom.nextFloat() * 6.0f + 1.0f;
lifetime = (int)(16.0f/(sharedRandom.nextFloat() * 0.8f + 0.2f)) + 2;
// noPhysics = true;
}
void tick()
{
xo = x;
yo = y;
zo = z;
if (age++ >= lifetime) remove();
tex = 7 - age * 8 / lifetime;
yd += 0.004f;
move(xd, yd, zd);
xd *= 0.90f;
yd *= 0.90f;
zd *= 0.90f;
if (onGround) {
xd *= 0.7f;
zd *= 0.7f;
}
}
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__ExplodeParticle_H__*/
#pragma once
//package net.minecraft.client.particle;
#include "Particle.h"
#include "../renderer/Tesselator.h"
#include "../../world/level/Level.h"
class ExplodeParticle: public Particle
{
typedef Particle super;
public:
ExplodeParticle(Level* level, float x, float y, float z, float xa, float ya, float za)
: super(level, x, y, z, xa, ya, za)
{
xd = xa + (Mth::random()*2.0f-1.0f) * 0.05f;
yd = ya + (Mth::random()*2.0f-1.0f) * 0.05f;
zd = za + (Mth::random()*2.0f-1.0f) * 0.05f;
rCol = gCol = bCol = sharedRandom.nextFloat() * 0.3f + 0.7f;
size = sharedRandom.nextFloat() * sharedRandom.nextFloat() * 6.0f + 1.0f;
lifetime = (int)(16.0f/(sharedRandom.nextFloat() * 0.8f + 0.2f)) + 2;
// noPhysics = true;
}
void tick()
{
xo = x;
yo = y;
zo = z;
if (age++ >= lifetime) remove();
tex = 7 - age * 8 / lifetime;
yd += 0.004f;
move(xd, yd, zd);
xd *= 0.90f;
yd *= 0.90f;
zd *= 0.90f;
if (onGround) {
xd *= 0.7f;
zd *= 0.7f;
}
}
};

View File

@@ -1,73 +1,71 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__FlameParticle_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__FlameParticle_H__
//package net.minecraft.client.particle;
#include "Particle.h"
#include "../renderer/Tesselator.h"
#include "../../world/level/Level.h"
class FlameParticle: public Particle
{
typedef Particle super;
float oSize;
public:
FlameParticle(Level* level, float x, float y, float z, float xa, float ya, float za)
: super(level, x, y, z, xa, ya, za)
{
xd = xd * 0.01f + xa;
yd = yd * 0.01f + ya;
zd = zd * 0.01f + za;
x += (sharedRandom.nextFloat()-sharedRandom.nextFloat()) * 0.05f;
y += (sharedRandom.nextFloat()-sharedRandom.nextFloat()) * 0.05f;
z += (sharedRandom.nextFloat()-sharedRandom.nextFloat()) * 0.05f;
//printf("xd, yd, zd: %f, %f, %f\n", xd, yd, zd);
oSize = size;
rCol = gCol = bCol = 1.0f;
lifetime = (int)(8.0f/(Mth::random()*0.8f+0.2f))+4;
noPhysics = true;
tex = 48;
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
float s = (age + a) / (float) lifetime;
size = oSize * (1 - s*s*0.5f);
super::render(t, a, xa, ya, za, xa2, za2);
}
float getBrightness(float a) {
return 1.0f;
/*
float l = (age+a)/lifetime;
if (l<0) l = 0;
if (l>1) l = 1;
float br = super::getBrightness(a);
return br*l+(1-l);
*/
}
void tick()
{
xo = x;
yo = y;
zo = z;
if (age++ >= lifetime) remove();
move(xd, yd, zd);
xd *= 0.96f;
yd *= 0.96f;
zd *= 0.96f;
if (onGround)
{
xd *= 0.7f;
zd *= 0.7f;
}
}
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__FlameParticle_H__*/
#pragma once
//package net.minecraft.client.particle;
#include "Particle.h"
#include "../renderer/Tesselator.h"
#include "../../world/level/Level.h"
class FlameParticle: public Particle
{
typedef Particle super;
float oSize;
public:
FlameParticle(Level* level, float x, float y, float z, float xa, float ya, float za)
: super(level, x, y, z, xa, ya, za)
{
xd = xd * 0.01f + xa;
yd = yd * 0.01f + ya;
zd = zd * 0.01f + za;
x += (sharedRandom.nextFloat()-sharedRandom.nextFloat()) * 0.05f;
y += (sharedRandom.nextFloat()-sharedRandom.nextFloat()) * 0.05f;
z += (sharedRandom.nextFloat()-sharedRandom.nextFloat()) * 0.05f;
//printf("xd, yd, zd: %f, %f, %f\n", xd, yd, zd);
oSize = size;
rCol = gCol = bCol = 1.0f;
lifetime = (int)(8.0f/(Mth::random()*0.8f+0.2f))+4;
noPhysics = true;
tex = 48;
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
float s = (age + a) / (float) lifetime;
size = oSize * (1 - s*s*0.5f);
super::render(t, a, xa, ya, za, xa2, za2);
}
float getBrightness(float a) {
return 1.0f;
/*
float l = (age+a)/lifetime;
if (l<0) l = 0;
if (l>1) l = 1;
float br = super::getBrightness(a);
return br*l+(1-l);
*/
}
void tick()
{
xo = x;
yo = y;
zo = z;
if (age++ >= lifetime) remove();
move(xd, yd, zd);
xd *= 0.96f;
yd *= 0.96f;
zd *= 0.96f;
if (onGround)
{
xd *= 0.7f;
zd *= 0.7f;
}
}
};

View File

@@ -1,72 +1,70 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__HugeExplosionParticle_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__HugeExplosionParticle_H__
//package net.minecraft.client.particle;
#include "../renderer/Tesselator.h"
#include "../renderer/Textures.h"
#include "../../world/level/Level.h"
class HugeExplosionParticle: public Particle
{
typedef Particle super;
public:
HugeExplosionParticle(Textures* textures, Level* level, float x, float y, float z, float xa, float ya, float za)
: super(level, x, y, z, 0, 0, 0),
life(0),
lifeTime(6 + sharedRandom.nextInt(4)),
textures(textures),
size(1 - xa * 0.5f)
{
rCol = gCol = bCol = sharedRandom.nextFloat() * 0.6f + 0.4f;
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
int tex = (int) ((life + a) * 15 / lifeTime);
if (tex > 15) return;
textures->loadAndBindTexture("misc/explosion.png");
float u0 = (tex % 4) / 4.0f;
float u1 = u0 + 0.999f / 4.0f;
float v0 = (tex / 4) / 4.0f;
float v1 = v0 + 0.999f / 4.0f;
// xa2 = 0;
// za2 = 1;
float r = size + size;
float x = xo + (this->x - xo) * a - xOff;
float y = yo + (this->y - yo) * a - yOff;
float z = zo + (this->z - zo) * a - zOff;
const float xar = xa * r, yar = ya * r, zar = za * r;
const float xa2r = xa2 * r, za2r = za2 * r;
t.begin();
t.color(rCol, gCol, bCol, 1.0f);
t.vertexUV(x - xar - xa2r, y - yar, z - zar - za2r, u1, v1);
t.vertexUV(x - xar + xa2r, y + yar, z - zar + za2r, u1, v0);
t.vertexUV(x + xar + xa2r, y + yar, z + zar + za2r, u0, v0);
t.vertexUV(x + xar - xa2r, y - yar, z + zar - za2r, u0, v1);
t.draw();
//glPolygonOffset(0, 0.0f);
}
void tick() {
xo = x;
yo = y;
zo = z;
life++;
if (life == lifeTime) remove();
}
int getParticleTexture() {
return ParticleEngine::ENTITY_PARTICLE_TEXTURE;
}
private:
int life;
int lifeTime;
float size;
Textures* textures;
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__HugeExplosionParticle_H__*/
#pragma once
//package net.minecraft.client.particle;
#include "../renderer/Tesselator.h"
#include "../renderer/Textures.h"
#include "../../world/level/Level.h"
class HugeExplosionParticle: public Particle
{
typedef Particle super;
public:
HugeExplosionParticle(Textures* textures, Level* level, float x, float y, float z, float xa, float ya, float za)
: super(level, x, y, z, 0, 0, 0),
life(0),
lifeTime(6 + sharedRandom.nextInt(4)),
textures(textures),
size(1 - xa * 0.5f)
{
rCol = gCol = bCol = sharedRandom.nextFloat() * 0.6f + 0.4f;
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
int tex = (int) ((life + a) * 15 / lifeTime);
if (tex > 15) return;
textures->loadAndBindTexture("misc/explosion.png");
float u0 = (tex % 4) / 4.0f;
float u1 = u0 + 0.999f / 4.0f;
float v0 = (tex / 4) / 4.0f;
float v1 = v0 + 0.999f / 4.0f;
// xa2 = 0;
// za2 = 1;
float r = size + size;
float x = xo + (this->x - xo) * a - xOff;
float y = yo + (this->y - yo) * a - yOff;
float z = zo + (this->z - zo) * a - zOff;
const float xar = xa * r, yar = ya * r, zar = za * r;
const float xa2r = xa2 * r, za2r = za2 * r;
t.begin();
t.color(rCol, gCol, bCol, 1.0f);
t.vertexUV(x - xar - xa2r, y - yar, z - zar - za2r, u1, v1);
t.vertexUV(x - xar + xa2r, y + yar, z - zar + za2r, u1, v0);
t.vertexUV(x + xar + xa2r, y + yar, z + zar + za2r, u0, v0);
t.vertexUV(x + xar - xa2r, y - yar, z + zar - za2r, u0, v1);
t.draw();
//glPolygonOffset(0, 0.0f);
}
void tick() {
xo = x;
yo = y;
zo = z;
life++;
if (life == lifeTime) remove();
}
int getParticleTexture() {
return ParticleEngine::ENTITY_PARTICLE_TEXTURE;
}
private:
int life;
int lifeTime;
float size;
Textures* textures;
};

View File

@@ -1,40 +1,38 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__HugeExplosionSeedParticle_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__HugeExplosionSeedParticle_H__
//package net.minecraft.client.particle;
#include "Particle.h"
class HugeExplosionSeedParticle: public Particle
{
typedef Particle super;
public:
HugeExplosionSeedParticle(Level* level, float x, float y, float z, float xa, float ya, float za)
: super(level, x, y, z, 0, 0, 0),
life(0),
lifeTime(8)
{
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {}
void tick() {
for (int i = 0; i < 6; i++) {
float xx = x + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 4;
float yy = y + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 4;
float zz = z + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 4;
level->addParticle(PARTICLETYPE(largeexplode), xx, yy, zz, life / (float) lifeTime, 0, 0);
}
life++;
if (life == lifeTime) remove();
}
int getParticleTexture() {
return ParticleEngine::TERRAIN_TEXTURE;
}
private:
int life;
int lifeTime;
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__HugeExplosionSeedParticle_H__*/
#pragma once
//package net.minecraft.client.particle;
#include "Particle.h"
class HugeExplosionSeedParticle: public Particle
{
typedef Particle super;
public:
HugeExplosionSeedParticle(Level* level, float x, float y, float z, float xa, float ya, float za)
: super(level, x, y, z, 0, 0, 0),
life(0),
lifeTime(8)
{
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {}
void tick() {
for (int i = 0; i < 6; i++) {
float xx = x + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 4;
float yy = y + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 4;
float zz = z + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 4;
level->addParticle(PARTICLETYPE(largeexplode), xx, yy, zz, life / (float) lifeTime, 0, 0);
}
life++;
if (life == lifeTime) remove();
}
int getParticleTexture() {
return ParticleEngine::TERRAIN_TEXTURE;
}
private:
int life;
int lifeTime;
};

View File

@@ -1,63 +1,61 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__LavaParticle_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__LavaParticle_H__
//package net.minecraft.client.particle;
#include "../renderer/Tesselator.h"
#include "../../world/level/Level.h"
class LavaParticle: public Particle
{
typedef Particle super;
float oSize;
public:
LavaParticle(Level* level, float x, float y, float z)
: super(level, x, y, z, 0, 0, 0)
{
xd *= 0.8f;
yd *= 0.8f;
zd *= 0.8f;
yd = sharedRandom.nextFloat() * 0.4f + 0.05f;
rCol = gCol = bCol = 1;
size *= (sharedRandom.nextFloat() * 2 + 0.2f);
oSize = size;
lifetime = (int) (16 / (Mth::random() * 0.8 + 0.2));
noPhysics = false;
tex = 49;
}
float getBrightness(float a) {
return 1;
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
float s = (age + a) / (float) lifetime;
size = oSize * (1 - s*s);
super::render(t, a, xa, ya, za, xa2, za2);
}
void tick() {
xo = x;
yo = y;
zo = z;
if (age++ >= lifetime) remove();
float odds = age / (float) lifetime;
if (sharedRandom.nextFloat() > odds) level->addParticle(PARTICLETYPE(smoke), x, y, z, xd, yd, zd);
yd -= 0.03f;
move(xd, yd, zd);
xd *= 0.999f;
yd *= 0.999f;
zd *= 0.999f;
if (onGround) {
xd *= 0.7f;
zd *= 0.7f;
}
}
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__LavaParticle_H__*/
#pragma once
//package net.minecraft.client.particle;
#include "../renderer/Tesselator.h"
#include "../../world/level/Level.h"
class LavaParticle: public Particle
{
typedef Particle super;
float oSize;
public:
LavaParticle(Level* level, float x, float y, float z)
: super(level, x, y, z, 0, 0, 0)
{
xd *= 0.8f;
yd *= 0.8f;
zd *= 0.8f;
yd = sharedRandom.nextFloat() * 0.4f + 0.05f;
rCol = gCol = bCol = 1;
size *= (sharedRandom.nextFloat() * 2 + 0.2f);
oSize = size;
lifetime = (int) (16 / (Mth::random() * 0.8 + 0.2));
noPhysics = false;
tex = 49;
}
float getBrightness(float a) {
return 1;
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
float s = (age + a) / (float) lifetime;
size = oSize * (1 - s*s);
super::render(t, a, xa, ya, za, xa2, za2);
}
void tick() {
xo = x;
yo = y;
zo = z;
if (age++ >= lifetime) remove();
float odds = age / (float) lifetime;
if (sharedRandom.nextFloat() > odds) level->addParticle(PARTICLETYPE(smoke), x, y, z, xd, yd, zd);
yd -= 0.03f;
move(xd, yd, zd);
xd *= 0.999f;
yd *= 0.999f;
zd *= 0.999f;
if (onGround) {
xd *= 0.7f;
zd *= 0.7f;
}
}
};

View File

@@ -1,46 +1,44 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__Particle_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__Particle_H__
//package net.minecraft.client.particle;
#include "../renderer/Tesselator.h"
#include "../../world/entity/Entity.h"
#include "../../world/level/Level.h"
#include "ParticleEngine.h"
class CompoundTag;
class Particle: public Entity {
typedef Entity super;
public:
static float xOff, yOff, zOff;
Particle(Level* level, float x, float y, float z, float xa, float ya, float za);
virtual ~Particle() {}
Particle* setPower(float power);
Particle* scale(float scale);
virtual void tick();
virtual void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2);
virtual int getParticleTexture();
virtual void addAdditonalSaveData(CompoundTag* entityTag) {}
virtual void readAdditionalSaveData(CompoundTag* tag) {}
virtual int getEntityTypeId() const { return 0; }
protected:
int tex;
float uo, vo;
int age;
int lifetime;
float size;
float gravity;
float rCol, gCol, bCol;
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__Particle_H__*/
#pragma once
//package net.minecraft.client.particle;
#include "../renderer/Tesselator.h"
#include "../../world/entity/Entity.h"
#include "../../world/level/Level.h"
#include "ParticleEngine.h"
class CompoundTag;
class Particle: public Entity {
typedef Entity super;
public:
static float xOff, yOff, zOff;
Particle(Level* level, float x, float y, float z, float xa, float ya, float za);
virtual ~Particle() {}
Particle* setPower(float power);
Particle* scale(float scale);
virtual void tick();
virtual void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2);
virtual int getParticleTexture();
virtual void addAdditonalSaveData(CompoundTag* entityTag) {}
virtual void readAdditionalSaveData(CompoundTag* tag) {}
virtual int getEntityTypeId() const { return 0; }
protected:
int tex;
float uo, vo;
int age;
int lifetime;
float size;
float gravity;
float rCol, gCol, bCol;
};

View File

@@ -1,54 +1,52 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__ParticleEngine_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__ParticleEngine_H__
//package net.minecraft.client.particle;
#include <vector>
#include "../../world/entity/Entity.h"
#include "../../world/level/tile/Tile.h"
#include "../renderer/gles.h"
class Textures;
class Level;
class Particle;
typedef std::vector<Particle*> ParticleList;
class ParticleEngine
{
public:
static const int MISC_TEXTURE = 0;
static const int TERRAIN_TEXTURE = 1;
static const int ITEM_TEXTURE = 2;
static const int ENTITY_PARTICLE_TEXTURE = 3;
static const int TEXTURE_COUNT = 4;
ParticleEngine(Level* level, Textures* textures);
~ParticleEngine();
void add(Particle* p);
void destroy(int x, int y, int z);
void tick();
void render(Entity* player, float a);
void renderLit(Entity* player, float a);
void setLevel(Level* level);
void crack(int x, int y, int z, int face);
std::string countParticles();
protected:
void clear();
Level* level;
GLuint textureIds[4];
private:
ParticleList particles[4];
Textures* textures;
Random random;
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__ParticleEngine_H__*/
#pragma once
//package net.minecraft.client.particle;
#include <vector>
#include "../../world/entity/Entity.h"
#include "../../world/level/tile/Tile.h"
#include "../renderer/gles.h"
class Textures;
class Level;
class Particle;
typedef std::vector<Particle*> ParticleList;
class ParticleEngine
{
public:
static const int MISC_TEXTURE = 0;
static const int TERRAIN_TEXTURE = 1;
static const int ITEM_TEXTURE = 2;
static const int ENTITY_PARTICLE_TEXTURE = 3;
static const int TEXTURE_COUNT = 4;
ParticleEngine(Level* level, Textures* textures);
~ParticleEngine();
void add(Particle* p);
void destroy(int x, int y, int z);
void tick();
void render(Entity* player, float a);
void renderLit(Entity* player, float a);
void setLevel(Level* level);
void crack(int x, int y, int z, int face);
std::string countParticles();
protected:
void clear();
Level* level;
GLuint textureIds[4];
private:
ParticleList particles[4];
Textures* textures;
Random random;
};

View File

@@ -1,17 +1,15 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__ParticleInclude_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__ParticleInclude_H__
#include "Particle.h"
#include "BubbleParticle.h"
#include "CritParticle2.h"
#include "ExplodeParticle.h"
#include "FlameParticle.h"
#include "LavaParticle.h"
#include "RedDustParticle.h"
#include "SmokeParticle.h"
#include "TerrainParticle.h"
#include "HugeExplosionSeedParticle.h"
#include "HugeExplosionParticle.h"
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__ParticleInclude_H__*/
#pragma once
#include "Particle.h"
#include "BubbleParticle.h"
#include "CritParticle2.h"
#include "ExplodeParticle.h"
#include "FlameParticle.h"
#include "LavaParticle.h"
#include "RedDustParticle.h"
#include "SmokeParticle.h"
#include "TerrainParticle.h"
#include "HugeExplosionSeedParticle.h"
#include "HugeExplosionParticle.h"

View File

@@ -1,73 +1,71 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__RedDustParticle_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__RedDustParticle_H__
//package net.minecraft.client.particle;
#include "../renderer/Tesselator.h"
#include "../../world/level/Level.h"
class RedDustParticle: public Particle
{
typedef Particle super;
public:
float oSize;
RedDustParticle(Level* level, float x, float y, float z, float rCol, float gCol, float bCol, float scale = 1.0f)
: super(level, x, y, z, 0, 0, 0)
{
xd *= 0.1f;
yd *= 0.1f;
zd *= 0.1f;
if (rCol == 0) {
rCol = 1;
}
float brr = (float) Mth::random() * 0.4f + 0.6f;
this->rCol = ((float) (Mth::random() * 0.2f) + 0.8f) * rCol * brr;
this->gCol = ((float) (Mth::random() * 0.2f) + 0.8f) * gCol * brr;
this->bCol = ((float) (Mth::random() * 0.2f) + 0.8f) * bCol * brr;
size *= 0.75f;
size *= scale;
oSize = size;
lifetime = (int) (8 / (Mth::random() * 0.8 + 0.2));
lifetime = (int)(lifetime * scale);
noPhysics = false;
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
float l = ((age + a) / lifetime) * 32;
if (l < 0) l = 0;
if (l > 1) l = 1;
size = oSize * l;
super::render(t, a, xa, ya, za, xa2, za2);
}
void tick() {
xo = x;
yo = y;
zo = z;
if (age++ >= lifetime) remove();
tex = 7 - age * 8 / lifetime;
move(xd, yd, zd);
if (y == yo) {
xd *= 1.1f;
zd *= 1.1f;
}
xd *= 0.96f;
yd *= 0.96f;
zd *= 0.96f;
if (onGround) {
xd *= 0.7f;
zd *= 0.7f;
}
}
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__RedDustParticle_H__*/
#pragma once
//package net.minecraft.client.particle;
#include "../renderer/Tesselator.h"
#include "../../world/level/Level.h"
class RedDustParticle: public Particle
{
typedef Particle super;
public:
float oSize;
RedDustParticle(Level* level, float x, float y, float z, float rCol, float gCol, float bCol, float scale = 1.0f)
: super(level, x, y, z, 0, 0, 0)
{
xd *= 0.1f;
yd *= 0.1f;
zd *= 0.1f;
if (rCol == 0) {
rCol = 1;
}
float brr = (float) Mth::random() * 0.4f + 0.6f;
this->rCol = ((float) (Mth::random() * 0.2f) + 0.8f) * rCol * brr;
this->gCol = ((float) (Mth::random() * 0.2f) + 0.8f) * gCol * brr;
this->bCol = ((float) (Mth::random() * 0.2f) + 0.8f) * bCol * brr;
size *= 0.75f;
size *= scale;
oSize = size;
lifetime = (int) (8 / (Mth::random() * 0.8 + 0.2));
lifetime = (int)(lifetime * scale);
noPhysics = false;
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
float l = ((age + a) / lifetime) * 32;
if (l < 0) l = 0;
if (l > 1) l = 1;
size = oSize * l;
super::render(t, a, xa, ya, za, xa2, za2);
}
void tick() {
xo = x;
yo = y;
zo = z;
if (age++ >= lifetime) remove();
tex = 7 - age * 8 / lifetime;
move(xd, yd, zd);
if (y == yo) {
xd *= 1.1f;
zd *= 1.1f;
}
xd *= 0.96f;
yd *= 0.96f;
zd *= 0.96f;
if (onGround) {
xd *= 0.7f;
zd *= 0.7f;
}
}
};

View File

@@ -1,69 +1,67 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__SmokeParticle_H__
#define NET_MINECRAFT_CLIENT_PARTICLE__SmokeParticle_H__
//package net.minecraft.client.particle;
#include "Particle.h"
class SmokeParticle: public Particle
{
typedef Particle super;
public:
float oSize;
SmokeParticle(Level* level, float x, float y, float z, float xa, float ya, float za, float scale = 1.0f)
: super(level, x, y, z, 0, 0, 0)
{
xd *= 0.1f;
yd *= 0.1f;
zd *= 0.1f;
xd += xa;
yd += ya;
zd += za;
rCol = gCol = bCol = (float) (Mth::random() * 0.5f);
size *= 0.75f;
size *= scale;
oSize = size;
lifetime = (int) (scale * 8.0f / (Mth::random() * 0.8f + 0.2f));
noPhysics = false;
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
float l = ((age + a) / lifetime) * 32;
if (l < 0) l = 0;
if (l > 1) l = 1;
size = oSize * l;
super::render(t, a, xa, ya, za, xa2, za2);
}
void tick() {
xo = x;
yo = y;
zo = z;
if (age++ >= lifetime) remove();
tex = 7 - age * 8 / lifetime;
yd += 0.004f;
move(xd, yd, zd);
if (y == yo) {
xd *= 1.1f;
zd *= 1.1f;
}
xd *= 0.96f;
yd *= 0.96f;
zd *= 0.96f;
if (onGround) {
xd *= 0.7f;
zd *= 0.7f;
}
}
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__SmokeParticle_H__*/
#pragma once
//package net.minecraft.client.particle;
#include "Particle.h"
class SmokeParticle: public Particle
{
typedef Particle super;
public:
float oSize;
SmokeParticle(Level* level, float x, float y, float z, float xa, float ya, float za, float scale = 1.0f)
: super(level, x, y, z, 0, 0, 0)
{
xd *= 0.1f;
yd *= 0.1f;
zd *= 0.1f;
xd += xa;
yd += ya;
zd += za;
rCol = gCol = bCol = (float) (Mth::random() * 0.5f);
size *= 0.75f;
size *= scale;
oSize = size;
lifetime = (int) (scale * 8.0f / (Mth::random() * 0.8f + 0.2f));
noPhysics = false;
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
float l = ((age + a) / lifetime) * 32;
if (l < 0) l = 0;
if (l > 1) l = 1;
size = oSize * l;
super::render(t, a, xa, ya, za, xa2, za2);
}
void tick() {
xo = x;
yo = y;
zo = z;
if (age++ >= lifetime) remove();
tex = 7 - age * 8 / lifetime;
yd += 0.004f;
move(xd, yd, zd);
if (y == yo) {
xd *= 1.1f;
zd *= 1.1f;
}
xd *= 0.96f;
yd *= 0.96f;
zd *= 0.96f;
if (onGround) {
xd *= 0.7f;
zd *= 0.7f;
}
}
};

Some files were not shown because too many files have changed in this diff Show More