forked from VoxeLibre/VoxeLibre
Compare commits
17 Commits
Author | SHA1 | Date |
---|---|---|
Guy Liner | 3f886f3882 | |
Guy Liner | cc18b2ecc5 | |
Guy Liner | 99c8e818dd | |
Guy Liner | 702c954cf0 | |
Guy Liner | 9630817f0e | |
Guy Liner | 531b17c5bd | |
Guy Liner | 48f6699a6a | |
GuyLiner | 3f625be8e2 | |
Guy Liner | 6801e6556d | |
Guy Liner | 838e09105e | |
Guy Liner | ea76517591 | |
Guy Liner | d51f7344ae | |
Guy Liner | 4a8f323192 | |
Guy Liner | fa248bf7da | |
bigboi_ | d38662475c | |
bigboi_ | 771a15b99e | |
Guy Liner | b4db8257a0 |
|
@ -245,11 +245,6 @@ need to state their sources. These PRs also need Fleckenstein's approval
|
|||
before they are merged.
|
||||
You can use these sources:
|
||||
|
||||
* Minecraft code (Name the source file and line, however DONT post any
|
||||
proprietary code). You can use
|
||||
[MCP](https://minecraft.fandom.com/wiki/Programs_and_editors/Mod_Coder_Pack)
|
||||
to decompile Minecraft or look at
|
||||
[Minestorm](https://github.com/Minestom/Minestom) code.
|
||||
* Testing things inside of Minecraft (Attach screenshots / video footage
|
||||
of the results)
|
||||
* [Official Minecraft Wiki](https://minecraft.fandom.com/wiki/Minecraft_Wiki)
|
||||
|
|
|
@ -15,7 +15,8 @@ movement_speed_walk = 4.317
|
|||
movement_speed_crouch = 1.295
|
||||
movement_speed_fast = 25.0
|
||||
|
||||
movement_speed_jump = 6.6
|
||||
#movement_speed_jump = 6.6
|
||||
movement_speed_jump = 8.5
|
||||
movement_speed_climb = 2.35
|
||||
# TODO: Add descend speed (3.0) when available
|
||||
|
||||
|
@ -23,7 +24,8 @@ movement_liquid_fluidity = 1.13
|
|||
movement_liquid_fluidity_smooth = 0.5
|
||||
movement_liquid_sink = 23
|
||||
|
||||
movement_gravity = 10.4
|
||||
#movement_gravity = 10.4
|
||||
movement_gravity = 14.4
|
||||
|
||||
# Mapgen stuff
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ minetest.register_node("mcl_crafting_table:crafting_table", {
|
|||
tiles = {"crafting_workbench_top.png", "default_wood.png", "crafting_workbench_side.png",
|
||||
"crafting_workbench_side.png", "crafting_workbench_front.png", "crafting_workbench_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
collision_box = { type = "fixed", fixed = {-0.40, 0.0, -0.40, 0.40, 0.5, 0.40}},
|
||||
groups = {handy=1,axey=1, deco_block=1, material_wood=1,flammable=-1},
|
||||
on_rightclick = function(pos, node, player, itemstack)
|
||||
if not player:get_player_control().sneak then
|
||||
|
|
|
@ -179,7 +179,7 @@ minetest.register_globalstep(function(dtime)
|
|||
local animation_speed_mod = model.animation_speed or 30
|
||||
|
||||
-- Determine if the player is walking
|
||||
if controls.up or controls.down or controls.left or controls.right then
|
||||
if controls.up or controls.down or controls.left or controls.right and mcl_playerinfo:collision_detect(player:get_pos(),player) then
|
||||
walking = true
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
local table = table
|
||||
--require "math"
|
||||
|
||||
-- Player state for public API
|
||||
mcl_playerinfo = {}
|
||||
|
@ -23,6 +24,85 @@ end
|
|||
|
||||
local time = 0
|
||||
|
||||
--[[
|
||||
Function that allows for detecting if a player is touching
|
||||
a wall at the moment. Useful for determining things like
|
||||
if the player should be sprinting.
|
||||
--]]
|
||||
function mcl_playerinfo:collision_detect(pos,player)
|
||||
--[[
|
||||
If the player loads in and these variables aren't
|
||||
set the game crashes
|
||||
--]]
|
||||
local around_player = {
|
||||
["left_ofplayer"] = pos,
|
||||
["right_ofplayer"] = pos,
|
||||
["front_ofplayer"] = pos,
|
||||
["front_ofplayerplus"] = pos
|
||||
}
|
||||
--Your distance from a block is < 1.1 if you're touching it.
|
||||
local too_close = 1.1
|
||||
local slab_too_close = 1.42
|
||||
--[[
|
||||
Takes the current degree angle that the player is facing
|
||||
Degrees in minetest are determined counter clock wise
|
||||
from +Z North
|
||||
--]]
|
||||
local deg = math.deg(player:get_look_horizontal())
|
||||
|
||||
--will help determine blocks near the player
|
||||
local nearme = vector.new(pos)
|
||||
|
||||
--[[
|
||||
Basically turns the X and Z axises into a 2D plane
|
||||
The 4 quadrants tell us what block on what axis
|
||||
should currently be on the left,right,front, or "frontplus"
|
||||
of the player. front plus is just if there is a block
|
||||
on top of the block in front of the player
|
||||
]]
|
||||
|
||||
if deg > 0 and deg < 90 then
|
||||
around_player["left_ofplayer"] = vector.add(nearme, vector.new(-1,0,0))
|
||||
around_player["right_ofplayer"] = vector.add(nearme, vector.new(1,0,0))
|
||||
around_player["front_ofplayer"] = vector.add(nearme, vector.new(0,0,1))
|
||||
around_player["front_ofplayerplus"] = vector.add(nearme, vector.new(0,1,1))
|
||||
elseif deg > 90 and deg < 180 then
|
||||
around_player["left_ofplayer"] = vector.add(nearme, vector.new(0,0,-1))
|
||||
around_player["right_ofplayer"] = vector.add(nearme, vector.new(0,0,1))
|
||||
around_player["front_ofplayer"] = vector.add(nearme, vector.new(-1,0,0))
|
||||
around_player["front_ofplayerplus"] = vector.add(nearme, vector.new(-1,1,0))
|
||||
|
||||
elseif deg > 180 and deg < 270 then
|
||||
around_player["left_ofplayer"] = vector.add(nearme, vector.new(1,0,0))
|
||||
around_player["right_ofplayer"] = vector.add(nearme, vector.new(-1,0,0))
|
||||
around_player["front_ofplayer"] = vector.add(nearme, vector.new(0,0,-1))
|
||||
around_player["front_ofplayerplus"] = vector.add(nearme, vector.new(0,1,-1))
|
||||
|
||||
elseif deg > 270 and deg < 360 then
|
||||
around_player["left_ofplayer"] = vector.add(nearme, vector.new(0,0,1))
|
||||
around_player["right_ofplayer"] = vector.add(nearme, vector.new(0,0,-1))
|
||||
around_player["front_ofplayer"] = vector.add(nearme, vector.new(1,0,0))
|
||||
around_player["front_ofplayerplus"] = vector.add(nearme, vector.new(1,0,0))
|
||||
end
|
||||
|
||||
for placement,coord in pairs(around_player) do
|
||||
local node = minetest.get_node(coord)
|
||||
local distance = vector.distance(pos, coord)
|
||||
-- How far is the player from the block in the given direction and
|
||||
-- if the block is not air the player is colliding with it
|
||||
--print(node.name)
|
||||
--print(distance)
|
||||
if vector.distance(pos, coord) < too_close and node.name ~= "air" then
|
||||
return false
|
||||
--Should be able to detect when your head is touching a slab
|
||||
elseif distance < slab_too_close and distance > too_close and placement == "front_ofplayerplus" and node.name ~= "air" then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
local function get_player_nodes(player_pos)
|
||||
local work_pos = table.copy(player_pos)
|
||||
|
||||
|
@ -75,7 +155,6 @@ end)
|
|||
-- set to blank on join (for 3rd party mods)
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
|
||||
mcl_playerinfo[name] = {
|
||||
node_head = "",
|
||||
node_feet = "",
|
||||
|
|
|
@ -40,8 +40,13 @@ function mcl_sprint.is_sprinting(playername)
|
|||
end
|
||||
end
|
||||
|
||||
-- Determines if a block is in front of a player
|
||||
--function mcl_sprint.touching_node(pos)
|
||||
-- local touch
|
||||
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local playerName = player:get_player_name()
|
||||
playerName = player:get_player_name()
|
||||
|
||||
players[playerName] = {
|
||||
sprinting = false,
|
||||
|
@ -159,17 +164,19 @@ minetest.register_globalstep(function(dtime)
|
|||
for playerName, playerInfo in pairs(players) do
|
||||
local player = get_player_by_name(playerName)
|
||||
if player then
|
||||
if mcl_playerinfo:collision_detect(player:get_pos(),player) then
|
||||
local ctrl = player:get_player_control()
|
||||
--Check if the player should be sprinting
|
||||
if players[playerName]["clientSprint"] or ctrl.aux1 and ctrl.up and not ctrl.sneak then
|
||||
players[playerName]["shouldSprint"] = true
|
||||
else
|
||||
players[playerName]["shouldSprint"] = false
|
||||
|
||||
end
|
||||
|
||||
local playerPos = player:get_pos()
|
||||
--If the player is sprinting, create particles behind and cause exhaustion
|
||||
if playerInfo["sprinting"] == true and not player:get_attach() and gameTime % 0.1 == 0 then
|
||||
if playerInfo["sprinting"] == true and players[playerName]["shouldSprint"] and not player:get_attach() and gameTime % 0.1 == 0 then
|
||||
-- Exhaust player for sprinting
|
||||
local lastPos = players[playerName].lastPos
|
||||
local dist = vector.distance({x=lastPos.x, y=0, z=lastPos.z}, {x=playerPos.x, y=0, z=playerPos.z})
|
||||
|
@ -222,7 +229,10 @@ minetest.register_globalstep(function(dtime)
|
|||
elseif players[playerName]["shouldSprint"] == false then
|
||||
setSprinting(playerName, false)
|
||||
end
|
||||
else
|
||||
setSprinting(playerName, 0)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue