use of net.katsstuff.mirror.data.Vector3 in project Solar by ArekkuusuJerii.
the class ItemCrystalQuartz method onEntityItemUpdate.
@Override
public boolean onEntityItemUpdate(EntityItem entity) {
if (!entity.world.isRemote) {
entity = makeQuantum(entity);
if (itemRand.nextFloat() < 0.1F) {
Vector3 from = new Vector3.WrappedVec3d(entity.getPositionVector()).asImmutable();
Vector3 to = Vector3.rotateRandom().multiply(2).add(from);
if (isValidSpawn(entity.world, to)) {
entity.setPositionAndUpdate(to.x(), to.y(), to.z());
entity.playSound(SoundEvents.ENTITY_SHULKER_TELEPORT, 0.25F, 0.5F);
}
}
} else {
Vector3 pos = new Vector3(entity).add(0D, entity.height * 1.75D, 0D);
Vector3 speedVec = Vector3.rotateRandom().multiply(0.01D);
FXUtil.spawnLight(entity.world, pos, speedVec, 45, 3F, 0x1BE564, Light.GLOW);
}
return false;
}
use of net.katsstuff.mirror.data.Vector3 in project Solar by ArekkuusuJerii.
the class ParticleVolt method calculateBolts.
private void calculateBolts() {
// TODO: Maybe use textures instead of raw gl lines?
ProfilerHelper.begin("[Particle Bolt] Calculating Bolts");
List<VoltSegment> branched = Lists.newArrayList();
for (int i = 0; i < generations; i++) {
List<VoltSegment> temp = Lists.newArrayList();
for (VoltSegment segment : segments) {
Vector3 from = segment.from;
Vector3 to = segment.to;
MutableVector3 mid = average(from, to).asMutable();
Vector3 midOffset = to.subtract(from);
mid = mid.add(midOffset.normalize().cross(Vector3.One()).multiply(Vector3.rotateRandom().multiply(offset)));
if (branch && rand.nextDouble() > 0.6D) {
MutableVector3 direction = mid.subtract(from);
float xAngle = (25.0F + 12.5F * rand.nextFloat()) * (rand.nextBoolean() ? 1 : -1);
float zAngle = (25.0F + 12.5F * rand.nextFloat()) * (rand.nextBoolean() ? 1 : -1);
Quat x = Quat.fromAxisAngle(Vector3.Forward(), xAngle);
Quat z = Quat.fromAxisAngle(Vector3.Right(), zAngle);
Vector3 splitEnd = direction.rotate(x.multiply(z)).multiply(0.7D).add(mid).asImmutable();
VoltSegment sub = new VoltSegment(mid.asImmutable(), splitEnd);
sub.alpha = segment.alpha;
temp.add(sub);
}
VoltSegment one = new VoltSegment(from, mid.asImmutable());
VoltSegment two = new VoltSegment(mid.asImmutable(), to);
if (fade) {
one.alpha = segment.alpha * 0.5F;
two.alpha = segment.alpha;
}
temp.add(one);
temp.add(two);
if (branched.isEmpty() || branched.contains(segment)) {
branched.add(two);
}
}
segments = temp;
offset /= 2;
}
ProfilerHelper.end();
}
use of net.katsstuff.mirror.data.Vector3 in project Solar by ArekkuusuJerii.
the class Events method renderGhostAngstrom.
@SubscribeEvent
public static void renderGhostAngstrom(RenderWorldLastEvent event) {
EntityPlayerSP player = Minecraft.getMinecraft().player;
ItemStack stack = player.getHeldItemMainhand();
if (stack.isEmpty() || stack.getItem() != ModItems.ANGSTROM) {
stack = player.getHeldItemOffhand();
}
if (!stack.isEmpty() && stack.getItem() == ModItems.ANGSTROM) {
RayTraceResult result = RayTraceHelper.tracePlayerHighlight(player);
if (result.typeOfHit != RayTraceResult.Type.BLOCK) {
Vector3 vec = Vector3.apply(player.posX, player.posY + player.getEyeHeight(), player.posZ).add(new Vector3(player.getLookVec()).multiply(2.5D));
BlockPos pos = new BlockPos(vec.toVec3d());
IBlockState replaced = player.world.getBlockState(pos);
if (player.world.isAirBlock(pos) || replaced.getBlock().isReplaceable(player.world, pos)) {
RenderHelper.renderGhostBlock(pos, ModBlocks.ANGSTROM.getDefaultState());
}
}
}
}
Aggregations