Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bind to any IP (useful for running on a separate machine a LAN)

Monitor incoming named_entity_spawns for nearby players
Wolf radar!
Notes! Type /n to add a note, /s to show notes.
Type /clock to see system time in-game. No more surprises!
  • Loading branch information...
commit 637a04b6ae110cea1e0b3a9ba60b3c2296b35485 1 parent 92565b4
@tspangler authored
View
6 bin/golem
@@ -5,7 +5,7 @@ $:.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
require "golem"
if ARGV.include?("-h") || ARGV.include?("--help")
- abort "golem [server=localhost [port=25565 [listen_port=8888]]] | bot [host=localhost [port=25565]]"
+ abort "golem [server=localhost [port=25565 [listen_port=8888 [bindaddress=localhost]]]] | bot [host=localhost [port=25565]]"
end
if ARGV.first == "bot"
@@ -17,6 +17,8 @@ else
server_host = ARGV.shift || "127.0.0.1"
server_port = (ARGV.shift || (server_host == "127.0.0.1" ? 8888 : 25565)).to_i
listen_port = (ARGV.shift || 25565).to_i
- Golem::Client.proxy("127.0.0.1", listen_port, server_host, server_port)
+ bind_address = ARGV.shift || "127.0.0.1"
+
+ Golem::Client.proxy(bind_address, listen_port, server_host, server_port)
end
View
4 lib/golem.rb
@@ -63,6 +63,10 @@ class ::Numeric
def in_degrees
self * 180 / Math::PI
end
+
+ def humanize
+ self / 32
+ end
end
end
View
29 lib/golem/proxy.rb
@@ -134,6 +134,17 @@ def proxy_command(message)
@fastdig = false
when /\/stop/
clear_current_action
+
+ when /\/n (.+)/
+ add_note($1)
+ tell_client "\xC2\xA76Created note #{$1} at coords #{state.coords.inspect}"
+
+ when /\/s/
+ show_notes
+
+ when /\/clock/
+ tell_client "\xC2\xA7dSystem time is #{Time.now.strftime('%R %p')}. Go to bed!"
+
else
return false
end
@@ -161,7 +172,7 @@ def send_pending_action_packets
end
def tell_client(msg)
- send_server_packet :chat, "<proxy> #{msg}"
+ send_server_packet :chat, msg
end
def fly_to(x, y, z)
@@ -179,6 +190,22 @@ def send_server_packet(kind, *values)
debug "<-- client #{packet.inspect}"
client.send_data packet.encode
end
+
+private
+ def add_note(note)
+ # Open the right file
+ # Filename format is #{username}_#{server}
@tspangler Owner

Not yet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+ File.open('notes', 'a') do |f|
+ f.puts "#{state.coords.inspect}: #{note}"
+ end
+ end
+
+ def show_notes
+ File.open('notes', 'r').each_line do |l|
+ tell_client "\xC2\xA76#{l}"
+ end
+ end
end
end
View
26 lib/golem/session.rb
@@ -24,7 +24,31 @@ def receive_data(data)
log "server disconnect: #{packet.message}"
EM.stop
end
-
+
+ # If there's a player coming into view, let us know
+ if packet.kind == :named_entity_spawn
+ x = packet.x.humanize
+ y = packet.y.humanize
+ z = packet.z.humanize
+ carrying = ITEMS[packet.current_item].nil? ? 'nothing' : 'a ' + ITEMS[packet.current_item].to_s.gsub(/_/, ' ')
+
+ # Send the client a bright green (ASCII 167) alert
+ tell_client "\xC2\xA7a" + '[' + x.to_s + ', ' + y.to_s + ', ' + z.to_s + '] A wild ' + packet.name + ' appears carrying ' + carrying + '!'
+ end
+
+ # Wolf alert!
+ if packet.kind == :mob_spawn && packet.type == 95
+ puts packet.inspect
+
+ x = packet.x.humanize
+ y = packet.y.humanize
+ z = packet.z.humanize
+
+ owner = packet.mob_data[0].empty? ? 'Untamed' : packet.mob_data[0].to_s + '\'s'
+
+ tell_client "\xC2\xA7a" + owner + ' wolf spotted at ' + x.to_s + ', ' + y.to_s + ', ' + z.to_s + '!'
+ end
+
handle packet
if current_action
Please sign in to comment.
Something went wrong with that request. Please try again.