Browse Source

ENTITY REWRITE: added bullet params

pull/3/head
asiekierka 8 years ago
parent
commit
66389f4bed

+ 22
- 11
client/CraftrGameScreen.java View File

@@ -155,13 +155,28 @@ public class CraftrGameScreen extends CraftrScreen
{
for(int ix=0;ix<c.FULLGRID_W;ix++)
{
t = blocks[ix+(iy*c.FULLGRID_W)];
if(t != null)
{
c.DrawChar(ix<<4,iy<<4,(byte)t.getDrawnChar(),(byte)t.getDrawnColor());
if(t.isBullet()) c.DrawChar(ix<<4,iy<<4,(byte)248,(byte)15);
t = blocks[ix+(iy*c.FULLGRID_W)];
if(t != null)
{
c.DrawChar(ix<<4,iy<<4,(byte)t.getDrawnChar(),(byte)t.getDrawnColor());
if(t.isBullet())
switch(t.getBullet())
{
case 1:
case 2:
case 3:
case 4:
c.DrawChar(ix<<4,iy<<4,(byte)248,(byte)15);
break;
case 5:
c.DrawChar(ix<<4,iy<<4,(byte)153,(byte)6);
break;
case 6:
c.DrawChar(ix<<4,iy<<4,(byte)227,(byte)0x0B);
break;
}
}else{
c.DrawChar(ix<<4,iy<<4,(byte)177,(byte)0x08);
c.DrawChar(ix<<4,iy<<4,(byte)177,(byte)0x08);
}
}
}
@@ -314,7 +329,7 @@ public class CraftrGameScreen extends CraftrScreen
if(drawType == 2) bsmt=3;
else if(isArrow() && barselMode == 1) bsmt=4;
else if(drawType == 17) bsmt=5;
else if(drawType >= 21 && drawType <= 23) bsmt=0;
else if(drawType >= 21 && drawType <= 22) bsmt=0;
if((drawType == 3 || drawType ==20)&& (gdrawChr()<24 || gdrawChr()>=28)) sdrawChr(25);
else if(drawType == 15 && !(gdrawChr()==30 || gdrawChr()==31 || gdrawChr()==16 || gdrawChr()==17)) sdrawChr(31);
else if(drawType==4) sdrawChr(206);
@@ -329,10 +344,6 @@ public class CraftrGameScreen extends CraftrScreen
sdrawCol(0x06);
sdrawChr(153);
} else if (drawType == 22)
{
sdrawCol(0x0D);
sdrawChr(5);
} else if (drawType == 23)
{
sdrawCol(0x0B);
sdrawChr(227);

+ 15
- 7
common/CraftrBlock.java View File

@@ -6,9 +6,9 @@ public class CraftrBlock
{
public int x = 0;
public int y = 0;
private byte[] block = new byte[7];
public static final int maxType = 23;
public static final int invalidTypes = 3;
private byte[] block = new byte[8];
public static final int maxType = 22;
public static final int invalidTypes = 2;
public static Random rand = new Random();
public CraftrBlock()
@@ -102,6 +102,16 @@ public class CraftrBlock
block[6]=t;
}
public int getBulletParam()
{
return 0xFF&(int)block[7];
}
public void setBulletParam(byte t)
{
block[7] = t;
}
public int getType()
{
return 0xFF&(int)block[0];
@@ -185,7 +195,7 @@ public class CraftrBlock
public static int getBDSize()
{
return 7;
return 8;
}
public byte[] getBlockData()
@@ -195,7 +205,7 @@ public class CraftrBlock
public static boolean isPlaceable(int t)
{
return !(t == 16 || t==18 || t==22);
return !(t == 16 || t==18);
}
public boolean isPlaceable()
@@ -252,8 +262,6 @@ public class CraftrBlock
case 21:
return "Bear";
case 22:
return "Ruffian";
case 23:
return "Tiger";
case -1:
return "Pushium";

+ 23
- 6
common/CraftrChunk.java View File

@@ -12,6 +12,7 @@ public class CraftrChunk {
public byte[] colp;
public byte[] chr2;
public byte[] col2;
public byte[] bullpar;
public byte[] mapinfo;
public int w;
@@ -37,6 +38,7 @@ public class CraftrChunk {
col2 = new byte[64*64];
chrp = new byte[64*64];
colp = new byte[64*64];
bullpar = new byte[64*64];
mapinfo = new byte[4096];
w = 64;
h = 64;
@@ -51,17 +53,21 @@ public class CraftrChunk {
{
// i love arraycopy, and all its mysteries!
// boom de yada, boom de yada...
int ver = rawdata[0];
int dec = 0;
System.arraycopy(rawdata,1+hdrsize,type,0,4096);
System.arraycopy(rawdata,1+hdrsize+4096,param,0,8192);
System.arraycopy(rawdata,1+hdrsize+(4096*3),chr,0,8192);
System.arraycopy(rawdata,1+hdrsize+(4096*5),col,0,8192);
System.arraycopy(rawdata,1+hdrsize+(4096*7),chrp,0,4096);
System.arraycopy(rawdata,1+hdrsize+(4096*8),colp,0,4096);
if(ver == 5) System.arraycopy(rawdata,1+hdrsize+(4096*9),bullpar,0,4096);
else dec = 4096;
byte[] tmp = new byte[2];
System.arraycopy(rawdata,4,tmp,0,2);
mapinfo_len = CraftrConvert.arrShort(tmp);
mapinfo_type = rawdata[3];
if(mapinfo_len > 0 && mapinfo_type > 0) System.arraycopy(rawdata,1+hdrsize+(4096*9),mapinfo,0,mapinfo_len);
if(mapinfo_len > 0 && mapinfo_type > 0) System.arraycopy(rawdata,1+hdrsize+(4096*10)-dec,mapinfo,0,mapinfo_len);
spawnX = rawdata[1];
spawnY = rawdata[2];
fixDisplay();
@@ -74,15 +80,16 @@ public class CraftrChunk {
public byte[] saveByte()
{
byte[] out = new byte[(4096*10)+1+hdrsize];
byte[] out = new byte[(4096*11)+1+hdrsize];
System.arraycopy(type,0,out,1+hdrsize,4096);
System.arraycopy(param,0,out,4096+1+hdrsize,8192);
System.arraycopy(chr,0,out,(4096*3)+1+hdrsize,8192);
System.arraycopy(col,0,out,(4096*5)+1+hdrsize,8192);
System.arraycopy(chrp,0,out,(4096*7)+1+hdrsize,4096);
System.arraycopy(colp,0,out,(4096*8)+1+hdrsize,4096);
System.arraycopy(mapinfo,0,out,(4096*9)+1+hdrsize,4096);
out[0] = 4; // version
System.arraycopy(bullpar,0,out,(4096*9)+1+hdrsize,4096);
System.arraycopy(mapinfo,0,out,(4096*10)+1+hdrsize,4096);
out[0] = 5; // version
out[1] = (byte)spawnX;
out[2] = (byte)spawnY;
out[3] = (byte)mapinfo_type;
@@ -141,7 +148,7 @@ public class CraftrChunk {
}
public byte[] getBlock(int x, int y)
{
byte[] data = new byte[7];
byte[] data = new byte[8];
int p = x+(y<<6);
data[0] = type[p];
data[1] = param[p];
@@ -150,6 +157,7 @@ public class CraftrChunk {
data[4] = chrp[p];
data[5] = colp[p];
data[6] = getBullet(x,y);
data[7] = bullpar[p];
return data;
}
public byte getBlockType(int x, int y)
@@ -185,10 +193,19 @@ public class CraftrChunk {
public byte getBullet(int x, int y)
{
return param[4096+x+(y<<6)];
}
}
public byte getBulletParam(int x, int y)
{
return bullpar[x+(y<<6)];
}
public void placeBullet(int x, int y, byte aType)
{
placeBullet(x,y,aType,(byte)0);
}
public void placeBullet(int x, int y, byte aType, byte aPar)
{
param[4096+x+(y<<6)]=aType;
bullpar[x+(y<<6)]=aPar;
}
public void place(int x, int y, byte aType, byte aChr, byte aCol, byte aPar)
{

+ 17
- 12
common/CraftrMap.java View File

@@ -237,9 +237,9 @@ public class CraftrMap
int hdrsize = CraftrChunk.hdrsize;
switch(buf[0])
{
case 3:
out = new byte[1+(4096*10)+hdrsize];
while(i<(1+(4096*8)+hdrsize) && i>-1) i += gin.read(out,i,(1+(4096*8)+hdrsize)-i);
case 4:
out = new byte[1+(4096*11)+hdrsize];
while(i<(1+(4096*10)+hdrsize) && i>-1) i += gin.read(out,i,out.length-i);
gin.close();
for(int ri=0;ri<4096;ri++)
{
@@ -248,13 +248,13 @@ public class CraftrMap
out[1+ri+hdrsize+4096]=(byte)1;
physics.addBlockToCheck(new CraftrBlockPos(x*64+(ri&63),y*64+(ri>>6)));
}
else if(physics.isReloaded(out[1+ri+hdrsize]))
else if(physics.isReloaded(out[1+ri+hdrsize]) || out[1+ri+(4096*9)+hdrsize] != 0)
physics.addBlockToCheck(new CraftrBlockPos(x*64+(ri&63),y*64+(ri>>6)));
}
return out;
case 4:
out = new byte[1+(4096*10)+hdrsize];
while(i<(1+(4096*10)+hdrsize) && i>-1) i += gin.read(out,i,out.length-i);
case 5:
out = new byte[1+(4096*11)+hdrsize];
while(i<(1+(4096*11)+hdrsize) && i>-1) i += gin.read(out,i,out.length-i);
gin.close();
for(int ri=0;ri<4096;ri++)
{
@@ -263,9 +263,8 @@ public class CraftrMap
out[1+ri+hdrsize+4096]=(byte)1;
physics.addBlockToCheck(new CraftrBlockPos(x*64+(ri&63),y*64+(ri>>6)));
}
else if(physics.isReloaded(out[1+ri+hdrsize]))
else if(physics.isReloaded(out[1+ri+hdrsize]) || out[1+ri+(4096*9)+hdrsize] != 0)
physics.addBlockToCheck(new CraftrBlockPos(x*64+(ri&63),y*64+(ri>>6)));
}
return out;
default:
@@ -403,14 +402,17 @@ public class CraftrMap
if(!multiplayer) System.exit(1);
}
}
public void setBullet(int x, int y, byte aType)
{
setBullet(x,y,aType,(byte)0);
}
public void setBullet(int x, int y, byte aType, byte aPar)
{
try
{
int px = x&63;
int py = y&63;
grabChunk((x>>6),(y>>6)).placeBullet(px,py,aType);
grabChunk((x>>6),(y>>6)).placeBullet(px,py,aType, aPar);
}
catch(Exception e)
{
@@ -419,7 +421,10 @@ public class CraftrMap
if(!multiplayer) System.exit(1);
}
}
public void setBulletNet(int x, int y, byte aType, byte aPar)
{
setBulletNet(x,y,aType);
}
public void setBulletNet(int x, int y, byte aType)
{
try

+ 5
- 1
common/CraftrPhysics.java View File

@@ -198,7 +198,7 @@ public class CraftrPhysics
}
}
// Bullet code
if(changeBullets && blockData[6]!=0)
if(changeBullets && blockData[6]>0 && blockData[6]<=4)
{
boolean bshot = false;
for(int i=0;i<256;i++)
@@ -249,6 +249,10 @@ public class CraftrPhysics
blockO.setBullet((byte)0);
addBlockToSet(blockO);
addBlockToCheck(new CraftrBlockPos(blockO.x,blockO.y));
}
else if(!changeBullets && blockData[6]==5)
{

}
else if(!changeBullets && blockData[6]!=0)
{

+ 1
- 1
common/CraftrVersion.java View File

@@ -7,7 +7,7 @@ public class CraftrVersion
private static final int majorVer = 2;
private static final int minorVer = 0;
private static final int patchVer = 0;
private static final String addon = "-b0-git";
private static final String addon = "-beta1";
//private static final String addon = "";
public CraftrVersion()
{

+ 1
- 1
config.txt View File

@@ -4,5 +4,5 @@ tp-for-all=1
port=25566
private-mode=0
name=[0.2] BETATESTING
spawn-x=0
spawn-x=1
spawn-y=3

Loading…
Cancel
Save