2018-12-20 00:39:10 +00:00
|
|
|
package net.shadowfacts.simplemultipart.util;
|
|
|
|
|
2018-12-28 18:10:59 +00:00
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2018-12-20 00:39:10 +00:00
|
|
|
import net.minecraft.util.HitResult;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.math.Direction;
|
|
|
|
import net.minecraft.util.math.Vec3d;
|
2018-12-28 18:10:59 +00:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.shadowfacts.simplemultipart.container.MultipartContainer;
|
2018-12-28 02:55:51 +00:00
|
|
|
import net.shadowfacts.simplemultipart.multipart.MultipartView;
|
2018-12-20 00:39:10 +00:00
|
|
|
|
|
|
|
/**
|
2018-12-28 18:10:59 +00:00
|
|
|
* A raytrace result for a multipart.
|
|
|
|
*
|
2018-12-20 00:39:10 +00:00
|
|
|
* @author shadowfacts
|
2018-12-28 18:10:59 +00:00
|
|
|
* @since 0.1.0
|
|
|
|
* @see MultipartHelper#rayTrace(MultipartContainer, World, BlockPos, PlayerEntity)
|
2018-12-20 00:39:10 +00:00
|
|
|
*/
|
|
|
|
public class MultipartHitResult extends HitResult {
|
|
|
|
|
2018-12-28 18:10:59 +00:00
|
|
|
/**
|
|
|
|
* The view of the hit multipart.
|
|
|
|
*/
|
2018-12-25 15:20:44 +00:00
|
|
|
public MultipartView view;
|
2018-12-20 00:39:10 +00:00
|
|
|
|
2018-12-25 15:20:44 +00:00
|
|
|
public MultipartHitResult(Vec3d pos, Direction side, BlockPos blockPos, MultipartView view) {
|
2018-12-20 00:39:10 +00:00
|
|
|
super(pos, side, blockPos);
|
2018-12-25 15:20:44 +00:00
|
|
|
this.view = view;
|
2018-12-20 00:39:10 +00:00
|
|
|
}
|
|
|
|
|
2018-12-25 15:20:44 +00:00
|
|
|
public MultipartHitResult(HitResult result, MultipartView view) {
|
|
|
|
this(result.pos, result.side, result.getBlockPos(), view);
|
2018-12-20 00:39:10 +00:00
|
|
|
if (result.type != Type.BLOCK) {
|
|
|
|
throw new IllegalArgumentException("Can't create a MultipartHitResult from a non BLOCK-type HitResult");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2018-12-25 15:20:44 +00:00
|
|
|
return "HitResult{type=" + type + ", blockpos=" + getBlockPos() + ", f=" + side + ", pos=" + pos + ", view=" + view + '}';
|
2018-12-20 00:39:10 +00:00
|
|
|
}
|
|
|
|
}
|