use of net.katsstuff.mirror.data.Vector3 in project Solar by ArekkuusuJerii.
the class TileVacuumConveyor method impulseEntityItem.
private void impulseEntityItem(Vector3 pos, EntityTemporalItem item) {
Vector3 fuzzy = pos.add(Vector3.rotateRandom().multiply(0.1D));
item.setPositionAndUpdate(fuzzy.x(), fuzzy.y(), fuzzy.z());
item.setMotion(0, 0, 0);
}
use of net.katsstuff.mirror.data.Vector3 in project Solar by ArekkuusuJerii.
the class TileVacuumConveyor method dropItems.
private void dropItems() {
if (cooldown <= 0) {
IItemHandler handler = from.getKey();
ISidedInventory sidedInv = from.getValue();
for (int slot = 0; slot < handler.getSlots(); slot++) {
ItemStack inSlot = handler.getStackInSlot(slot);
if (!inSlot.isEmpty() && (lookup.isEmpty() || ItemHandlerHelper.canItemStacksStack(lookup, inSlot)) && (sidedInv == null || sidedInv.canExtractItem(slot, inSlot, getFacingLazy()))) {
BlockPos offset = pos.offset(getFacingLazy());
Vector3 spawn = Vector3.apply(offset.getX(), offset.getY(), offset.getZ()).add(0.5D);
ItemStack out = handler.extractItem(slot, Integer.MAX_VALUE, false);
EntityTemporalItem entity = new EntityTemporalItem(world, spawn.x(), spawn.y(), spawn.z(), out);
impulseEntityItem(spawn, entity);
world.spawnEntity(entity);
break;
}
}
cooldown = 5;
} else
cooldown--;
applyGravity(repulse, -1.25D);
}
use of net.katsstuff.mirror.data.Vector3 in project Solar by ArekkuusuJerii.
the class EntityLumen method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
if (world.isRemote) {
int lumen = MathHelper.clamp(handler.get(), 0, 4);
Vector3 pos = Vector3.apply(posX, posY, posZ);
for (int i = 0; i < lumen; i++) {
Quat x = Quat.fromAxisAngle(Vector3.Forward(), (world.rand.nextFloat() * 2F - 1F) * 25F);
Quat z = Quat.fromAxisAngle(Vector3.Right(), (world.rand.nextFloat() * 2F - 1F) * 25F);
Vector3 vec = Vector3.apply(motionX, motionY, motionZ).rotate(x.multiply(z)).multiply(0.1D);
FXUtil.spawnTunneling(world, pos, vec, 30 + world.rand.nextInt(40), 2F, 0xFFE077, GlowTexture.GLINT);
}
} else {
double rest = 1D * (1 - (double) handler.get() / 1000D);
motionX *= rest;
motionY *= rest;
motionZ *= rest;
if (tick++ % 80 == 0 && tick > 1) {
handler.set((int) ((float) handler.get() * 0.75F));
}
if (handler.get() <= 0)
setDead();
}
move(MoverType.SELF, motionX, motionY, motionZ);
}
use of net.katsstuff.mirror.data.Vector3 in project Solar by ArekkuusuJerii.
the class ObeliskDecorator method gen.
@Override
void gen(World world, int x, int z, IChunkGenerator generator, IChunkProvider provider) {
random.setSeed(world.getSeed());
long good = random.nextLong();
long succ = random.nextLong();
good *= x >> 3;
succ *= z >> 3;
random.setSeed(good * succ * world.getSeed());
// Generate
if (GEN_CONFIG.monolith.decorator.rarity > 0D && GEN_CONFIG.monolith.decorator.rarity / 100D > random.nextDouble()) {
List<AxisAlignedBB> occupied = Lists.newArrayList();
for (int i = 0; i < GEN_CONFIG.monolith.decorator.size; i++) {
BlockPos top = world.getTopSolidOrLiquidBlock(randomVector().add(x, 0, z).toBlockPos());
int below = random.nextInt(7);
if (top.getY() > below) {
top = top.add(0, -below, 0);
}
Template obelisk = obelisks.next().load(world);
Rotation rotation = Rotation.values()[random.nextInt(4)];
Vector3 vec = rotate(new Vector3.WrappedVec3i(obelisk.getSize()).asImmutable(), rotation);
vec = vec.offset(rotate(Vector3.apply(-1, -1, -1), rotation), 1);
AxisAlignedBB obeliskBB = new AxisAlignedBB(top, top.add(vec.toBlockPos())).grow(1);
if (occupied.stream().noneMatch(bb -> bb.intersects(obeliskBB))) {
PlacementSettings settings = new PlacementSettings();
settings.setRotation(rotation);
settings.setRandom(random);
obelisk.addBlocksToWorld(world, top, settings);
BlockPos.getAllInBox(top, top.add(vec.toBlockPos())).forEach(p -> {
if (random.nextFloat() < 0.05) {
IBlockState glyph = ModBlocks.MONOLITHIC_GLYPH.getDefaultState().withProperty(BlockMonolithicGlyph.GLYPH, random.nextInt(16));
world.setBlockState(p, glyph);
}
});
occupied.add(obeliskBB);
}
}
}
}
use of net.katsstuff.mirror.data.Vector3 in project Solar by ArekkuusuJerii.
the class ItemAngstrom method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
RayTraceResult result = RayTraceHelper.tracePlayerHighlight(player);
if (result.typeOfHit != RayTraceResult.Type.BLOCK) {
if (!world.isRemote) {
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 = world.getBlockState(pos);
if (world.isAirBlock(pos) || replaced.getBlock().isReplaceable(world, pos)) {
IBlockState state = ModBlocks.ANGSTROM.getDefaultState();
SoundType type = ModBlocks.ANGSTROM.getSoundType(state, world, pos, player);
world.setBlockState(pos, state);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), type.getPlaceSound(), SoundCategory.BLOCKS, 0.75F, 0.8F);
}
if (!player.capabilities.isCreativeMode) {
stack.shrink(1);
}
}
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
Aggregations