Skip to content

Instantly share code, notes, and snippets.

View squiddy's full-sized avatar
🏠
Working from home

Reiner Gerecke squiddy

🏠
Working from home
View GitHub Profile
diff --git a/bravo/packets.py b/bravo/packets.py
index 400f09b..43d04e5 100644
--- a/bravo/packets.py
+++ b/bravo/packets.py
@@ -73,6 +73,9 @@ metadata = Struct("metadata",
),
Const(UBInt8("terminator"), 0x7f),
)
+from construct import StringAdapter, RepeatUntil, Field
+metadata = StringAdapter(RepeatUntil(lambda obj, ctx: obj == "\x7f",
@squiddy
squiddy / bravo_light_strength.diff
Created March 30, 2011 22:26
Bravo skylight spreading strength (MasterofJOKers)
diff --git a/bravo/chunk.py b/bravo/chunk.py
index 1b53573..6d6d519 100644
--- a/bravo/chunk.py
+++ b/bravo/chunk.py
@@ -198,7 +198,8 @@ class Chunk(object):
while glow:
for coords in spread:
- if coords[2] > max_height:
+ if lightmap[coords] <= glow:
@squiddy
squiddy / skylight_spreading_benchmark.py
Created March 30, 2011 13:37
Benchmark for skylight spreading for bravo
import math
import time
from bravo.chunk import Chunk
from bravo.plugins.generators import simplex, caves
def average(l):
return sum(l) / len(l)
def stddev(l):
@squiddy
squiddy / ampoule_bug_test.py
Created March 22, 2011 22:26
Windows twisted amp bug
from ampoule import child, util
from twisted.protocols import amp
class Test(amp.Command):
response = [("blocks", amp.String())]
class MyChild(child.AMPChild):
@Test.responder
def test(self):
return {"blocks": '\x00'*4073}
class Block(object):
"""
Block IDs this class is responsible for.
"""
slots = tuple()
def build(self, factory, player, x, y, z, face):
"""
Called when a player places a block of this type.