mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-28 07:35:40 +00:00
Account for client /server desync when teleporting items with magnet (#305)
This commit is contained in:
1 parent
dee1277753
commit
bfba45e796
1 file changed
+6
-2
@@ -60,9 +60,10 @@ public class WirelessMagnet {
|
|||||||
return data.hasKey(modeKey);
|
return data.hasKey(modeKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method uses the same algorithm as the magnet from draconic evolution
|
||||||
|
// if changes are ever made, they should be made on both
|
||||||
public static void doMagnet(ItemStack wirelessTerm, EntityPlayer player) {
|
public static void doMagnet(ItemStack wirelessTerm, EntityPlayer player) {
|
||||||
if (player.ticksExisted % 5 != 0 || player.isSneaking() || !isConfigured(wirelessTerm)) return;
|
if (player.ticksExisted % 5 != 0 || player.isSneaking() || !isConfigured(wirelessTerm)) return;
|
||||||
|
|
||||||
World world = player.worldObj;
|
World world = player.worldObj;
|
||||||
final List<EntityItem> items = getEntitiesInRange(
|
final List<EntityItem> items = getEntitiesInRange(
|
||||||
EntityItem.class,
|
EntityItem.class,
|
||||||
@@ -73,6 +74,9 @@ public class WirelessMagnet {
|
|||||||
magnetRange);
|
magnetRange);
|
||||||
final boolean skipPlayerCheck = world.playerEntities.size() < 2;
|
final boolean skipPlayerCheck = world.playerEntities.size() < 2;
|
||||||
boolean playSound = false;
|
boolean playSound = false;
|
||||||
|
// account for the server/client desync
|
||||||
|
double playerEyesPos = player.posY
|
||||||
|
+ (world.isRemote ? player.getEyeHeight() - player.getDefaultEyeHeight() : player.getEyeHeight());
|
||||||
|
|
||||||
for (EntityItem itemToGet : items) {
|
for (EntityItem itemToGet : items) {
|
||||||
if (itemToGet.getEntityItem() == null || itemToGet instanceof EntityFloatingItem) {
|
if (itemToGet.getEntityItem() == null || itemToGet instanceof EntityFloatingItem) {
|
||||||
@@ -93,7 +97,7 @@ public class WirelessMagnet {
|
|||||||
itemToGet.motionZ = 0;
|
itemToGet.motionZ = 0;
|
||||||
itemToGet.setPosition(
|
itemToGet.setPosition(
|
||||||
player.posX - 0.2 + (world.rand.nextDouble() * 0.4),
|
player.posX - 0.2 + (world.rand.nextDouble() * 0.4),
|
||||||
player.posY - 0.6,
|
playerEyesPos - 0.62,
|
||||||
player.posZ - 0.2 + (world.rand.nextDouble() * 0.4));
|
player.posZ - 0.2 + (world.rand.nextDouble() * 0.4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user