D0431791
Members-
Posts
6 -
Joined
-
Last visited
Everything posted by D0431791
-
[1.7.10]How to ensure world.setBlock successful?
D0431791 replied to D0431791's topic in Modder Support
I have tested the case setting a single block; it works fine. However, the case swapping two blocks failed; neither blocks are changed. zbt=zb[i]; zmt=zm[i]; if(!world.isRemote){ world.setBlock(zx[i],zy[i],zz[i],zb[j],zm[j],2); world.setBlock(zx[j],zy[j],zz[j],zbt,zmt,2); } Is it solvable? -
This problem may be found in many released mods. The function world.setBlock is called by updateEntity function of a TileEntity. I have tried the three set of codes below: world.setBlock(x,y,z,Blocks.packed_ice); world.setBlock(x,y,z,Blocks.packed_ice,0,2); world.setBlock(x,y,z,Blocks.packed_ice,0,3); However, sometimes world.setBlock is not successful. When it is not successful, only the texture of the block changes, but the block is not changed; the player can right click the block to change the texture back. I also have tried repeating setting block until the block is indeed changed, but it does not solve the problem. What is the real solution on earth?
-
[1.7.10][and newer]How to get the speed part pushed by water?
D0431791 replied to D0431791's topic in Modder Support
Now I can see the effect. The code looks like this now: public static Vec3 getSpeedPartByWater(Entity x,World xworld){ Vec3 y=Vec3.createVectorHelper(0d,0d,0d); AxisAlignedBB zaabb=x.boundingBox.expand(0d,-0.40234375,0d).contract(0.001D, 0.001D, 0.001D); int i1=(int)Math.floor(zaabb.minX); int i2=(int)Math.floor(zaabb.maxX)+1; int j1=(int)Math.floor(zaabb.minY); int j2=(int)Math.floor(zaabb.maxY)+1; int k1=(int)Math.floor(zaabb.minZ); int k2=(int)Math.floor(zaabb.maxZ)+1; if (!xworld.checkChunksExist(i1,j1,k1,i2,j2,k2)) {return y;} int i,j,k; Block zblock=null; for(i=i1;i<i2;i++){ for(j=j1;j<j2;j++){ for(k=k1;k<k2;k++){ zblock=xworld.getBlock(i,j,k); if(zblock==null){continue;} if(zblock.getMaterial()!=Material.water){continue;} if(j2<j+1-BlockLiquid.getLiquidHeightPercent(xworld.getBlockMetadata(i,j,k))){continue;} zblock.velocityToAddToEntity(xworld,i,j,k,x,y); } } } if(y.lengthVector()>0&&x.isPushedByWater()) { y=y.normalize(); y.xCoord=x.motionX*0.15+y.xCoord*0.0119; y.yCoord=x.motionY*0.15+y.yCoord*0.0119; y.zCoord=x.motionZ*0.15+y.zCoord*0.0119; } return y; } -
Entities can be pushed by water. How to get the speed part pushed by water? The code is expected as below: public static Vec3 getSpeedPartByWater(Eneity x){ Vec3 y=㊣㊣㊣㊣㊣; ㊣㊣㊣㊣㊣ ㊣㊣㊣㊣㊣ ㊣㊣㊣㊣㊣ return y; } example : make a player move 2x in water Vec3 playerSpeedPartByWater=getSpeedPartByWater(player); player.moveEntity(player.motionX-playerSpeedPartByWater.xCoord , player.motionY-playerSpeedPartByWater.yCoord, player.motionZ-playerSpeedPartByWater.zCoord);
-
[1.7.10]How to make a StructureComponent generated in explored area?
D0431791 replied to D0431791's topic in Modder Support
Now some components can be generated. The basic code looks like this: public class _SS extends StructureStart{ public _SS(World xw,Random xr,int xx,int xy,int xz){ StructureComponent yy=new ComponentScatteredFeaturePieces.DesertPyramid(xr,xx,xz); components.add(yy); boundingBox=new StructureBoundingBox(xx-80,0,xz-80,xx+80,255,xz+80); yy.buildComponent(yy, components, xr); generateStructure(xw, xr, boundingBox); updateBoundingBox(); } } Using new _SS(xw,xr,xx,xy,xz); can create a Desert Temple without the underground chest room. However, we need to do advanced researching for how to correctly create the full structure for indivisual structures. -
It seems that every StructureComponent generates before its location is visited. Now I want to make a mod that generates a StructureComponent in explored area. Example : Steve places a "Desert Temple Sapling" in visited ocean and lets it grow a desert temple. I have tried buildComponent, but nothing was generated. The search engines only gave me unrelated information, like how to add a new village house type. How to make such "Desert Temple Sapling" works?