Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Massive update #84

Merged
merged 34 commits into from
Oct 10, 2020
Merged

Massive update #84

merged 34 commits into from
Oct 10, 2020

Conversation

twitchyliquid64
Copy link

@twitchyliquid64 twitchyliquid64 commented Oct 6, 2020

Sorry this is such a big update. It includes:

  1. Update to 1.16.3
  2. Fixes for parsing and storing world chunks, as well as keeping track of entities
  3. Proper generation and data dictionaries for blocks, items, collision shapes, entities, packet IDs, etc
  4. Implement generation scripts for the above data dictionaries. Note that even though some reference 1.16.2 files, this is still correct: most data dictionaries did not change across the two versions.
  5. Player physics simulation on solid ground, falling, ladders, and blocks (including those with custom collision shapes). All movements in my testing seem smooth and are accepted by a vanilla 1.16.2 server.
  6. Pathfinding, with most movements implemented (block traversal, jump 1, decend 1/2, ladders, stairs, jump across 1)
  7. A ton of new events to support inventory operations, physics, etc

Pathfinding from a current location to a known location looks like this:

pos := c.GetPos()
nav := &path.Nav{
	World: &c.Wd,
	Start: path.V3{X: int(math.Floor(pos.X)), Y: int(math.Floor(pos.Y - 0.6)), Z: int(math.Floor(pos.Z))},
	Dest:  path.V3{X: x, Y: y - 1, Z: z},
}

path, _, found := nav.Path()
if !found {
	return 0, errors.New("no path to destination")
}

// On each physics tick (use the pre physics event/hook) you'll need to compute this:
start:
move := path[len(path)-1].(path.Tile)
dX, dY, dZ := pos.X-float64(move.Pos.X)-0.48, pos.Y-float64(move.Pos.Y)-1, pos.Z-float64(move.Pos.Z)-0.48
if move.IsComplete(path.Point{X: dX, Y: dY, Z: dZ}) {
	fmt.Printf("Completed tile %+v\n", move)
	path = path[:len(path)-1]
	goto start
}
c.Inputs = move.Inputs(
	path.Point{X: pos.X, Y: pos.Y, Z: pos.Z},
	path.Point{X: dX, Y: dY, Z: dZ},
	vel,
	time.Now().Sub(c.tileStarted),
), true

@twitchyliquid64
Copy link
Author

Friendly ping :)

If this is too large and you would rather keep it as a fork thats cool too, let me know =]

@Tnze Tnze merged commit 5120b2d into Tnze:master Oct 10, 2020
@Tnze
Copy link
Owner

Tnze commented Oct 11, 2020

It's quite busy that I have no time to check this these days even I forget it. I'm really sorry about that.
So it's unreviewed merged but even if there is any problem, hope the person who finds out will create an issue :)

Finally, thank you very much for your great contribution!

@twitchyliquid64
Copy link
Author

No problem at all 😃 thanks for merging!

Happy to help with any issues if they come up.

@Tnze
Copy link
Owner

Tnze commented Feb 27, 2021

Hello! @twitchyliquid64
I'm refactoring the bot package a lot >_<. And sorry for temporarily removed packages like bot/world in order to be able to compile. (I'm happy to add them back later and be compatible with the new structure & may need your help at that time.)

Then I run into an problem, and need some help. The client is kicked with the reason: Time out. Keep Alive packet is handled of course.
Do you have any idea? Is it required that keeping sending PlayerPositionAndLook(Serverbound) packet?

@Tnze
Copy link
Owner

Tnze commented Jun 20, 2021

Hello! It's a friendly reminder.
There is a problem with your gen_entity.go file in version 1.17, which causes the generated entity.go file to fail to compile. I solved this problem by deleting the entire data/entity package directly: (, if you can fix the problem, of course, it's best, or lets just keep it empty there, it's fine.

# github.com/Tnze/go-mc/data/entity
Error: data/entity/entity.go:38:163: syntax error: unexpected }, expecting expression
Error: data/entity/entity.go:39:156: syntax error: unexpected }, expecting expression
Error: data/entity/entity.go:40:146: syntax error: unexpected }, expecting expression
Error: data/entity/entity.go:41:148: syntax error: unexpected }, expecting expression
Error: data/entity/entity.go:42:139: syntax error: unexpected }, expecting expression
Error: data/entity/entity.go:43:138: syntax error: unexpected }, expecting expression
Error: data/entity/entity.go:44:143: syntax error: unexpected }, expecting expression
Error: data/entity/entity.go:45:144: syntax error: unexpected }, expecting expression
Error: data/entity/entity.go:46:138: syntax error: unexpected }, expecting expression
Error: data/entity/entity.go:47:155: syntax error: unexpected }, expecting expression
Error: data/entity/entity.go:47:155: too many errors

The Categore is empty as you see.
AreaEffectCloud = Entity{ID: 0, InternalID: 0, DisplayName: "Area Effect Cloud", Name: "area_effect_cloud", Width: 6, Height: 0.5, Type: "other", Category: }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants