Matrix Frame
This commit is contained in:
@@ -21,8 +21,11 @@ package appeng.block;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.util.LookDirection;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -32,12 +35,12 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.math.shapes.EntitySelectionContext;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
@@ -93,11 +96,6 @@ public abstract class AEBaseBlock extends Block
|
||||
return this.isFullSize() && this.isOpaque();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
// FIXME @SuppressWarnings( "deprecation" )
|
||||
// FIXME @Override
|
||||
// FIXME public void addCollisionBoxToList(final BlockState state, final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, @Nullable final Entity e, boolean p_185477_7_ )
|
||||
@@ -124,86 +122,68 @@ public abstract class AEBaseBlock extends Block
|
||||
// FIXME }
|
||||
// FIXME
|
||||
|
||||
// FIXME @SuppressWarnings( "deprecation" )
|
||||
// FIXME @Override
|
||||
// FIXME @OnlyIn( Dist.CLIENT )
|
||||
// FIXME public VoxelShape getRaytraceShape(BlockState state, IBlockReader w, BlockPos pos)
|
||||
// FIXME {
|
||||
// FIXME final ICustomCollision collisionHandler = this.getCustomCollision( w, pos );
|
||||
// FIXME
|
||||
// FIXME if( collisionHandler != null )
|
||||
// FIXME {
|
||||
// FIXME if( Platform.isClient() )
|
||||
// FIXME {
|
||||
// FIXME final PlayerEntity player = Minecraft.getInstance().player;
|
||||
// FIXME final LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset( player ) );
|
||||
// FIXME
|
||||
// FIXME final Iterable<VoxelShape> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, pos, Minecraft.getInstance().player, true );
|
||||
// FIXME VoxelShape br = null;
|
||||
// FIXME
|
||||
// FIXME double lastDist = 0;
|
||||
// FIXME
|
||||
// FIXME for( final VoxelShape bb : bbs )
|
||||
// FIXME {
|
||||
// FIXME final RayTraceResult r = bb.rayTrace(ld.getA(), ld.getB(), pos);
|
||||
// FIXME
|
||||
// FIXME if( r != null )
|
||||
// FIXME {
|
||||
// FIXME final double xLen = ( ld.getA().x - r.getHitVec().x );
|
||||
// FIXME final double yLen = ( ld.getA().y - r.getHitVec().y );
|
||||
// FIXME final double zLen = ( ld.getA().z - r.getHitVec().z );
|
||||
// FIXME
|
||||
// FIXME final double thisDist = xLen * xLen + yLen * yLen + zLen * zLen;
|
||||
// FIXME
|
||||
// FIXME if( br == null || lastDist > thisDist )
|
||||
// FIXME {
|
||||
// FIXME lastDist = thisDist;
|
||||
// FIXME br = bb;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME if( br != null )
|
||||
// FIXME {
|
||||
// FIXME return br;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME VoxelShape b = null; // new AxisAlignedBB( 16d, 16d, 16d, 0d, 0d, 0d );
|
||||
// FIXME
|
||||
// FIXME for( final VoxelShape bx : collisionHandler.getSelectedBoundingBoxesFromPool( w, pos, null, false ) )
|
||||
// FIXME {
|
||||
// FIXME if( b == null )
|
||||
// FIXME {
|
||||
// FIXME b = bx;
|
||||
// FIXME continue;
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME final double minX = Math.min( b.minX, bx.minX );
|
||||
// FIXME final double minY = Math.min( b.minY, bx.minY );
|
||||
// FIXME final double minZ = Math.min( b.minZ, bx.minZ );
|
||||
// FIXME final double maxX = Math.max( b.maxX, bx.maxX );
|
||||
// FIXME final double maxY = Math.max( b.maxY, bx.maxY );
|
||||
// FIXME final double maxZ = Math.max( b.maxZ, bx.maxZ );
|
||||
// FIXME
|
||||
// FIXME b = new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ );
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME if( b == null )
|
||||
// FIXME {
|
||||
// FIXME b = new AxisAlignedBB( 16d, 16d, 16d, 0d, 0d, 0d );
|
||||
// FIXME }
|
||||
// FIXME else
|
||||
// FIXME {
|
||||
// FIXME b = new AxisAlignedBB( b.minX + pos.getX(), b.minY + pos.getY(), b.minZ + pos.getZ(), b.maxX + pos.getX(), b.maxY + pos.getY(), b.maxZ + pos
|
||||
// FIXME .getZ() );
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME return b;
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME return super.getSelectedBoundingBox( state, w, pos );
|
||||
// FIXME }
|
||||
|
||||
// @Override
|
||||
// public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
// final ICustomCollision collisionHandler = this.getCustomCollision( w, pos );
|
||||
//
|
||||
// if( context instanceof EntitySelectionContext && collisionHandler != null )
|
||||
// {
|
||||
// EntitySelectionContext entitySelectionContext = (EntitySelectionContext) context;
|
||||
//
|
||||
// if( Platform.isClient() )
|
||||
// {
|
||||
// final PlayerEntity player = Minecraft.getInstance().player;
|
||||
// if (player != null && player == entitySelectionContext.getEntity()) {
|
||||
// final LookDirection ld = Platform.getPlayerRay(player);
|
||||
//
|
||||
// final Iterable<VoxelShape> bbs = collisionHandler.getSelectedBoundingBoxesFromPool(w, pos, Minecraft.getInstance().player, true);
|
||||
// VoxelShape br = null;
|
||||
//
|
||||
// double lastDist = 0;
|
||||
//
|
||||
// for (final VoxelShape bb : bbs) {
|
||||
// final RayTraceResult r = bb.rayTrace(ld.getA(), ld.getB(), pos);
|
||||
//
|
||||
// if (r != null) {
|
||||
// final double xLen = (ld.getA().x - r.getHitVec().x);
|
||||
// final double yLen = (ld.getA().y - r.getHitVec().y);
|
||||
// final double zLen = (ld.getA().z - r.getHitVec().z);
|
||||
//
|
||||
// final double thisDist = xLen * xLen + yLen * yLen + zLen * zLen;
|
||||
//
|
||||
// if (br == null || lastDist > thisDist) {
|
||||
// lastDist = thisDist;
|
||||
// br = bb;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (br != null) {
|
||||
// return br;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // FIXME: This seems fishy because it is NOT solely related to selection
|
||||
//// VoxelShape b = VoxelShapes.empty();
|
||||
////
|
||||
//// for( final VoxelShape bx : collisionHandler.getSelectedBoundingBoxesFromPool( w, pos, null, false ) )
|
||||
//// {
|
||||
//// if( b.isEmpty() )
|
||||
//// {
|
||||
//// b = bx;
|
||||
//// continue;
|
||||
//// }
|
||||
////
|
||||
//// b = VoxelShapes.or(b, bx);
|
||||
//// }
|
||||
////
|
||||
//// return b;
|
||||
// }
|
||||
//
|
||||
// return super.getShape( state, w, pos, context );
|
||||
// }
|
||||
|
||||
// FIXME: Move to state
|
||||
// FIXME @Override
|
||||
|
||||
@@ -25,6 +25,8 @@ import java.util.List;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.MaterialColor;
|
||||
import net.minecraft.block.material.PushReaction;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -42,15 +44,15 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
|
||||
|
||||
public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision
|
||||
public class BlockMatrixFrame extends AEBaseBlock
|
||||
{
|
||||
|
||||
private static final Material MATERIAL = new Material(MaterialColor.AIR, false, true, true, false, false, false, false, PushReaction.PUSH_ONLY);
|
||||
|
||||
public BlockMatrixFrame()
|
||||
{
|
||||
super( Properties.create(Material.ANVIL).hardnessAndResistance(-1.0F, 6000000.0F).noDrops().notSolid() );
|
||||
super( Properties.create(MATERIAL).hardnessAndResistance(-1.0F, 6000000.0F).noDrops().notSolid() );
|
||||
// FIXME this.setLightOpacity( 0 );
|
||||
// FIXME this.setOpaque( false );
|
||||
}
|
||||
@@ -68,22 +70,15 @@ public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getRaytraceShape(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return VoxelShapes.fullCube();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VoxelShape> getSelectedBoundingBoxesFromPool(IBlockReader w, BlockPos pos, Entity thePlayer, boolean b ) {
|
||||
return Collections.emptyList();// AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 )
|
||||
// } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e )
|
||||
{
|
||||
out.add( new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
|
||||
return false;
|
||||
@@ -95,7 +90,15 @@ public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision
|
||||
// Don't explode.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEntityDestroy( final BlockState state, final IBlockReader world, final BlockPos pos, final Entity entity )
|
||||
|
||||
@@ -49,6 +49,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
@@ -932,32 +934,32 @@ public class Platform
|
||||
// {
|
||||
// return I18n.format( string );
|
||||
// }
|
||||
//
|
||||
// public static LookDirection getPlayerRay(final PlayerEntity playerIn, final float eyeOffset )
|
||||
// {
|
||||
// final double x = playerIn.prevPosX + ( playerIn.getPosX() - playerIn.prevPosX );
|
||||
// final double y = playerIn.prevPosY + ( playerIn.getPosY() - playerIn.prevPosY ) + playerIn.getEyeHeight();
|
||||
// final double z = playerIn.prevPosZ + ( playerIn.getPosZ() - playerIn.prevPosZ );
|
||||
//
|
||||
// final float playerPitch = playerIn.prevRotationPitch + ( playerIn.rotationPitch - playerIn.prevRotationPitch );
|
||||
// final float playerYaw = playerIn.prevRotationYaw + ( playerIn.rotationYaw - playerIn.prevRotationYaw );
|
||||
//
|
||||
// final float yawRayX = MathHelper.sin( -playerYaw * 0.017453292f - (float) Math.PI );
|
||||
// final float yawRayZ = MathHelper.cos( -playerYaw * 0.017453292f - (float) Math.PI );
|
||||
//
|
||||
// final float pitchMultiplier = -MathHelper.cos( -playerPitch * 0.017453292F );
|
||||
// final float eyeRayY = MathHelper.sin( -playerPitch * 0.017453292F );
|
||||
// final float eyeRayX = yawRayX * pitchMultiplier;
|
||||
// final float eyeRayZ = yawRayZ * pitchMultiplier;
|
||||
//
|
||||
// double reachDistance = playerIn.getAttribute(PlayerEntity.REACH_DISTANCE).getValue();
|
||||
//
|
||||
// final Vec3d from = new Vec3d( x, y, z );
|
||||
// final Vec3d to = from.add( eyeRayX * reachDistance, eyeRayY * reachDistance, eyeRayZ * reachDistance );
|
||||
//
|
||||
// return new LookDirection( from, to );
|
||||
// }
|
||||
//
|
||||
|
||||
public static LookDirection getPlayerRay(final PlayerEntity playerIn )
|
||||
{
|
||||
final double x = playerIn.prevPosX + ( playerIn.getPosX() - playerIn.prevPosX );
|
||||
final double y = playerIn.prevPosY + ( playerIn.getPosY() - playerIn.prevPosY ) + playerIn.getEyeHeight();
|
||||
final double z = playerIn.prevPosZ + ( playerIn.getPosZ() - playerIn.prevPosZ );
|
||||
|
||||
final float playerPitch = playerIn.prevRotationPitch + ( playerIn.rotationPitch - playerIn.prevRotationPitch );
|
||||
final float playerYaw = playerIn.prevRotationYaw + ( playerIn.rotationYaw - playerIn.prevRotationYaw );
|
||||
|
||||
final float yawRayX = MathHelper.sin( -playerYaw * 0.017453292f - (float) Math.PI );
|
||||
final float yawRayZ = MathHelper.cos( -playerYaw * 0.017453292f - (float) Math.PI );
|
||||
|
||||
final float pitchMultiplier = -MathHelper.cos( -playerPitch * 0.017453292F );
|
||||
final float eyeRayY = MathHelper.sin( -playerPitch * 0.017453292F );
|
||||
final float eyeRayX = yawRayX * pitchMultiplier;
|
||||
final float eyeRayZ = yawRayZ * pitchMultiplier;
|
||||
|
||||
double reachDistance = playerIn.getAttribute(PlayerEntity.REACH_DISTANCE).getValue();
|
||||
|
||||
final Vec3d from = new Vec3d( x, y, z );
|
||||
final Vec3d to = from.add( eyeRayX * reachDistance, eyeRayY * reachDistance, eyeRayZ * reachDistance );
|
||||
|
||||
return new LookDirection( from, to );
|
||||
}
|
||||
|
||||
// public static RayTraceResult rayTrace(final PlayerEntity p, final boolean hitBlocks, final boolean hitEntities )
|
||||
// {
|
||||
// final World w = p.getEntityWorld();
|
||||
|
||||
Reference in New Issue
Block a user