fix an anticheat, world names added, water in maps shown

This commit is contained in:
olebeck 2022-08-15 20:55:05 +02:00
parent ac0db41e92
commit c5abf07dad
4 changed files with 40 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import (
"image"
"image/color"
"github.com/df-mc/dragonfly/server/block"
"github.com/df-mc/dragonfly/server/world"
"github.com/df-mc/dragonfly/server/world/chunk"
)
@ -11,11 +12,14 @@ import (
func Chunk2Img(c *chunk.Chunk) *image.RGBA {
img := image.NewRGBA(image.Rect(0, 0, 16, 16))
hm := c.HeightMap()
hml := c.LiquidHeightMap()
for x := uint8(0); x < 16; x++ {
for z := uint8(0); z < 16; z++ {
height := hm.At(x, z)
col := color.RGBA{uint8(height), 0, 0, 255}
height_liquid := hml.At(x, z)
col := color.RGBA{0, 0, 0, 255}
block_rid := c.Block(x, height, z, 0)
b, found := world.BlockByRuntimeID(block_rid)
@ -23,6 +27,22 @@ func Chunk2Img(c *chunk.Chunk) *image.RGBA {
col = b.Color()
}
/*
if col.R == 255 && col.B == 255 {
name, nbt := b.EncodeBlock()
fmt.Printf("unknown color %s %s %s\n", reflect.TypeOf(b), name, nbt)
b.Color()
}
*/
if height_liquid > height {
bw := &block.Water{}
wcol := bw.Color()
col.R = col.R/2 + wcol.R/2
col.G = col.G/2 + wcol.G/2
col.B = col.B/2 + wcol.B/2
}
img.SetRGBA(int(x), int(z), col)
}
}

4
go.mod
View File

@ -20,9 +20,9 @@ require (
//replace github.com/df-mc/dragonfly => ./dragonfly
replace github.com/sandertv/gophertunnel => github.com/olebeck/gophertunnel v1.24.4
replace github.com/sandertv/gophertunnel => github.com/olebeck/gophertunnel v1.24.5
replace github.com/df-mc/dragonfly => github.com/olebeck/dragonfly v0.8.2-2
replace github.com/df-mc/dragonfly => github.com/olebeck/dragonfly v0.8.2-3
require (
github.com/brentp/intintmap v0.0.0-20190211203843-30dc0ade9af9 // indirect

4
go.sum
View File

@ -39,8 +39,12 @@ github.com/olebeck/dragonfly v0.8.2-1 h1:hC0iWH7WFOpsvR3XeTwJSRKtKO+GhEcMq+H+DHU
github.com/olebeck/dragonfly v0.8.2-1/go.mod h1:xgpCDhHoP03RygPaTrzzDwsSTcEZhxNPMV3CAxETj+I=
github.com/olebeck/dragonfly v0.8.2-2 h1:rIUAEJx2ZeQhsRFNkHXrfYR3Zl85WB5spS/SZEH91ag=
github.com/olebeck/dragonfly v0.8.2-2/go.mod h1:xgpCDhHoP03RygPaTrzzDwsSTcEZhxNPMV3CAxETj+I=
github.com/olebeck/dragonfly v0.8.2-3 h1:qzcNc76U1E8RXpg98Fv02kxFulhsR/TWcKArqRY+xdY=
github.com/olebeck/dragonfly v0.8.2-3/go.mod h1:xgpCDhHoP03RygPaTrzzDwsSTcEZhxNPMV3CAxETj+I=
github.com/olebeck/gophertunnel v1.24.4 h1:nX7Std61XpXW4VP7KKd2RvinRwx1nGB5l8QnbwrArLE=
github.com/olebeck/gophertunnel v1.24.4/go.mod h1:dMOw79FHxr2azEqiGH20AwdljisAN1kqwu5SjPBnZ5k=
github.com/olebeck/gophertunnel v1.24.5 h1:FtpHzfp833qQGBSJtKysSmRzFzsSheq5l61d5gTp03s=
github.com/olebeck/gophertunnel v1.24.5/go.mod h1:dMOw79FHxr2azEqiGH20AwdljisAN1kqwu5SjPBnZ5k=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=

View File

@ -303,7 +303,13 @@ func (w *WorldState) Reset() {
// writes the world to a folder, resets all the chunks
func (w *WorldState) SaveAndReset() {
fmt.Println("Saving world")
folder := path.Join("worlds", fmt.Sprintf("%s/%s-%d", w.ServerName, w.WorldName, w.worldCounter))
var world_name string
if w.WorldName == "world" {
world_name = fmt.Sprintf("%s-%d", w.WorldName, w.worldCounter)
} else {
world_name = w.WorldName
}
folder := path.Join("worlds", fmt.Sprintf("%s/%s", w.ServerName, world_name))
os.MkdirAll(folder, 0777)
provider, err := mcdb.New(folder, opt.DefaultCompression)
if err != nil {
@ -336,6 +342,8 @@ func (w *WorldState) SaveAndReset() {
int(w.PlayerPos.Position[1]),
int(w.PlayerPos.Position[2]),
}
s.Name = w.WorldName
ld := provider.LevelDat()
for _, gr := range w.ServerConn.GameData().GameRules {
switch gr.Name {
@ -492,6 +500,10 @@ func handleConn(ctx context.Context, l *minecraft.Listener, cc, sc *minecraft.Co
pk.Enabled = false
w.ServerConn.WritePacket(pk)
skip = true
case *packet.MobEquipment:
if pk.NewItem.Stack.NBTData["map_uuid"] == int64(VIEW_MAP_ID) {
skip = true
}
case *packet.Animate:
w.ProcessAnimate(pk)
case *packet.CommandRequest: