merge "main" into AlexRa:main
This commit is contained in:
commit
18cc2bf867
@ -1,27 +1,30 @@
|
||||
{
|
||||
"blocks": [
|
||||
"dirt",
|
||||
"grass_block",
|
||||
"lamp",
|
||||
"glass",
|
||||
"planks",
|
||||
"wood",
|
||||
"leaves",
|
||||
"stone",
|
||||
"water",
|
||||
"sand",
|
||||
"bazalt",
|
||||
"grass",
|
||||
"flower",
|
||||
"brick",
|
||||
"metal",
|
||||
"rust",
|
||||
"red_lamp",
|
||||
"green_lamp",
|
||||
"blue_lamp",
|
||||
"pane",
|
||||
"pipe",
|
||||
"lightbulb",
|
||||
"torch"
|
||||
]
|
||||
}
|
||||
"items": [
|
||||
"bazalt_breaker"
|
||||
],
|
||||
"blocks": [
|
||||
"dirt",
|
||||
"grass_block",
|
||||
"lamp",
|
||||
"glass",
|
||||
"planks",
|
||||
"wood",
|
||||
"leaves",
|
||||
"stone",
|
||||
"water",
|
||||
"sand",
|
||||
"bazalt",
|
||||
"grass",
|
||||
"flower",
|
||||
"brick",
|
||||
"metal",
|
||||
"rust",
|
||||
"red_lamp",
|
||||
"green_lamp",
|
||||
"blue_lamp",
|
||||
"pane",
|
||||
"pipe",
|
||||
"lightbulb",
|
||||
"torch"
|
||||
]
|
||||
}
|
||||
4
res/content/base/items/bazalt_breaker.json
Normal file
4
res/content/base/items/bazalt_breaker.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"icon-type": "sprite",
|
||||
"icon": "items:bazalt_breaker"
|
||||
}
|
||||
3
res/content/base/scripts/bazalt_breaker.lua
Normal file
3
res/content/base/scripts/bazalt_breaker.lua
Normal file
@ -0,0 +1,3 @@
|
||||
function on_block_break_by(x, y, z, p)
|
||||
set_block(x, y, z, 0, 0)
|
||||
end
|
||||
BIN
res/content/base/textures/items/bazalt_breaker.png
Normal file
BIN
res/content/base/textures/items/bazalt_breaker.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 672 B |
@ -14,6 +14,7 @@ menu.Quit=Выхад
|
||||
menu.Continue=Працягнуть
|
||||
menu.Save and Quit to Menu=Захаваць і Выйсці ў Меню
|
||||
menu.missing-content=Адсутнічае Кантэнт!
|
||||
menu.Content Error=Памылка Кантэнту
|
||||
menu.Controls=Кіраванне
|
||||
menu.Back to Main Menu=Вярнуцца ў Меню
|
||||
menu.Settings=Налады
|
||||
@ -50,4 +51,4 @@ player.attack=Атакаваць / Ламаць
|
||||
player.build=Паставіць Блок
|
||||
player.flight=Палёт
|
||||
camera.zoom=Прыбліжэнне
|
||||
camera.mode=Змяніць Рэжым Камеры
|
||||
camera.mode=Змяніць Рэжым Камеры
|
||||
|
||||
@ -260,7 +260,7 @@ void PlayerController::updateInteraction(){
|
||||
}
|
||||
|
||||
if (lclick) {
|
||||
if (!input.shift && item->rt.funcsset.on_use_on_block) {
|
||||
if (!input.shift && item->rt.funcsset.on_block_break_by) {
|
||||
if (scripting::on_item_break_block(player, item, x, y, z))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -14,10 +14,10 @@
|
||||
#include "../../lighting/Lighting.h"
|
||||
#include "../../logic/BlocksController.h"
|
||||
|
||||
#if (LUA_VERSION_NUM < 503 && !defined(LUAJIT_VERSION))
|
||||
static void luaL_openlib(lua_State* L, const char* name, const luaL_Reg* libfuncs) {
|
||||
#if (LUA_VERSION_NUM < 502)
|
||||
inline void luaL_openlib(lua_State* L, const char* name, const luaL_Reg* libfuncs, int nup) {
|
||||
lua_newtable(L);
|
||||
luaL_setfuncs(L, libfuncs, 0);
|
||||
luaL_setfuncs(L, libfuncs, nup);
|
||||
lua_setglobal(L, name);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -36,7 +36,8 @@ void PhysicsSolver::step(
|
||||
|
||||
vel += gravity * dt * gravityScale;
|
||||
if (collisions) {
|
||||
colisionCalc(chunks, hitbox, vel, pos, half);
|
||||
colisionCalc(chunks, hitbox, vel, pos, half,
|
||||
(gravityScale > 0.0f) ? 0.5f : 0.0f);
|
||||
}
|
||||
vel.x *= glm::max(0.0f, 1.0f - dt * linear_damping);
|
||||
vel.z *= glm::max(0.0f, 1.0f - dt * linear_damping);
|
||||
@ -78,7 +79,8 @@ void PhysicsSolver::colisionCalc(
|
||||
Hitbox* hitbox,
|
||||
vec3& vel,
|
||||
vec3& pos,
|
||||
const vec3 half)
|
||||
const vec3 half,
|
||||
float stepHeight)
|
||||
{
|
||||
// step size (smaller - more accurate, but slower)
|
||||
float s = 2.0f/BLOCK_AABB_GRID;
|
||||
@ -86,7 +88,7 @@ void PhysicsSolver::colisionCalc(
|
||||
const AABB* aabb;
|
||||
|
||||
if (vel.x < 0.0f){
|
||||
for (float y = (pos.y-half.y+E); y <= (pos.y+half.y-E); y+=s){
|
||||
for (float y = (pos.y-half.y+E+stepHeight); y <= (pos.y+half.y-E); y+=s){
|
||||
for (float z = (pos.z-half.z+E); z <= (pos.z+half.z-E); z+=s){
|
||||
float x = (pos.x-half.x-E);
|
||||
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
||||
@ -101,7 +103,7 @@ void PhysicsSolver::colisionCalc(
|
||||
}
|
||||
}
|
||||
if (vel.x > 0.0f){
|
||||
for (float y = (pos.y-half.y+E); y <= (pos.y+half.y-E); y+=s){
|
||||
for (float y = (pos.y-half.y+E+stepHeight); y <= (pos.y+half.y-E); y+=s){
|
||||
for (float z = (pos.z-half.z+E); z <= (pos.z+half.z-E); z+=s){
|
||||
float x = (pos.x+half.x+E);
|
||||
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
||||
@ -117,7 +119,7 @@ void PhysicsSolver::colisionCalc(
|
||||
}
|
||||
|
||||
if (vel.z < 0.0f){
|
||||
for (float y = (pos.y-half.y+E); y <= (pos.y+half.y-E); y+=s){
|
||||
for (float y = (pos.y-half.y+E+stepHeight); y <= (pos.y+half.y-E); y+=s){
|
||||
for (float x = (pos.x-half.x+E); x <= (pos.x+half.x-E); x+=s){
|
||||
float z = (pos.z-half.z-E);
|
||||
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
||||
@ -133,7 +135,7 @@ void PhysicsSolver::colisionCalc(
|
||||
}
|
||||
|
||||
if (vel.z > 0.0f){
|
||||
for (float y = (pos.y-half.y+E); y <= (pos.y+half.y-E); y+=s){
|
||||
for (float y = (pos.y-half.y+E+stepHeight); y <= (pos.y+half.y-E); y+=s){
|
||||
for (float x = (pos.x-half.x+E); x <= (pos.x+half.x-E); x+=s){
|
||||
float z = (pos.z+half.z+E);
|
||||
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
||||
@ -164,6 +166,21 @@ void PhysicsSolver::colisionCalc(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stepHeight > 0.0 && vel.y <= 0.0f){
|
||||
for (float x = (pos.x-half.x+E); x <= (pos.x+half.x-E); x+=s){
|
||||
for (float z = (pos.z-half.z+E); z <= (pos.z+half.z-E); z+=s){
|
||||
float y = (pos.y-half.y+E);
|
||||
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
||||
vel.y *= 0.0f;
|
||||
float newy = floor(y) + aabb->max().y + half.y;
|
||||
if (glm::abs(newy-pos.y) <= MAX_FIX+stepHeight) {
|
||||
pos.y = newy;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (vel.y > 0.0f){
|
||||
for (float x = (pos.x-half.x+E); x <= (pos.x+half.x-E); x+=s){
|
||||
for (float z = (pos.z-half.z+E); z <= (pos.z+half.z-E); z+=s){
|
||||
|
||||
@ -8,18 +8,24 @@ class Hitbox;
|
||||
class Chunks;
|
||||
|
||||
class PhysicsSolver {
|
||||
glm::vec3 gravity;
|
||||
glm::vec3 gravity;
|
||||
public:
|
||||
PhysicsSolver(glm::vec3 gravity);
|
||||
void step(Chunks* chunks,
|
||||
Hitbox* hitbox,
|
||||
float delta,
|
||||
uint substeps,
|
||||
bool shifting,
|
||||
float gravityScale,
|
||||
bool collisions);
|
||||
void colisionCalc(Chunks* chunks, Hitbox* hitbox, glm::vec3& vel, glm::vec3& pos, const glm::vec3 half);
|
||||
bool isBlockInside(int x, int y, int z, Hitbox* hitbox);
|
||||
PhysicsSolver(glm::vec3 gravity);
|
||||
void step(Chunks* chunks,
|
||||
Hitbox* hitbox,
|
||||
float delta,
|
||||
uint substeps,
|
||||
bool shifting,
|
||||
float gravityScale,
|
||||
bool collisions);
|
||||
void colisionCalc(
|
||||
Chunks* chunks,
|
||||
Hitbox* hitbox,
|
||||
glm::vec3& vel,
|
||||
glm::vec3& pos,
|
||||
const glm::vec3 half,
|
||||
float stepHeight);
|
||||
bool isBlockInside(int x, int y, int z, Hitbox* hitbox);
|
||||
};
|
||||
|
||||
#endif /* PHYSICS_PHYSICSSOLVER_H_ */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user