frommc2import*definterfaceupdate(s):ifs.rsmoveitemandnotkeydown(KEY_OK):s.rsmoveitem=Falseifnots.rsmoveitemandkeydown(KEY_OK)ands.inInv!=0:s.rsmoveitem=Trues.onmoveitem=nots.onmoveitemifs.onmoveitem:get=s.invnumbers[s.invcase]ifkeydown(KEY_RIGHT)andnots.invcasein{22,32}:get=ceil(get/2)s.inventory[36]=s.inventory[s.invcase]s.invnumbers[36]=gets.invdata[36]=s.invdata[s.invcase]s.invdata[s.invcase]=0useitem(s,s.invcase,get)ifs.invcase==22:debug(s.inventory[s.invcase])forxutinrange(4):useitem(s,18+xut,1)refreshcase(s.parent,18+xut)elifs.invcase==32ands.inventory[s.invcase]!="*":forxutinrange(9):useitem(s,23+xut,1)refreshcase(s.parent,23+xut)refreshcase(s.parent,s.invcase)refreshcase(s.parent,36)else:ifs.invcase==22ands.inventory[s.invcase]!="*":s.onmoveitem=Trueifs.inventory[36]==s.inventory[22]:tempi=getstackvalue(s.parent,s.inventory[36])addo=tempi-s.invnumbers[36]ifaddo>0:s.invnumbers[36]+=s.invnumbers[22]refreshcase(s.parent,36)forxutinrange(4):useitem(s,18+xut,1)refreshcase(s.parent,18+xut)elifs.invcase==32ands.inventory[s.invcase]!="*":s.onmoveitem=Trueifs.inventory[36]==s.inventory[32]:tempi=getstackvalue(s.parent,s.inventory[36])addo=tempi-s.invnumbers[36]ifaddo>0:s.invnumbers[36]+=s.invnumbers[32]refreshcase(s.parent,36)forxutinrange(9):useitem(s,23+xut,1)refreshcase(s.parent,23+xut)elifs.invcase!=35:topose=s.invnumbers[36]ifkeydown(KEY_LEFT):iftopose!=1:s.onmoveitem=Truetopose=1ifs.inventory[s.invcase]=="*":s.inventory[s.invcase]=s.inventory[36]s.invnumbers[s.invcase]+=toposes.invdata[s.invcase]=s.invdata[36]s.invdata[36]=0useitem(s,36,topose)elifs.inventory[s.invcase]==s.inventory[36]:tempi=getstackvalue(s.parent,s.inventory[36])addo=tempi-s.invnumbers[s.invcase]iftopose>addo:useitem(s,36,addo)s.onmoveitem=Trues.invnumbers[s.invcase]+=addoelse:useitem(s,36,topose)s.invnumbers[s.invcase]+=toposeelse:s.onmoveitem=Trues.inventory[s.invcase],s.inventory[36]=s.inventory[36],s.inventory[s.invcase]s.invnumbers[s.invcase],s.invnumbers[36]=s.invnumbers[36],s.invnumbers[s.invcase]s.invdata[s.invcase],s.invdata[36]=s.invdata[36],s.invdata[s.invcase]refreshcase(s.parent,s.invcase)refreshcase(s.parent,36)ifs.inInv==0:forelein{0,1,2,3,4,5}:ifkeydown(s.keyindex[ele]):s.invcase=elehotbarrefresh(s)returnelse:foreleins.prerangedihuit:ifkeydown(s.keyindex[ele]):s.invcase=elehotbarrefresh(s)ifs.inInv==1:minicraftupdate(s)elifs.inInv==2:bigcraftupdate(s)elifs.inInv==3:furnaceupdate(s)deffurnaceupdate(s):ifs.inventory[33]ins.parent.cookable:ifs.inventory[34]ins.parent.fuels:if0==0:useitem(s,34,1)tp={30:33,42:34,39:35}foreleintp.keys():ifkeydown(ele):s.invcase=tp[ele]hotbarrefresh(s)breakdefminicraftupdate(s):tp={30:18,31:19,36:20,37:21,39:22}forlintp.keys():ifkeydown(l):s.invcase=tp[l];hotbarrefresh(s);breakm=s.inventory[18]+s.inventory[19]+s.inventory[20]+s.inventory[21]t=get_item_craft_mini(m)ifs.inventory[22]!=t[0]:s.inventory[22]=t[0];s.invnumbers[22]=t[1];refreshcase(s.parent,22)defbigcraftupdate(s):tp={30:23,31:24,32:25,36:26,37:27,38:28,42:29,43:30,44:31,39:32}foreleintp.keys():ifkeydown(ele):s.invcase=tp[ele]hotbarrefresh(s)breakbigcraftis=s.inventorytemp=get_item_craft_big(bigcraftis)ifs.inventory[32]!=temp[0]:tempo=s.parent.invcaseposition[32]s.inventory[32]=temp[0]s.invnumbers[32]=temp[1]s.invdata[32]=100refreshcase(s.parent,32)defupdatebloc(gamegeror,xb,yb,to,canreplace,extra={}):blockpos=xb+yb*16temp=gamegeror.actualchunkifnotcanreplaceandtemp[blockpos]!="*":returnFalsegamegeror.actualchunkticker[xb+yb*16]=getblocticks(to)tp=temp[0:blockpos]+to+temp[blockpos+1:144]gamegeror.actualchunk=tpafftex(xb*20,yb*20,to,gamegeror)returntemp[blockpos]defhotbarrefresh(p):ifp.invcase==p.oldinvcase:returntemp=p.parent.invcasepositionrefreshcase(p.parent,p.invcase)refreshcase(p.parent,p.oldinvcase)p.oldinvcase=p.invcasedefhotbarprint(player):forspxinrange(6):refreshcase(player.parent,spx)defphysicupdate(s,dt,game):ret={"wall":[]}ifs.speedx!=0:nbofchecks=2+s.colly//20dep=s.colly/nbofchecks-1checks=[s.Py+dep*adforadinrange(nbofchecks+1)]s.Px+=s.speedx*dtcondis=[]xpos=s.Px+s.collx*(s.speedx>0)forycheckinchecks:ypos=int(ycheck/20)ifypos<9:tp=getblock(int(xpos/20),ypos,game)condis.append(tpins.parent.traversable)ret["wall"].append(tp)else:condis.append(True)ifFalseincondis:s.Px-=s.speedx*dts.speedx=0s.speedy-=dt*9.81nbofchecks=2+s.collx//20dep=s.collx/nbofchecks-1checks=[s.Px+dep*adforadinrange(nbofchecks+1)]maxh=Falseifs.speedy>0:maxh=Trueifmaxhands.speedy<0:s.lastmaxheight=s.Pydescente=s.speedy<0s.Py-=s.speedycondis=[]ifdescente:ypos=int((s.Py+s.colly-1)/20)else:ypos=int((s.Py)/20)forxcheckinchecks:ifypos<9:condis.append(getblock(int((xcheck)/20),ypos,game)ins.parent.traversable)else:condis.append(True)ifFalseincondis:ifdescente:s.onground=Truedif=s.Py-s.lastmaxheightifdif>60:dam=int(dif/20)-2changelife(s,-dam)s.lastmaxheight=s.Pys.Py+=s.speedys.speedy=0else:ifdescente:s.onground=FalsereturnretdefAffBigCraft(player):temp=player.parent.invcasepositionforxinrange(9):refreshcase(player.parent,23+x)refreshcase(player.parent,32)bx=temp[32][0]-25by=temp[32][1]+10f(bx,by,15,6,"gray")forxinrange(6):f(bx+20-x,by+x+4,1,-2*(x+1),"gray")defBlocKSelectRefresh(p):p.destimer=0ifint(p.Py/20)-p.Blolistpos[p.Bloselectn][1]<9:tempbl=getblock(int(p.Px/20)+p.Blolistpos[p.Bloselectn][0],int(p.Py/20)-p.Blolistpos[p.Bloselectn][1],p.parent)iftempblinp.parent.blocksbreakstime.keys():p.blocktodestime=p.parent.blocksbreakstime[tempbl]else:p.blocktodestime=2000else:p.blocktodestime=2000ifint(p.Py/20)-p.Blolistpos[p.Bloselectn][1]<9:f(p.BlX*20,p.BlY*20,20,1,"black")f(p.BlX*20,p.BlY*20+19,20,1,"black")f(p.BlX*20,p.BlY*20,1,20,"black")f(p.BlX*20+19,p.BlY*20,1,20,"black")ifp.oldBlX+p.oldBlY*16<144:afftex(p.oldBlX*20,p.oldBlY*20,p.parent.actualchunk[p.oldBlX+p.oldBlY*16],p.parent)p.oldBlX=p.BlXp.oldBlY=p.BlYp.lsblx=int(p.Px/20)p.lsbly=int(p.Py/20)classmob():def__init__(s,game,posx=0,posy=0,typ=0,dim=0):s.dimension=dims.lastmaxheight=300iftyp==0:s.collx=10iftyp==1:s.collx=20s.colly=20s.col=20s.life=20s.typ=typs.Px=posxs.Py=posys.lPx=posxs.lPy=posys.parent=games.mov=0s.onground=Falses.speedy=0s.speedx=0s.speedmax=30s.movloader=0s.theplayer=game.players.Chx=game.player.Chxs.Chy=game.player.Chydefupdate(s,game):ifs.theplayer.inInv:returnifs.Chx!=game.player.Chxors.Chy!=game.player.Chyors.dimension!=game.player.dimension:returnifs.life<=0:f(int(s.lPx),int(s.lPy),s.collx,s.colly,game.skycolor)ifs.typ==1:debug("yyy")s.parent.itemgeror.append(grounditem(int(s.Px),int(s.Py),s.Chx,s.Chy,s.dimension,{"nb":1,"typ":"Y"}))game.mobgeror.remove(s)delsreturnifs.typ==0:zombieupdate(s,game)elifs.typ==1:blazeupdate(s,game)defblazeupdate(s,g):f(int(s.lPx),int(s.lPy),s.collx,s.colly,g.skycolor)px=int(s.Px)py=int(s.Py)f(px+6,py,8,6,"yellow")f(px+6,py+6,8,2,"brown")se(px+7,py+2,"white")se(px+12,py+2,"white")se(px+8,py+2,"black")se(px+11,py+2,"black")f(px+2,py+3,2,7,"yellow")f(px+17,py,2,7,"yellow")f(px+2,py+3,2,7,"yellow")f(px+7,py+5,2,7,"yellow")f(px+13,py+4,2,7,"yellow")f(px+3,py+11,2,7,"yellow")f(px+10,py+12,2,7,"yellow")f(px+16,py+11,2,7,"yellow")defzombieupdate(s,g):ifs.Px>s.theplayer.Px:s.mov=2s.speedx=-s.speedmaxelse:s.mov=1s.speedx=s.speedmaxifdistance2(s.Px,s.Py,s.theplayer.Px,s.theplayer.Py)<1600:changelife(s.theplayer,-1)temp=physicupdate(s,game.dt,game)["wall"]foreleintemp:ifelenotingame.traversable:ifs.onground:s.speedy=0.4refresh(s,zombie=True)classgrounditem():def__init__(s,px,py,cx,cy,dim,info):s.collx=10s.colly=10s.speedy=0s.speedx=0s.Px=pxs.Py=pys.lPx=pxs.lPy=pys.Chx=cxs.Chy=cys.iteminfo=infos.lastmaxheight=0s.dimension=dims.life=9s.inte=randint(0,9)s.ain=0defupdate(se,g):ifse.Chx!=g.player.Chxorse.Chy!=g.player.Chyorse.dimension!=g.player.dimension:returnse.ain+=1ifse.ain==10:se.ain=0ifse.inte!=se.ain:returnse.parent=gf(int(se.lPx),int(se.lPy),se.collx,se.colly,g.skycolor)ifse.Py>160:g.itemgeror.remove(se)f(int(se.Px),int(se.Py),10,10,g.skycolor)delsereturnphysicupdate(se,g.dt*10,g)f(int(se.Px),int(se.Py),10,10,color(240,216,129))f(int(se.Px),int(se.Py),10,2,color(120,96,9))se.lPx=se.Pxse.lPy=se.Pyifdistance2(se.Px,se.Py,g.player.Px,g.player.Py)<1600:temp=addinventory(g.player,se.iteminfo["typ"],se.iteminfo["nb"],False)iftemp!="Nope":g.itemgeror.remove(se)f(int(se.Px),int(se.Py),10,10,g.skycolor)delsereturndefaddinventory(s,objid,nbof,cre=True):#to make
gamegeror=s.parentret=[]foreleinrange(18):ifs.inventory[ele]==objid:tempi=getstackvalue(s.parent,s.inventory[ele])addmax=tempi-s.invnumbers[ele]ret.append(ele)ifaddmax>=nbof:s.invnumbers[ele]+=nbofifele<6:refreshcase(s.parent,ele)returnretelse:s.invnumbers[ele]+=addmaxnbof-=addmaxforeleinrange(18):ifs.inventory[ele]=="*":s.inventory[ele]=objids.invnumbers[ele]=nbofret.append(ele)ifele<6:refreshcase(s.parent,ele)returnretifcre:curx=int(s.Px/20)+s.Blolistpos[s.Bloselectn][0]cury=int(s.Py/20)-s.Blolistpos[s.Bloselectn][1]s.parent.itemgeror.append(grounditem(curx*20+5,cury*20+5,s.Chx,s.Chy,s.dimension,{"nb":nbof,"typ":objid}))return"Nope"
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.