From 4d7cf2ab1e10d9926d03afb5a3f883bcf5312469 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sun, 10 Sep 2017 18:51:59 +0300 Subject: [PATCH] New implementation of module Items, *.cfg files now deprecated --- libs/Lib_items_store.class | Bin 5892 -> 4174 bytes libs/Lib_items_store.java | 122 ++-- make.sh | 16 + src/Blocks.mpsrc | 28 + src/CAVE.mpsrc | 326 +++++++++- src/Items.pas | 794 +++++++++++++++++++++++++ src/Mobs.pas | 6 +- src/{Particles.mpsrc => Particles.pas} | 0 src/Player.mpsrc | 8 +- src/cellui.mpsrc | 8 +- src/console.pas | 8 - src/craft.mpsrc | 3 +- src/drop.mpsrc | 20 +- src/func.mpsrc | 15 +- src/furnace.mpsrc | 12 +- src/inv.mpsrc | 26 +- src/invui.mpsrc | 22 +- src/items.mpsrc | 101 ---- src/items_logic.mpsrc | 17 +- src/vars.mpsrc | 5 + src/worldgen.mpsrc | 7 +- 21 files changed, 1274 insertions(+), 270 deletions(-) create mode 100644 src/Blocks.mpsrc create mode 100644 src/Items.pas rename src/{Particles.mpsrc => Particles.pas} (100%) delete mode 100644 src/items.mpsrc diff --git a/libs/Lib_items_store.class b/libs/Lib_items_store.class index c6958aa63c19e8e1249dc8850fe83108a44a9055..161cba0801033b50306a6d2980814672cce4dc0c 100644 GIT binary patch literal 4174 zcmai0OL$XN5T4uSd2^GNv}v2$2cSp`*zzc#Afoavlop|Y2vXDZwgl3oCMi!rK^OYD zP*%P-zUl-0K7!)+DZ)lv_}Hi$b)#-{r7K$8~C!l zjAS*^#cd>=7|r9wP&%7DG*}RjvJZ^IN14fNI_)kB*(??|Abl8iNO{?z0(PhzwpV64 zrIC@$B}NK8eS^HKM%8;c(~$EpKY?dqS@rK6uzeJS*Vnw}jgSE+V)G7&Ey?I&=Ep5- z*zp-ojKSZxDwRnUR%7pudAl_7tj!LiVl};~jMXIT9 zokRAM;Y1;Us2x4>lQ-fmJmGG@Pi*CA*pBcP-%M}^?artip3HJ{6kj+_L2NQ=A1}&%C3~Hq|gJ!arMY9dMiLINdO`|$?T9{5`Mi;I>nzY6Xscgni zXAF9bVRP8;7DmivtDQv$i+L>Ovsl35R_ZjUi^W1-E@H%DwwAEyX0epTGTsusP?D!c zwNpv-4;{3UIQ(gO4IId2kEo`p8PBCMg&l=N^3Xsok+i_38Pk!dfdb4CR)A@W22;@> zD;j)7gOq6S5)Epi!A>*?iUvo~peY(mMT4wp@D&ZpqQP1;h>Hey(V#CH6%dUgK(jB7 zhBUezRx7jy?VbN2Y3E^Rv;xv64>1a8CEWp=T?e77pxez$feTb6vf8|)Um%azUXi{@ z3iK|xNP+Vbq7D1`VR6tlScEI!!wujgj^c!y_<(V~b8);uT19u-n~mZV#NG>w*s1yK zK#{7=7FHg!wZBMSGv?uy&y0D`4os51(iiu+o6bSN(oH+D?xF~8Nj)w}3+~7qT#+u^ zkRYvg8J@Hmt`H_c;iiin5^0DGi;Re@5m{Txc@e@o+s`K*EY^VYT5w(m&g;Q>12}I) z3Y&11dyvp(6nG0#xr^?$`9B5zjNDkHpyIEaEg&8;TbZ|E^A8LEB1O!YkDu3=F+b~C zGZs*F3C4qNT~=X((!{o5eJ_P+JL<9nbs0cXJJD6U&^Ehq9QPsBJxJ^xP*AsEG4250 zf-oo6J%j!|b*{Ji99|OKbT_;%PW$m>5YN}T@J<^ZERt?^xlk_(RPXNBL96VAHej4yIfNv@Xuc-)s0`MmR z?P4l>g4{{OQ*!dZYb@A>s#?zgnkZv@I3n9 z1@ys-xN;|k!?;t~B1Nm0s1B%uAu}NAS)$sY4u%>8Q7p5zxD4WI`E{9A~mWmYElCxuEvWg!-fA{c;jAoI<(TP zYj#54Y7G?88Y!kVQL7fGcFn|254zP@jGgSSW+VT5>F#zveb;?8wV9~JEWi`x;Fuv5 l;Bx_Q2Yjd;JYEsr33wOa$#QVBB77;}%W!nVsB0Bj{{f&?xZ?l- literal 5892 zcmbtYTX0*|72Q|5dP{aJ z-tRzohF5{1KZThvG(RZ3hDqsk23m%h_6ug1fv@(f{o~R8w1uv{&%Fo9QIR!d#{2AZ zbnaPeKkvEu=$m)nBcc&{Axyn=dx(1I4ig2huTo@Vh(fSwJ|a|VTS zgMw-yd&E`eY^a{eF?VmSFk3VzEZb)D_WlL@Fr6=E4o#KiA*COf#~!6-iut^rl#4}7 zoCorUp-0p%=cu4_R0;4(&F2h?W=i&Kd2II-qZ;I$WTp{!abXc_F`4bTcEZ`C9^v_t zpBV@Yn22L{P;?;^7Ik4ho1Jm@%-D0-@86s&{Nv|6IgmG1OuZ5m zuLRLlq4PPej_g;!Y9nLg)UdnAv2-W$w7Xp$5_R^uXNegSFxU|VHPIEfsKX5eg&yaI zsj|XU`QR1jd&-EqhvUsya)7XB8ZzSt8CWLj06kR)=?CS&n7h|usSjcxJrO|RFDV56 zVel6{2VVz-y#zgz2dy)~)8rB9wa$c3lPS7S zr2ixZ$Ip9JS-_EQL!i4k&It2bM490`0kN7)x{S8U^MkaF zwqyNy{I%n^Rb;?~08U!V8Z*3{u5cKB3Lu6UseoS3iHQn%tzI5XE4imaJ}YkW%x}eg zCnio(_+o#;ubHj^i&~~bm=9A6yw-sP>qUO8L3#}%yO`;f_;nrmgsGoFX@@XnZ6`D) zH$rJ>?6eW=-wt}LjX^U-`zbV^*p|euLGl~&PZ>C@r)=d_H11eAg{^#KjIA79N#EXi zYTSED@Iu7*1m*3pY}$yGP1>^&tht_zIegi(9Q3gEY>0N%1M@Zny9|eHZ5nL12Agy& z3vtATwN*Z3Os!Qrv69w6fhwy)ORPd_JNXi#JsPOWg}#PX?SfUiHP~`p__KOo{)S)^ z0K2wnu&Z^ERuD-}j!jaGAt}$W=n;`okui}iB3nhSs4d$IkmRn**Mkz#4RHC5NR%m* z?M*0K8)Z9}_aX+uOTJZpnE39}>m3Al*(xtr_NndNtAqdAmz0i|7p zCG&Wx+>EzI37u~NC0rJ3WU#DYbWR@{O0q(2Jr}BbPdgO!O}^@w2~+pOHj3+h*d|wzGvM_*@Olru z@b|)H0}ktQ`W|0alDh9D(d*UqCW(%(t~W{A56vrGECGkb$>c7k8d$G0;ofyX^L^Ff z+h3s$)#>BX={xH&?f@6JgLjIV?_>S}I`|*a!T$tLeyCX|s#y1H*8RejyLG>C<(FhX zhqV#%$2jMcAA(${S8g2*%k49i+vkGISNY}ko zM`Rgpl{AVjk=-H_BCXoi(Ty)oH{HswHis zN4Jduw{4Vg!%=PH56DZtk)$frrOL2d^^SzPaanTX;tt|V_;d$J0=$;qzcK$0K9>HA z+W!XK;#(R-vGIq}7M#D@sYz~7DV_N#xg&8+rsR&q{z>89rEX9uT7+gwUG%_r1LTvN zk!mV~?u@(2VI9>en8U~5 Make libs" +makelibs + echo "===> Generate symbols" for I in $SOURCES @@ -87,3 +97,9 @@ MicroEdition-Profile: MIDP-2.0 MIDlet-Icon: $ICO Created-By: $VEN ! + +#proguard -injars libs -outjars classes \ +# `find $LIBDIR -type f -name '*.jar' -printf '-libraryjars %p '` +# -dontoptimize -dontshrink -microedition -dontobfuscate \ +# -overloadaggressively -repackageclasses '' -allowaccessmodification \ +# -keep public class FW extends javax.microedition.midlet.MIDlet diff --git a/src/Blocks.mpsrc b/src/Blocks.mpsrc new file mode 100644 index 0000000..49e86ed --- /dev/null +++ b/src/Blocks.mpsrc @@ -0,0 +1,28 @@ +unit Blocks; + +interface + + function IsTransporent(id : integer) : boolean; + function IsForeground(id : integer) : boolean; + function IsOverlapped(id : integer) : boolean; + +implementation + + uses items_store; + + function IsTransporent(id : integer) : boolean; + begin + result := (items_store.GetBlockFlags(id) and 1) <> 0; + end; + + function IsForeground(id : integer) : boolean; + begin + result := (getBlockFlags(id) and 2) <> 0; + end; + + function IsOverlapped(id : integer) : boolean; + begin + result := (getBlockFlags(id) and 4) <> 0; + end; + +end. diff --git a/src/CAVE.mpsrc b/src/CAVE.mpsrc index 0d30584..830a6ab 100644 --- a/src/CAVE.mpsrc +++ b/src/CAVE.mpsrc @@ -1,6 +1,7 @@ program CAVE; uses + Items, sign, jsr75i, drop, @@ -10,7 +11,6 @@ uses memory, worldgen, canvas, - items, safeload, mobs, console, @@ -28,7 +28,8 @@ uses chest, inv, items_store, - video; + video, + Blocks; const version_map = 9; @@ -116,7 +117,7 @@ procedure ClearTextures; float := no; compas := no; for ix := 0 to 7 do - clock[ix] := no; + Vars.clock[ix] := no; for ix := 0 to maxBlockTex do begin @@ -187,7 +188,7 @@ procedure loadtexture(path:string); compas:=ld_tex('compass.png',path,'gui/'); im:=ld_tex('clock.png',path,'gui/'); for ix:=0 to 7 do - clock[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0); + Vars.clock[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0); if load_back_tex then begin im:=ld_tex('back.png',path,''); @@ -1712,11 +1713,10 @@ function setBlock(invcur, x, y:integer):boolean; item:=inv.getItem(invcur); sum:=inv.getSum(invcur); block:=getMap(x, y); - sblock:=getItemInfo(item); + sblock := Items.GetData(item); - if getItemType(item)=ITEM_TYPE_BLOCK then - if inv.isNull(invcur)=false then - if getBlockSet(block)=true then + if (Items.GetType(item) = Items.block) and (Inv.IsNull(invcur) = false) then + if Blocks.IsOverlapped(block) then // if (coll_xy(x, y)=false) or (getBlockColl(item)=0) then begin if set_block_code(sblock, x, y)=false then @@ -1961,20 +1961,13 @@ procedure draw; for ix:=minx to maxx do for iy:=miny to maxy do begin - if ifosad then if (getBackMap(ix)>=iy) and (osadki=true) and getBlockTrans(getmap(ix,iy)) then - begin - if getBiomMap(ix)=0 then drawimage(osad[0,osadki_ani],(ix*16)-camx,(iy*16)-camy); - else - if getBiomMap(ix)=2 then drawimage(osad[1,osadki_ani],(ix*16)-camx,(iy*16)-camy); - else - if getBiomMap(ix)=3 then drawimage(osad[0,osadki_ani],(ix*16)-camx,(iy*16)-camy); - end; - if drw_back then - if getBlockTrans(getmap(ix,iy)) then - draw_back(ix,iy); - - if getBlockFore(getmap(ix,iy))=false then - draw_block(ix,iy); + if ifosad and osadki and (getBackMap(ix) >= iy) and Blocks.IsTransporent(getmap(ix, iy)) then begin + if getBiomMap(ix) = 0 then drawimage(osad[0, osadki_ani], (ix * 16) - camx, (iy * 16) - camy) + else if getBiomMap(ix) = 2 then drawimage(osad[1, osadki_ani], (ix * 16) - camx, (iy * 16) - camy) + else if getBiomMap(ix) = 3 then drawimage(osad[0, osadki_ani], (ix * 16) - camx, (iy * 16) - camy) + end; + if drw_back and Blocks.IsTransporent(getmap(ix, iy)) then draw_back(ix, iy); + if Blocks.IsForeground(getmap(ix,iy)) = false then draw_block(ix,iy); end; {===================[drop]===================} Drop.Draw(camx, camy); @@ -1988,8 +1981,7 @@ procedure draw; for ix:=minx to maxx do for iy:=miny to maxy do begin - if getBlockFore(getmap(ix, iy)) then - draw_block(ix, iy); + if Blocks.IsForeground(getmap(ix, iy)) then draw_block(ix, iy); setcolor(0, 0, 0); if light_type = 1 then @@ -2036,7 +2028,7 @@ procedure draw; drawimage(gui[1],tmp_ax,0); for ix:=0 to 8 do begin - drawItem(inv.getItem(ix), inv.getSum(ix), (ix*16)+tmp_ax+ix*2+4, 1, true); + Items.Draw(inv.getItem(ix), inv.getSum(ix), (ix*16)+tmp_ax+ix*2+4, 1, true); end; drawimage(gui[17],(invslot*16)+tmp_ax+invslot*2+2,0); @@ -2177,14 +2169,14 @@ procedure usetools(invcur, x, y:integer); else if (block>0) then begin - if (getItemType(item)=ITEM_TYPE_TOOL) and (getBlockTool(block)=getToolType(item)) then + if (Items.GetType(item) = Items.tool) and (getBlockTool(block)=getToolType(item)) then toolus:=toolus+getToolSpeed(item); else toolus:=toolus+1; if toolus>=getBlockHP(block) then begin - if ((getItemType(item)=ITEM_TYPE_TOOL) and (getBlockTool(block)=getToolType(item)) and (getToolLvl(item)>=getBlockLvl(block))) or (getBlockLvl(block)<=0) then + if ((Items.GetType(item) = Items.tool) and (getBlockTool(block)=getToolType(item)) and (getToolLvl(item)>=getBlockLvl(block))) or (getBlockLvl(block)<=0) then begin setMap(0, x, y); destroy_block_1(block, x, y); @@ -2197,7 +2189,7 @@ procedure usetools(invcur, x, y:integer); setMapInfo(0, x, y); end; - if getItemType(item)=ITEM_TYPE_TOOL then + if Items.GetType(item) = Items.tool then begin inv.setSum(inv.getSum(invcur)-1, invcur); inv.fixNull(invcur); @@ -2223,7 +2215,7 @@ function rt_useweap:boolean; h:=player.getH; item:=inv.getItem(invslot); - if getItemType(item)=1 then + if Items.GetType(item) = Items.tool then damg:=getToolDamg(item); else damg:=1; @@ -3008,12 +3000,288 @@ procedure draw_debug; drawImage(light[i], getWidth - 16, 16 * i); end; + function ItemToString(id : integer) : string; + var + name : string; + begin + if id = Items.none then name := 'none' + else if id = Items.dirt then name := 'dirt' + else if id = Items.grass then name := 'grass' + else if id = Items.stone then name := 'stone' + else if id = Items.oakWoodPlanks then name := 'oakWoodPlanks' + else if id = Items.cobblestone then name := 'cobblestone' + else if id = Items.bedrock then name := 'bedrock' + else if id = Items.sand then name := 'sand' + else if id = Items.gravel then name := 'gravel' + else if id = Items.oakWood then name := 'oakWood' + else if id = Items.obsidian then name := 'obsidian' + else if id = Items.bookshelf then name := 'bookshelf' + else if id = Items.mossStone then name := 'mossStone' + else if id = Items.blockOfIron then name := 'blockOfIron' + else if id = Items.blockOfGold then name := 'blockOfGold' + else if id = Items.blockOfDiamond then name := 'blockOfDiamond' + else if id = Items.goldOre then name := 'goldOre' + else if id = Items.ironOre then name := 'ironOre' + else if id = Items.coalOre then name := 'coalOre' + else if id = Items.diamondOre then name := 'diamondOre' + else if id = Items.redstoneOre then name := 'redstoneOre' + else if id = Items.oakLeaves then name := 'oakLeaves' + else if id = Items.redFlower then name := 'redFlower' + else if id = Items.yellowFlower then name := 'yellowFlower' + else if id = Items.redMooshroom then name := 'redMooshroom' + else if id = Items.brownMooshroom then name := 'brownMooshroom' + else if id = Items.torch then name := 'torch' + else if id = Items.tnt then name := 'tnt' + else if id = Items.chest then name := 'chest' + else if id = Items.craftingTable then name := 'craftingTable' + else if id = Items.cactus then name := 'cactus' + else if id = Items.glass then name := 'glass' + else if id = Items.wool1 then name := 'wool1' + else if id = Items.wool2 then name := 'wool2' + else if id = Items.wool3 then name := 'wool3' + else if id = Items.wool4 then name := 'wool4' + else if id = Items.wool5 then name := 'wool5' + else if id = Items.wool6 then name := 'wool6' + else if id = Items.wool7 then name := 'wool7' + else if id = Items.wool8 then name := 'wool8' + else if id = Items.wool9 then name := 'wool9' + else if id = Items.wool10 then name := 'wool10' + else if id = Items.wool11 then name := 'wool11' + else if id = Items.wool12 then name := 'wool12' + else if id = Items.wool13 then name := 'wool13' + else if id = Items.wool14 then name := 'wool14' + else if id = Items.wool15 then name := 'wool15' + else if id = Items.wool16 then name := 'wool16' + else if id = Items.snow then name := 'snow' + else if id = Items.ladder then name := 'ladder' + else if id = Items.water then name := 'water' + else if id = Items.lava then name := 'lava' + else if id = Items.oakSapling then name := 'oakSapling' + else if id = Items.sponge then name := 'sponge' + else if id = Items.lapisLazuliOre then name := 'lapisLazuliOre' + else if id = Items.lapisLazuliBlock then name := 'lapisLazuliBlock' + else if id = Items.sandstone then name := 'sandstone' + else if id = Items.tallGrass then name := 'tallGrass' + else if id = Items.deadBush then name := 'deadBush' + else if id = Items.cobweb then name := 'cobweb' + else if id = Items.bricks then name := 'bricks' + else if id = Items.snowBlock then name := 'snowBlock' + else if id = Items.ice then name := 'ice' + else if id = Items.snowLayer then name := 'snowLayer' + else if id = Items.clayBlock then name := 'clayBlock' + else if id = Items.sugarCane then name := 'sugarCane' + else if id = Items.pumpkin then name := 'pumpkin' + else if id = Items.jackLantern then name := 'jackLantern' + else if id = Items.stoneBricks then name := 'stoneBricks' + else if id = Items.mossyStoneBricks then name := 'mossyStoneBricks' + else if id = Items.crackedStoneBricks then name := 'crackedStoneBricks' + else if id = Items.chiseledStokeBricks then name := 'chiseledStokeBricks' + else if id = Items.ironBras then name := 'ironBras' + else if id = Items.melonBlock then name := 'melonBlock' + else if id = Items.mycelium then name := 'mycelium' + else if id = Items.backgroundOakWood then name := 'backgroundOakWood' + else if id = Items.spawner then name := 'spawner' + else if id = Items.bed1 then name := 'bed1' + else if id = Items.bed2 then name := 'bed2' + else if id = Items.openWoodenDoor1 then name := 'openWoodenDoor1' + else if id = Items.openWoodenDoor2 then name := 'openWoodenDoor2' + else if id = Items.closedWoodenDoor1 then name := 'closedWoodenDoor1' + else if id = Items.closedWoodenDoor2 then name := 'closedWoodenDoor2' + else if id = Items.birchWood then name := 'birchWood' + else if id = Items.backgroundBirchWood then name := 'backgroundBirchWood' + else if id = Items.spruceWood then name := 'spruceWood' + else if id = Items.backgroundSpruceWood then name := 'backgroundSpruceWood' + else if id = Items.spruceLeaves then name := 'spruceLeaves' + else if id = Items.redMushroomBlock1 then name := 'redMushroomBlock1' + else if id = Items.redMushroomBlock2 then name := 'redMushroomBlock2' + else if id = Items.brownMushroomBlock1 then name := 'brownMushroomBlock1' + else if id = Items.brownMushroomBlock2 then name := 'brownMushroomBlock2' + else if id = Items.oakFence then name := 'oakFence' + else if id = Items.backgroundOakFence then name := 'backgroundOakFence' + else if id = Items.backgroundOakWoodPlanks then name := 'backgroundOakWoodPlanks' + else if id = Items.painting1 then name := 'painting1' + else if id = Items.painting2 then name := 'painting2' + else if id = Items.painting3 then name := 'painting3' + else if id = Items.painting4 then name := 'painting4' + else if id = Items.painting5 then name := 'painting5' + else if id = Items.painting6 then name := 'painting6' + else if id = Items.painting7 then name := 'painting7' + else if id = Items.reservedBlockItem1 then name := 'reservedBlockItem1' + else if id = Items.vines then name := 'vines' + else if id = Items.sign then name := 'sign' + else if id = Items.redstoneTorch then name := 'redstoneTorch' + else if id = Items.furnace then name := 'furnace' + else if id = Items.closedWoodenTrapdoor then name := 'closedWoodenTrapdoor' + else if id = Items.openWoodenTrapdoor then name := 'openWoodenTrapdoor' + else if id = Items.netherrack then name := 'netherrack' + else if id = Items.netherPortal then name := 'netherPortal' + else if id = Items.glowstone then name := 'glowstone' + else if id = Items.birchLeaves then name := 'birchLeaves' + else if id = Items.soulSand then name := 'soulSand' + else if id = Items.birchSapling then name := 'birchSapling' + else if id = Items.spruceSapling then name := 'spruceSapling' + else if id = Items.redstoneLampOff then name := 'redstoneLampOff' + else if id = Items.redstoneLampOn then name := 'redstoneLampOn' + else if id = Items.backgroundObsidian then name := 'backgroundObsidian' + else if id = Items.glassPlane then name := 'glassPlane' + else if id = Items.farmland then name := 'farmland' + else if id = Items.cake then name := 'cake' + else if id = Items.reservedBlockItem2 then name := 'reservedBlockItem2' + else if id = Items.reservedBlockItem3 then name := 'reservedBlockItem3' + else if id = Items.reservedBlockItem4 then name := 'reservedBlockItem4' + else if id = Items.reservedBlockItem5 then name := 'reservedBlockItem5' + else if id = Items.reservedBlockItem6 then name := 'reservedBlockItem6' + else if id = Items.stick then name := 'stick' + else if id = Items.dandelionYellow then name := 'dandelionYellow' + else if id = Items.roseRed then name := 'roseRed' + else if id = Items.superSpecialUnneededTool then name := 'superSpecialUnneededTool' + else if id = Items.pickaxe1 then name := 'pickaxe1' + else if id = Items.pickaxe2 then name := 'pickaxe2' + else if id = Items.pickaxe3 then name := 'pickaxe3' + else if id = Items.pickaxe4 then name := 'pickaxe4' + else if id = Items.pickaxe5 then name := 'pickaxe5' + else if id = Items.shovel1 then name := 'shovel1' + else if id = Items.shovel2 then name := 'shovel2' + else if id = Items.shovel3 then name := 'shovel3' + else if id = Items.shovel4 then name := 'shovel4' + else if id = Items.shovel5 then name := 'shovel5' + else if id = Items.axe1 then name := 'axe1' + else if id = Items.axe2 then name := 'axe2' + else if id = Items.axe3 then name := 'axe3' + else if id = Items.axe4 then name := 'axe4' + else if id = Items.axe5 then name := 'axe5' + else if id = Items.shears then name := 'shears' + else if id = Items.sword1 then name := 'sword1' + else if id = Items.sword2 then name := 'sword2' + else if id = Items.sword3 then name := 'sword3' + else if id = Items.sword4 then name := 'sword4' + else if id = Items.sword5 then name := 'sword5' + else if id = Items.fishingRod then name := 'fishingRod' + else if id = Items.lighter then name := 'lighter' + else if id = Items.hoe1 then name := 'hoe1' + else if id = Items.hoe2 then name := 'hoe2' + else if id = Items.hoe3 then name := 'hoe3' + else if id = Items.hoe4 then name := 'hoe4' + else if id = Items.hoe5 then name := 'hoe5' + else if id = Items.reservedToolItem then name := 'reservedToolItem' + else if id = Items.coal then name := 'coal' + else if id = Items.redstone then name := 'redstone' + else if id = Items.diamond then name := 'diamond' + else if id = Items.brick then name := 'brick' + else if id = Items.ironIngot then name := 'ironIngot' + else if id = Items.goldIngot then name := 'goldIngot' + else if id = Items.lapisLazuli then name := 'lapisLazuli' + else if id = Items.strand then name := 'strand' + else if id = Items.snowball then name := 'snowball' + else if id = Items.clay then name := 'clay' + else if id = Items.book then name := 'book' + else if id = Items.bucket then name := 'bucket' + else if id = Items.waterBucket then name := 'waterBucket' + else if id = Items.lavaBucket then name := 'lavaBucket' + else if id = Items.milkBucket then name := 'milkBucket' + else if id = Items.paper then name := 'paper' + else if id = Items.melon then name := 'melon' + else if id = Items.egg then name := 'egg' + else if id = Items.door then name := 'door' + else if id = Items.bed then name := 'bed' + else if id = Items.spawnEggZombie then name := 'spawnEggZombie' + else if id = Items.spawnEggSheep then name := 'spawnEggSheep' + else if id = Items.spawnEggPig then name := 'spawnEggPig' + else if id = Items.gunpowder then name := 'gunpowder' + else if id = Items.bowl then name := 'bowl' + else if id = Items.mushroomStew then name := 'mushroomStew' + else if id = Items.map then name := 'map' + else if id = Items.painting then name := 'painting' + else if id = Items.rawPorkchop then name := 'rawPorkchop' + else if id = Items.cookedPorkchop then name := 'cookedPorkchop' + else if id = Items.rottenFlesh then name := 'rottenFlesh' + else if id = Items.camera1 then name := 'camera1' + else if id = Items.camera2 then name := 'camera2' + else if id = Items.camera3 then name := 'camera3' + else if id = Items.goldNugget then name := 'goldNugget' + else if id = Items.sugar then name := 'sugar' + else if id = Items.spiderEye then name := 'spiderEye' + else if id = Items.feather then name := 'feather' + else if id = Items.leather then name := 'leather' + else if id = Items.rawBeef then name := 'rawBeef' + else if id = Items.steak then name := 'steak' + else if id = Items.apple then name := 'apple' + else if id = Items.goldenApple then name := 'goldenApple' + else if id = Items.rawChicken then name := 'rawChicken' + else if id = Items.cookedChicken then name := 'cookedChicken' + else if id = Items.spawnEggChicken then name := 'spawnEggChicken' + else if id = Items.spawnEggCreeper then name := 'spawnEggCreeper' + else if id = Items.flint then name := 'flint' + else if id = Items.spawnEggCow then name := 'spawnEggCow' + else if id = Items.spawnEggMooshroom then name := 'spawnEggMooshroom' + else if id = Items.rawFish then name := 'rawFish' + else if id = Items.cookedFish then name := 'cookedFish' + else if id = Items.spawnEggPigman then name := 'spawnEggPigman' + else if id = Items.spawnEggSpider then name := 'spawnEggSpider' + else if id = Items.glowstoneDust then name := 'glowstoneDust' + else if id = Items.clock then name := 'clock' + else if id = Items.compass then name := 'compass' + else if id = Items.seeds then name := 'seeds' + else if id = Items.wheat then name := 'wheat' + else if id = Items.bread then name := 'bread' + else if id = Items.boneMeal then name := 'boneMeal' + else if id = Items.melonSeeds then name := 'melonSeeds' + else if id = Items.pumpkinSeeds then name := 'pumpkinSeeds' + else name := '' + id; + result := name; + end; + + procedure PrintItem(id, typ, tex, max, info, texsource, indicator : integer; dividable : boolean); + var + name, tname, indname : string; + begin + name := ItemToString(id); + + if typ = Items.block then tname := 'block' + else if typ = Items.tool then tname := 'tool' + else if typ = Items.reserved then tname := 'reserved' + else if typ = Items.orditem then tname := 'orditem' + else tname := '' + typ; + + if indicator = Items.noindicator then indname := 'noindicator' + else if indicator = Items.numeric then indname := 'numeric' + else if indicator = Items.line then indname := 'line' + else indname := '' + indicator; + + Debug(' InitItem(' + name + ', ' + tname + ', ' + tex + ', ' + max + ', ' + info + ', ' + texsource + ', ' + indname + ', ' + dividable + ');'); + end; + + procedure PrintItemTable; + var + id : integer; + begin + for id := 0 to 222 do begin + PrintItem( + id, + Items.GetType(id), + Items.GetTexture(id), + Items.GetMaximum(id), + Items.GetData(id), + Items.GetTextureSource(id), + Items.GetIndicatorType(id), + Items.IsDividable(id) + ); + end; + + for id := 0 to 194 do begin + Debug(' InitOrdItem(' + ItemToString(Items.GetOrdinary(id)) + ');'); + end; + end; + begin qt_start; hung_time:=getrelativetimems; hp_time:=getrelativetimems; air_time:=getrelativetimems; portal_time:=getrelativetimems; + + PrintItemTable; + repeat proc_fps; keyhandler; diff --git a/src/Items.pas b/src/Items.pas new file mode 100644 index 0000000..9ebb84e --- /dev/null +++ b/src/Items.pas @@ -0,0 +1,794 @@ +unit Items; + +interface + + (* https://minecraft.gamepedia.com/Item *) + (* https://minecraft.gamepedia.com/index.php?title=Block&oldid=470025 *) + + const (* Item id *) + none = 0; + dirt = 1; + grass = 2; + stone = 3; + oakWoodPlanks = 4; + cobblestone = 5; + bedrock = 6; + sand = 7; + gravel = 8; + oakWood = 9; + obsidian = 10; + bookshelf = 11; + mossStone = 12; + blockOfIron = 13; + blockOfGold = 14; + blockOfDiamond = 15; + goldOre = 16; + ironOre = 17; + coalOre = 18; + diamondOre = 19; + redstoneOre = 20; + oakLeaves = 21; + redFlower = 22; + yellowFlower = 23; + redMooshroom = 24; + brownMooshroom = 25; + torch = 26; + tnt = 27; + chest = 28; + craftingTable = 29; + cactus = 30; + glass = 31; + wool1 = 32; + wool2 = 33; + wool3 = 34; + wool4 = 35; + wool5 = 36; + wool6 = 37; + wool7 = 38; + wool8 = 39; + wool9 = 40; + wool10 = 41; + wool11 = 42; + wool12 = 43; + wool13 = 44; + wool14 = 45; + wool15 = 46; + wool16 = 47; + snow = 48; + ladder = 49; + water = 50; + lava = 51; + oakSapling = 52; + sponge = 53; + lapisLazuliOre = 54; + lapisLazuliBlock = 55; + sandstone = 56; + tallGrass = 57; + deadBush = 58; + cobweb = 59; + bricks = 60; + snowBlock = 61; + ice = 62; + snowLayer = 63; + clayBlock = 64; + sugarCane = 65; + pumpkin = 66; + jackLantern = 67; + stoneBricks = 68; + mossyStoneBricks = 69; + crackedStoneBricks = 70; + chiseledStokeBricks = 71; + ironBras = 72; + melonBlock = 73; + mycelium = 74; + backgroundOakWood = 75; + spawner = 76; + bed1 = 77; + bed2 = 78; + openWoodenDoor1 = 79; + openWoodenDoor2 = 80; + closedWoodenDoor1 = 81; + closedWoodenDoor2 = 82; + birchWood = 83; + backgroundBirchWood = 84; + spruceWood = 85; + backgroundSpruceWood = 86; + spruceLeaves = 87; + redMushroomBlock1 = 88; + redMushroomBlock2 = 89; + brownMushroomBlock1 = 90; + brownMushroomBlock2 = 91; + oakFence = 92; + backgroundOakFence = 93; + backgroundOakWoodPlanks = 94; + painting1 = 95; + painting2 = 96; + painting3 = 97; + painting4 = 98; + painting5 = 99; + painting6 = 100; + painting7 = 101; + reservedBlockItem1 = 102; + vines = 103; + sign = 104; + redstoneTorch = 105; + furnace = 106; + closedWoodenTrapdoor = 107; + openWoodenTrapdoor = 108; + netherrack = 109; + netherPortal = 110; + glowstone = 111; + birchLeaves = 112; + soulSand = 113; + birchSapling = 114; + spruceSapling = 115; + redstoneLampOff = 116; + redstoneLampOn = 117; + backgroundObsidian = 118; + glassPlane = 119; + farmland = 120; + cake = 121; + reservedBlockItem2 = 122; + reservedBlockItem3 = 123; + reservedBlockItem4 = 124; + reservedBlockItem5 = 125; + reservedBlockItem6 = 126; + stick = 127; + dandelionYellow = 128; + roseRed = 129; + superSpecialUnneededTool = 130; + pickaxe1 = 131; + pickaxe2 = 132; + pickaxe3 = 133; + pickaxe4 = 134; + pickaxe5 = 135; + shovel1 = 136; + shovel2 = 137; + shovel3 = 138; + shovel4 = 139; + shovel5 = 140; + axe1 = 141; + axe2 = 142; + axe3 = 143; + axe4 = 144; + axe5 = 145; + shears = 146; + sword1 = 147; + sword2 = 148; + sword3 = 149; + sword4 = 150; + sword5 = 151; + fishingRod = 152; + lighter = 153; + hoe1 = 154; + hoe2 = 155; + hoe3 = 156; + hoe4 = 157; + hoe5 = 158; + reservedToolItem = 159; + coal = 160; + redstone = 161; + diamond = 162; + brick = 163; + ironIngot = 164; + goldIngot = 165; + lapisLazuli = 166; + strand = 167; + snowball = 168; + clay = 169; + book = 170; + bucket = 171; + waterBucket = 172; + lavaBucket = 173; + milkBucket = 174; + paper = 175; + melon = 176; + egg = 177; + door = 178; + bed = 179; + spawnEggZombie = 180; + spawnEggSheep = 181; + spawnEggPig = 182; + gunpowder = 183; + bowl = 184; + mushroomStew = 185; + map = 186; + painting = 187; + rawPorkchop = 188; + cookedPorkchop = 189; + rottenFlesh = 190; + camera1 = 191; + camera2 = 192; + camera3 = 193; + goldNugget = 194; + sugar = 195; + spiderEye = 196; + feather = 197; + leather = 198; + rawBeef = 199; + steak = 200; + apple = 201; + goldenApple = 202; + rawChicken = 203; + cookedChicken = 204; + spawnEggChicken = 205; + spawnEggCreeper = 206; + flint = 207; + spawnEggCow = 208; + spawnEggMooshroom = 209; + rawFish = 210; + cookedFish = 211; + spawnEggPigman = 212; + spawnEggSpider = 213; + glowstoneDust = 214; + clock = 215; + compass = 216; + seeds = 217; + wheat = 218; + bread = 219; + boneMeal = 220; + melonSeeds = 221; + pumpkinSeeds = 222; + + const (* Item class *) + block = 0; + tool = 1; + reserved = 2; + orditem = 3; + + const (* Indicator class *) + noindicator = 0; + numeric = 1; + line = 2; + + function GetType(id : integer) : integer; + function GetMaximum(id : integer) : integer; + function GetData(id : integer) : integer; + function GetTexture(id : integer) : integer; + function GetTextureSource(id : integer) : integer; + function GetIndicatorType(id : integer) : integer; + function IsDividable(id : integer) : boolean; + + function GetOrdinary(i : integer) : integer; + + procedure DrawSmall(id, x, y : integer); + procedure Draw(id, sum, x, y : integer; drawIndicator : boolean); + +implementation + + uses Vars, Func; + + const + lastItem = 222; + lastOrdItem = 194; + + var + itype, itex, imax, idata, iflags : array [0..lastItem] of integer; + countOrdItems : integer; + ordItems : array [0..lastOrdItem] of integer; + + (* Bits + xxxx xxxx | xxxx xxxx | xxxx xxxx | xxxx xxxx + ^^^^ + |||+-- texture source + |++--- indicator + +----- dividable + *) + + function GetType(id : integer) : integer; + begin + result := itype[id]; + end; + + function GetMaximum(id : integer) : integer; + begin + result := imax[id]; + end; + + function GetData(id : integer) : integer; + begin + result := idata[id]; + end; + + function GetTexture(id : integer) : integer; + begin + result := itex[id]; + end; + + function GetTextureSource(id : integer) : integer; + begin + result := iflags[id] and 1; + end; + + function GetIndicatorType(id : integer) : integer; + begin + result := (iflags[id] >> 1) and 3; + end; + + function IsDividable(id : integer) : boolean; + begin + result := ((iflags[id] >> 3) and 1) <> 0; + end; + + procedure InitItem(id, typ, tex, max, data, texsource, indicator : integer; dividable : boolean); + begin + Assert((id >= 0) and (id <= lastItem)); + Assert((typ >= 0) and (typ <= 3)); + Assert((tex >= 0) and (tex <= 255)); + Assert((max >= 0) and (max <= 65535)); + Assert((texsource >= 0) and (texsource <= 1)); + Assert((indicator >= 0) and (indicator <= 2)); + itype[id] := typ; + itex[id] := tex; + imax[id] := max; + idata[id] := data; + if dividable then iflags[id] := (1 << 3); + iflags[id] := iflags[id] or (indicator << 1); + iflags[id] := iflags[id] or (texsource << 0); + end; + + function GetOrdinary(i : integer) : integer; + begin + GetOrdinary := none; + if (i >= 0) and (i <= lastOrdItem) then GetOrdinary := ordItems[i] + end; + + procedure InitOrdItem(id : integer); + begin + Assert(countOrdItems <= lastOrdItem); + ordItems[countOrdItems] := id; + countOrdItems := countOrdItems + 1; + end; + + procedure DrawSmall(id, x, y : integer); + begin + if GetTextureSource(id) = 0 then DrawImage(Vars.tex8[itex[id]], x, y) + else if GetTextureSource(id) = 1 then DrawImage(Vars.item8[itex[id]], x, y) + end; + + procedure Draw(id, sum, x, y : integer; drawIndicator : boolean); + const + maxLength = 15; + maxHeight = 14; + redLength = 3; + var + class, len : integer; + begin + if sum <= 0 then exit; + + if GetTextureSource(id) = 0 then DrawImage(Vars.tex[itex[id]], x, y) + else if GetTextureSource(id) = 1 then DrawImage(Vars.item[itex[id]], x, y) + + if drawIndicator and (sum > 1) then begin + class := GetIndicatorType(id); + if class = numeric then begin + Func.DrawFontText('' + sum, x, y + 8) + end else if class = line then begin + len := sum * maxLength / imax[id]; + if len <= redLength then SetColor(255, 0, 0) else SetColor(0, 255, 0); + DrawLine(x, y + maxHeight, x + len, y + maxHeight); + end; + end; + end; + +initialization + InitItem(none, block, 0, 0, 0, 0, noindicator, false); + InitItem(dirt, block, 1, 64, 1, 0, numeric, true); + InitItem(grass, block, 2, 64, 2, 0, numeric, true); + InitItem(stone, block, 3, 64, 3, 0, numeric, true); + InitItem(oakWoodPlanks, block, 4, 64, 4, 0, numeric, true); + InitItem(cobblestone, block, 5, 64, 5, 0, numeric, true); + InitItem(bedrock, block, 6, 64, 6, 0, numeric, true); + InitItem(sand, block, 7, 64, 7, 0, numeric, true); + InitItem(gravel, block, 8, 64, 8, 0, numeric, true); + InitItem(oakWood, block, 9, 64, 9, 0, numeric, true); + InitItem(obsidian, block, 10, 64, 10, 0, numeric, true); + InitItem(bookshelf, block, 11, 64, 11, 0, numeric, true); + InitItem(mossStone, block, 12, 64, 12, 0, numeric, true); + InitItem(blockOfIron, block, 13, 64, 13, 0, numeric, true); + InitItem(blockOfGold, block, 14, 64, 14, 0, numeric, true); + InitItem(blockOfDiamond, block, 15, 64, 15, 0, numeric, true); + InitItem(goldOre, block, 16, 64, 16, 0, numeric, true); + InitItem(ironOre, block, 17, 64, 17, 0, numeric, true); + InitItem(coalOre, block, 18, 64, 18, 0, numeric, true); + InitItem(diamondOre, block, 19, 64, 19, 0, numeric, true); + InitItem(redstoneOre, block, 20, 64, 20, 0, numeric, true); + InitItem(oakLeaves, block, 21, 64, 21, 0, numeric, true); + InitItem(redFlower, block, 22, 64, 22, 0, numeric, true); + InitItem(yellowFlower, block, 23, 64, 23, 0, numeric, true); + InitItem(redMooshroom, block, 24, 64, 24, 0, numeric, true); + InitItem(brownMooshroom, block, 25, 64, 25, 0, numeric, true); + InitItem(torch, block, 26, 64, 26, 0, numeric, true); + InitItem(tnt, block, 27, 64, 27, 0, numeric, true); + InitItem(chest, block, 28, 64, 28, 0, numeric, true); + InitItem(craftingTable, block, 29, 64, 29, 0, numeric, true); + InitItem(cactus, block, 30, 64, 30, 0, numeric, true); + InitItem(glass, block, 31, 64, 31, 0, numeric, true); + InitItem(wool1, block, 32, 64, 32, 0, numeric, true); + InitItem(wool2, block, 33, 64, 33, 0, numeric, true); + InitItem(wool3, block, 34, 64, 34, 0, numeric, true); + InitItem(wool4, block, 35, 64, 35, 0, numeric, true); + InitItem(wool5, block, 36, 64, 36, 0, numeric, true); + InitItem(wool6, block, 37, 64, 37, 0, numeric, true); + InitItem(wool7, block, 38, 64, 38, 0, numeric, true); + InitItem(wool8, block, 39, 64, 39, 0, numeric, true); + InitItem(wool9, block, 40, 64, 40, 0, numeric, true); + InitItem(wool10, block, 41, 64, 41, 0, numeric, true); + InitItem(wool11, block, 42, 64, 42, 0, numeric, true); + InitItem(wool12, block, 43, 64, 43, 0, numeric, true); + InitItem(wool13, block, 44, 64, 44, 0, numeric, true); + InitItem(wool14, block, 45, 64, 45, 0, numeric, true); + InitItem(wool15, block, 46, 64, 46, 0, numeric, true); + InitItem(wool16, block, 47, 64, 47, 0, numeric, true); + InitItem(snow, block, 48, 64, 48, 0, numeric, true); + InitItem(ladder, block, 49, 64, 49, 0, numeric, true); + InitItem(water, block, 50, 64, 50, 0, numeric, true); + InitItem(lava, block, 51, 64, 51, 0, numeric, true); + InitItem(oakSapling, block, 60, 64, 52, 0, numeric, true); + InitItem(sponge, block, 61, 64, 53, 0, numeric, true); + InitItem(lapisLazuliOre, block, 62, 64, 54, 0, numeric, true); + InitItem(lapisLazuliBlock, block, 63, 64, 55, 0, numeric, true); + InitItem(sandstone, block, 64, 64, 56, 0, numeric, true); + InitItem(tallGrass, block, 65, 64, 57, 0, numeric, true); + InitItem(deadBush, block, 66, 64, 58, 0, numeric, true); + InitItem(cobweb, block, 67, 64, 59, 0, numeric, true); + InitItem(bricks, block, 68, 64, 60, 0, numeric, true); + InitItem(snowBlock, block, 69, 64, 61, 0, numeric, true); + InitItem(ice, block, 70, 64, 62, 0, numeric, true); + InitItem(snowLayer, block, 71, 64, 63, 0, numeric, true); + InitItem(clayBlock, block, 72, 64, 64, 0, numeric, true); + InitItem(sugarCane, block, 116, 64, 65, 1, numeric, true); + InitItem(pumpkin, block, 74, 64, 66, 0, numeric, true); + InitItem(jackLantern, block, 75, 64, 67, 0, numeric, true); + InitItem(stoneBricks, block, 76, 64, 68, 0, numeric, true); + InitItem(mossyStoneBricks, block, 77, 64, 69, 0, numeric, true); + InitItem(crackedStoneBricks, block, 78, 64, 70, 0, numeric, true); + InitItem(chiseledStokeBricks, block, 79, 64, 71, 0, numeric, true); + InitItem(ironBras, block, 80, 64, 72, 0, numeric, true); + InitItem(melonBlock, block, 81, 64, 73, 0, numeric, true); + InitItem(mycelium, block, 82, 64, 74, 0, numeric, true); + InitItem(backgroundOakWood, block, 98, 64, 75, 0, numeric, true); + InitItem(spawner, block, 83, 64, 76, 0, numeric, true); + InitItem(bed1, block, 84, 64, 77, 0, numeric, true); + InitItem(bed2, block, 85, 64, 78, 0, numeric, true); + InitItem(openWoodenDoor1, block, 86, 64, 79, 0, numeric, true); + InitItem(openWoodenDoor2, block, 102, 64, 80, 0, numeric, true); + InitItem(closedWoodenDoor1, block, 88, 64, 81, 0, numeric, true); + InitItem(closedWoodenDoor2, block, 104, 64, 82, 0, numeric, true); + InitItem(birchWood, block, 90, 64, 83, 0, numeric, true); + InitItem(backgroundBirchWood, block, 99, 64, 84, 0, numeric, true); + InitItem(spruceWood, block, 91, 64, 85, 0, numeric, true); + InitItem(backgroundSpruceWood, block, 100, 64, 86, 0, numeric, true); + InitItem(spruceLeaves, block, 92, 64, 87, 0, numeric, true); + InitItem(redMushroomBlock1, block, 93, 64, 88, 0, numeric, true); + InitItem(redMushroomBlock2, block, 95, 64, 89, 0, numeric, true); + InitItem(brownMushroomBlock1, block, 94, 64, 90, 0, numeric, true); + InitItem(brownMushroomBlock2, block, 95, 64, 91, 0, numeric, true); + InitItem(oakFence, block, 96, 64, 92, 0, numeric, true); + InitItem(backgroundOakFence, block, 101, 64, 93, 0, numeric, true); + InitItem(backgroundOakWoodPlanks, block, 97, 64, 94, 0, numeric, true); + InitItem(painting1, block, 106, 1, 95, 0, numeric, true); + InitItem(painting2, block, 107, 1, 96, 0, numeric, true); + InitItem(painting3, block, 108, 1, 97, 0, numeric, true); + InitItem(painting4, block, 109, 1, 98, 0, numeric, true); + InitItem(painting5, block, 110, 1, 99, 0, numeric, true); + InitItem(painting6, block, 111, 1, 100, 0, numeric, true); + InitItem(painting7, block, 112, 1, 101, 0, numeric, true); + InitItem(reservedBlockItem1, block, 0, 0, 0, 0, noindicator, false); + InitItem(vines, block, 114, 64, 103, 0, numeric, true); + InitItem(sign, block, 98, 16, 104, 1, numeric, true); + InitItem(redstoneTorch, block, 116, 64, 105, 0, numeric, true); + InitItem(furnace, block, 117, 64, 106, 0, numeric, true); + InitItem(closedWoodenTrapdoor, block, 118, 64, 107, 0, numeric, true); + InitItem(openWoodenTrapdoor, block, 119, 64, 108, 0, numeric, true); + InitItem(netherrack, block, 120, 64, 109, 0, numeric, true); + InitItem(netherPortal, block, 129, 64, 110, 0, numeric, true); + InitItem(glowstone, block, 121, 64, 111, 0, numeric, true); + InitItem(birchLeaves, block, 135, 64, 112, 0, numeric, true); + InitItem(soulSand, block, 122, 64, 113, 0, numeric, true); + InitItem(birchSapling, block, 123, 64, 114, 0, numeric, true); + InitItem(spruceSapling, block, 124, 64, 115, 0, numeric, true); + InitItem(redstoneLampOff, block, 125, 64, 116, 0, numeric, true); + InitItem(redstoneLampOn, block, 126, 64, 117, 0, numeric, true); + InitItem(backgroundObsidian, block, 127, 64, 118, 0, numeric, true); + InitItem(glassPlane, block, 128, 64, 119, 0, numeric, true); + InitItem(farmland, block, 136, 64, 120, 0, numeric, true); + InitItem(cake, block, 137, 64, 121, 0, numeric, true); + InitItem(reservedBlockItem2, block, 0, 0, 0, 0, noindicator, false); + InitItem(reservedBlockItem3, block, 0, 0, 0, 0, noindicator, false); + InitItem(reservedBlockItem4, block, 0, 0, 0, 0, noindicator, false); + InitItem(reservedBlockItem5, block, 0, 0, 0, 0, noindicator, false); + InitItem(reservedBlockItem6, block, 0, 0, 0, 0, noindicator, false); + InitItem(stick, orditem, 0, 64, 0, 1, numeric, true); + InitItem(dandelionYellow, orditem, 8, 64, 0, 1, numeric, true); + InitItem(roseRed, orditem, 9, 64, 0, 1, numeric, true); + InitItem(superSpecialUnneededTool, tool, 0, 0, 0, 1, line, false); + InitItem(pickaxe1, tool, 48, 60, 1, 1, line, false); + InitItem(pickaxe2, tool, 49, 132, 2, 1, line, false); + InitItem(pickaxe3, tool, 50, 251, 3, 1, line, false); + InitItem(pickaxe4, tool, 51, 1562, 4, 1, line, false); + InitItem(pickaxe5, tool, 52, 33, 5, 1, line, false); + InitItem(shovel1, tool, 32, 60, 6, 1, line, false); + InitItem(shovel2, tool, 33, 132, 7, 1, line, false); + InitItem(shovel3, tool, 34, 251, 8, 1, line, false); + InitItem(shovel4, tool, 35, 1562, 9, 1, line, false); + InitItem(shovel5, tool, 36, 33, 10, 1, line, false); + InitItem(axe1, tool, 64, 60, 11, 1, line, false); + InitItem(axe2, tool, 65, 132, 12, 1, line, false); + InitItem(axe3, tool, 66, 251, 13, 1, line, false); + InitItem(axe4, tool, 67, 1562, 14, 1, line, false); + InitItem(axe5, tool, 68, 33, 15, 1, line, false); + InitItem(shears, tool, 10, 239, 16, 1, line, false); + InitItem(sword1, tool, 16, 60, 17, 1, line, false); + InitItem(sword2, tool, 17, 132, 18, 1, line, false); + InitItem(sword3, tool, 18, 251, 19, 1, line, false); + InitItem(sword4, tool, 19, 1562, 20, 1, line, false); + InitItem(sword5, tool, 20, 33, 21, 1, line, false); + InitItem(fishingRod, tool, 101, 65, 22, 1, line, false); + InitItem(lighter, tool, 106, 65, 23, 1, line, false); + InitItem(hoe1, tool, 80, 60, 24, 1, line, false); + InitItem(hoe2, tool, 81, 132, 25, 1, line, false); + InitItem(hoe3, tool, 82, 251, 26, 1, line, false); + InitItem(hoe4, tool, 83, 1562, 27, 1, line, false); + InitItem(hoe5, tool, 84, 33, 28, 1, line, false); + InitItem(reservedToolItem, block, 0, 0, 0, 0, noindicator, false); + InitItem(coal, orditem, 2, 64, 0, 1, numeric, true); + InitItem(redstone, orditem, 7, 64, 0, 1, numeric, true); + InitItem(diamond, orditem, 6, 64, 0, 1, numeric, true); + InitItem(brick, orditem, 3, 64, 0, 1, numeric, true); + InitItem(ironIngot, orditem, 4, 64, 0, 1, numeric, true); + InitItem(goldIngot, orditem, 5, 64, 0, 1, numeric, true); + InitItem(lapisLazuli, orditem, 11, 64, 0, 1, numeric, true); + InitItem(strand, orditem, 12, 64, 0, 1, numeric, true); + InitItem(snowball, orditem, 13, 16, 0, 1, numeric, true); + InitItem(clay, orditem, 14, 64, 0, 1, numeric, true); + InitItem(book, orditem, 15, 64, 0, 1, numeric, true); + InitItem(bucket, orditem, 21, 1, 0, 1, numeric, true); + InitItem(waterBucket, orditem, 22, 1, 0, 1, numeric, true); + InitItem(lavaBucket, orditem, 23, 1, 0, 1, numeric, true); + InitItem(milkBucket, orditem, 24, 1, 0, 1, numeric, true); + InitItem(paper, orditem, 25, 64, 0, 1, numeric, true); + InitItem(melon, orditem, 26, 64, 0, 1, numeric, true); + InitItem(egg, orditem, 27, 64, 0, 1, numeric, true); + InitItem(door, orditem, 28, 64, 0, 1, numeric, true); + InitItem(bed, orditem, 30, 64, 0, 1, numeric, true); + InitItem(spawnEggZombie, orditem, 37, 64, 0, 1, numeric, true); + InitItem(spawnEggSheep, orditem, 38, 64, 0, 1, numeric, true); + InitItem(spawnEggPig, orditem, 39, 64, 0, 1, numeric, true); + InitItem(gunpowder, orditem, 31, 64, 0, 1, numeric, true); + InitItem(bowl, orditem, 40, 64, 0, 1, numeric, true); + InitItem(mushroomStew, orditem, 41, 64, 0, 1, numeric, true); + InitItem(map, orditem, 53, 1, 0, 1, numeric, true); + InitItem(painting, orditem, 54, 64, 0, 1, numeric, true); + InitItem(rawPorkchop, orditem, 55, 64, 0, 1, numeric, true); + InitItem(cookedPorkchop, orditem, 56, 64, 0, 1, numeric, true); + InitItem(rottenFlesh, orditem, 57, 64, 0, 1, numeric, true); + InitItem(camera1, orditem, 69, 1, 0, 1, numeric, true); + InitItem(camera2, orditem, 70, 1, 0, 1, numeric, true); + InitItem(camera3, orditem, 71, 1, 0, 1, numeric, true); + InitItem(goldNugget, orditem, 42, 64, 0, 1, numeric, true); + InitItem(sugar, orditem, 58, 64, 0, 1, numeric, true); + InitItem(spiderEye, orditem, 74, 64, 0, 1, numeric, true); + InitItem(feather, orditem, 85, 64, 0, 1, numeric, true); + InitItem(leather, orditem, 86, 64, 0, 1, numeric, true); + InitItem(rawBeef, orditem, 87, 64, 0, 1, numeric, true); + InitItem(steak, orditem, 88, 64, 0, 1, numeric, true); + InitItem(apple, orditem, 89, 64, 0, 1, numeric, true); + InitItem(goldenApple, orditem, 90, 64, 0, 1, numeric, true); + InitItem(rawChicken, orditem, 72, 64, 0, 1, numeric, true); + InitItem(cookedChicken, orditem, 73, 64, 0, 1, numeric, true); + InitItem(spawnEggChicken, orditem, 96, 64, 0, 1, numeric, true); + InitItem(spawnEggCreeper, orditem, 97, 64, 0, 1, numeric, true); + InitItem(flint, orditem, 1, 64, 0, 1, numeric, true); + InitItem(spawnEggCow, orditem, 99, 64, 0, 1, numeric, true); + InitItem(spawnEggMooshroom, orditem, 100, 64, 0, 1, numeric, true); + InitItem(rawFish, orditem, 102, 64, 0, 1, numeric, true); + InitItem(cookedFish, orditem, 103, 64, 0, 1, numeric, true); + InitItem(spawnEggPigman, orditem, 104, 64, 0, 1, numeric, true); + InitItem(spawnEggSpider, orditem, 105, 64, 0, 1, numeric, true); + InitItem(glowstoneDust, orditem, 107, 64, 0, 1, numeric, true); + InitItem(clock, orditem, 109, 1, 0, 1, numeric, true); + InitItem(compass, orditem, 108, 1, 0, 1, numeric, true); + InitItem(seeds, orditem, 110, 64, 0, 1, numeric, true); + InitItem(wheat, orditem, 111, 64, 0, 1, numeric, true); + InitItem(bread, orditem, 112, 64, 0, 1, numeric, true); + InitItem(boneMeal, orditem, 113, 64, 0, 1, numeric, true); + InitItem(melonSeeds, orditem, 114, 64, 0, 1, numeric, true); + InitItem(pumpkinSeeds, orditem, 115, 64, 0, 1, numeric, true); + + InitOrdItem(dirt); + InitOrdItem(grass); + InitOrdItem(stone); + InitOrdItem(oakWoodPlanks); + InitOrdItem(cobblestone); + InitOrdItem(bedrock); + InitOrdItem(sand); + InitOrdItem(gravel); + InitOrdItem(oakWood); + InitOrdItem(obsidian); + InitOrdItem(bookshelf); + InitOrdItem(mossStone); + InitOrdItem(blockOfIron); + InitOrdItem(blockOfGold); + InitOrdItem(blockOfDiamond); + InitOrdItem(goldOre); + InitOrdItem(ironOre); + InitOrdItem(coalOre); + InitOrdItem(diamondOre); + InitOrdItem(redstoneOre); + InitOrdItem(oakLeaves); + InitOrdItem(redFlower); + InitOrdItem(yellowFlower); + InitOrdItem(redMooshroom); + InitOrdItem(brownMooshroom); + InitOrdItem(torch); + InitOrdItem(tnt); + InitOrdItem(chest); + InitOrdItem(craftingTable); + InitOrdItem(cactus); + InitOrdItem(glass); + InitOrdItem(wool1); + InitOrdItem(wool2); + InitOrdItem(wool3); + InitOrdItem(wool4); + InitOrdItem(wool5); + InitOrdItem(wool6); + InitOrdItem(wool7); + InitOrdItem(wool8); + InitOrdItem(wool9); + InitOrdItem(wool10); + InitOrdItem(wool11); + InitOrdItem(wool12); + InitOrdItem(wool13); + InitOrdItem(wool14); + InitOrdItem(wool15); + InitOrdItem(wool16); + InitOrdItem(snow); + InitOrdItem(ladder); + InitOrdItem(water); + InitOrdItem(lava); + InitOrdItem(oakSapling); + InitOrdItem(sponge); + InitOrdItem(lapisLazuliOre); + InitOrdItem(lapisLazuliBlock); + InitOrdItem(sandstone); + InitOrdItem(tallGrass); + InitOrdItem(deadBush); + InitOrdItem(cobweb); + InitOrdItem(snowBlock); + InitOrdItem(ice); + InitOrdItem(clayBlock); + InitOrdItem(sugarCane); + InitOrdItem(pumpkin); + InitOrdItem(jackLantern); + InitOrdItem(stoneBricks); + InitOrdItem(mossyStoneBricks); + InitOrdItem(crackedStoneBricks); + InitOrdItem(chiseledStokeBricks); + InitOrdItem(ironBras); + InitOrdItem(melonBlock); + InitOrdItem(mycelium); + InitOrdItem(backgroundOakWood); + InitOrdItem(spawner); + InitOrdItem(birchWood); + InitOrdItem(backgroundBirchWood); + InitOrdItem(spruceWood); + InitOrdItem(backgroundSpruceWood); + InitOrdItem(spruceLeaves); + InitOrdItem(redMushroomBlock1); + InitOrdItem(redMushroomBlock2); + InitOrdItem(brownMushroomBlock1); + InitOrdItem(brownMushroomBlock2); + InitOrdItem(oakFence); + InitOrdItem(backgroundOakFence); + InitOrdItem(backgroundOakWoodPlanks); + InitOrdItem(vines); + InitOrdItem(sign); + InitOrdItem(redstoneTorch); + InitOrdItem(furnace); + InitOrdItem(openWoodenTrapdoor); + InitOrdItem(netherrack); + InitOrdItem(glowstone); + InitOrdItem(birchLeaves); + InitOrdItem(soulSand); + InitOrdItem(birchSapling); + InitOrdItem(spruceSapling); + InitOrdItem(redstoneLampOff); + InitOrdItem(backgroundObsidian); + InitOrdItem(glassPlane); + InitOrdItem(cake); + InitOrdItem(stick); + InitOrdItem(dandelionYellow); + InitOrdItem(roseRed); + InitOrdItem(pickaxe1); + InitOrdItem(pickaxe2); + InitOrdItem(pickaxe3); + InitOrdItem(pickaxe4); + InitOrdItem(pickaxe5); + InitOrdItem(shovel1); + InitOrdItem(shovel2); + InitOrdItem(shovel3); + InitOrdItem(shovel4); + InitOrdItem(shovel5); + InitOrdItem(axe1); + InitOrdItem(axe2); + InitOrdItem(axe3); + InitOrdItem(axe4); + InitOrdItem(axe5); + InitOrdItem(shears); + InitOrdItem(sword1); + InitOrdItem(sword2); + InitOrdItem(sword3); + InitOrdItem(sword4); + InitOrdItem(sword5); + InitOrdItem(fishingRod); + InitOrdItem(lighter); + InitOrdItem(hoe1); + InitOrdItem(hoe2); + InitOrdItem(hoe3); + InitOrdItem(hoe4); + InitOrdItem(hoe5); + InitOrdItem(coal); + InitOrdItem(redstone); + InitOrdItem(diamond); + InitOrdItem(brick); + InitOrdItem(ironIngot); + InitOrdItem(goldIngot); + InitOrdItem(lapisLazuli); + InitOrdItem(strand); + InitOrdItem(snowball); + InitOrdItem(clay); + InitOrdItem(book); + InitOrdItem(bucket); + InitOrdItem(waterBucket); + InitOrdItem(lavaBucket); + InitOrdItem(milkBucket); + InitOrdItem(paper); + InitOrdItem(melon); + InitOrdItem(egg); + InitOrdItem(door); + InitOrdItem(bed); + InitOrdItem(spawnEggZombie); + InitOrdItem(spawnEggSheep); + InitOrdItem(spawnEggPig); + InitOrdItem(gunpowder); + InitOrdItem(bowl); + InitOrdItem(mushroomStew); + InitOrdItem(map); + InitOrdItem(painting); + InitOrdItem(rawPorkchop); + InitOrdItem(cookedPorkchop); + InitOrdItem(rottenFlesh); + InitOrdItem(camera1); + InitOrdItem(camera2); + InitOrdItem(camera3); + InitOrdItem(goldNugget); + InitOrdItem(sugar); + InitOrdItem(spiderEye); + InitOrdItem(feather); + InitOrdItem(leather); + InitOrdItem(rawBeef); + InitOrdItem(steak); + InitOrdItem(apple); + InitOrdItem(goldenApple); + InitOrdItem(rawChicken); + InitOrdItem(cookedChicken); + InitOrdItem(spawnEggChicken); + InitOrdItem(spawnEggCreeper); + InitOrdItem(flint); + InitOrdItem(spawnEggCow); + InitOrdItem(spawnEggMooshroom); + InitOrdItem(rawFish); + InitOrdItem(cookedFish); + InitOrdItem(spawnEggPigman); + InitOrdItem(spawnEggSpider); + InitOrdItem(glowstoneDust); + InitOrdItem(clock); + InitOrdItem(compass); + InitOrdItem(seeds); + InitOrdItem(wheat); + InitOrdItem(bread); + InitOrdItem(boneMeal); + InitOrdItem(melonSeeds); + InitOrdItem(pumpkinSeeds); +end. diff --git a/src/Mobs.pas b/src/Mobs.pas index 519cf9c..252f22f 100644 --- a/src/Mobs.pas +++ b/src/Mobs.pas @@ -26,13 +26,15 @@ interface implementation - uses phy, player, canvas, jsr75i, func, drop, items; + uses phy, player, canvas, jsr75i, func, drop; const lastType = 1; lastMob = 31; lastZombyFrame = 11; + rottenMeat = 190; + var mtype, mx, my, mvx, mvy, mpos, mhp, ma, mb, mc : array [0..lastMob] of integer; mjump : array [0..lastMob] of boolean; @@ -142,7 +144,7 @@ implementation x := mx[i] + GetW(i) / 2; y := my[i] + GetH(i) / 2; if mtype[i] = zomby then begin - Drop.Create(Items.rottenMeat, x, y, Random(3)); + Drop.Create(rottenMeat, x, y, Random(3)); end; mtype[i] := none; end; diff --git a/src/Particles.mpsrc b/src/Particles.pas similarity index 100% rename from src/Particles.mpsrc rename to src/Particles.pas diff --git a/src/Player.mpsrc b/src/Player.mpsrc index b41c8e3..947adf9 100644 --- a/src/Player.mpsrc +++ b/src/Player.mpsrc @@ -42,7 +42,7 @@ interface implementation - uses func, phy, vars, Canvas, drop, items, jsr75i, inv; + uses func, phy, vars, Canvas, drop, jsr75i, inv, Items; const PLAYER_W=8; @@ -188,9 +188,9 @@ implementation DrawImage(playerBody[posi], x - camx, y - camy); DrawImage(playerLegs[posi, animLegs], x - 2 - camx, y + 20 - camy); - if animHand = 0 then DrawSmallItem(Inv.GetItem(invslot), x - camx, y + 14 - camy); - else if posi = POSI_RIGHT then DrawSmallItem(Inv.GetItem(invslot), x + 10 - camx, y + 5 - camy + animHand); - else if posi = POSI_LEFT then DrawSmallItem(Inv.GetItem(invslot), x - 10 - camx, y + 5 - camy + animHand); + if animHand = 0 then Items.DrawSmall(Inv.GetItem(invslot), x - camx, y + 14 - camy); + else if posi = POSI_RIGHT then Items.DrawSmall(Inv.GetItem(invslot), x + 10 - camx, y + 5 - camy + animHand); + else if posi = POSI_LEFT then Items.DrawSmall(Inv.GetItem(invslot), x - 10 - camx, y + 5 - camy + animHand); if (animHand = 0) or (posi = POSI_RIGHT) then DrawImage(playerHand[posi, animHand], x + 2 - camx, y + 8 - camy); else DrawImage(playerHand[posi, animHand], x - 6 - camx, y + 8 - camy); diff --git a/src/cellui.mpsrc b/src/cellui.mpsrc index 070ea0e..3b14c3f 100644 --- a/src/cellui.mpsrc +++ b/src/cellui.mpsrc @@ -75,7 +75,7 @@ interface function FindCurrentWindowsType:boolean; implementation - uses vars, Canvas, items, console, furnace, chest, inv, func, items_store; + uses vars, Canvas, console, furnace, chest, inv, func, items_store, Items; var layer:integer; last_cell: array [0..CONST_MAX_LAYERS] of integer; @@ -227,7 +227,7 @@ implementation getItemIdx:=inv.getItem(id); else if _type=CELL_TYPE_CREWATIVE_INV then - getItemIdx:=getItemList(id); + getItemIdx:=Items.GetOrdinary(id); else if _type=CELL_TYPE_CHEST then getItemIdx:=chest.getItem(id, data); @@ -269,7 +269,7 @@ implementation getSumIdx:=inv.getSum(id); else if _type=CELL_TYPE_CREWATIVE_INV then - getSumIdx:=getItemMax(getItemList(id)); + getSumIdx:=Items.GetMaximum(Items.GetOrdinary(id)); else if _type=CELL_TYPE_CHEST then getSumIdx:=chest.getSum(id, data); @@ -336,7 +336,7 @@ implementation for j:=0 to CONST_MAX_CELLS do if inv_type[i, j]<>CELL_TYPE_NULL then begin - drawItem(getItemIdx(j, i), getSumIdx(j, i), x+inv_x[i, j], y+inv_y[i, j], getCellFlagIndicator(i, j)); + Items.Draw(getItemIdx(j, i), getSumIdx(j, i), x+inv_x[i, j], y+inv_y[i, j], getCellFlagIndicator(i, j)); end; end; diff --git a/src/console.pas b/src/console.pas index c6c2f69..3d227f8 100644 --- a/src/console.pas +++ b/src/console.pas @@ -50,7 +50,6 @@ implementation keyboard, vars, maps, - items, canvas, mobs, worldgen, @@ -759,13 +758,6 @@ procedure exeCommand(str:string); decodeInt(tmp2)); end; else - if com='SET_MAX_ITEM_LIST' then - setMaxItemList(decodeInt(nextWord)); - else - if com='SET_ITEM_LIST' then - setItemList(decodeInt(nextWord), - decodeInt(nextWord)); - else if com='BIND_KEY' then begin tmp:=nextWord; diff --git a/src/craft.mpsrc b/src/craft.mpsrc index db148dd..f60d988 100644 --- a/src/craft.mpsrc +++ b/src/craft.mpsrc @@ -5,7 +5,8 @@ interface function canCreateCraft(id, mode:integer):boolean; implementation - uses vars, items, func, player, inv, items_store; + + uses vars, func, player, inv, items_store; procedure createCraft(id, mode:integer); var diff --git a/src/drop.mpsrc b/src/drop.mpsrc index e6f95cd..3738c12 100644 --- a/src/drop.mpsrc +++ b/src/drop.mpsrc @@ -26,7 +26,7 @@ interface procedure loadData; implementation - uses phy, jsr75i, vars, items_store, items, func; + uses phy, jsr75i, vars, items_store, func, Items; const MAX_DROP=255; DROP_W=8; @@ -139,15 +139,15 @@ implementation end; end; - procedure draw(camx, camy:integer); - var - i:integer; - begin - if drw_drp then - for i:=0 to 255 do - if isNull(i)=false then - drawSmallItem(drop_item[i], drop_x[i]-camx, drop_y[i]-camy); - end; + procedure draw(camx, camy : integer); + var + i : integer; + begin + if not drw_drp then exit; + for i:=0 to 255 do if IsNull(i) = false then begin + Items.DrawSmall(drop_item[i], drop_x[i] - camx, drop_y[i] - camy); + end; + end; procedure reflux; var diff --git a/src/func.mpsrc b/src/func.mpsrc index 5089d0c..bce8640 100644 --- a/src/func.mpsrc +++ b/src/func.mpsrc @@ -4,8 +4,10 @@ interface function get_spawn_x:integer;//Возвращает блок по X где должен появиться игрок function get_spawn_y:integer;//Возвращает блок по Y где должен появиться игрок procedure draw_block(xx,yy:integer); +(* procedure drawSmallItem(item, x, y:integer); procedure drawItem(item, sum, x, y:integer; indicator:boolean;); +*) procedure LoadDrawFont(s:string); procedure DrawFontTextSpec(str:string; x, y, color:integer; spec:boolean;); procedure DrawFontText(str:string; x, y:integer); @@ -18,7 +20,7 @@ procedure writestr(s:string); function readstr:string; implementation - uses canvas,imgcolor,jsr75i, vars, safeload, items,maps, items_store; + uses canvas, imgcolor, jsr75i, vars, safeload, Blocks, maps, items_store; //Загрузка текстуры с автоматическим выбором источника function ld_tex(name, path, folder : String) : Image; @@ -102,6 +104,7 @@ function readstr:string; if getmap(get_spawn_x,iy)<>0 then begin get_spawn_y:=(iy-2); break; end; end; +(* procedure drawSmallItem(item, x, y:integer); begin if getItemTexType(item)=0 then @@ -110,6 +113,7 @@ function readstr:string; if getItemTexType(item)=1 then drawimage(item8[getItemTex(item)], x, y); end; +*) procedure draw_block(xx,yy:integer); begin @@ -122,9 +126,9 @@ function readstr:string; end; else if (getmap(xx,yy)=92) or (getmap(xx,yy)=93) then begin - if (getBlockSet(getmap(xx-1,yy))=false) and (getBlockSet(getmap(xx+1,yy))=true) then setclip((xx*16)-camx,(yy*16)-camy,10,16); else - if (getBlockSet(getmap(xx+1,yy))=false) and (getBlockSet(getmap(xx-1,yy))=true) then setclip((xx*16)-camx+6,(yy*16)-camy,10,16); else - if (getBlockSet(getmap(xx+1,yy))=true) and (getBlockSet(getmap(xx-1,yy))=true) then setclip((xx*16)-camx+6,(yy*16)-camy,4,16); + if (Blocks.IsOverlapped(getmap(xx - 1, yy)) = false) and (Blocks.IsOverlapped(getmap(xx + 1, yy)) = true) then setclip((xx*16)-camx,(yy*16)-camy,10,16); else + if (Blocks.IsOverlapped(getmap(xx + 1, yy)) = false) and (Blocks.IsOverlapped(getmap(xx - 1, yy)) = true) then setclip((xx*16)-camx+6,(yy*16)-camy,10,16); else + if (Blocks.IsOverlapped(getmap(xx + 1, yy)) = true) and (Blocks.IsOverlapped(getmap(xx - 1, yy)) = true) then setclip((xx*16)-camx+6,(yy*16)-camy,4,16); drawimage(tex[getBlockTex(getmap(xx,yy))],(xx*16)-camx,(yy*16)-camy); setclip(0,0,getwidth,getheight); end; else @@ -166,6 +170,7 @@ function readstr:string; drawimage(tex[getBlockTex(getmap(xx,yy))],(xx*16)-camx,(yy*16)-camy); end; +(* procedure drawItem(item, sum, x, y:integer; indicator:boolean;); var pa_xo,ugol:integer; @@ -213,7 +218,7 @@ function readstr:string; drawfonttext(''+sum, x, y+8); end; end; - +*) //Загрузка шрифта из файла под именем s procedure LoadDrawFont(s:string); diff --git a/src/furnace.mpsrc b/src/furnace.mpsrc index 7b37737..1cf9185 100644 --- a/src/furnace.mpsrc +++ b/src/furnace.mpsrc @@ -43,7 +43,7 @@ interface procedure ResetData; implementation - uses maps, drop, items_store, items, jsr75i, func; + uses maps, drop, items_store, jsr75i, func, Items; var furnace_b: array [0..MAX_FURNACE] of boolean; @@ -265,9 +265,9 @@ implementation sumOUT:=GetFurSum(FURNACE_OUT, i); recipeOUT:=GetReceptOut(itemIN); - if (itemIN<>0) and (recipeOUT<>FURNACE_ERROR) then - if (itemOUT=0) or ((itemOUT=recipeOUT) and (sumOUT 0) and (recipeOUT <> FURNACE_ERROR) then + if (itemOUT = 0) or ((itemOUT = recipeOUT) and (sumOUT < Items.GetMaximum(itemOUT))) then + canUpdate := true; end; function furnaceBurn(i:integer):boolean; @@ -291,7 +291,7 @@ implementation item:=GetFurItem(FURNACE_FUEL, i); sum:=GetFurSum(FURNACE_FUEL, i); - if getItemDiv(item) then + if Items.IsDividable(item) then begin sum:=sum-1; if sum<0 then @@ -319,7 +319,7 @@ implementation sumOUT:=GetFurSum(FURNACE_OUT, i); recipeOUT:=GetReceptOut(itemIN); - if getItemDiv(itemIN) then + if Items.IsDividable(itemIN) then begin sumIN:=sumIN-1; if sumIN<0 then diff --git a/src/inv.mpsrc b/src/inv.mpsrc index 76ba270..740b8ee 100644 --- a/src/inv.mpsrc +++ b/src/inv.mpsrc @@ -19,7 +19,7 @@ interface procedure loadData; implementation - uses items_store, vars, jsr75i, items, func; + uses items_store, vars, jsr75i, func, Items; var inv_item: array [0..INV_SIZE] of integer; inv_sum: array [0..INV_SIZE] of integer; @@ -62,25 +62,26 @@ implementation //Добавить предмет в инвентарь, возващает количество не полученых предметов. function giveItem(ityp, isum:integer):integer; var - i, item, sum:integer; + i, item, sum, max:integer; begin //Ищем такой же предмет только если он имеет возможность делиться - if getItemDiv(ityp) then + if Items.IsDividable(ityp) then for i:=0 to INV_SIZE do begin - item:=getItem(i); - sum:=getSum(i); + item :=getItem(i); + sum :=getSum(i); + max := Items.GetMaximum(ityp); if (item=ityp) and (isNull(i)=false) then - if isumgetItemMax(ityp) then + if sum > max then begin - isum:=sum-getItemMax(ityp); - sum:=sum-isum; + isum := sum - max; + sum := sum - isum; end; setSum(sum, i); @@ -95,11 +96,12 @@ function giveItem(ityp, isum:integer):integer; begin sum:=isum; isum:=0; + max := Items.GetMaximum(ityp); - if sum>getItemMax(ityp) then + if sum > max then begin - isum:=sum-getItemMax(ityp); - sum:=sum-isum; + isum := sum - max; + sum := sum - isum; end; setItem(ityp, i); diff --git a/src/invui.mpsrc b/src/invui.mpsrc index 3b642f5..0fbac2e 100644 --- a/src/invui.mpsrc +++ b/src/invui.mpsrc @@ -10,7 +10,7 @@ interface function WindowKeyHanler:boolean; implementation - uses vars, CellUI, console, Canvas, items, utils, craft, furnace, func, items_store, player, keyboard; + uses vars, CellUI, console, Canvas, utils, craft, furnace, func, items_store, player, keyboard, Items; const WINDOW_PLAYER_INV=1; WINDOW_DIV_ITEMS=2; @@ -176,11 +176,11 @@ implementation for i:=0 to 1 do for j:=0 to 1 do begin - drawItem(getCraftInItem(craftid, id), getCraftInSum(craftid, id), x+52+j*18, y+17+i*18, true); + Items.Draw(getCraftInItem(craftid, id), getCraftInSum(craftid, id), x+52+j*18, y+17+i*18, true); id:=id+1; end; - drawItem(getCraftOutItem(craftid), getCraftOutSum(craftid), x+108, y+27, true); + Items.Draw(getCraftOutItem(craftid), getCraftOutSum(craftid), x+108, y+27, true); i:=calcScrollBar(52, getImageHeight(fcScrollImg), MAX_FASTCRAFT_OFFSET, getOffset(0)); drawimage(fcScrollImg, x+156, y+66+i); @@ -409,8 +409,8 @@ implementation sum1:=GetWindowInfo(WINDOW_INFO_DIV_SUM1); sum2:=GetWindowInfo(WINDOW_INFO_DIV_SUM2); - drawItem(item, (sum1-sum2), x+8, y+8, true); - drawItem(item, sum2, x+64, y+8, true); + Items.Draw(item, (sum1-sum2), x+8, y+8, true); + Items.Draw(item, sum2, x+64, y+8, true); i:=calcScrollBar(72, getImageWidth(DivScrollImg), sum1, sum2); @@ -566,15 +566,15 @@ implementation fresult:=true; if (tmp_item1=tmp_item2) and (Idx1<>Idx2) then - if tmp_sum2getItemMax(tmp_item2) then + if tmp_sum2 > GetMaximum(tmp_item2) then begin - tmp_sum1:=tmp_sum2-getItemMax(tmp_item2); - tmp_sum2:=tmp_sum2-tmp_sum1; + tmp_sum1 := tmp_sum2 - Items.GetMaximum(tmp_item2); + tmp_sum2 := tmp_sum2 - tmp_sum1; end; if tmp_sum1<=0 then @@ -664,7 +664,7 @@ implementation function CanDivItem:boolean; begin - if getItemDiv(getItem(GetCurIndex(GetCur))) then + if Items.IsDividable(getItem(GetCurIndex(GetCur))) then if (GetCur=CUR_SELECT1) and (getSum(GetCurIndex(GetCur))>0) then CanDivItem:=true; end; @@ -717,7 +717,7 @@ implementation begin if GetTimer(T_KEY_DROPITEM)>TIMER_OK then begin - if getItemDiv(item) then + if Items.IsDividable(item) then begin player.dropItem(item, 1); decItem(curidx); diff --git a/src/items.mpsrc b/src/items.mpsrc deleted file mode 100644 index d1b914a..0000000 --- a/src/items.mpsrc +++ /dev/null @@ -1,101 +0,0 @@ -unit items; - -interface - const - ITEM_TYPE_BLOCK=0; - ITEM_TYPE_TOOL=1; - - ITEM_FLAG_IND1=1; - ITEM_FLAG_IND2=2; - ITEM_FLAG_DIV=4; - ITEM_FLAG_TEX=8; - - rottenMeat = 190; - - var - compas:image; - clock:array[0..7] of image; - none0:image; - clock_stage:integer; - - function getBlockTrans(id:integer;):boolean; - function getBlockFore(id:integer;):boolean; - function getBlockSet(id:integer;):boolean; - - function getItemIndNum(id:integer):boolean; - function getItemIndLine(id:integer):boolean; - function getItemDiv(id:integer):boolean; - function getItemTexType(id:integer):integer; - - procedure setMaxItemList(i:integer); - procedure setItemList(item, i:integer); - function getItemList(i:integer):integer; - -implementation - uses items_store; - const - BLOCK_FLAG_Trans=1; - BLOCK_FLAG_FORE=2; - BLOCK_FLAG_SET=4; - - var - itemListSize:integer; - itemList: array [0..0] of integer; - - function getBlockTrans(id:integer;):boolean; - begin - getBlockTrans:=(getBlockFlags(id) and BLOCK_FLAG_Trans)>0; - end; - - function getBlockFore(id:integer;):boolean; - begin - getBlockFore:=(getBlockFlags(id) and BLOCK_FLAG_FORE)>0; - end; - - function getBlockSet(id:integer;):boolean; - begin - getBlockSet:=(getBlockFlags(id) and BLOCK_FLAG_SET)>0; - end; - - function getItemIndNum(id:integer):boolean; - begin - getItemIndNum:=(getItemFlags(id) and ITEM_FLAG_IND1)>0; - end; - - function getItemIndLine(id:integer):boolean; - begin - getItemIndLine:=(getItemFlags(id) and ITEM_FLAG_IND2)>0; - end; - - function getItemDiv(id:integer):boolean; - begin - getItemDiv:=(getItemFlags(id) and ITEM_FLAG_DIV)>0; - end; - - function getItemTexType(id:integer):integer; - begin - getItemTexType:=(getItemFlags(id) and ITEM_FLAG_TEX)>>3; - end; - - procedure setMaxItemList(i:integer); - begin - itemListSize:=i; - i:=i+1; - bytecode - iload 0; - newarray 10; - putstatic field 'items', 'itemlist', '[I'; - end; - end; - - procedure setItemList(i, item:integer); - begin - itemList[i]:=item; - end; - - function getItemList(i:integer):integer; - begin - if (i>=0) and (i<=itemListSize) then - getItemList:=itemList[i]; - end; -end. diff --git a/src/items_logic.mpsrc b/src/items_logic.mpsrc index a3d41c0..84db334 100644 --- a/src/items_logic.mpsrc +++ b/src/items_logic.mpsrc @@ -12,7 +12,8 @@ interface procedure updateBlock(x, y:integer); implementation - uses invui, maps, drop, console, furnace, png3, func, jpeg, mobs, vars, bmp, items, chest, inv, player, items_store, particles, worldgen, phy, sign; + + uses invui, maps, drop, console, furnace, png3, func, jpeg, mobs, vars, bmp, chest, inv, player, items_store, particles, worldgen, phy, sign, Blocks; procedure usebonemeal(block:integer); var @@ -1153,7 +1154,7 @@ procedure fluidLogic(x, y, ifbx, thenbx, ifby, thenby:integer); setMap(thenby, x, y+1); else //Если нижний блок можно уничтожить, то ставим туда копию - if getBlockSet(blockYp1) then + if Blocks.IsOverlapped(blockYp1) then begin destroy_block_0(blockYp1, x, y+1); setMap(block, x, y+1); @@ -1164,7 +1165,7 @@ procedure fluidLogic(x, y, ifbx, thenbx, ifby, thenby:integer); if blockXm1=ifbx then setMap(thenbx, x-1, y); else - if getBlockSet(blockXm1) then + if Blocks.IsOverlapped(blockXm1) then begin destroy_block_1(blockXm1, x-1, y); setMap(block, x-1, y); @@ -1173,7 +1174,7 @@ procedure fluidLogic(x, y, ifbx, thenbx, ifby, thenby:integer); if blockXp1=ifbx then setMap(thenbx, x+1, y); else - if getBlockSet(blockXp1) then + if Blocks.IsOverlapped(blockXp1) then begin destroy_block_1(blockXp1, x+1, y); setMap(block, x+1, y); @@ -1202,7 +1203,7 @@ procedure updateBlock(x, y:integer); if block=2 then begin //Трава разрастается при условии что освещение выше чем 3 - if (getBlockSet(getMap(x, y-1))=false) or (light=0) then + if (light = 0) or (Blocks.IsOverlapped(getMap(x, y - 1)) = false) then setMap(1, x, y); else if light>3 then @@ -1219,7 +1220,7 @@ procedure updateBlock(x, y:integer); else if block=7 then begin - if getBlockSet(getMap(x, y+1)) then + if Blocks.IsOverlapped(getMap(x, y+1)) then begin setMap(0, x, y); setMap(7, x, y+1); @@ -1228,7 +1229,7 @@ procedure updateBlock(x, y:integer); else if block=8 then begin - if getBlockSet(getMap(x, y+1)) then + if Blocks.IsOverlapped(getMap(x, y+1)) then begin setMap(0, x, y); setMap(8, x, y+1); @@ -1260,7 +1261,7 @@ procedure updateBlock(x, y:integer); else if block=74 then begin - if getBlockSet(getMap(x, y-1))=false then + if Blocks.IsOverlapped(getMap(x, y-1))=false then setMap(1, x, y); else if light>3 then diff --git a/src/vars.mpsrc b/src/vars.mpsrc index 5ac6cb8..e7db3e3 100644 --- a/src/vars.mpsrc +++ b/src/vars.mpsrc @@ -50,6 +50,11 @@ interface font:array [0..127] of image; none4:image; + compas:image; + clock:array[0..7] of image; + none5:image; + clock_stage:integer; + procedure initBlockTex(i:integer); procedure initItemTex(i:integer); diff --git a/src/worldgen.mpsrc b/src/worldgen.mpsrc index d49159a..e9e7a06 100644 --- a/src/worldgen.mpsrc +++ b/src/worldgen.mpsrc @@ -17,7 +17,8 @@ interface implementation -uses maps,randoms,vars,items,func, player, chest, items_store; + + uses maps, randoms, vars, func, player, chest, items_store, Items, Blocks; function rnd_min:integer; begin @@ -575,8 +576,8 @@ procedure create_bonus_chest(chx,chy:integer); l:=rnd(26); if rnd(75)=rnd(75) then begin - chest.setItem(133 ,l, id); - chest.setSum(getItemMax(133), l, id); + chest.setItem(Items.pickaxe3 ,l, id); + chest.setSum(Items.GetMaximum(Items.pickaxe3), l, id); end; else if rnd(25)=rnd(25) then begin -- 2.29.2