Posted March 25, 20169 yr Good days i been spend the day making again mi guns and billets in 1.9 and get in the new changes to the DataWacher in entities i use the data wacher to sync data betwin the entities in server side to entity's in client side soo i could fix a Little issue about the position and rotations, anyway scavenging code i see the changes and I'm trying to figure out how to use them in this case i wanna use <Rotations> to store values in the server side and latter retrieve client side but client side i only get zeroes this its a resume of what i get private static final DataParameter <Byte> CRITICAL = EntityDataManager.<Byte>createKey(bala9mmEntity.class, DataSerializers.BYTE); private static final DataParameter<Integer> SHOOTINGID = EntityDataManager.<Integer>createKey(bala9mmEntity.class, DataSerializers.VARINT); private static final DataParameter<Rotations> BALAPXYZ = EntityDataManager.<Rotations>createKey(bala9mmEntity.class, DataSerializers.ROTATIONS); private static final DataParameter<Rotations> BALAMXYZ = EntityDataManager.<Rotations>createKey(bala9mmEntity.class, DataSerializers.ROTATIONS); private static final DataParameter<Rotations> BALARPY = EntityDataManager.<Rotations>createKey(bala9mmEntity.class, DataSerializers.ROTATIONS); The plan is update bullet position using BALAPXYZ, update bullet motions using BALAMXYZ and update rotation pitch and yawn in BALARPY so make the init() to load the values in the entity // ############################################################################################3 protected void entityInit() { this.dataWatcher.register(CRITICAL, Byte.valueOf((byte)0)); this.dataWatcher.register(SHOOTINGID, Integer.valueOf((int)0)); //Rotation resemble Vec3D to mi Rotations PXYZ = new Rotations(0,0,0); //just for dummy reasons this.dataWatcher.register(BALAPXYZ, (PXYZ) ); this.dataWatcher.register(BALAMXYZ, (PXYZ) ); this.dataWatcher.register(BALARPY, (PXYZ) ); } and here come the troubles, in the onUpdate method i read and write the values every 10Ticks public void onUpdate() { super.onUpdate(); if ( (onUpdateTick % 10) == 0) { World worldIn = this.worldObj; Rotations PXYZ = null; if (!worldIn.isRemote) { this.dataWatcher.set(SHOOTINGID, Integer.valueOf(this.shootingEntityID)); PXYZ = new Rotations((float)this.posX, (float)this.posY, (float)this.posZ); this.dataWatcher.set(BALAPXYZ, (PXYZ) ); } else { this.shootingEntityID = ((Integer)this.dataWatcher.get(SHOOTINGID)).intValue(); PXYZ = ( this.dataWatcher.get(BALAPXYZ) ); //PXYZ = DataSerializers.ROTATIONS. .read(this.dataWatcher.get(BALAPXYZ)); this.posX = PXYZ.getX(); this.posY = PXYZ.getY(); this.posZ = PXYZ.getZ(); } System.out.println("########## onUpdate() mundo="+worldIn.isRemote+" tick="+onUpdateTick+" SHID="+this.shootingEntityID+ "\nPXYZ x="+PXYZ.getX()+" y="+PXYZ.getY()+" z="+PXYZ.getZ() ); } onUpdateTick ++; ##### what is the correct way to serialize the Rotations() object to store it in the datawacher ? Rotations PXYZ = new Rotations((float)this.posX, (float)this.posY, (float)this.posZ); this.dataWatcher.set(BALAPXYZ, (PXYZ) ); ##### and whats the rightfull way to get again the values in the client side ? Rotations PXYZ = ( this.dataWatcher.get(BALAPXYZ) ); this.posX = PXYZ.getX(); this.posY = PXYZ.getY(); this.posZ = PXYZ.getZ(); coz in the console i get [12:08:49] [server thread/INFO] [sTDOUT]: [mercenarymod.entidades.balas.bala9mmEntity:onUpdate:278]: ########## onUpdate() mundo=false tick=0 SHID=292 PXYZ x=-225.7 y=65.52 z=602.7627 [12:08:49] [Client thread/INFO] [sTDOUT]: [mercenarymod.entidades.balas.bala9mmEntity:onUpdate:278]: ########## onUpdate() mundo=true tick=0 SHID=292 PXYZ x=0.0 y=0.0 z=0.0 Soo i think i have both wrong, i need and example of this thanks for reading
March 25, 20169 yr Author if you say it becoze the lines at the begining saying private static final DataParameter <Byte> CRITICAL = EntityDataManager.<Byte>createKey(bala9mmEntity.class, DataSerializers.BYTE); private static final DataParameter<Byte> CRITICAL = EntityDataManager.<Byte>createKey(bala9mmEntity.class, DataSerializers.BYTE); private static final DataParameter<Integer> SHOOTINGID = EntityDataManager.<Integer>createKey(bala9mmEntity.class, DataSerializers.VARINT); private static final DataParameter<Integer> TARGETID = EntityDataManager.<Integer>createKey(bala9mmEntity.class, DataSerializers.VARINT); private static final DataParameter<Integer> BYNARYDATA = EntityDataManager.<Integer>createKey(bala9mmEntity.class, DataSerializers.VARINT); private static final DataParameter<Float> BALAPX = EntityDataManager.<Float>createKey(bala9mmEntity.class, DataSerializers.FLOAT); private static final DataParameter<Float> BALAPY = EntityDataManager.<Float>createKey(bala9mmEntity.class, DataSerializers.FLOAT); private static final DataParameter<Float> BALAPZ = EntityDataManager.<Float>createKey(bala9mmEntity.class, DataSerializers.FLOAT); private static final DataParameter<Float> BALAMX = EntityDataManager.<Float>createKey(bala9mmEntity.class, DataSerializers.FLOAT); private static final DataParameter<Float> BALAMY = EntityDataManager.<Float>createKey(bala9mmEntity.class, DataSerializers.FLOAT); private static final DataParameter<Float> BALAMZ = EntityDataManager.<Float>createKey(bala9mmEntity.class, DataSerializers.FLOAT); private static final DataParameter<Float> BALAPRP = EntityDataManager.<Float>createKey(bala9mmEntity.class, DataSerializers.FLOAT); private static final DataParameter<Float> BALAPRY = EntityDataManager.<Float>createKey(bala9mmEntity.class, DataSerializers.FLOAT); private static final DataParameter<Float> BALARP = EntityDataManager.<Float>createKey(bala9mmEntity.class, DataSerializers.FLOAT); private static final DataParameter<Float> BALARY = EntityDataManager.<Float>createKey(bala9mmEntity.class, DataSerializers.FLOAT); private static final DataParameter<Rotations> BALAPXYZ = EntityDataManager.<Rotations>createKey(bala9mmEntity.class, DataSerializers.ROTATIONS); private static final DataParameter<Rotations> BALAMXYZ = EntityDataManager.<Rotations>createKey(bala9mmEntity.class, DataSerializers.ROTATIONS); private static final DataParameter<Rotations> BALARPY = EntityDataManager.<Rotations>createKey(bala9mmEntity.class, DataSerializers.ROTATIONS); i du not know why. is something i take it from the entityArrow.class they declare the values in the datawacher in similar way as i declare the properties in the block class and i been experimenting whith this to know how far i can get until now looks like the limit of 32 values in the datawacher is no more a trouble for the (Rotations) i du not know whath they have in mind but i thing i could use it to replace vec3d actualy i have in mi proto bullet like 17 values in the datawacher and is working well, i only have issues with entityTracker sometimes dont spwn the client side bullet
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.