use of arekkuusu.solar.api.entanglement.energy.data.ILumen in project Solar by ArekkuusuJerii.
the class TilePholarizer method spit.
private void spit() {
EnumFacing facing = getFacingLazy();
BlockPos pos = getPos().offset(facing);
IBlockState state = world.getBlockState(pos);
facing = facing.getOpposite();
TileEntity tile;
if (state.getBlock().hasTileEntity(state) && (tile = world.getTileEntity(pos)).hasCapability(ModCapability.LUMEN_CAPABILITY, facing)) {
ILumen wrapper = tile.getCapability(ModCapability.LUMEN_CAPABILITY, facing);
if (wrapper.get() > 0) {
EntityLumen lumen = EntityLumen.spawn(world, new Vector3.WrappedVec3i(getPos()).asImmutable().add(0.5D), wrapper.drain(64));
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 = new Vector3.WrappedVec3i(getFacingLazy().getOpposite().getDirectionVec()).asImmutable().rotate(x.multiply(z)).multiply(0.1D);
lumen.motionX = vec.x();
lumen.motionY = vec.y();
lumen.motionZ = vec.z();
}
}
}
use of arekkuusu.solar.api.entanglement.energy.data.ILumen in project Solar by ArekkuusuJerii.
the class BlockNeutronBattery method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
if (!world.isRemote) {
getTile(TileNeutronBattery.class, world, pos).ifPresent(neutron -> {
IEntangledStack entangled = (IEntangledStack) stack.getItem();
if (!entangled.getKey(stack).isPresent()) {
entangled.setKey(stack, UUID.randomUUID());
}
entangled.getKey(stack).ifPresent(neutron::setKey);
if (placer instanceof EntityPlayer && ((EntityPlayer) placer).capabilities.isCreativeMode) {
ILumen lumen = neutron.getCapability(ModCapability.LUMEN_CAPABILITY, EnumFacing.UP);
if (lumen != null) {
// CHEATER!!
lumen.set(neutron.getCapacityLazy().max);
}
}
});
}
}
use of arekkuusu.solar.api.entanglement.energy.data.ILumen in project Solar by ArekkuusuJerii.
the class TilePholarizer method succ.
private void succ() {
EnumFacing facing = getFacingLazy();
BlockPos pos = getPos().offset(facing);
IBlockState state = world.getBlockState(pos);
facing = facing.getOpposite();
TileEntity tile;
if (state.getBlock().hasTileEntity(state) && (tile = world.getTileEntity(pos)).hasCapability(ModCapability.LUMEN_CAPABILITY, facing)) {
ILumen wrapper = tile.getCapability(ModCapability.LUMEN_CAPABILITY, facing);
if (wrapper.get() < wrapper.getMax()) {
world.getEntitiesWithinAABB(EntityLumen.class, new AxisAlignedBB(pos).grow(10D)).stream().filter(e -> !e.isDead && e.hasCapability(ModCapability.LUMEN_CAPABILITY, null)).forEach(e -> {
double x = getPos().getX() + 0.5D - e.posX;
double y = getPos().getY() + 0.5D - e.posY;
double z = getPos().getZ() + 0.5D - e.posZ;
double sqrt = Math.sqrt(x * x + y * y + z * z);
double effect = sqrt / 10D;
double strength = (1 - effect) * (1 - effect);
double power = 0.025D;
e.motionX += (x / sqrt) * strength * power;
e.motionY += (y / sqrt) * strength * power;
e.motionZ += (z / sqrt) * strength * power;
});
world.getEntitiesWithinAABB(EntityLumen.class, new AxisAlignedBB(pos).grow(0.5D)).stream().filter(e -> !e.isDead && e.hasCapability(ModCapability.LUMEN_CAPABILITY, null)).forEach(e -> {
ILumen lumen = e.getCapability(ModCapability.LUMEN_CAPABILITY, null);
lumen.set(wrapper.fill(lumen.get()));
if (lumen.get() <= 0)
e.setDead();
});
}
}
}
Aggregations