Posted December 11, 20168 yr I've been trying to get the server and client instances of an entity I've been working on synchronized properly. I'm using packets to send data from the server instance to the client, but I can't find a way to identify the entity on arrival. I tried entityID and UUID, but both seem to be different between the client and server instances. Any suggestions? thanks.
December 11, 20168 yr Use net.minecraft.entity.Entity#getEntityId. It should be same. If it doesn't help, show the synchronisation code.
December 12, 20168 yr Author I had it print out the ID via this.getEntityId() when it spawns, and I got this: 75495 Spawning via Item... Client?false 75495 Sending... Client? false 75496 Spawning... Client?true the only one I'm spawning is the top one, and the bottom one is client-side, so it's spawning properly, but it's entityID is different. ...wait... this is really weird. I guess it does work, but I had a few typos in my receiving code. So even though it wasn't showing a different ID, but it was working. Well, thanks for helping. EntityId looks like the way to go. WAIT A MINUTE it's sending it to a client version of the entity, but I can't see it! it's invisible, or somewhere else! here's the code that's run in my packetHandler when the IMessageHandler receives a message: [embed=425,349] public void clientReceiveString(String s1, MessageContext ctx) { int md = s1.indexOf("/"); String s2 = s1.substring(0, md).trim(); String s3 = s1.substring(md+1).trim(); entityBiplane tP = null; if (Minecraft.getMinecraft().theWorld.getEntityByID(Integer.valueOf(s2)) != null) if (Minecraft.getMinecraft().theWorld.getEntityByID(Integer.valueOf(s2)) instanceof entityBiplane) tP = (entityBiplane)Minecraft.getMinecraft().theWorld.getEntityByID(Integer.valueOf(s2)); if (tP != null) { tP.decodePacket(s3); } }[/embed] and this is what's called in entityBiplane: [embed=425,349]public boolean decodePacket(String s1) { System.out.printf(this.getEntityId()+" Received: "+s1+" Client? "+this.worldObj.isRemote+"\n"); int md = s1.indexOf("/"); String s2 = s1.substring(0, md).trim(); String s3 = s1.substring(md+1).trim(); if (s2.contains("owner")) { this.ownerID = s3.trim(); return true; } if (s2.contains("pitch")) { this.pitch = Float.valueOf(s3); return true; } if (s2.contains("yaw")) { this.yaw = Float.valueOf(s3); return true; } if (s2.contains("roll")) { this.roll = Float.valueOf(s3); return true; } if (s2.contains("rotorSpeed")) { this.rotorSpeed = Double.valueOf(s3); return true; } if (s2.contains("seatPosX")) { this.seatPos.x = Double.valueOf(s3); return true; } if (s2.contains("seatPosY")) { this.seatPos.y = Double.valueOf(s3); return true; } if (s2.contains("seatPosZ")) { this.seatPos.z = Double.valueOf(s3); return true; } int sx = Integer.valueOf(s2); if (sx < this.maxWidth) { md = s3.indexOf("/"); if (md == -1) return false; s2 = s3.substring(0, md).trim(); s3 = s3.substring(md+1).trim(); int sy = Integer.valueOf(s2); if (sy < this.maxHeight) { md = s3.indexOf("/"); if (md == -1) return false; s2 = s3.substring(0, md).trim(); s3 = s3.substring(md+1).trim(); int sz = Integer.valueOf(s2); if (sz < this.maxDepth) { md = s3.indexOf("/"); if (md == -1) return false; s2 = s3.substring(0, md).trim(); s3 = s3.substring(md+1).trim(); if (s2 == "BLOCKDAT") { if (s3.contains("/") && getPart(sx,sy,sz) != null) { md = s3.indexOf("/"); if (md == -1) return false; s2 = s3.substring(0, md).trim(); s3 = s3.substring(md+1).trim(); getPart(sx,sy,sz).decodePacket(s2, s3); //TODO return true; } else { md = s3.indexOf(":"); if (md == -1) return false; s2 = s3.substring(0, md).trim(); s3 = s3.substring(md+1).trim(); if (materialHandler.getPart(s2) != null) { //if (!s2.contains("NULL")) System.out.printf(s2+"\n"); setPart(materialHandler.getPart(s2).newInstance(),sx,sy,sz); //getPart(sx,sy,sz).readFromNBT(NBT,sx,sy,sz); getPart(sx,sy,sz).updateTexture(); return true; } } } else if (s2 == "INBLOCKDAT") { if (s3.contains("/") && getInPart(sx,sy,sz) != null) { md = s3.indexOf("/"); if (md == -1) return false; s2 = s3.substring(0, md).trim(); s3 = s3.substring(md+1).trim(); getInPart(sx,sy,sz).decodePacket(s2, s3); //TODO return true; } else { md = s3.indexOf(":"); if (md == -1) return false; s2 = s3.substring(0, md).trim(); s3 = s3.substring(md+1).trim(); if (materialHandler.getInPart(s2) != null) { //if (!s2.contains("NULL")) System.out.printf(s2+"\n"); setInPart(materialHandler.getInPart(s2).newInstance(),sx,sy,sz); //getInPart(sx,sy,sz).readFromNBT(NBT,sx,sy,sz); getInPart(sx,sy,sz).updateTexture(); return true; } } } } } } return false; }[/embed] and this is what comes up on the console when I spawn the entity: [embed=425,349]134459 Spawning via Item... Client?false 134459 Sending... Client? false 134460 Spawning... Client?true Received 134459/pitch/0.0 134459 Received: pitch/0.0 Client? true Received 134459/yaw/180.0 134459 Received: yaw/180.0 Client? true Received 134459/roll/0.0 134459 Received: roll/0.0 Client? true Received 134459/rotorSpeed/0.0 134459 Received: rotorSpeed/0.0 Client? true Received 134459/seatPosX/0.0 134459 Received: seatPosX/0.0 Client? true Received 134459/seatPosY/1.5 134459 Received: seatPosY/1.5 Client? true Received 134459/seatPosZ/2.5 134459 Received: seatPosZ/2.5 Client? true Received 134459/5/0/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 5/0/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/5/0/6/BLOCKDAT:BLOCKoakWood 134459 Received: 5/0/6/BLOCKDAT:BLOCKoakWood Client? true Received 134459/5/0/6/BLOCKDAT:BOTTOMWINGoakWood 134459 Received: 5/0/6/BLOCKDAT:BOTTOMWINGoakWood Client? true Received 134459/5/1/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 5/1/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/5/1/6/BLOCKDAT:BLOCKoakWood 134459 Received: 5/1/6/BLOCKDAT:BLOCKoakWood Client? true Received 134459/5/1/6/BLOCKDAT:TOPWINGoakWood 134459 Received: 5/1/6/BLOCKDAT:TOPWINGoakWood Client? true Received 134459/6/0/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 6/0/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/6/0/6/BLOCKDAT:BLOCKoakWood 134459 Received: 6/0/6/BLOCKDAT:BLOCKoakWood Client? true Received 134459/6/0/6/BLOCKDAT:BOTTOMWINGoakWood 134459 Received: 6/0/6/BLOCKDAT:BOTTOMWINGoakWood Client? true Received 134459/6/0/9/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 6/0/9/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/6/0/9/BLOCKDAT:BLOCKoakWood 134459 Received: 6/0/9/BLOCKDAT:BLOCKoakWood Client? true Received 134459/6/0/9/BLOCKDAT:TOPWINGoakWood 134459 Received: 6/0/9/BLOCKDAT:TOPWINGoakWood Client? true Received 134459/6/1/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 6/1/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/6/1/6/BLOCKDAT:BLOCKoakWood 134459 Received: 6/1/6/BLOCKDAT:BLOCKoakWood Client? true Received 134459/6/1/6/BLOCKDAT:TOPWINGoakWood 134459 Received: 6/1/6/BLOCKDAT:TOPWINGoakWood Client? true Received 134459/7/0/6/BLOCKDAT/PLATING:PLATINGsteelPlating 134459 Received: 7/0/6/BLOCKDAT/PLATING:PLATINGsteelPlating Client? true Received 134459/7/0/6/BLOCKDAT:BLOCKsteel 134459 Received: 7/0/6/BLOCKDAT:BLOCKsteel Client? true Received 134459/7/0/7/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 7/0/7/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/7/0/7/BLOCKDAT:BLOCKoakWood 134459 Received: 7/0/7/BLOCKDAT:BLOCKoakWood Client? true Received 134459/7/0/8/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 7/0/8/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/7/0/8/BLOCKDAT:BLOCKoakWood 134459 Received: 7/0/8/BLOCKDAT:BLOCKoakWood Client? true Received 134459/7/0/9/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 7/0/9/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/7/0/9/BLOCKDAT:BLOCKoakWood 134459 Received: 7/0/9/BLOCKDAT:BLOCKoakWood Client? true Received 134459/7/0/9/BLOCKDAT:TOPSLABoakWood 134459 Received: 7/0/9/BLOCKDAT:TOPSLABoakWood Client? true Received 134459/7/1/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 7/1/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/7/1/6/BLOCKDAT:BLOCKoakWood 134459 Received: 7/1/6/BLOCKDAT:BLOCKoakWood Client? true Received 134459/7/1/6/BLOCKDAT:TOPWINGoakWood 134459 Received: 7/1/6/BLOCKDAT:TOPWINGoakWood Client? true Received 134459/7/1/9/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 7/1/9/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/7/1/9/BLOCKDAT:CENTERSToakWood 134459 Received: 7/1/9/BLOCKDAT:CENTERSToakWood Client? true Received 134459/8/0/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 8/0/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/8/0/6/BLOCKDAT:BLOCKoakWood 134459 Received: 8/0/6/BLOCKDAT:BLOCKoakWood Client? true Received 134459/8/0/6/BLOCKDAT:BOTTOMWINGoakWood 134459 Received: 8/0/6/BLOCKDAT:BOTTOMWINGoakWood Client? true Received 134459/8/0/9/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 8/0/9/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/8/0/9/BLOCKDAT:BLOCKoakWood 134459 Received: 8/0/9/BLOCKDAT:BLOCKoakWood Client? true Received 134459/8/0/9/BLOCKDAT:TOPWINGoakWood 134459 Received: 8/0/9/BLOCKDAT:TOPWINGoakWood Client? true Received 134459/8/1/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 8/1/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/8/1/6/BLOCKDAT:BLOCKoakWood 134459 Received: 8/1/6/BLOCKDAT:BLOCKoakWood Client? true Received 134459/8/1/6/BLOCKDAT:TOPWINGoakWood 134459 Received: 8/1/6/BLOCKDAT:TOPWINGoakWood Client? true Received 134459/9/0/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 9/0/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/9/0/6/BLOCKDAT:BLOCKoakWood 134459 Received: 9/0/6/BLOCKDAT:BLOCKoakWood Client? true Received 134459/9/0/6/BLOCKDAT:BOTTOMWINGoakWood 134459 Received: 9/0/6/BLOCKDAT:BOTTOMWINGoakWood Client? true Received 134459/9/1/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating 134459 Received: 9/1/6/BLOCKDAT/PLATING:PLATINGoakWoodPlating Client? true Received 134459/9/1/6/BLOCKDAT:BLOCKoakWood 134459 Received: 9/1/6/BLOCKDAT:BLOCKoakWood Client? true Received 134459/9/1/6/BLOCKDAT:TOPWINGoakWood 134459 Received: 9/1/6/BLOCKDAT:TOPWINGoakWood Client? true[/embed] the "Received ..." is generated by the IMessageHandler oh, and here's the code that spawns the entity (in an item): [embed=425,349]public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if (!player.capabilities.isCreativeMode) --itemStack.stackSize; double x, y, z; if (!world.isRemote) {//TODO ! x = player.getLookVec().xCoord + player.posX; y = player.getLookVec().yCoord + player.posY; z = player.getLookVec().zCoord + player.posZ; entityBiplane test = new entityBiplane(world,0,0,0); test.engineMake = planeType; //if (!test.worldObj.isRemote) biplanesMod.channel.sendToServer(new sendBiplaneDatC(test.getEntityId() + "/" + planeType)); if (planeType == 0) { test.blockDat[7][0][5] = new tPlaneStructDummy(); test.blockDat[7][0][6] = new tPlaneStructBlock("steel").setPlatingMaterial("steelPlating"); test.blockDat[7][0][7] = new tPlaneStructBlock("oakWood").setPlatingMaterial("oakWoodPlating"); test.blockDat[7][0][8] = new tPlaneStructBlock("oakWood").setPlatingMaterial("oakWoodPlating"); test.blockDat[7][0][9] = new tPlaneStructSlab("oakWood").setPlatingMaterial("oakWoodPlating"); test.blockDat[6][0][9] = new tPlaneStructWing("oakWood").setWingPos(2).setPlatingMaterial("oakWoodPlating"); test.blockDat[7][1][9] = new tPlaneStructStabilizer("oakWood").setWingPos(1).setPlatingMaterial("oakWoodPlating"); test.blockDat[8][0][9] = new tPlaneStructWing("oakWood").setWingPos(2).setPlatingMaterial("oakWoodPlating"); //test.blockDat[4][0][6] = new tPlaneStructWing("oakWood").setWingPos(0).setPlatingMaterial("oakWoodPlating"); test.blockDat[5][0][6] = new tPlaneStructWing("oakWood").setWingPos(0).setPlatingMaterial("oakWoodPlating"); test.blockDat[6][0][6] = new tPlaneStructWing("oakWood").setWingPos(0).setPlatingMaterial("oakWoodPlating"); test.blockDat[8][0][6] = new tPlaneStructWing("oakWood").setWingPos(0).setPlatingMaterial("oakWoodPlating"); test.blockDat[9][0][6] = new tPlaneStructWing("oakWood").setWingPos(0).setPlatingMaterial("oakWoodPlating"); //test.blockDat[10][0][6] = new tPlaneStructWing("oakWood").setWingPos(0).setPlatingMaterial("oakWoodPlating"); //test.blockDat[4][1][6] = new tPlaneStructWing("oakWood").setWingPos(2).setPlatingMaterial("oakWoodPlating"); test.blockDat[5][1][6] = new tPlaneStructWing("oakWood").setWingPos(2).setPlatingMaterial("oakWoodPlating"); test.blockDat[6][1][6] = new tPlaneStructWing("oakWood").setWingPos(2).setPlatingMaterial("oakWoodPlating"); test.blockDat[7][1][6] = new tPlaneStructWing("oakWood").setWingPos(2).setPlatingMaterial("oakWoodPlating"); test.blockDat[8][1][6] = new tPlaneStructWing("oakWood").setWingPos(2).setPlatingMaterial("oakWoodPlating"); test.blockDat[9][1][6] = new tPlaneStructWing("oakWood").setWingPos(2).setPlatingMaterial("oakWoodPlating"); //test.blockDat[10][1][6] = new tPlaneStructWing("oakWood").setWingPos(2).setPlatingMaterial("oakWoodPlating"); //test.inBlockDat[7][0][8] = new tPlaneChest(biplanesMod.chestRender); test.inBlockDat[7][0][7] = new tPlaneSeat(biplanesMod.seatRender); test.inBlockDat[7][0][6] = new tPlaneFTank(biplanesMod.fTankRender); test.inBlockDat[7][0][5] = new tPlaneEngine(biplanesMod.engineRender).setRotor(((rotorItem)biplanesMod.itemRotorWood2).rotor).setCowling(((cowlingItem)biplanesMod.itemCowling[0]).cowling); test.inBlockDat[6][0][9] = new tPlaneAileron(biplanesMod.aileronRender, "steel"); test.inBlockDat[7][1][9] = new tPlaneAileron(biplanesMod.aileronRender, "steel"); test.inBlockDat[8][0][9] = new tPlaneAileron(biplanesMod.aileronRender,"steel"); test.inBlockDat[5][1][6] = new tPlaneAileron(biplanesMod.aileronRender,"steel"); test.inBlockDat[9][1][6] = new tPlaneAileron(biplanesMod.aileronRender,"steel"); test.inBlockDat[5][0][6] = new tPlaneAileron(biplanesMod.aileronRender,"steel"); test.inBlockDat[9][0][6] = new tPlaneAileron(biplanesMod.aileronRender,"steel"); } else if (planeType == 1) { ... ... } else if (planeType == 2) { ... ... } for (int zx = 0; zx < test.maxWidth; zx++) { for (int zy = 0; zy < test.maxHeight; zy++) { for (int zz = 0; zz < test.maxDepth; zz++) { if (test.getPart(zx,zy,zz) != null) { test.getPart(zx,zy,zz).onPlaced(test, zx, zy, zz); } if (test.getInPart(zx,zy,zz) != null) { test.getInPart(zx,zy,zz).onPlaced(test, zx, zy, zz); } } } } test.calcPlaneValues(); float temp = Math.round(player.rotationYawHead/90)*90 + 180; while (temp >= 360) temp -= 360; while (temp < 0) temp += 360; test.yaw = temp; if (test.yaw == 0) { test.setPosition(Math.round(x) + 0.5, Math.round(y) - 1.0, Math.round(z) - 1.0); } else if (test.yaw == 90) { test.setPosition(Math.round(x) + 1.0, Math.round(y) - 1.0, Math.round(z) - 0.5); } else if (test.yaw == 180) { test.setPosition(Math.round(x) + 0.5, Math.round(y) - 1.0, Math.round(z) + 1.0); } else if (test.yaw == 270) { test.setPosition(Math.round(x) - 1.0, Math.round(y) - 1.0, Math.round(z) - 0.5); } test.owner = player; world.spawnEntityInWorld(test); test.sendContentsToClient(); } return itemStack; }[/embed] and... once again I'm the user who cried error. It was another interpretation bug in my code. Well, thanks again.
December 13, 20168 yr Jesus freaking christ, use a [nobbc] [/nobbc] tag! Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.