Add job for farming trees and object physics
This commit is contained in:
34
bot.py
34
bot.py
@@ -22,7 +22,7 @@ from minecraft.networking.packets import Packet, clientbound, serverbound
|
||||
|
||||
from protocol.managers import DataManager, ChunksManager, ChatManager, ChunkNotLoadedException
|
||||
|
||||
from bunch import Bunch
|
||||
from munch import Munch
|
||||
from panda3d.core import LPoint3f, LVector3f
|
||||
|
||||
import game
|
||||
@@ -59,6 +59,37 @@ def tick(global_state):
|
||||
|
||||
g.chunks.unload_chunks(p)
|
||||
|
||||
########## object physics ##########
|
||||
|
||||
for eid, obj in g.objects.items():
|
||||
start_x = obj.x
|
||||
|
||||
if obj.velocity_x:
|
||||
obj.x += obj.velocity_x / 8000
|
||||
if obj.velocity_y:
|
||||
obj.y += obj.velocity_y / 8000
|
||||
if obj.velocity_z:
|
||||
obj.z += obj.velocity_z / 8000
|
||||
|
||||
block_below = g.chunks.get_block_at(floor(obj.x), int(obj.y-0.20), floor(obj.z))
|
||||
in_air = block_below in blocks.NON_SOLID_IDS
|
||||
|
||||
if in_air:
|
||||
obj.velocity_x *= 0.988
|
||||
obj.velocity_y -= 390
|
||||
obj.velocity_z *= 0.988
|
||||
else:
|
||||
obj.y = int(obj.y-0.20)+1
|
||||
obj.velocity_x *= 0.5
|
||||
obj.velocity_y = 0
|
||||
obj.velocity_z *= 0.5
|
||||
|
||||
if abs(obj.velocity_x) < 1: obj.velocity_x = 0
|
||||
if abs(obj.velocity_z) < 1: obj.velocity_z = 0
|
||||
|
||||
|
||||
########## player physics ##########
|
||||
|
||||
if g.path and len(g.path):
|
||||
target = LPoint3f(g.path[0])
|
||||
target.x += 0.5
|
||||
@@ -162,6 +193,7 @@ def init(global_state):
|
||||
g.window = None
|
||||
|
||||
g.job = jobs.JobStates(g)
|
||||
g.chopped_tree = False
|
||||
|
||||
def bot(global_state):
|
||||
g = global_state
|
||||
|
Reference in New Issue
Block a user