Skip to content

Commit

Permalink
Fixed positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
erjadi committed Jan 11, 2022
1 parent 96f0ff6 commit d47ef8f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
28 changes: 15 additions & 13 deletions src/app/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"

"github.com/sandertv/mcwss/mctype"
"github.com/sandertv/mcwss"
)

Expand All @@ -15,17 +15,19 @@ func MOTD(player *mcwss.Player) {
// InitArea will spawn an initial playing area with 4 animal pens and a beacon at the center (currently hardcoded) and set the init position
func InitArea(p *mcwss.Player) {
// Create animal pens
fmt.Println("Creating Animal Pens ", initpos)
p.Position(func(pos mctype.Position){
fmt.Println("Creating Animal Pens ", pos)

Fill(p, initpos, -20, -2, -20, 20, 15, 20, "air")
Fill(p, initpos, -15, -2, -15, 15, -1, 15, "stone 4")
Fill(p, initpos, -1, -2, -1, 1, -2, 1, "glass")
Fill(p, initpos, 0, -2, 0, 0, -2, 0, "beacon")
Fill(p, initpos, -14, -1, -14, 14, -1, 14, "air")
Fill(p, initpos, -14, -2, -14, -2, -2, -2, "grass")
Fill(p, initpos, -14, -1, -14, -2, -1, -2, "fence")
Fill(p, initpos, -13, -1, -13, -9, -1, -9, "air")
Fill(p, initpos, -13, -1, -7, -9, -1, -3, "air")
Fill(p, initpos, -7, -1, -13, -3, -1, -9, "air")
Fill(p, initpos, -7, -1, -7, -3, -1, -3, "air")
Fill(p, pos, -20, -2, -20, 20, 15, 20, "air")
Fill(p, pos, -15, -2, -15, 15, -1, 15, "stone 4")
Fill(p, pos, -1, -2, -1, 1, -2, 1, "glass")
Fill(p, pos, 0, -2, 0, 0, -2, 0, "beacon")
Fill(p, pos, -14, -1, -14, 14, -1, 14, "air")
Fill(p, pos, -14, -2, -14, -2, -2, -2, "grass")
Fill(p, pos, -14, -1, -14, -2, -1, -2, "fence")
Fill(p, pos, -13, -1, -13, -9, -1, -9, "air")
Fill(p, pos, -13, -1, -7, -9, -1, -3, "air")
Fill(p, pos, -7, -1, -13, -3, -1, -9, "air")
Fill(p, pos, -7, -1, -7, -3, -1, -3, "air")
})
}
1 change: 0 additions & 1 deletion src/app/kubecraftadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func ReconcileKubetoMC(p *mcwss.Player, clientset *kubernetes.Clientset) {
kubeentities = append(kubeentities, fmt.Sprintf("%s:deployment:%s", deployment.Namespace, deployment.Name))
playerKubeMap[p.Name()] = kubeentities
if !Contains(playerEntitiesMap[p.Name()], fmt.Sprintf("%s:deployment:%s", deployment.Namespace, deployment.Name)) {
fmt.Printf("Summoning %s:deployment:%s\n", deployment.Namespace, deployment.Name)
Summonpos(p, clientset, namespacesp[i], "horse", fmt.Sprintf("%s:deployment:%s", deployment.Namespace, deployment.Name))
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ func main() {
playerInitMap := make(map[string]bool)
playerInitMap[playerName] = false

GetPlayerPosition(player)
SetNamespacesPosition()

player.OnTravelled(func(event *event.PlayerTravelled) {
player.Exec("testforblock ~ ~-1 ~ beacon", func(response *command.LocalPlayerName) {
if response.StatusCode == 0 {
player.Position(func(pos mctype.Position) {
SetNamespacesPositionByPos(pos)
})
if !playerInitMap[playerName] {
playerInitMap[playerName] = true
fmt.Println("initialized!")
Expand Down Expand Up @@ -134,8 +134,9 @@ func main() {
// Initialize admin area
if (strings.Compare(event.Message, "init")) == 0 {
DeleteEntities(player)
GetPlayerPosition(player)
SetNamespacesPosition()
player.Position(func(pos mctype.Position) {
SetNamespacesPositionByPos(pos)
})
InitArea(player)
}

Expand Down
11 changes: 10 additions & 1 deletion src/app/mcutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func GetPlayerPosition(player *mcwss.Player) {
})
}

// Get Namspace Positions
// Set Namspace Positions
func SetNamespacesPosition() {
namespacesp = []mctype.Position{
{X: initpos.X - 11, Y: initpos.Y + 5, Z: initpos.Z - 11},
Expand All @@ -97,3 +97,12 @@ func SetNamespacesPosition() {
{X: initpos.X - 5, Y: initpos.Y + 5, Z: initpos.Z - 5},
}
}

func SetNamespacesPositionByPos(pos mctype.Position) {
namespacesp = []mctype.Position{
{X: pos.X - 11, Y: pos.Y + 5, Z: pos.Z - 11},
{X: pos.X - 11, Y: pos.Y + 5, Z: pos.Z - 5},
{X: pos.X - 5, Y: pos.Y + 5, Z: pos.Z - 11},
{X: pos.X - 5, Y: pos.Y + 5, Z: pos.Z - 5},
}
}

0 comments on commit d47ef8f

Please sign in to comment.