Merge branch 'rv1' of https://bitbucket.org/AlgorithmX2/appliedenergistics2 into rv1
This commit is contained in:
commit
2873efc828
4 changed files with 35 additions and 15 deletions
|
@ -38,6 +38,7 @@ import appeng.client.render.BlockRenderInfo;
|
||||||
import appeng.client.render.WorldRender;
|
import appeng.client.render.WorldRender;
|
||||||
import appeng.client.texture.FlipableIcon;
|
import appeng.client.texture.FlipableIcon;
|
||||||
import appeng.client.texture.MissingIcon;
|
import appeng.client.texture.MissingIcon;
|
||||||
|
import appeng.core.CommonHelper;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
import appeng.core.features.AEFeatureHandler;
|
import appeng.core.features.AEFeatureHandler;
|
||||||
import appeng.core.features.IAEFeature;
|
import appeng.core.features.IAEFeature;
|
||||||
|
@ -531,7 +532,8 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||||
{
|
{
|
||||||
if ( Platform.isClient() )
|
if ( Platform.isClient() )
|
||||||
{
|
{
|
||||||
LookDirection ld = Platform.getPlayerRay( Minecraft.getMinecraft().thePlayer );
|
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||||
|
LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset(player ) );
|
||||||
|
|
||||||
Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxsFromPool( w, x, y, z, Minecraft.getMinecraft().thePlayer, true );
|
Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxsFromPool( w, x, y, z, Minecraft.getMinecraft().thePlayer, true );
|
||||||
AxisAlignedBB br = null;
|
AxisAlignedBB br = null;
|
||||||
|
|
|
@ -16,6 +16,7 @@ public class PacketPartPlacement extends AppEngPacket
|
||||||
{
|
{
|
||||||
|
|
||||||
int x, y, z, face;
|
int x, y, z, face;
|
||||||
|
float eyeHeight;
|
||||||
|
|
||||||
// automatic.
|
// automatic.
|
||||||
public PacketPartPlacement(ByteBuf stream) throws IOException {
|
public PacketPartPlacement(ByteBuf stream) throws IOException {
|
||||||
|
@ -23,6 +24,7 @@ public class PacketPartPlacement extends AppEngPacket
|
||||||
y = stream.readInt();
|
y = stream.readInt();
|
||||||
z = stream.readInt();
|
z = stream.readInt();
|
||||||
face = stream.readByte();
|
face = stream.readByte();
|
||||||
|
eyeHeight = stream.readFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,12 +32,13 @@ public class PacketPartPlacement extends AppEngPacket
|
||||||
{
|
{
|
||||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||||
CommonHelper.proxy.updateRenderMode( sender );
|
CommonHelper.proxy.updateRenderMode( sender );
|
||||||
|
PartPlacement.eyeHeight = eyeHeight;
|
||||||
PartPlacement.place( sender.getHeldItem(), x, y, z, face, sender, sender.worldObj, PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0 );
|
PartPlacement.place( sender.getHeldItem(), x, y, z, face, sender, sender.worldObj, PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0 );
|
||||||
CommonHelper.proxy.updateRenderMode( null );
|
CommonHelper.proxy.updateRenderMode( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
// api
|
// api
|
||||||
public PacketPartPlacement(int x, int y, int z, int face) throws IOException {
|
public PacketPartPlacement(int x, int y, int z, int face, float eyeHeight ) throws IOException {
|
||||||
|
|
||||||
ByteBuf data = Unpooled.buffer();
|
ByteBuf data = Unpooled.buffer();
|
||||||
|
|
||||||
|
@ -44,6 +47,7 @@ public class PacketPartPlacement extends AppEngPacket
|
||||||
data.writeInt( y );
|
data.writeInt( y );
|
||||||
data.writeInt( z );
|
data.writeInt( z );
|
||||||
data.writeByte( face );
|
data.writeByte( face );
|
||||||
|
data.writeFloat( eyeHeight );
|
||||||
|
|
||||||
configureWrite( data );
|
configureWrite( data );
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class PartPlacement
|
||||||
{
|
{
|
||||||
if ( !world.isRemote )
|
if ( !world.isRemote )
|
||||||
{
|
{
|
||||||
LookDirection dir = Platform.getPlayerRay( player );
|
LookDirection dir = Platform.getPlayerRay( player, getEyeOffset(player) );
|
||||||
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
|
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
|
||||||
if ( mop != null )
|
if ( mop != null )
|
||||||
{
|
{
|
||||||
|
@ -169,7 +169,7 @@ public class PartPlacement
|
||||||
player.swingItem();
|
player.swingItem();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face ) );
|
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
@ -223,7 +223,7 @@ public class PartPlacement
|
||||||
player.swingItem();
|
player.swingItem();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face ) );
|
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
@ -247,7 +247,7 @@ public class PartPlacement
|
||||||
Block block = world.getBlock( x, y, z );
|
Block block = world.getBlock( x, y, z );
|
||||||
if ( host != null && player.isSneaking() && block != null )
|
if ( host != null && player.isSneaking() && block != null )
|
||||||
{
|
{
|
||||||
LookDirection dir = Platform.getPlayerRay( player );
|
LookDirection dir = Platform.getPlayerRay( player, getEyeOffset(player) );
|
||||||
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
|
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
|
||||||
if ( mop != null )
|
if ( mop != null )
|
||||||
{
|
{
|
||||||
|
@ -260,7 +260,7 @@ public class PartPlacement
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face ) );
|
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
@ -323,7 +323,7 @@ public class PartPlacement
|
||||||
player.swingItem();
|
player.swingItem();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face ) );
|
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
@ -365,7 +365,7 @@ public class PartPlacement
|
||||||
if ( !world.isRemote )
|
if ( !world.isRemote )
|
||||||
{
|
{
|
||||||
Block block = world.getBlock( x, y, z );
|
Block block = world.getBlock( x, y, z );
|
||||||
LookDirection dir = Platform.getPlayerRay( player );
|
LookDirection dir = Platform.getPlayerRay( player, getEyeOffset(player) );
|
||||||
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
|
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
|
||||||
if ( mop != null )
|
if ( mop != null )
|
||||||
{
|
{
|
||||||
|
@ -402,7 +402,7 @@ public class PartPlacement
|
||||||
player.swingItem();
|
player.swingItem();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face ) );
|
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
@ -412,6 +412,15 @@ public class PartPlacement
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float eyeHeight = 0.0f;
|
||||||
|
private static float getEyeOffset( EntityPlayer p )
|
||||||
|
{
|
||||||
|
if ( p.worldObj.isRemote )
|
||||||
|
return Platform.getEyeOffset( p );
|
||||||
|
|
||||||
|
return eyeHeight;
|
||||||
|
}
|
||||||
|
|
||||||
private static SelectedPart selectPart(EntityPlayer player, IPartHost host, Vec3 pos)
|
private static SelectedPart selectPart(EntityPlayer player, IPartHost host, Vec3 pos)
|
||||||
{
|
{
|
||||||
CommonHelper.proxy.updateRenderMode( player );
|
CommonHelper.proxy.updateRenderMode( player );
|
||||||
|
|
|
@ -1200,16 +1200,15 @@ public class Platform
|
||||||
return a.isItemEqual( b );
|
return a.isItemEqual( b );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LookDirection getPlayerRay(EntityPlayer player)
|
public static LookDirection getPlayerRay(EntityPlayer player, float eyeoffset)
|
||||||
{
|
{
|
||||||
float f = 1.0F;
|
float f = 1.0F;
|
||||||
float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
|
float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
|
||||||
float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
|
float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
|
||||||
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
|
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
|
||||||
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f
|
double d1 = eyeoffset;
|
||||||
+ (double) (player.worldObj.isRemote ? player.getEyeHeight() - player.getDefaultEyeHeight() : player.getEyeHeight()); // isRemote
|
|
||||||
|
|
||||||
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
|
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
|
||||||
|
|
||||||
Vec3 vec3 = Vec3.createVectorHelper( d0, d1, d2 );
|
Vec3 vec3 = Vec3.createVectorHelper( d0, d1, d2 );
|
||||||
float f3 = MathHelper.cos( -f2 * 0.017453292F - (float) Math.PI );
|
float f3 = MathHelper.cos( -f2 * 0.017453292F - (float) Math.PI );
|
||||||
float f4 = MathHelper.sin( -f2 * 0.017453292F - (float) Math.PI );
|
float f4 = MathHelper.sin( -f2 * 0.017453292F - (float) Math.PI );
|
||||||
|
@ -1792,4 +1791,10 @@ public class Platform
|
||||||
}
|
}
|
||||||
return AxisAlignedBB.getBoundingBox( 0, 0, 0, 1, 1, 1 );
|
return AxisAlignedBB.getBoundingBox( 0, 0, 0, 1, 1, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float getEyeOffset(EntityPlayer player)
|
||||||
|
{
|
||||||
|
assert player.worldObj.isRemote : "Valid only on client";
|
||||||
|
return (float) (player.posY +player.getEyeHeight() - player.getDefaultEyeHeight());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue