-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
stoneskin
committed
Jun 16, 2020
1 parent
bc8fcee
commit 306028d
Showing
16 changed files
with
876 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
from functions.drawing import * | ||
from random import choice | ||
import mcpi_e.minecraft as minecraft | ||
from mcpi_e.block import * | ||
|
||
address="server" | ||
name="stoneskin" | ||
mc = minecraft.Minecraft.create(address,4712,name) | ||
|
||
drawing = Drawing(mc) | ||
|
||
pos = mc.player.getTilePos() | ||
radius = 10 | ||
A = WOOL_ORANGE = Block(WOOL.id, 1) | ||
C = WOOL_GREEN = Block(WOOL.id, 13) | ||
G= WOOL_BLUE = Block(WOOL.id, 11) | ||
T= WOOL_RED = Block(WOOL.id, 14) | ||
|
||
|
||
blocks = { "A":(A,T), "C":(C,G), "T":(T,A), "G":(G,C) } | ||
# sequence taken from somewhere in chromosome 5, retrieved via Wolfram Alpha | ||
sequence = "CAAAAGTGTGGGGAAATTAATTTGGGAATTACTCTCCTCATTGAAAAATATCTCATTTGCTAAAATAAGACAGTAAAACAGTACAGTTTAAATATTTATAAAAATAGGAAAGTTTGGCAAAAAGAGAGGAGTACACACCTGTGACTACTGAGTTGCTGTGAAAATTTCATTTCCTGATACAAAATTGTCTAAAGCACTTG" | ||
|
||
def getPair(i): | ||
return blocks[sequence[-i-1]] | ||
|
||
prev = None | ||
skip = 2 | ||
for y in range(240): | ||
theta = y * pi / (skip*10) | ||
y1 = pos.y + y | ||
x1 = pos.x - radius * cos(theta) | ||
x2 = pos.x + radius * cos(theta) | ||
z1 = pos.z + radius * sin(theta) | ||
z2 = pos.z - radius * sin(theta) | ||
if y % skip == 0: | ||
pair = getPair(y//skip) | ||
drawing.penwidth(1) | ||
drawing.line(x1,y1,z1,pos.x,y1,pos.z,pair[0]) | ||
drawing.line(x2,y1,z2,pos.x,y1,pos.z,pair[1]) | ||
|
||
if prev is not None: | ||
drawing.penwidth(2) | ||
drawing.line(prev[0],prev[1],prev[2],x1,y1,z1,block.WOOL_WHITE) | ||
drawing.line(prev[3],prev[4],prev[5],x2,y1,z2,block.WOOL_WHITE) | ||
prev = x1,y1,z1,x2,y1,z2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from mcpi_e.minecraft import Minecraft | ||
from mcpi_e import block | ||
from time import sleep | ||
from random import * | ||
from math import * | ||
|
||
def draw_donut(mcx,mcy,mcz,R,r,mcblock): | ||
for x in range(-R-r,R+r): | ||
for y in range(-R-r,R+r): | ||
xy_dist = sqrt(x**2 + y**2) | ||
if (xy_dist > 0): | ||
ringx = x / xy_dist * R # nearest point on major ring | ||
ringy = y / xy_dist * R | ||
ring_dist_sq = (x-ringx)**2 + (y-ringy)**2 | ||
|
||
for z in range(-R-r,R+r): | ||
if (ring_dist_sq + z**2 <= r**2): | ||
mc.setBlock(mcx+x, mcy+z, mcz+y, mcblock) | ||
|
||
serverAddress="server" # change to your minecraft server | ||
playerName ="stoneskin" | ||
pythonApiPort=4712 | ||
|
||
mc=Minecraft.create(serverAddress,pythonApiPort,playerName) | ||
playerPos=mc.player.getTilePos() | ||
|
||
draw_donut(playerPos.x, playerPos.y + 9, playerPos.z, 18, 9, block.GLASS) | ||
mc.postToChat("Glass donut done") | ||
draw_donut(playerPos.x, playerPos.y + 9, playerPos.z, 18, 6, block.WATER_STATIONARY) | ||
mc.postToChat("Water donut done") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import sys | ||
import mcpi_e.block as block | ||
from mcpi_e.minecraft import Minecraft | ||
from math import * | ||
Block = block.Block | ||
|
||
def egg(block=block.GOLD_BLOCK, h=40, a=2.5, b=1, c=0.1): | ||
for y in range(0,h+1): | ||
l = y / float(h) | ||
# Formula from: http://www.jolyon.co.uk/myresearch/image-analysis/egg-shape-modelling/ | ||
r = h*a*exp((-0.5*l*l+c*l-.5*c*c)/(b*b))*sqrt(1-l)*sqrt(l)/(pi*b) | ||
r2 = r*r | ||
for x in range(-h,h+1): | ||
for z in range(-h,h+1): | ||
myr2 = x*x + z*z | ||
if myr2 <= r2: | ||
if x==0 and z==0: | ||
theta = 0 | ||
else: | ||
theta = atan2(z,x) | ||
yield (x,y,z,block,theta) | ||
|
||
address="server" | ||
name="stoneskin" | ||
mc = Minecraft.create(address,4712,name) | ||
|
||
|
||
if len(sys.argv) >= 2: | ||
height = int(sys.argv[1]) | ||
else: | ||
height = 50 | ||
|
||
if len(sys.argv) >= 3: | ||
material = Block.byName(sys.argv[2]) | ||
else: | ||
material = block.GOLD_BLOCK | ||
|
||
pos = mc.player.getPos() | ||
|
||
for (x,y,z,block,theta) in egg(h=height,block=material): | ||
mc.setBlock(x+pos.x,y+pos.y,z+pos.z,block) |
Oops, something went wrong.