minecraft_utils 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/coords +41 -0
  3. data/bin/stacks +56 -0
  4. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ade4161dc2a89c78868302a98e54664ec94ed1a61d7f7cad45f716344ffe08cb
4
+ data.tar.gz: e4bfc6cbc5ded8615131b0a230ebe8d72c43fe4d8a911405fca9a5dc8797b3d1
5
+ SHA512:
6
+ metadata.gz: 462b31765ee8a35e729ab3ad04a5ee5abaf6125aa0ebaaaecbc8b12ce132da9d78db6157e3ce575f915643159adfe3e8b2a634ac9440800344e2dddf774ba179
7
+ data.tar.gz: 9402dad2988380246b5f9cd9f8545785361a587347e89defdd43a13f2a8ce541f82ffc56961c69649396fe3aca40159c0ecfd6335f4682c7445dec93bca21ffa
data/bin/coords ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require "optparse"
4
+
5
+ ARGV.push "-h" if ARGV.empty?
6
+
7
+ options = {}
8
+ location = "Nether"
9
+ OptionParser.new do |opts|
10
+ opts.banner = "Usage: coords [options] X Z"
11
+
12
+ opts.on("-o", "--overworld",
13
+ "calculates nether -> overworld coordinates") do |o|
14
+ options[:overworld] = o
15
+ location = "Overworld"
16
+ end
17
+ end.parse!
18
+
19
+ # Try and find 2 valid numbers in the args.
20
+ # They could run `coords 550 fuck you 700` for all I care.
21
+ case (coords = ARGV.grep(/^\d+$/).map &:to_i).size
22
+ when 3
23
+ # If they give XYZ, strip the Y
24
+ coords -= [coords[1]]
25
+ when 2
26
+ # Perfect
27
+ else
28
+ puts "No proper coordinate input found."
29
+ exit 1
30
+ end
31
+
32
+ # Transform the coordinates
33
+ x, z = coords.map do |c|
34
+ if options[:overworld]
35
+ c * 8
36
+ else
37
+ (c / 8.0).round
38
+ end
39
+ end
40
+
41
+ puts "#{location} Coordinates: #{x}, #{z}"
data/bin/stacks ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require "optparse"
4
+
5
+ ARGV.push "-h" if ARGV.empty?
6
+
7
+ options = {}
8
+ OptionParser.new do |opts|
9
+ opts.banner = "Usage: stacks [options] AMOUNT [STACK SIZE=64]"
10
+
11
+ opts.on("-s", "--shulkers", "prints amount of shulker boxes to fill") do |o|
12
+ options[:shulkers] = o
13
+ end
14
+
15
+ opts.on("-d", "--dye",
16
+ "prints amount of dye needed for stained glass or concrete") do |o|
17
+ options[:dye] = o
18
+ end
19
+ end.parse!
20
+
21
+ unless ARGV[0].match? /^\d+$/
22
+ puts "Amount must be a number!"
23
+ exit 1
24
+ end
25
+
26
+ unless ARGV[1].nil? or ARGV[1].match? /^\d+$/
27
+ puts "Stack size must be a number!"
28
+ exit 1
29
+ end
30
+
31
+ def calc_stacks(n, stack_size=64)
32
+ stacks = (n / stack_size).floor
33
+ return [stacks, n - (stacks * stack_size)]
34
+ end
35
+
36
+ amount = ARGV[0].to_i
37
+ stacks, blocks = calc_stacks(amount, ARGV[1].nil? ? 64 : ARGV[1].to_i)
38
+
39
+ puts "#{stacks} stacks, #{blocks} blocks"
40
+
41
+ if options[:shulkers]
42
+ boxes = (stacks / 27).floor
43
+ puts "#{boxes} shulkers, #{stacks-(boxes * 27)} stacks, #{blocks} blocks"
44
+ end
45
+
46
+ if options[:dye]
47
+ dye = (amount / 8.0).ceil
48
+ print "Dye needed: #{dye}"
49
+
50
+ if dye > 64
51
+ stacks, blocks = calc_stacks dye
52
+ print " (#{stacks} stacks, #{blocks} blocks)"
53
+ end
54
+
55
+ puts
56
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minecraft_utils
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vinny Diehl
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-05-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Tools for calculating stacks of items and Nether coordinates.
14
+ email: vinny.diehl@gmail.com
15
+ executables:
16
+ - stacks
17
+ - coords
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - bin/coords
22
+ - bin/stacks
23
+ homepage: https://github.com/vinnydiehl/minecraft_utils
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '2.0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubygems_version: 3.1.3
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: A simple set of calculator tools for Minecraft.
46
+ test_files: []