forked from Automat-GH/minecrift
/
EntityPlayerSP.java.patch
715 lines (687 loc) · 23.8 KB
/
EntityPlayerSP.java.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
--- a/net/minecraft/client/entity/EntityPlayerSP.java
+++ b/net/minecraft/client/entity/EntityPlayerSP.java
@@ -1,5 +1,17 @@
package net.minecraft.client.entity;
+import java.lang.reflect.Field;
+
+import com.mtbs3d.minecrift.api.IRoomscaleAdapter;
+import com.mtbs3d.minecrift.provider.MCOpenVR;
+import com.mtbs3d.minecrift.provider.OpenVRPlayer;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockLiquid;
+import net.minecraft.block.material.Material;
+import com.mtbs3d.minecrift.settings.VRSettings;
+import com.mtbs3d.minecrift.utils.Utils;
+
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiCommandBlock;
@@ -26,11 +38,14 @@
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.item.EntityMinecartHopper;
import net.minecraft.entity.passive.EntityHorse;
+import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
+import net.minecraft.src.Reflector;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityBeacon;
import net.minecraft.tileentity.TileEntityBrewingStand;
@@ -47,6 +62,7 @@
import net.minecraft.util.MovementInput;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Session;
+import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntityPlayerSP extends AbstractClientPlayer
@@ -61,6 +77,19 @@
*/
protected int sprintToggleTimer;
+ // VIVE START - teleport movement
+ public int movementTeleportTimer;
+ // VIVE END - teleport movement
+
+
+ /** MINECRIFT **/
+ public float headPitch = 0;
+ public double additionX = 0;
+ public double additionZ = 0;
+ public double additionY = 0;
+ public final float PIOVER180 = (float)Math.PI / 180.0F;
+ /** END MINECRIFT **/
+
/** Ticks left before sprinting is disabled. */
public int sprintingTicksLeft;
public float renderArmYaw;
@@ -80,13 +109,46 @@
public float prevTimeInPortal;
private static final String __OBFID = "CL_00000938";
+
public EntityPlayerSP(Minecraft p_i1238_1_, World p_i1238_2_, Session p_i1238_3_, int p_i1238_4_)
{
super(p_i1238_2_, p_i1238_3_.getProfile());
this.mc = p_i1238_1_;
this.dimension = p_i1238_4_;
+
}
+ //VIVECRAFT
+ protected Field inuse, inusedur;
+
+ public void setItemInUseClient(ItemStack item){
+ if(this.inuse==null){
+ return;
+ }
+
+ try {
+ this.inuse.set(this, item);
+ } catch (IllegalArgumentException e) {
+ } catch (Exception e) {
+ }
+ }
+
+
+ public void setItemInUseCountClient(int count){
+ if(this.inusedur==null){
+ return;
+ }
+
+ try {
+ this.inusedur.set(this, count);
+ } catch (IllegalArgumentException e) {
+ } catch (Exception e) {
+ }
+ }
+
+ //END VIVECRAFT
+
+
public void updateEntityActionState()
{
super.updateEntityActionState();
@@ -99,6 +161,7 @@
this.renderArmYaw = (float)((double)this.renderArmYaw + (double)(this.rotationYaw - this.renderArmYaw) * 0.5D);
}
+
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
@@ -182,7 +245,9 @@
}
boolean var1 = this.movementInput.jump;
- float var2 = 0.8F;
+ /** MINECRIFT */
+ float var2 = 0.8F * this.mc.vrSettings.movementSpeedMultiplier;
+ /** END MINECRIFT */
boolean var3 = this.movementInput.moveForward >= var2;
this.movementInput.updatePlayerMoveState();
@@ -195,20 +260,28 @@
if (this.movementInput.sneak && this.yOffset2 < 0.2F)
{
- this.yOffset2 = 0.2F;
+ // VIVE NON NON SVP this.yOffset2 = 0.2F;
}
- this.pushOutOfBlocks(this.posX - (double)this.width * 0.35D, this.boundingBox.minY + 0.5D, this.posZ + (double)this.width * 0.35D);
- this.pushOutOfBlocks(this.posX - (double)this.width * 0.35D, this.boundingBox.minY + 0.5D, this.posZ - (double)this.width * 0.35D);
- this.pushOutOfBlocks(this.posX + (double)this.width * 0.35D, this.boundingBox.minY + 0.5D, this.posZ - (double)this.width * 0.35D);
- this.pushOutOfBlocks(this.posX + (double)this.width * 0.35D, this.boundingBox.minY + 0.5D, this.posZ + (double)this.width * 0.35D);
+ //VIVE CRAWLING
+
+ this.pushOutOfBlocks(this.posX - (double)this.width * 0.35D, this.boundingBox.minY + this.height, this.posZ + (double)this.width * 0.35D);
+ this.pushOutOfBlocks(this.posX - (double)this.width * 0.35D, this.boundingBox.minY + this.height, this.posZ - (double)this.width * 0.35D);
+
+ this.pushOutOfBlocks(this.posX + (double)this.width * 0.35D, this.boundingBox.minY + this.height, this.posZ - (double)this.width * 0.35D);
+ this.pushOutOfBlocks(this.posX + (double)this.width * 0.35D, this.boundingBox.minY + this.height, this.posZ + (double)this.width * 0.35D);
+
+ //CRAWLING
+
boolean var4 = (float)this.getFoodStats().getFoodLevel() > 6.0F || this.capabilities.allowFlying;
if (this.onGround && !var3 && this.movementInput.moveForward >= var2 && !this.isSprinting() && var4 && !this.isUsingItem() && !this.isPotionActive(Potion.blindness))
{
if (this.sprintToggleTimer <= 0 && !this.mc.gameSettings.keyBindSprint.getIsKeyPressed())
{
- this.sprintToggleTimer = 7;
+ //VIVECRAFT
+ this.sprintToggleTimer = 14;
+ //END VIVECRAFT
}
else
{
@@ -252,7 +325,7 @@
this.motionY += 0.15D;
}
}
-
+
if (this.isRidingHorse())
{
if (this.horseJumpPowerCounter < 0)
@@ -296,6 +369,10 @@
super.onLivingUpdate();
+ // VIVE START - teleport movement
+ mc.vrPlayer.onLivingUpdate(this, this.mc, this.rand);
+ // VIVE END - teleport movement
+
if (this.onGround && this.capabilities.isFlying)
{
this.capabilities.isFlying = false;
@@ -341,7 +418,14 @@
var1 *= 1.0F - var4 * 0.15F;
}
- return var1;
+ /** MINECRIFT FORGE **/
+ if (Reflector.forgeExists()) {
+ return (Float)Reflector.call(Reflector.ForgeHooksClient_getOffsetFov, new Object[] {this, var1});
+ }
+ else {
+ return var1;
+ }
+ /** END MINECRIFT FORGE **/
}
/**
@@ -524,70 +608,168 @@
{
return this.worldObj.getBlock(p_71153_1_, p_71153_2_, p_71153_3_).isNormalCube();
}
-
+ /** MINECRIFT FORGE **/
+ private boolean isHeadspaceFree(int x, int y, int z, int height)
+ {
+ for (int i1 = 0; i1 < height; i1++)
+ {
+ if (isBlockNormal(x, y + i1, z + 1)) return false;
+ }
+ return true;
+ }
+ /** END MINECRIFT FORGE **/
protected boolean pushOutOfBlocks(double x, double y, double z)
{
- int var7 = MathHelper.floor_double(x);
- int var8 = MathHelper.floor_double(y);
- int var9 = MathHelper.floor_double(z);
- double var10 = x - (double)var7;
- double var12 = z - (double)var9;
-
- if (this.isBlockNormal(var7, var8, var9) || this.isBlockNormal(var7, var8 + 1, var9))
+ if (this.noClip)
{
- boolean var14 = !this.isBlockNormal(var7 - 1, var8, var9) && !this.isBlockNormal(var7 - 1, var8 + 1, var9);
- boolean var15 = !this.isBlockNormal(var7 + 1, var8, var9) && !this.isBlockNormal(var7 + 1, var8 + 1, var9);
- boolean var16 = !this.isBlockNormal(var7, var8, var9 - 1) && !this.isBlockNormal(var7, var8 + 1, var9 - 1);
- boolean var17 = !this.isBlockNormal(var7, var8, var9 + 1) && !this.isBlockNormal(var7, var8 + 1, var9 + 1);
- byte var18 = -1;
- double var19 = 9999.0D;
+ return false;
+ }
+
+ /** MINECRIFT FORGE **/
+ if (Reflector.forgeExists()) {
+
+ int i = MathHelper.floor_double(x);
+ int j = MathHelper.floor_double(y);
+ int k = MathHelper.floor_double(z);
+ double d3 = x - (double)i;
+ double d4 = z - (double)k;
- if (var14 && var10 < var19)
- {
- var19 = var10;
- var18 = 0;
- }
+ int entHeight = Math.max(Math.round(this.height), 1);
- if (var15 && 1.0D - var10 < var19)
- {
- var19 = 1.0D - var10;
- var18 = 1;
- }
+ boolean inTranslucentBlock = true;
- if (var16 && var12 < var19)
+ for (int i1 = 0; i1 < entHeight; i1++)
{
- var19 = var12;
- var18 = 4;
+ if (!this.isBlockNormal(i, j + i1, k))
+ {
+ inTranslucentBlock = false;
+ }
}
- if (var17 && 1.0D - var12 < var19)
+ if (inTranslucentBlock)
{
- var19 = 1.0D - var12;
- var18 = 5;
- }
+ boolean flag = !isHeadspaceFree(i - 1, j, k, entHeight);
+ boolean flag1 = !isHeadspaceFree(i + 1, j, k, entHeight);
+ boolean flag2 = !isHeadspaceFree(i, j, k - 1, entHeight);
+ boolean flag3 = !isHeadspaceFree(i, j, k + 1, entHeight);
+ byte b0 = -1;
+ double d5 = 9999.0D;
- float var21 = 0.1F;
+ if (flag && d3 < d5)
+ {
+ d5 = d3;
+ b0 = 0;
+ }
- if (var18 == 0)
- {
- this.motionX = (double)(-var21);
- }
+ if (flag1 && 1.0D - d3 < d5)
+ {
+ d5 = 1.0D - d3;
+ b0 = 1;
+ }
- if (var18 == 1)
- {
- this.motionX = (double)var21;
- }
+ if (flag2 && d4 < d5)
+ {
+ d5 = d4;
+ b0 = 4;
+ }
- if (var18 == 4)
- {
- this.motionZ = (double)(-var21);
+ if (flag3 && 1.0D - d4 < d5)
+ {
+ d5 = 1.0D - d4;
+ b0 = 5;
+ }
+
+ float f = 0.1F;
+
+ if (b0 == 0)
+ {
+ this.motionX = (double)(-f);
+ }
+
+ if (b0 == 1)
+ {
+ this.motionX = (double)f;
+ }
+
+ if (b0 == 4)
+ {
+ this.motionZ = (double)(-f);
+ }
+
+ if (b0 == 5)
+ {
+ this.motionZ = (double)f;
+ }
}
+ }
+ else {
+ int var7 = MathHelper.floor_double(x);
+ int var8 = MathHelper.floor_double(y);
+ int var9 = MathHelper.floor_double(z);
+ double var10 = x - (double)var7;
+ double var12 = z - (double)var9;
+
+ //CRAWLING
+ boolean tall = Math.floor(this.height) > 0;
+ //
+
+ if ((tall && this.isBlockNormal(var7, var8 - 1 , var9)) || this.isBlockNormal(var7, var8, var9))
+ {
+ boolean var14 = !this.isBlockNormal(var7 - 1, var8, var9) && !this.isBlockNormal(var7 - 1, var8 + 1, var9);
+ boolean var15 = !this.isBlockNormal(var7 + 1, var8, var9) && !this.isBlockNormal(var7 + 1, var8 + 1, var9);
+ boolean var16 = !this.isBlockNormal(var7, var8, var9 - 1) && !this.isBlockNormal(var7, var8 + 1, var9 - 1);
+ boolean var17 = !this.isBlockNormal(var7, var8, var9 + 1) && !this.isBlockNormal(var7, var8 + 1, var9 + 1);
+ byte var18 = -1;
+ double var19 = 9999.0D;
- if (var18 == 5)
- {
- this.motionZ = (double)var21;
+ if (var14 && var10 < var19)
+ {
+ var19 = var10;
+ var18 = 0;
+ }
+
+ if (var15 && 1.0D - var10 < var19)
+ {
+ var19 = 1.0D - var10;
+ var18 = 1;
+ }
+
+ if (var16 && var12 < var19)
+ {
+ var19 = var12;
+ var18 = 4;
+ }
+
+ if (var17 && 1.0D - var12 < var19)
+ {
+ var19 = 1.0D - var12;
+ var18 = 5;
+ }
+
+ float var21 = 0.1F;
+
+ if (var18 == 0)
+ {
+ this.motionX = (double)(-var21);
+ }
+
+ if (var18 == 1)
+ {
+ this.motionX = (double)var21;
+ }
+
+ if (var18 == 4)
+ {
+ this.motionZ = (double)(-var21);
+ }
+
+ if (var18 == 5)
+ {
+ this.motionZ = (double)var21;
+ }
}
}
+ /** END MINECRIFT FORGE **/
return false;
}
@@ -640,6 +822,15 @@
public void playSound(String name, float volume, float pitch)
{
+ /** MINECRIFT FORGE **/
+ if (Reflector.forgeExists()) {
+ Object event = Reflector.newInstance(Reflector.ForgePlaySoundAtEntityEvent_Constructor, new Object[] {this, name, volume, pitch});
+ if (Reflector.postForgeBusEvent(event)) {
+ return;
+ }
+ name = (String)Reflector.getFieldValue(event, Reflector.ForgePlaySoundAtEntityEvent_name);
+ }
+ /** END MINECRIFT FORGE **/
this.worldObj.playSound(this.posX, this.posY - (double)this.yOffset, this.posZ, name, volume, pitch, false);
}
@@ -662,4 +853,283 @@
}
protected void sendHorseJump() {}
+
+
+ /**** MINECRIFT ADDITIONS BELOW ****/
+
+
+ /** MINECRIFT **/
+ public void doDrag()
+ {
+
+
+ float var3 = 0.91F;
+
+ if (this.onGround)
+ {
+ var3 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.91F;
+ }
+
+ double xFactor = var3;
+ double zFactor = var3;
+
+ //VIVECRAFT account for stock drag code we can't change in EntityLivingBase
+ this.motionX /= xFactor;
+ this.motionZ /= zFactor;
+ //
+
+ int inertiaFactor = Minecraft.getMinecraft().vrSettings.inertiaFactor;
+ double addFactor = VRSettings.getInertiaAddFactor(inertiaFactor);
+
+ double boundedAdditionX = getBoundedAddition(additionX);
+ double targetLimitX = (var3 * boundedAdditionX) / (1f - var3);
+ double multiFactorX = targetLimitX / (var3 * (targetLimitX + (boundedAdditionX * addFactor)));
+ xFactor *= multiFactorX;
+
+ double boundedAdditionZ = getBoundedAddition(additionZ);
+ double targetLimitZ = (var3 * boundedAdditionZ) / (1f - var3);
+ double multiFactorZ = targetLimitZ / (var3 * (targetLimitZ + (boundedAdditionZ * addFactor)));
+ zFactor *= multiFactorZ;
+
+
+ this.motionX *= xFactor;
+ this.motionZ *= zFactor;
+ }
+
+ public double getBoundedAddition(double orig)
+ {
+ if (orig >= -1.0E-6D && orig <= 1.0E-6D) {
+ return 1.0E-6D;
+ }
+ else {
+ return orig;
+ }
+ }
+
+
+ /**
+ * Used in both water and by flying objects
+ */
+ @Override
+ public void moveFlying(float strafe, float forward, float friction)
+ {
+// super.moveFlying(strafe, forward, friction);;
+
+ OpenVRPlayer vr = mc.vrPlayer;
+ if (!vr.getFreeMoveMode()) {return;}
+
+ int inertiaFactor = Minecraft.getMinecraft().vrSettings.inertiaFactor;
+ float speed = strafe * strafe + forward * forward;
+
+ double mX = 0d;
+ double mZ = 0d;
+ double mY = 0d;
+ double addFactor = 1f;
+
+ if (speed >= 1.0E-4F)
+ {
+ speed = MathHelper.sqrt_float(speed);
+
+ if (speed < 1.0F)
+ {
+ speed = 1.0F;
+ }
+
+ speed = friction / speed;
+ strafe *= speed;
+ forward *= speed;
+
+ Vec3 directionVec = Vec3.createVectorHelper(strafe, 0, forward);
+
+ //VIVE DO PITCH FLYING
+
+ IRoomscaleAdapter con = mc.roomScale;
+
+ // Account for pitch if required
+ if(mc.vrSettings.seated){
+ directionVec=directionVec.rotateYaw(-con.getControllerOffhandYaw_World() * PIOVER180);
+ }else{
+ if(this.capabilities.isFlying || this.inWater){
+ switch (mc.vrSettings.vrFreeMoveMode){
+ case VRSettings.FREEMOVE_CONTROLLER:
+ directionVec.rotateAroundX(con.getControllerOffhandPitch_World() * PIOVER180);
+ break;
+ case VRSettings.FREEMOVE_HMD:
+ directionVec.rotateAroundX(con.getHMDPitch_World()* PIOVER180);
+ break;
+ case VRSettings.FREEMOVE_RUNINPLACE:
+ //hmd pitch
+ directionVec.rotateAroundX(con.getHMDPitch_World()* PIOVER180);
+ break;
+ }
+ }
+
+ switch (mc.vrSettings.vrFreeMoveMode){
+ case VRSettings.FREEMOVE_CONTROLLER:
+ directionVec.rotateAroundY(-con.getControllerOffhandYaw_World() * PIOVER180);
+ break;
+ case VRSettings.FREEMOVE_HMD:
+ directionVec.rotateAroundY(-con.getHMDYaw_World() * PIOVER180);
+ break;
+ case VRSettings.FREEMOVE_RUNINPLACE:
+ directionVec=directionVec.rotateYaw((float) (-mc.runTracker.getYaw() * PIOVER180));
+ directionVec=directionVec.scale(mc.runTracker.getSpeed());
+ break;
+ }
+ }
+
+ mX = directionVec.xCoord;
+ mY = directionVec.yCoord;
+ mZ = directionVec.zCoord;
+
+ // Modify acceleration sequence (each tick)
+ if(!this.capabilities.isFlying && !this.inWater) addFactor = VRSettings.getInertiaAddFactor(inertiaFactor);
+
+ float yAdd = 1f;
+ if(this.capabilities.isFlying) yAdd = 3f; //HACK
+
+ this.motionX = this.motionX + (mX * addFactor);
+ this.motionZ = this.motionZ + (mZ * addFactor);
+ this.motionY = this.motionY + (mY * yAdd);
+
+ this.additionX = mX;
+ this.additionZ = mZ;
+ }
+
+ //if (this instanceof EntityPlayerSP) {
+ // System.out.println(String.format("FLYING: %B, forward: %.4f, strafe: %.4f, pitch: %.4f, yaw: %.4f, mx: %.4f, mz: %.4f, my: %.4f", allowYAdjust, forward, strafe, this.headPitch, this.rotationYaw, mX, mZ, mY));
+ //}
+
+
+ if(!this.capabilities.isFlying && !this.inWater) doDrag(); //TODO put back intertia while flying.. doesnt work for some reason.
+
+/** END MINECRIFT **/
+
+ }
+
+ /**
+ * Checks if the current block the entity is within of the specified material type
+ */
+ @Override
+ public boolean isInsideOfMaterial(Material materialIn)
+ {
+ double var2 = this.posY + (double) this.getEyeHeight(); // TODO: Use actual centre-eye position
+ int var4 = MathHelper.floor_double(this.posX);
+ int var5 = MathHelper.floor_float((float) MathHelper.floor_double(var2));
+ int var6 = MathHelper.floor_double(this.posZ);
+ Block var7 = this.worldObj.getBlock(var4, var5, var6);
+
+ if (var7.getMaterial() == materialIn)
+ {
+ float var8 = BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata(var4, var5, var6)) - 0.11111111F;
+ float var9 = (float) (var5 + 1) - var8;
+ return var2 < (double) var9;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public boolean initFromServer = false;
+ public void setPositionAndRotation(double x, double y, double z, float yaw, float pitch)
+ {
+ super.setPositionAndRotation(x, y, z, yaw, pitch);
+
+ OpenVRPlayer.get().snapRoomOriginToPlayerEntity(this, true, false);
+
+ if(initFromServer == false){
+ initFromServer = true;
+ }
+ }
+
+ public void readFromNBT(NBTTagCompound tagCompund)
+ {
+ super.readFromNBT(tagCompund);
+ }
+
+ /**
+ * Sets the location and Yaw/Pitch of an entity in the world
+ */
+ @Override
+ public void setLocationAndAngles(double x, double y, double z, float yaw, float pitch)
+ {
+
+// Vec3 roomOrigin = OpenVRPlayer.get().getRoomOriginPos_World();
+// double ox = roomOrigin.xCoord - posX;
+// double oz = roomOrigin.zCoord - posZ;
+//
+ super.setLocationAndAngles(x, y, z, yaw, pitch);
+
+ if(!initFromServer) return;
+ else { //still init.
+ mc.vrPlayer.snapRoomOriginToPlayerEntity(this, true, false);
+
+// OpenVRPlayer.get().setRoomOrigin(
+// posX + ox,
+// this.boundingBox.minY,
+// posZ + oz, false);
+ }
+ }
+
+ // VIVE START - update room origin when player entity is moved
+ public void setPosition(double x, double y, double z)
+ { //this is also called when riding to move this around.
+ if(this.isRiding()){
+ Vec3 roomOrigin = OpenVRPlayer.get().getRoomOriginPos_World();
+ double ox = roomOrigin.xCoord - posX;
+ double oz = roomOrigin.zCoord - posZ;
+ super.setPosition(x, y, z);
+ OpenVRPlayer.get().setRoomOrigin(
+ posX + ox,
+ this.ridingEntity.boundingBox.minY,
+ posZ + oz, false, false);
+
+ } else
+ super.setPosition(x, y, z);
+
+ }
+
+ @Override
+ public void moveEntity(double x, double y, double z)
+ {
+ boolean client = this instanceof EntityPlayerSP;
+ boolean freemove = OpenVRPlayer.get().getFreeMoveMode();
+ boolean doY = freemove || (Minecraft.getMinecraft().vrSettings.simulateFalling && !this.isOnLadder()) && !this.isSneaking();
+
+ Vec3 roomOrigin = OpenVRPlayer.get().getRoomOriginPos_World();
+ // Vec3 camloc = Minecraft.getMinecraft().roomScale.getHMDPos_World();
+
+ if (this.isRiding() || freemove && (this.moveForward != 0 || Math.abs(this.motionX) > 0.01 || Math.abs(this.motionZ) > 0.01))
+ {
+ double ox = roomOrigin.xCoord - posX;
+ double oz = roomOrigin.zCoord - posZ;
+ super.moveEntity(x,y,z);
+
+ if (client){
+ double oy = this.boundingBox.minY;
+ if (this.isRiding()) oy = this.ridingEntity.boundingBox.minY;
+ OpenVRPlayer.get().setRoomOrigin(
+ posX + ox,
+ oy,
+ posZ + oz, false, false);
+ }
+ } else {
+ if(doY) {
+ super.moveEntity(0,y,0);
+ if (client){
+ OpenVRPlayer.get().setRoomOrigin(
+ OpenVRPlayer.get().getRoomOriginPos_World().xCoord,
+ this.boundingBox.minY,
+ OpenVRPlayer.get().getRoomOriginPos_World().zCoord, false, false);
+ }
+
+ } else {
+ this.onGround = true; //
+ //do not move player, VRPlayer.moveplayerinroom will move him around.
+ }
+ }
+ }
+
+
}